Bug 595839 - Unknown protocol warning dialog appears more than once [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 15 Sep 2010 12:41:31 +0200
changeset 66591 1db691fab2b14ac4aac3251f775ca4e3b739a85f
parent 66590 7d030abb71e941ce7e8102ab9aba524a7427bb9c
child 66592 19e18b47969e8b6ee7f0afd479571e2997c87ec0
child 66650 98bc118caee2b337187f7116eda2a83ab2f30db5
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)
reviewersmfinkle
bugs595839
Bug 595839 - Unknown protocol warning dialog appears more than once [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -701,23 +701,23 @@ var Browser = {
     let hasLocal = Util.isLocalScheme(currentURI);
 
     if (hasLocal != useLocal) {
       let oldTab = this.selectedTab;
       if (currentURI == "about:blank" && !browser.canGoBack && !browser.canGoForward) {
         this.closeTab(oldTab);
         oldTab = null;
       }
-      let tab = Browser.addTab(aURI, true, oldTab);
-      tab.browser.stop();
+      Browser.addTab(aURI, true, oldTab, aParams);
     }
-
-    let params = aParams || {};
-    let flags = params.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
-    getBrowser().loadURIWithFlags(aURI, flags, params.referrerURI, params.charset, params.postData);
+    else {
+      let params = aParams || {};
+      let flags = params.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
+      getBrowser().loadURIWithFlags(aURI, flags, params.referrerURI, params.charset, params.postData);
+    }
   },
 
   /**
    * Return the currently active <browser> object
    */
   get selectedBrowser() {
     return this._selectedTab.browser;
   },
@@ -744,22 +744,22 @@ var Browser = {
   getTabFromChrome: function getTabFromChrome(chromeTab) {
     for (var t = 0; t < this._tabs.length; t++) {
       if (this._tabs[t].chromeTab == chromeTab)
         return this._tabs[t];
     }
     return null;
   },
 
-  addTab: function(uri, bringFront, aOwner) {
-    let newTab = new Tab(uri);
+  addTab: function(aURI, aBringFront, aOwner, aParams) {
+    let newTab = new Tab(aURI, aParams);
     newTab.owner = aOwner || null;
     this._tabs.push(newTab);
 
-    if (bringFront)
+    if (aBringFront)
       this.selectedTab = newTab;
 
     let event = document.createEvent("Events");
     event.initEvent("TabOpen", true, false);
     newTab.chromeTab.dispatchEvent(event);
     newTab.browser.messageManager.sendAsyncMessage("Browser:TabOpen");
 
     return newTab;
@@ -2483,31 +2483,33 @@ var OfflineApps = {
 
   receiveMessage: function receiveMessage(aMessage) {
     if (aMessage.name == "Browser:MozApplicationManifest") {
       this.offlineAppRequested(aMessage.json);
     }
   }
 };
 
-function Tab(aURI) {
+function Tab(aURI, aParams) {
   this._id = null;
   this._browser = null;
   this._browserViewportState = null;
   this._state = null;
   this._listener = null;
   this._loading = false;
   this._chromeTab = null;
   this.owner = null;
 
   // Set to 0 since new tabs that have not been viewed yet are good tabs to
   // toss if app needs more memory.
   this.lastSelected = 0;
 
-  this.create(aURI);
+  // aParams is an object that contains some properties for the initial tab
+  // loading like flags, a referrerURI, a charset or even a postData.
+  this.create(aURI, aParams || {});
 }
 
 Tab.prototype = {
   get browser() {
     return this._browser;
   },
 
   get browserViewportState() {
@@ -2613,22 +2615,33 @@ Tab.prototype = {
       bv.setAggressive(true);
     }
   },
 
   isLoading: function isLoading() {
     return this._loading;
   },
 
-  create: function create(aURI) {
+  create: function create(aURI, aParams) {
     // Initialize a viewport state for BrowserView
     this._browserViewportState = BrowserView.Util.createBrowserViewportState();
 
     this._chromeTab = document.getElementById("tabs").addTab();
-    this._createBrowser(aURI);
+    let browser = this._createBrowser(aURI);
+
+    // Attach a separate progress listener to the browser
+    let flags = Ci.nsIWebProgress.NOTIFY_LOCATION |
+                Ci.nsIWebProgress.NOTIFY_SECURITY |
+                Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
+                Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT;
+    this._listener = new ProgressController(this);
+    browser.webProgress.addProgressListener(this._listener, flags);
+
+    let flags = aParams.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
+    browser.loadURIWithFlags(aURI, flags, aParams.referrerURI, aParams.charset, aParams.postData);
   },
 
   destroy: function destroy() {
     document.getElementById("tabs").removeTab(this._chromeTab);
     this._chromeTab = null;
     this._destroyBrowser();
   },
 
@@ -2641,32 +2654,24 @@ Tab.prototype = {
     this._chromeTab.linkedBrowser = browser;
 
     browser.setAttribute("style", "overflow: -moz-hidden-unscrollable; visibility: hidden;");
     browser.setAttribute("type", "content");
 
     let useRemote = Services.prefs.getBoolPref("browser.tabs.remote");
     let useLocal = Util.isLocalScheme(aURI);
     browser.setAttribute("remote", (!useLocal && useRemote) ? "true" : "false");
-    
+
     // Append the browser to the document, which should start the page load
     document.getElementById("browsers").appendChild(browser);
 
     // stop about:blank from loading
     browser.stop();
 
-    // Attach a separate progress listener to the browser
-    let flags = Ci.nsIWebProgress.NOTIFY_LOCATION |
-                Ci.nsIWebProgress.NOTIFY_SECURITY |
-                Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
-                Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT;
-    this._listener = new ProgressController(this);
-    browser.webProgress.addProgressListener(this._listener, flags);
-
-    browser.setAttribute("src", aURI);
+    return browser;
   },
 
   _destroyBrowser: function _destroyBrowser() {
     if (this._browser) {
       var browser = this._browser;
       browser.removeProgressListener(this._listener);
 
       this._browser = null;