summaryrefslogtreecommitdiffstats
path: root/mobile/android/modules/geckoview/GeckoViewActorChild.jsm
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/android/modules/geckoview/GeckoViewActorChild.jsm')
-rw-r--r--mobile/android/modules/geckoview/GeckoViewActorChild.jsm52
1 files changed, 52 insertions, 0 deletions
diff --git a/mobile/android/modules/geckoview/GeckoViewActorChild.jsm b/mobile/android/modules/geckoview/GeckoViewActorChild.jsm
new file mode 100644
index 0000000000..8f80039353
--- /dev/null
+++ b/mobile/android/modules/geckoview/GeckoViewActorChild.jsm
@@ -0,0 +1,52 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const { GeckoViewUtils } = ChromeUtils.import(
+ "resource://gre/modules/GeckoViewUtils.jsm"
+);
+
+var EXPORTED_SYMBOLS = ["GeckoViewActorChild"];
+
+class GeckoViewActorChild extends JSWindowActorChild {
+ static initLogging(aModuleName) {
+ const tag = aModuleName.replace("GeckoView", "") + "[C]";
+ return GeckoViewUtils.initLogging(tag);
+ }
+
+ actorCreated() {
+ this.eventDispatcher = GeckoViewUtils.getDispatcherForWindow(
+ this.docShell.domWindow
+ );
+ }
+
+ /** Returns true if this docShell is of type Content, false otherwise. */
+ get isContentWindow() {
+ if (!this.docShell) {
+ return false;
+ }
+
+ // Some WebExtension windows are tagged as content but really they are not
+ // for us (e.g. the remote debugging window or the background extension
+ // page).
+ const browser = this.browsingContext.top.embedderElement;
+ if (browser) {
+ const viewType = browser.getAttribute("webextension-view-type");
+ if (viewType) {
+ debug`webextension-view-type: ${viewType}`;
+ return false;
+ }
+ const debugTarget = browser.getAttribute(
+ "webextension-addon-debug-target"
+ );
+ if (debugTarget) {
+ debug`webextension-addon-debug-target: ${debugTarget}`;
+ return false;
+ }
+ }
+
+ return this.docShell.itemType == this.docShell.typeContent;
+ }
+}
+
+const { debug, warn } = GeckoViewUtils.initLogging("Actor[C]");