ContentFrameMessageManager.h (1884B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_ContentFrameMessageManager_h 8 #define mozilla_dom_ContentFrameMessageManager_h 9 10 #include "mozilla/DOMEventTargetHelper.h" 11 #include "mozilla/dom/MessageManagerGlobal.h" 12 #include "nsContentUtils.h" 13 #include "xpcpublic.h" 14 15 namespace mozilla::dom { 16 17 template <typename> 18 struct Nullable; 19 class WindowProxyHolder; 20 21 #define NS_CONTENTFRAMEMESSAGEMANAGER_IID \ 22 {0x97e192a6, 0xab7a, 0x4c8f, {0xb7, 0xdd, 0xf7, 0xec, 0x36, 0x38, 0x71, 0xb5}} 23 24 /** 25 * Base class for implementing the WebIDL ContentFrameMessageManager class. 26 */ 27 class ContentFrameMessageManager : public DOMEventTargetHelper, 28 public MessageManagerGlobal { 29 public: 30 using DOMEventTargetHelper::AddRef; 31 using DOMEventTargetHelper::Release; 32 33 NS_INLINE_DECL_STATIC_IID(NS_CONTENTFRAMEMESSAGEMANAGER_IID) 34 35 virtual Nullable<WindowProxyHolder> GetContent(ErrorResult& aError) = 0; 36 virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) = 0; 37 virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() = 0; 38 39 nsFrameMessageManager* GetMessageManager() { return mMessageManager; } 40 void DisconnectMessageManager() { 41 mMessageManager->Disconnect(); 42 mMessageManager = nullptr; 43 } 44 45 JSObject* GetOrCreateWrapper(); 46 47 protected: 48 explicit ContentFrameMessageManager(nsFrameMessageManager* aMessageManager) 49 : DOMEventTargetHelper(xpc::NativeGlobal(xpc::PrivilegedJunkScope())), 50 MessageManagerGlobal(aMessageManager) {} 51 }; 52 53 } // namespace mozilla::dom 54 55 #endif // mozilla_dom_ContentFrameMessageManager_h