Bug 561016 - e10s: Add support for openURIInFrame in BrowserAccess [r=stechz]
authorMark Finkle <mfinkle@mozilla.com>
Mon, 24 May 2010 15:27:45 -0400
changeset 66246 b4bb0b98c03c74437593085b6681d38d379b957c
parent 66245 0ebb56d5d83ef27e60784c7f3c64639d6ce30f53
child 66247 0fd159165ae5f77a7378580be47809eb23f70ebe
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstechz
bugs561016
Bug 561016 - e10s: Add support for openURIInFrame in BrowserAccess [r=stechz]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1623,64 +1623,71 @@ function nsBrowserAccess()
 
 nsBrowserAccess.prototype = {
   QueryInterface: function(aIID) {
     if (aIID.equals(Ci.nsIBrowserDOMWindow) || aIID.equals(Ci.nsISupports))
       return this;
     throw Components.results.NS_NOINTERFACE;
   },
 
-  openURI: function(aURI, aOpener, aWhere, aContext) {
-    var isExternal = (aContext == Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
-    if (isExternal && aURI && aURI.schemeIs("chrome")) {
-      //dump("use -chrome command-line option to load external chrome urls\n");
+  _getBrowser: function _getBrowser(aURI, aOpener, aWhere, aContext) {
+    let isExternal = (aContext == Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
+    if (isExternal && aURI && aURI.schemeIs("chrome"))
       return null;
-    }
-
-    var loadflags = isExternal ?
-                       Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
-                       Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
-    var location;
+
+    let loadflags = isExternal ?
+                      Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
+                      Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
+    let location;
     if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW) {
       switch (aContext) {
         case Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL :
           aWhere = gPrefService.getIntPref("browser.link.open_external");
           break;
         default : // OPEN_NEW or an illegal value
           aWhere = gPrefService.getIntPref("browser.link.open_newwindow");
       }
     }
 
-    var newWindow;
+    let browser;
     if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW) {
-      var url = aURI ? aURI.spec : "about:blank";
-      newWindow = openDialog("chrome://browser/content/browser.xul", "_blank",
-                             "all,dialog=no", url, null, null, null);
+      let url = aURI ? aURI.spec : "about:blank";
+      let newWindow = openDialog("chrome://browser/content/browser.xul", "_blank",
+                                 "all,dialog=no", url, null, null, null);
+      browser = newWindow.Browser.selectedBrowser;
     } else {
       if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB)
-        newWindow = Browser.addTab("about:blank", true).browser.contentWindow;
-      else
-        newWindow = aOpener ? aOpener.top : browser.contentWindow;
+        browser = Browser.addTab("about:blank", true).browser;
+      else // OPEN_CURRENTWINDOW and illegal values
+        browser = Browser.selectedBrowser;
     }
-
+    
     try {
-      var referrer;
+      let referrer;
       if (aURI) {
         if (aOpener) {
           location = aOpener.location;
           referrer = gIOService.newURI(location, null, null);
         }
-        newWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .loadURI(aURI.spec, loadflags, referrer, null, null);
+        browser.loadURI(aURI.spec, loadflags, referrer, null, null);
       }
-      newWindow.focus();
+      browser.focus();
     } catch(e) { }
 
-    return newWindow;
+    return browser;
+  },
+
+  openURI: function(aURI, aOpener, aWhere, aContext) {
+    let browser = this._getBrowser(aURI, aOpener, aWhere, aContext);
+    return browser ? browser.contentWindow : null;
+  },
+
+  openURIInFrame: function(aURI, aOpener, aWhere, aContext) {
+    let browser = this._getBrowser(aURI, aOpener, aWhere, aContext);
+    return browser ? browser.QueryInterface(Ci.nsIFrameLoaderOwner) : null;
   },
 
   isTabContentWindow: function(aWindow) {
     return Browser.browsers.some(function (browser) browser.contentWindow == aWindow);
   }
 };
 
 const BrowserSearch = {