Bug 931534 - Make back/forward dropdowns work using CPOWs (r=felipe)
This commit is contained in:
@@ -114,6 +114,10 @@ let WebNavigation = {
|
||||
addMessageListener("WebNavigation:LoadURI", this);
|
||||
addMessageListener("WebNavigation:Reload", this);
|
||||
addMessageListener("WebNavigation:Stop", this);
|
||||
|
||||
// Send a CPOW for the sessionHistory object.
|
||||
let history = this._webNavigation.sessionHistory;
|
||||
sendAsyncMessage("WebNavigation:setHistory", {}, {history: history});
|
||||
},
|
||||
|
||||
receiveMessage: function(message) {
|
||||
@@ -125,16 +129,16 @@ let WebNavigation = {
|
||||
this.goForward();
|
||||
break;
|
||||
case "WebNavigation:GotoIndex":
|
||||
this.gotoIndex(message);
|
||||
this.gotoIndex(message.data.index);
|
||||
break;
|
||||
case "WebNavigation:LoadURI":
|
||||
this.loadURI(message);
|
||||
this.loadURI(message.data.uri, message.data.flags);
|
||||
break;
|
||||
case "WebNavigation:Reload":
|
||||
this.reload(message);
|
||||
this.reload(message.data.flags);
|
||||
break;
|
||||
case "WebNavigation:Stop":
|
||||
this.stop(message);
|
||||
this.stop(message.data.flags);
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -149,22 +153,19 @@ let WebNavigation = {
|
||||
this._webNavigation.goForward();
|
||||
},
|
||||
|
||||
gotoIndex: function(message) {
|
||||
this._webNavigation.gotoIndex(message.index);
|
||||
gotoIndex: function(index) {
|
||||
this._webNavigation.gotoIndex(index);
|
||||
},
|
||||
|
||||
loadURI: function(message) {
|
||||
let flags = message.json.flags || this._webNavigation.LOAD_FLAGS_NONE;
|
||||
this._webNavigation.loadURI(message.json.uri, flags, null, null, null);
|
||||
loadURI: function(uri, flags) {
|
||||
this._webNavigation.loadURI(uri, flags, null, null, null);
|
||||
},
|
||||
|
||||
reload: function(message) {
|
||||
let flags = message.json.flags || this._webNavigation.LOAD_FLAGS_NONE;
|
||||
reload: function(flags) {
|
||||
this._webNavigation.reload(flags);
|
||||
},
|
||||
|
||||
stop: function(message) {
|
||||
let flags = message.json.flags || this._webNavigation.STOP_ALL;
|
||||
stop: function(flags) {
|
||||
this._webNavigation.stop(flags);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,18 +33,9 @@
|
||||
|
||||
<field name="_remoteWebNavigation">null</field>
|
||||
|
||||
<property name="webNavigation" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (!this._remoteWebNavigation) {
|
||||
let jsm = "resource://gre/modules/RemoteWebNavigation.jsm";
|
||||
let RemoteWebNavigation = Cu.import(jsm, {}).RemoteWebNavigation;
|
||||
this._remoteWebNavigation = new RemoteWebNavigation(this);
|
||||
}
|
||||
return this._remoteWebNavigation;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
<property name="webNavigation"
|
||||
onget="return this._remoteWebNavigation;"
|
||||
readonly="true"/>
|
||||
|
||||
<field name="_remoteWebProgress">null</field>
|
||||
|
||||
@@ -111,6 +102,10 @@
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
let jsm = "resource://gre/modules/RemoteWebNavigation.jsm";
|
||||
let RemoteWebNavigation = Cu.import(jsm, {}).RemoteWebNavigation;
|
||||
this._remoteWebNavigation = new RemoteWebNavigation(this);
|
||||
|
||||
this.messageManager.addMessageListener("DOMTitleChanged", this);
|
||||
this.messageManager.addMessageListener("ImageDocumentLoaded", this);
|
||||
this.messageManager.loadFrameScript("chrome://global/content/browser-child.js", true);
|
||||
@@ -121,7 +116,7 @@
|
||||
this.messageManager.loadFrameScript("chrome://global/content/select-child.js", true);
|
||||
}
|
||||
|
||||
let jsm = "resource://gre/modules/RemoteController.jsm";
|
||||
jsm = "resource://gre/modules/RemoteController.jsm";
|
||||
let RemoteController = Components.utils.import(jsm, {}).RemoteController;
|
||||
this._controller = new RemoteController(this);
|
||||
this.controllers.appendController(this._controller);
|
||||
|
||||
@@ -11,9 +11,17 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function makeURI(url)
|
||||
{
|
||||
return Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(url, null, null);
|
||||
}
|
||||
|
||||
function RemoteWebNavigation(browser)
|
||||
{
|
||||
this._browser = browser;
|
||||
this._browser.messageManager.addMessageListener("WebNavigation:setHistory", this);
|
||||
}
|
||||
|
||||
RemoteWebNavigation.prototype = {
|
||||
@@ -42,28 +50,48 @@ RemoteWebNavigation.prototype = {
|
||||
|
||||
canGoBack: false,
|
||||
canGoForward: false,
|
||||
goBack: function() { this._sendMessage("WebNavigation:GoBack", {}); },
|
||||
goForward: function() { this._sendMessage("WebNavigation:GoForward", {}); },
|
||||
gotoIndex: function(aIndex) { this._sendMessage("WebNavigation:GotoIndex", {index: aIndex}); },
|
||||
goBack: function() {
|
||||
this._sendMessage("WebNavigation:GoBack", {});
|
||||
},
|
||||
goForward: function() {
|
||||
this._sendMessage("WebNavigation:GoForward", {});
|
||||
},
|
||||
gotoIndex: function(aIndex) {
|
||||
this._sendMessage("WebNavigation:GotoIndex", {index: aIndex});
|
||||
},
|
||||
loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
|
||||
this._browser._contentTitle = "";
|
||||
this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
|
||||
},
|
||||
reload: function(aReloadFlags) { this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags}); },
|
||||
stop: function(aStopFlags) { this._sendMessage("WebNavigation:Stop", {flags: aStopFlags}); },
|
||||
get document() { return this._browser.contentDocument; },
|
||||
reload: function(aReloadFlags) {
|
||||
this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags});
|
||||
},
|
||||
stop: function(aStopFlags) {
|
||||
this._sendMessage("WebNavigation:Stop", {flags: aStopFlags});
|
||||
},
|
||||
|
||||
get document() {
|
||||
return this._browser.contentDocument;
|
||||
},
|
||||
|
||||
_currentURI: null,
|
||||
get currentURI() {
|
||||
if (!this._currentURI)
|
||||
this._currentURI = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService).newURI("about:blank", null, null);
|
||||
if (!this._currentURI) {
|
||||
this._currentURI = makeURI("about:blank");
|
||||
}
|
||||
|
||||
return this._currentURI;
|
||||
},
|
||||
set currentURI(aURI) { this.loadURI(aURI.spec, null, null, null); },
|
||||
set currentURI(aURI) {
|
||||
this.loadURI(aURI.spec, null, null, null);
|
||||
},
|
||||
|
||||
referringURI: null,
|
||||
get sessionHistory() { return null; },
|
||||
|
||||
_sessionHistory: null,
|
||||
get sessionHistory() { return this._sessionHistory; },
|
||||
set sessionHistory(aValue) { },
|
||||
|
||||
_currentURI: null,
|
||||
_sendMessage: function(aMessage, aData) {
|
||||
try {
|
||||
this._browser.messageManager.sendAsyncMessage(aMessage, aData);
|
||||
@@ -71,5 +99,13 @@ RemoteWebNavigation.prototype = {
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "WebNavigation:setHistory":
|
||||
this._sessionHistory = aMessage.objects.history;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user