Bumping manifests a=b2g-bump
[gecko.git] / browser / modules / E10SUtils.jsm
blob563c9331db6d88e8e88fbb026c1ed63069fba679
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/. */
5 "use strict";
7 this.EXPORTED_SYMBOLS = ["E10SUtils"];
9 const {interfaces: Ci, utils: Cu, classes: Cc} = Components;
11 Cu.import("resource://gre/modules/Services.jsm");
13 this.E10SUtils = {
14   shouldBrowserBeRemote: function(aURL) {
15     // loadURI in browser.xml treats null as about:blank
16     if (!aURL)
17       aURL = "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")) {
24       return false;
25     }
27     return true;
28   },
30   shouldLoadURI: function(aDocShell, aURI, aReferrer) {
31     // about:blank is the initial document and can load anywhere
32     if (aURI.spec == "about:blank")
33       return true;
35     // Inner frames should always load in the current process
36     if (aDocShell.QueryInterface(Ci.nsIDocShellTreeItem).sameTypeParent)
37       return true;
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)
42       return true;
44     return false;
45   },
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", {
54       loadOptions: {
55         uri: aURI.spec,
56         flags: Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
57         referrer: aReferrer ? aReferrer.spec : null,
58       },
59       historyIndex: sessionHistory.requestedIndex,
60     });
61     return false;
62   },