1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_extensions_DocumentObserver_h
7 #define mozilla_extensions_DocumentObserver_h
9 #include "mozilla/dom/BindingDeclarations.h"
10 #include "mozilla/dom/MozDocumentObserverBinding.h"
12 #include "mozilla/extensions/WebExtensionContentScript.h"
15 class nsPIDOMWindowOuter
;
18 namespace extensions
{
20 class DocumentObserver final
: public nsISupports
, public nsWrapperCache
{
21 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
22 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DocumentObserver
)
24 static already_AddRefed
<DocumentObserver
> Constructor(
25 dom::GlobalObject
& aGlobal
, dom::MozDocumentCallback
& aCallbacks
);
27 void Observe(const dom::Sequence
<OwningNonNull
<MozDocumentMatcher
>>& matchers
,
32 const nsTArray
<RefPtr
<MozDocumentMatcher
>>& Matchers() const {
36 void NotifyMatch(MozDocumentMatcher
& aMatcher
, nsPIDOMWindowOuter
* aWindow
);
37 void NotifyMatch(MozDocumentMatcher
& aMatcher
, nsILoadInfo
* aLoadInfo
);
39 nsISupports
* GetParentObject() const { return mParent
; }
40 JSObject
* WrapObject(JSContext
* aCx
,
41 JS::Handle
<JSObject
*> aGivenProto
) override
;
44 virtual ~DocumentObserver() = default;
47 explicit DocumentObserver(nsISupports
* aParent
,
48 dom::MozDocumentCallback
& aCallbacks
)
49 : mParent(aParent
), mCallbacks(&aCallbacks
) {}
51 nsCOMPtr
<nsISupports
> mParent
;
52 RefPtr
<dom::MozDocumentCallback
> mCallbacks
;
53 nsTArray
<RefPtr
<MozDocumentMatcher
>> mMatchers
;
56 } // namespace extensions
57 } // namespace mozilla
59 #endif // mozilla_extensions_DocumentObserver_h