1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 this.EXPORTED_SYMBOLS = ["E10SUtils"];
9 const {interfaces: Ci, utils: Cu, classes: Cc} = Components;
11 Cu.import("resource://gre/modules/Services.jsm");
14 shouldBrowserBeRemote: function(aURL) {
15 // loadURI in browser.xml treats null as about:blank
19 if (aURL.startsWith("about:") &&
20 aURL.toLowerCase() != "about:home" &&
21 aURL.toLowerCase() != "about:blank" &&
22 !aURL.toLowerCase().startsWith("about:neterror") &&
23 !aURL.toLowerCase().startsWith("about:certerror")) {
30 shouldLoadURI: function(aDocShell, aURI, aReferrer) {
31 // about:blank is the initial document and can load anywhere
32 if (aURI.spec == "about:blank")
35 // Inner frames should always load in the current process
36 if (aDocShell.QueryInterface(Ci.nsIDocShellTreeItem).sameTypeParent)
39 // If the URI can be loaded in the current process then continue
40 let isRemote = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
41 if (this.shouldBrowserBeRemote(aURI.spec) == isRemote)
47 redirectLoad: function(aDocShell, aURI, aReferrer) {
48 // Retarget the load to the correct process
49 let messageManager = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
50 .getInterface(Ci.nsIContentFrameMessageManager);
51 let sessionHistory = aDocShell.getInterface(Ci.nsIWebNavigation).sessionHistory;
53 messageManager.sendAsyncMessage("Browser:LoadURI", {
56 flags: Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
57 referrer: aReferrer ? aReferrer.spec : null,
59 historyIndex: sessionHistory.requestedIndex,