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 { 16 namespace dom { 17 18 template <typename> 19 struct Nullable; 20 class WindowProxyHolder; 21 22 #define NS_CONTENTFRAMEMESSAGEMANAGER_IID \ 23 { \ 24 0x97e192a6, 0xab7a, 0x4c8f, { \ 25 0xb7, 0xdd, 0xf7, 0xec, 0x36, 0x38, 0x71, 0xb5 \ 26 } \ 27 } 28 29 /** 30 * Base class for implementing the WebIDL ContentFrameMessageManager class. 31 */ 32 class ContentFrameMessageManager : public DOMEventTargetHelper, 33 public MessageManagerGlobal { 34 public: 35 using DOMEventTargetHelper::AddRef; 36 using DOMEventTargetHelper::Release; 37 38 NS_DECLARE_STATIC_IID_ACCESSOR(NS_CONTENTFRAMEMESSAGEMANAGER_IID) 39 40 virtual Nullable<WindowProxyHolder> GetContent(ErrorResult& aError) = 0; 41 virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) = 0; 42 virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() = 0; 43 GetMessageManager()44 nsFrameMessageManager* GetMessageManager() { return mMessageManager; } DisconnectMessageManager()45 void DisconnectMessageManager() { 46 mMessageManager->Disconnect(); 47 mMessageManager = nullptr; 48 } 49 50 JSObject* GetOrCreateWrapper(); 51 52 protected: ContentFrameMessageManager(nsFrameMessageManager * aMessageManager)53 explicit ContentFrameMessageManager(nsFrameMessageManager* aMessageManager) 54 : DOMEventTargetHelper(xpc::NativeGlobal(xpc::PrivilegedJunkScope())), 55 MessageManagerGlobal(aMessageManager) {} 56 }; 57 58 NS_DEFINE_STATIC_IID_ACCESSOR(ContentFrameMessageManager, 59 NS_CONTENTFRAMEMESSAGEMANAGER_IID) 60 61 } // namespace dom 62 } // namespace mozilla 63 64 #endif // mozilla_dom_ContentFrameMessageManager_h 65