1 // -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 this.EXPORTED_SYMBOLS = ["RemoteWebNavigation"];
8 const Ci = Components.interfaces;
9 const Cc = Components.classes;
10 const Cu = Components.utils;
12 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
16 return Cc["@mozilla.org/network/io-service;1"].
17 getService(Ci.nsIIOService).
18 newURI(url, null, null);
21 function RemoteWebNavigation(browser)
23 this._browser = browser;
24 this._browser.messageManager.addMessageListener("WebNavigation:setHistory", this);
27 RemoteWebNavigation.prototype = {
28 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebNavigation, Ci.nsISupports]),
30 LOAD_FLAGS_MASK: 65535,
32 LOAD_FLAGS_IS_REFRESH: 16,
33 LOAD_FLAGS_IS_LINK: 32,
34 LOAD_FLAGS_BYPASS_HISTORY: 64,
35 LOAD_FLAGS_REPLACE_HISTORY: 128,
36 LOAD_FLAGS_BYPASS_CACHE: 256,
37 LOAD_FLAGS_BYPASS_PROXY: 512,
38 LOAD_FLAGS_CHARSET_CHANGE: 1024,
39 LOAD_FLAGS_STOP_CONTENT: 2048,
40 LOAD_FLAGS_FROM_EXTERNAL: 4096,
41 LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP: 8192,
42 LOAD_FLAGS_FIRST_LOAD: 16384,
43 LOAD_FLAGS_ALLOW_POPUPS: 32768,
44 LOAD_FLAGS_BYPASS_CLASSIFIER: 65536,
45 LOAD_FLAGS_FORCE_ALLOW_COOKIES: 131072,
54 this._sendMessage("WebNavigation:GoBack", {});
56 goForward: function() {
57 this._sendMessage("WebNavigation:GoForward", {});
59 gotoIndex: function(aIndex) {
60 this._sendMessage("WebNavigation:GotoIndex", {index: aIndex});
62 loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
63 this._browser._contentTitle = "";
64 this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
66 reload: function(aReloadFlags) {
67 this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags});
69 stop: function(aStopFlags) {
70 this._sendMessage("WebNavigation:Stop", {flags: aStopFlags});
74 return this._browser.contentDocument;
79 if (!this._currentURI) {
80 this._currentURI = makeURI("about:blank");
83 return this._currentURI;
85 set currentURI(aURI) {
86 this.loadURI(aURI.spec, null, null, null);
91 _sessionHistory: null,
92 get sessionHistory() { return this._sessionHistory; },
93 set sessionHistory(aValue) { },
95 _sendMessage: function(aMessage, aData) {
97 this._browser.messageManager.sendAsyncMessage(aMessage, aData);
104 receiveMessage: function(aMessage) {
105 switch (aMessage.name) {
106 case "WebNavigation:setHistory":
107 this._sessionHistory = aMessage.objects.history;