Bug 1281847 Part 1 switch disco browser to <iframe mozbrowser>
MozReview-Commit-ID: LWNCwY0DvFX
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2065,16 +2065,17 @@ var gHeader = {
var gDiscoverView = {
node: null,
enabled: true,
// Set to true after the view is first shown. If initialization completes
// after this then it must also load the discover homepage
loaded: false,
_browser: null,
+ _browserDocshell: null,
_loading: null,
_error: null,
homepageURL: null,
_loadListeners: [],
hideHeader: true,
initialize: function() {
this.enabled = isDiscoverEnabled();
@@ -2082,16 +2083,19 @@ var gDiscoverView = {
gCategories.get("addons://discover/").hidden = true;
return;
}
this.node = document.getElementById("discover-view");
this._loading = document.getElementById("discover-loading");
this._error = document.getElementById("discover-error");
this._browser = document.getElementById("discover-browser");
+ this._browserDocshell = this._browser.frameLoader.docShell;
+ this._browserDocshell.QueryInterface(Ci.nsIWebProgress);
+ this._browserDocshell.QueryInterface(Ci.nsIWebNavigation);
let compatMode = "normal";
if (!AddonManager.checkCompatibility)
compatMode = "ignore";
else if (AddonManager.strictCompatibility)
compatMode = "strict";
var url = Services.prefs.getCharPref(PREF_DISCOVERURL);
@@ -2102,18 +2106,18 @@ var gDiscoverView = {
try {
this.homepageURL = Services.io.newURI(aURL, null, null);
} catch (e) {
this.showError();
notifyInitialized();
return;
}
- this._browser.homePage = this.homepageURL.spec;
- this._browser.addProgressListener(this);
+ this._browser.src = this.homepageURL.spec;
+ this._browserDocshell.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_ALL);
if (this.loaded)
this._loadURL(this.homepageURL.spec, false, notifyInitialized);
else
notifyInitialized();
}
if (Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED) == false) {
@@ -2198,33 +2202,35 @@ var gDiscoverView = {
hide: function() { },
showError: function() {
this.node.selectedPanel = this._error;
},
_loadURL: function(aURL, aKeepHistory, aCallback) {
- if (this._browser.currentURI.spec == aURL) {
+ if (this._browserDocshell.currentURI.spec == aURL) {
if (aCallback)
aCallback();
return;
}
if (aCallback)
this._loadListeners.push(aCallback);
var flags = 0;
if (!aKeepHistory)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
- this._browser.loadURIWithFlags(aURL, flags);
+ aURL = aURL.slice(0, 86);
+ this._browserDocshell.loadURI(aURL, flags, null, null, null);
},
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
+ dump(`onLocationChange to ${aLocation.spec}\n`);
// Ignore the about:blank load
if (aLocation.spec == "about:blank")
return;
// When using the real session history the inner-frame will update the
// session history automatically, if using the fake history though it must
// be manually updated
if (gHistory == FakeHistory) {
@@ -2267,16 +2273,17 @@ var gDiscoverView = {
return;
// Canceling the request will send an error to onStateChange which will show
// the error page
aRequest.cancel(Components.results.NS_BINDING_ABORTED);
},
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
+ dump(`got onStateChange, status ${aStatus}\n`);
let transferStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
Ci.nsIWebProgressListener.STATE_IS_REQUEST |
Ci.nsIWebProgressListener.STATE_TRANSFERRING;
// Once transferring begins show the content
if ((aStateFlags & transferStart) === transferStart)
this.node.selectedPanel = this._browser;
// Only care about the network events
--- a/toolkit/mozapps/extensions/content/extensions.xul
+++ b/toolkit/mozapps/extensions/content/extensions.xul
@@ -184,18 +184,17 @@
<description class="discover-description">&discover.description2;</description>
<description class="discover-footer">&discover.footer;</description>
</vbox>
</hbox>
<spacer class="discover-spacer-after"/>
</hbox>
<spacer class="alert-spacer-after"/>
</vbox>
- <browser id="discover-browser" type="content" flex="1"
- disablehistory="true" homepage="about:blank"/>
+ <xhtml:iframe id="discover-browser" mozbrowser="true" />
</deck>
<!-- container for views with the search/tools header -->
<vbox id="headered-views" flex="1">
<!-- main header -->
<hbox id="header" align="center">
<button id="show-all-extensions" hidden="true"
label="&showAllExtensions.button.label;"