Bug 1472491: Part 5u - Add URIFixupChild actor. r=gijs
authorKris Maglione <maglione.k@gmail.com>
Sun, 29 Jul 2018 22:30:34 -0700
changeset 431474 7699b1ced009a10ec61806cd6fdbc339c304106d
parent 431473 7c87ed2a2a357f965f071bab78149d970a01e164
child 431475 a3e7ca5cf109f0db99b3179e62c073a090201218
push id34443
push usercsabou@mozilla.com
push dateWed, 15 Aug 2018 00:53:32 +0000
treeherdermozilla-central@b80906e2fbc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs
bugs1472491
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472491: Part 5u - Add URIFixupChild actor. r=gijs MozReview-Commit-ID: IqFGfjXhc6z
browser/actors/URIFixupChild.jsm
browser/actors/moz.build
browser/base/content/tab-content.js
browser/components/nsBrowserGlue.js
new file mode 100644
--- /dev/null
+++ b/browser/actors/URIFixupChild.jsm
@@ -0,0 +1,37 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
+/* 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/. */
+"use strict";
+
+var EXPORTED_SYMBOLS = ["URIFixupChild"];
+
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
+
+class URIFixupChild extends ActorChild {
+  observe(subject) {
+    let fixupInfo = subject.QueryInterface(Ci.nsIURIFixupInfo);
+    if (!fixupInfo.consumer) {
+      return;
+    }
+
+    // Ignore info from other docshells
+    let parent = fixupInfo.consumer.QueryInterface(Ci.nsIDocShellTreeItem).sameTypeRootTreeItem;
+    if (parent != this.mm.docShell)
+      return;
+
+    let data = {};
+    for (let f of Object.keys(fixupInfo)) {
+      if (f == "consumer" || typeof fixupInfo[f] == "function")
+        continue;
+
+      if (fixupInfo[f] && fixupInfo[f] instanceof Ci.nsIURI) {
+        data[f] = fixupInfo[f].spec;
+      } else {
+        data[f] = fixupInfo[f];
+      }
+    }
+
+    this.mm.sendAsyncMessage("Browser:URIFixup", data);
+  }
+}
--- a/browser/actors/moz.build
+++ b/browser/actors/moz.build
@@ -25,9 +25,10 @@ FINAL_TARGET_FILES.actors += [
     'ContextMenuChild.jsm',
     'DOMFullscreenChild.jsm',
     'LightWeightThemeInstallChild.jsm',
     'NetErrorChild.jsm',
     'OfflineAppsChild.jsm',
     'PageInfoChild.jsm',
     'PageStyleChild.jsm',
     'PluginChild.jsm',
+    'URIFixupChild.jsm',
 ]
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -56,46 +56,16 @@ addEventListener("pageshow", function({ 
 
 // Keep a reference to the translation content handler to avoid it it being GC'ed.
 var trHandler = null;
 if (Services.prefs.getBoolPref("browser.translation.detectLanguage")) {
   ChromeUtils.import("resource:///modules/translation/TranslationContentHandler.jsm");
   trHandler = new TranslationContentHandler(global, docShell);
 }
 
-function gKeywordURIFixup(fixupInfo) {
-  fixupInfo.QueryInterface(Ci.nsIURIFixupInfo);
-  if (!fixupInfo.consumer) {
-    return;
-  }
-
-  // Ignore info from other docshells
-  let parent = fixupInfo.consumer.QueryInterface(Ci.nsIDocShellTreeItem).sameTypeRootTreeItem;
-  if (parent != docShell)
-    return;
-
-  let data = {};
-  for (let f of Object.keys(fixupInfo)) {
-    if (f == "consumer" || typeof fixupInfo[f] == "function")
-      continue;
-
-    if (fixupInfo[f] && fixupInfo[f] instanceof Ci.nsIURI) {
-      data[f] = fixupInfo[f].spec;
-    } else {
-      data[f] = fixupInfo[f];
-    }
-  }
-
-  sendAsyncMessage("Browser:URIFixup", data);
-}
-Services.obs.addObserver(gKeywordURIFixup, "keyword-uri-fixup");
-addEventListener("unload", () => {
-  Services.obs.removeObserver(gKeywordURIFixup, "keyword-uri-fixup");
-}, false);
-
 var WebBrowserChrome = {
   onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab) {
     return BrowserUtils.onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab);
   },
 
   // Check whether this URI should load in the current process
   shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData, aTriggeringPrincipal) {
     if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData)) {
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -204,16 +204,24 @@ let ACTORS = {
         "BrowserPlugins:Test:ClearCrashData",
       ],
 
       observers: [
         "decoder-doctor-notification",
       ],
     },
   },
+
+  URIFixup: {
+    child: {
+      module: "resource:///actors/URIFixupChild.jsm",
+      group: "browsers",
+      observers: ["keyword-uri-fixup"],
+    },
+  },
 };
 
 (function earlyBlankFirstPaint() {
   if (!Services.prefs.getBoolPref("browser.startup.blankWindow", false))
     return;
 
   let store = Services.xulStore;
   let getValue = attr =>