2010-06-07 19:44:06 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
|
|
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
-
|
|
|
|
- The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
- 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
- the License. You may obtain a copy of the License at
|
|
|
|
- http://www.mozilla.org/MPL/
|
|
|
|
-
|
|
|
|
- Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
- for the specific language governing rights and limitations under the
|
|
|
|
- License.
|
|
|
|
-
|
|
|
|
- The Original Code is this file as it was released on March 28, 2001.
|
|
|
|
-
|
|
|
|
- The Initial Developer of the Original Code is
|
|
|
|
- Peter Annema.
|
|
|
|
- Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
- the Initial Developer. All Rights Reserved.
|
|
|
|
-
|
|
|
|
- Contributor(s):
|
|
|
|
- Peter Annema <disttsc@bart.nl> (Original Author of <browser>)
|
|
|
|
- Peter Parente <parente@cs.unc.edu>
|
|
|
|
- Christopher Thomas <cst@yecc.com>
|
|
|
|
- Michael Ventnor <m.ventnor@gmail.com>
|
|
|
|
- Arpad Borsos <arpad.borsos@googlemail.com>
|
|
|
|
-
|
|
|
|
- Alternatively, the contents of this file may be used under the terms of
|
|
|
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
- of those above. If you wish to allow use of your version of this file only
|
|
|
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
- use your version of this file under the terms of the MPL, indicate your
|
|
|
|
- decision by deleting the provisions above and replace them with the notice
|
|
|
|
- and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
- the provisions above, a recipient may use your version of this file under
|
|
|
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
-
|
|
|
|
- ***** END LICENSE BLOCK ***** -->
|
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findbar.dtd" >
|
|
|
|
%findBarDTD;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<bindings id="remoteBrowserBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<binding id="local-browser" extends="chrome://global/content/bindings/browser.xml#browser">
|
2010-06-07 19:44:06 -07:00
|
|
|
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
|
2010-06-16 06:53:29 -07:00
|
|
|
<field name="_securityUI">null</field>
|
|
|
|
<property name="securityUI">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._securityUI) {
|
|
|
|
const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
|
|
|
|
if (!this.hasAttribute("disablesecurity") && SECUREBROWSERUI_CONTRACTID in Components.classes) {
|
|
|
|
this.messageManager.sendAsyncMessage('SecurityUI:Init', { });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._securityUI || {};
|
|
|
|
]]></getter>
|
|
|
|
<setter><![CDATA[
|
|
|
|
this._securityUI = val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<field name="_searchEngines">[]</field>
|
|
|
|
<property name="searchEngines"
|
|
|
|
onget="return this._searchEngines"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-08 08:22:20 -07:00
|
|
|
<field name="_documentURI">null</field>
|
|
|
|
<property name="documentURI"
|
2010-07-13 07:36:09 -07:00
|
|
|
onget="return Services.io.newURI(this._documentURI, null, null)"
|
2010-06-08 08:22:20 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
<field name="contentWindowId">null</field>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<property name="messageManager"
|
|
|
|
onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<field name="_contentTitle">null</field>
|
|
|
|
|
|
|
|
<field name="_ios">
|
|
|
|
Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<method name="receiveMessage">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
switch (aMessage.name) {
|
2010-06-08 08:22:20 -07:00
|
|
|
case "DOMPopupBlocked":
|
|
|
|
this.onPopupBlocked(aMessage);
|
2010-06-07 19:44:06 -07:00
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
|
|
|
case "pageshow":
|
|
|
|
this.onPageShow(aMessage);
|
2010-06-15 11:05:17 -07:00
|
|
|
|
2010-06-22 06:24:02 -07:00
|
|
|
if (this.mIconURL == "" && this._documentURI)
|
2010-06-15 11:05:17 -07:00
|
|
|
this.mIconURL = this.documentURI.prePath + "/favicon.ico";
|
2010-06-07 19:44:06 -07:00
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
|
|
|
case "pagehide":
|
|
|
|
this.onPageHide(aMessage);
|
2010-06-07 19:44:06 -07:00
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
|
|
|
case "DOMTitleChanged":
|
|
|
|
this._contentTitle = aMessage.json.title;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "DOMLinkAdded":
|
2010-06-07 19:44:06 -07:00
|
|
|
let link = aMessage.json;
|
2010-06-21 13:18:42 -07:00
|
|
|
// ignore results from subdocuments
|
|
|
|
if (link.windowId != this.contentWindowId)
|
2010-07-01 11:11:02 -07:00
|
|
|
return;
|
2010-06-07 19:44:06 -07:00
|
|
|
|
|
|
|
let linkType = this._getLinkType(link);
|
|
|
|
switch(linkType) {
|
|
|
|
case "icon":
|
2010-07-13 07:36:09 -07:00
|
|
|
let iconURI = Services.io.newURI(link.href, link.charset, null);
|
2010-06-07 19:44:06 -07:00
|
|
|
if (!iconURI.schemeIs("javascript") && !gFaviconService.isFailedFavicon(iconURI)) {
|
|
|
|
gFaviconService.setAndLoadFaviconForPage(this.currentURI, iconURI, true);
|
|
|
|
this.mIconURL = iconURI.spec;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "search":
|
|
|
|
this._searchEngines.push({ title: link.title, href: link.href });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2010-07-28 14:37:24 -07:00
|
|
|
|
|
|
|
case "Prompt:Alert":
|
|
|
|
alert(aMessage.json.message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Prompt:Confirm":
|
|
|
|
return confirm(aMessage.json.message);
|
|
|
|
|
|
|
|
case "Prompt:Prompt":
|
|
|
|
return prompt(aMessage.json.text, aMessage.json.value);
|
2010-08-27 08:36:11 -07:00
|
|
|
|
|
|
|
case "MozScrolledAreaChanged":
|
|
|
|
this._widthInDevicePx = aMessage.json.width;
|
|
|
|
this._heightInDevicePx = aMessage.json.height;
|
|
|
|
break;
|
2010-08-27 12:12:48 -07:00
|
|
|
|
|
|
|
case "Content:FastScrollTo:Return":
|
|
|
|
this._flushingFastScroll = false;
|
|
|
|
break;
|
2010-06-07 19:44:06 -07:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_getLinkType">
|
|
|
|
<parameter name="aLink" />
|
|
|
|
<body><![CDATA[
|
|
|
|
let type = "";
|
|
|
|
if (/\bicon\b/i(aLink.rel)) {
|
|
|
|
type = "icon";
|
|
|
|
}
|
|
|
|
else if (/\bsearch\b/i(aLink.rel) && aLink.type && aLink.title) {
|
|
|
|
let linkType = aLink.type.replace(/^\s+|\s*(?:;.*)?$/g, "").toLowerCase();
|
|
|
|
if (linkType == "application/opensearchdescription+xml" && /^(?:https?|ftp):/i.test(aLink.href)) {
|
|
|
|
type = "search";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<field name="_webProgress"><![CDATA[
|
|
|
|
({
|
2010-06-09 13:07:32 -07:00
|
|
|
_listeners: [],
|
2010-06-08 19:36:04 -07:00
|
|
|
_browser: this,
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
_init: function() {
|
2010-06-09 13:07:32 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StateChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:ProgressChange", this);
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:LocationChange", this);
|
2010-06-09 13:07:32 -07:00
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StatusChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:SecurityChange", this);
|
|
|
|
},
|
|
|
|
|
|
|
|
addProgressListener: function(aListener, aNotifyFlags) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener == aListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._listeners.some(hasFilter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._listeners.push({
|
|
|
|
listener: aListener,
|
|
|
|
flags: aNotifyFlags
|
|
|
|
});
|
2010-07-26 17:48:46 -07:00
|
|
|
|
|
|
|
this._browser.messageManager.sendAsyncMessage("WebProgress:AddProgressListener", {
|
|
|
|
notifyFlags: aNotifyFlags,
|
|
|
|
});
|
2010-06-08 12:30:46 -07:00
|
|
|
},
|
2010-06-07 19:44:06 -07:00
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
removeProgressListener: function(aListener) {
|
2010-07-28 12:43:13 -07:00
|
|
|
let self = this;
|
2010-06-09 13:07:32 -07:00
|
|
|
function hasFilter(item) {
|
2010-07-26 17:48:46 -07:00
|
|
|
if (item.listener == aListener)
|
2010-07-28 12:43:13 -07:00
|
|
|
self._browser.messageManager.sendAsyncMessage("WebProgress:RemoveProgressListener", {
|
2010-07-26 17:48:46 -07:00
|
|
|
notifyFlags: item.flags,
|
|
|
|
});
|
2010-06-09 13:07:32 -07:00
|
|
|
return item.listener != aListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._listeners = this._listeners.filter(hasFilter);
|
|
|
|
},
|
|
|
|
get DOMWindow() { throw "DOMWindow: Not Remoteable" },
|
|
|
|
get isLoadingDocument() { throw "isLoadingDocument: Not Remoteable"; },
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
receiveMessage: function(aMessage) {
|
2010-06-09 13:07:32 -07:00
|
|
|
let args;
|
2010-06-08 12:30:46 -07:00
|
|
|
let json = aMessage.json;
|
|
|
|
switch (aMessage.name) {
|
2010-06-09 13:07:32 -07:00
|
|
|
case "WebProgress:StateChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.stateFlags,
|
|
|
|
json.status
|
|
|
|
];
|
|
|
|
|
|
|
|
this._notify(json.notifyFlags, "onStateChange", args);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:ProgressChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.curSelf,
|
|
|
|
json.maxSelf,
|
|
|
|
json.curTotal,
|
|
|
|
json.maxTotal
|
|
|
|
];
|
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS,
|
|
|
|
"onProgressChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
case "WebProgress:LocationChange":
|
2010-06-09 13:07:32 -07:00
|
|
|
let locationURI = this._browser._ios.newURI(json.location, null, null);
|
|
|
|
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
locationURI
|
|
|
|
];
|
|
|
|
|
|
|
|
if (this._browser.contentWindowId != json.windowId) {
|
|
|
|
this._browser.contentWindowId = json.windowId;
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser._documentURI = json.documentURI;
|
|
|
|
this._browser._searchEngines = [];
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
|
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
|
|
|
"onLocationChange",
|
|
|
|
args);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:StatusChange":
|
|
|
|
args = [
|
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
|
|
|
{},
|
|
|
|
json.status,
|
|
|
|
json.message
|
|
|
|
];
|
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_STATUS,
|
|
|
|
"onStatusChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "WebProgress:SecurityChange":
|
|
|
|
args = [
|
2010-06-16 06:53:29 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-09 13:07:32 -07:00
|
|
|
{},
|
|
|
|
json.state
|
|
|
|
];
|
2010-06-16 06:53:29 -07:00
|
|
|
|
|
|
|
this._browser._securityUI = {
|
|
|
|
SSLStatus: json.SSLStatus,
|
|
|
|
state: json.state
|
|
|
|
}
|
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_SECURITY,
|
|
|
|
"onSecurityChange",
|
|
|
|
args);
|
2010-06-08 12:30:46 -07:00
|
|
|
break;
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
_notify: function(aFlags, aName, aArguments) {
|
|
|
|
this._listeners.forEach(function(item) {
|
|
|
|
if (item.flags & aFlags) {
|
|
|
|
item.listener[aName].apply(item.listener, aArguments);
|
|
|
|
}
|
|
|
|
});
|
2010-06-08 12:30:46 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
<property name="webProgress"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._webProgress"/>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<method name="onPageShow">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.attachFormFill();
|
|
|
|
if (this.pageReport) {
|
|
|
|
var json = aMessage.json;
|
|
|
|
var i = 0;
|
|
|
|
while (i < this.pageReport.length) {
|
|
|
|
// Filter out irrelevant reports.
|
|
|
|
if (this.pageReport[i].requestingWindowId == json.windowId)
|
|
|
|
i++;
|
|
|
|
else
|
|
|
|
this.pageReport.splice(i, 1);
|
|
|
|
}
|
|
|
|
if (this.pageReport.length == 0) {
|
|
|
|
this.pageReport = null;
|
|
|
|
this.updatePageReport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPageHide">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.pageReport) {
|
|
|
|
this.pageReport = null;
|
|
|
|
this.updatePageReport();
|
|
|
|
}
|
|
|
|
// Delete the feeds cache if we're hiding the topmost page
|
|
|
|
// (as opposed to one of its iframes).
|
2010-06-22 06:24:02 -07:00
|
|
|
if (this.feeds && aMessage.target == this)
|
2010-06-08 12:30:46 -07:00
|
|
|
this.feeds = null;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPopupBlocked">
|
|
|
|
<parameter name="aMessage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this.pageReport) {
|
|
|
|
this.pageReport = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
let json = aMessage.json;
|
|
|
|
// XXX Replacing requestingWindow && requestingDocument affects
|
|
|
|
// http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#500
|
|
|
|
var obj = {
|
|
|
|
requestingWindowId: json.windowId,
|
2010-07-13 07:36:09 -07:00
|
|
|
popupWindowURI: Services.io.newURI(json.popupWindowURI.spec, json.popupWindowURI.charset, null),
|
2010-06-08 12:30:46 -07:00
|
|
|
popupWindowFeatures: json.popupWindowFeatures,
|
|
|
|
popupWindowName: json.popupWindowName
|
|
|
|
};
|
|
|
|
|
|
|
|
this.pageReport.push(obj);
|
|
|
|
this.pageReport.reported = false;
|
|
|
|
this.updatePageReport();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
<property name="_frameLoader"
|
|
|
|
onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-08-27 12:12:48 -07:00
|
|
|
<field name="_flushingFastScroll">false</field>
|
2010-08-27 08:36:11 -07:00
|
|
|
<field name="_widthInDevicePx">0</field>
|
|
|
|
<field name="_heightInDevicePx">0</field>
|
2010-08-27 12:12:48 -07:00
|
|
|
<field name="_zoomLevel">1</field>
|
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
<property name="widthInDevicePx"
|
|
|
|
onget="return this._widthInDevicePx;"
|
|
|
|
readonly="true"/>
|
|
|
|
<property name="heightInDevicePx"
|
|
|
|
onget="return this._heightInDevicePx;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-08-27 12:12:48 -07:00
|
|
|
<property name="zoomLevel"
|
|
|
|
onget="return this._zoomLevel;"
|
|
|
|
onset="return this._setZoomLevel(val);"/>
|
|
|
|
|
|
|
|
<method name="_setZoomLevel">
|
|
|
|
<parameter name="zl"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
throw "Not supported yet!";
|
|
|
|
if (zl <= 0) throw "Bad zoom level given.";
|
|
|
|
this._zoomLevel = zl;
|
|
|
|
this.messageManager.sendAsyncMessage("Content:ZoomLevel", { zoomLevel: zl });
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
<method name="flushScroll">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
this.messageManager.sendAsyncMessage("Content:ScrollTo", {
|
|
|
|
x: frameLoader.viewportScrollX,
|
|
|
|
y: frameLoader.viewportScrollY
|
|
|
|
});
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="scrollBy">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
|
|
|
|
// XXX don't assume window size is viewport size
|
|
|
|
let viewportWidth = window.innerWidth;
|
|
|
|
let viewportHeight = window.innerHeight;
|
|
|
|
|
|
|
|
x = Math.max(0, Math.min(this.widthInDevicePx - viewportWidth, frameLoader.viewportScrollX + x)) - frameLoader.viewportScrollX;
|
|
|
|
y = Math.max(0, Math.min(this.heightInDevicePx - viewportHeight, frameLoader.viewportScrollY + y)) - frameLoader.viewportScrollY;
|
2010-08-27 12:12:48 -07:00
|
|
|
|
|
|
|
if (x == 0 && y == 0)
|
|
|
|
return;
|
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
frameLoader.scrollViewportBy(x, y);
|
2010-08-27 12:12:48 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
XXX broken right now
|
|
|
|
if (this._flushingFastScroll == false) {
|
|
|
|
this._flushingFastScroll = true;
|
|
|
|
this.messageManager.sendAsyncMessage("Content:FastScrollTo", {
|
|
|
|
x: frameLoader.viewportScrollX + x,
|
|
|
|
y: frameLoader.viewportScrollY + y
|
|
|
|
});
|
|
|
|
}
|
|
|
|
*/
|
2010-08-27 08:36:11 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="scrollTo">
|
|
|
|
<parameter name="x"/>
|
|
|
|
<parameter name="y"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
|
|
|
|
// XXX don't assume window size is viewport size
|
|
|
|
let viewportWidth = window.innerWidth;
|
|
|
|
let viewportHeight = window.innerHeight;
|
|
|
|
|
|
|
|
x = Math.max(0, Math.min(this.widthInDevicePx - viewportWidth, x));
|
|
|
|
y = Math.max(0, Math.min(this.heightInDevicePx - viewportHeight, y));
|
|
|
|
frameLoader.scrollViewportTo(x, y);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- XXX There is no reason this API needs to act like scrollbar's.
|
|
|
|
Should we change it to something less XPCOMy? -->
|
|
|
|
<method name="getPosition">
|
|
|
|
<parameter name="scrollX"/>
|
|
|
|
<parameter name="scrollY"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let frameLoader = this._frameLoader;
|
|
|
|
scrollX.value = frameLoader.viewportScrollX;
|
|
|
|
scrollY.value = frameLoader.viewportScrollY;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<constructor>
|
2010-06-07 19:44:06 -07:00
|
|
|
<![CDATA[
|
2010-08-27 08:36:11 -07:00
|
|
|
this.messageManager.loadFrameScript("chrome://browser/content/bindings/browser.js", true);
|
|
|
|
this.messageManager.addMessageListener("DOMTitleChanged", this);
|
|
|
|
this.messageManager.addMessageListener("DOMLinkAdded", this);
|
2010-06-08 12:30:46 -07:00
|
|
|
|
|
|
|
// Listen for first load for lazy attachment to form fill controller
|
2010-08-27 08:36:11 -07:00
|
|
|
this.messageManager.addMessageListener("pageshow", this);
|
|
|
|
this.messageManager.addMessageListener("pagehide", this);
|
|
|
|
this.messageManager.addMessageListener("DOMPopupBlocked", this);
|
2010-06-08 12:30:46 -07:00
|
|
|
|
2010-07-28 14:37:24 -07:00
|
|
|
// Prompt remoting
|
|
|
|
["Alert", "Confirm", "Prompt"].forEach(function(name) {
|
2010-08-27 08:36:11 -07:00
|
|
|
this.messageManager.addMessageListener("Prompt:" + name, this);
|
2010-07-28 14:37:24 -07:00
|
|
|
}, this);
|
|
|
|
|
2010-08-27 08:36:11 -07:00
|
|
|
this.messageManager.addMessageListener("MozScrolledAreaChanged", this);
|
2010-08-27 12:12:48 -07:00
|
|
|
this.messageManager.addMessageListener("Content:FastScrollTo:Return", this);
|
2010-08-27 08:36:11 -07:00
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
this._webProgress._init();
|
2010-06-07 19:44:06 -07:00
|
|
|
]]>
|
2010-06-08 12:30:46 -07:00
|
|
|
</constructor>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="remote-browser" extends="#local-browser">
|
|
|
|
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
throw "accessibleType: Supports Remote?";
|
|
|
|
]]>
|
2010-06-07 19:44:06 -07:00
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<property name="autoscrollEnabled">
|
2010-06-07 19:44:06 -07:00
|
|
|
<getter>
|
2010-06-08 12:30:46 -07:00
|
|
|
<![CDATA[
|
|
|
|
throw "autoscrollEnabled: Supports Remote?";
|
|
|
|
]]>
|
2010-06-07 19:44:06 -07:00
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
<property name="docShell"
|
|
|
|
onget="throw 'docShell: Not Remotable'"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<field name="_contentTitle">null</field>
|
|
|
|
|
2010-06-24 15:13:01 -07:00
|
|
|
<property name="contentTitle"
|
|
|
|
onget="return this._contentTitle;"
|
|
|
|
readonly="true"/>
|
2010-06-08 12:30:46 -07:00
|
|
|
|
|
|
|
<field name="_webNavigation"><![CDATA[
|
|
|
|
({
|
2010-06-29 06:19:50 -07:00
|
|
|
LOAD_FLAGS_MASK: 65535,
|
|
|
|
LOAD_FLAGS_NONE: 0,
|
|
|
|
LOAD_FLAGS_IS_REFRESH: 16,
|
|
|
|
LOAD_FLAGS_IS_LINK: 32,
|
|
|
|
LOAD_FLAGS_BYPASS_HISTORY: 64,
|
|
|
|
LOAD_FLAGS_REPLACE_HISTORY: 128,
|
|
|
|
LOAD_FLAGS_BYPASS_CACHE: 256,
|
|
|
|
LOAD_FLAGS_BYPASS_PROXY: 512,
|
|
|
|
LOAD_FLAGS_CHARSET_CHANGE: 1024,
|
|
|
|
LOAD_FLAGS_STOP_CONTENT: 2048,
|
|
|
|
LOAD_FLAGS_FROM_EXTERNAL: 4096,
|
|
|
|
LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP: 8192,
|
|
|
|
LOAD_FLAGS_FIRST_LOAD: 16384,
|
|
|
|
LOAD_FLAGS_ALLOW_POPUPS: 32768,
|
|
|
|
LOAD_FLAGS_BYPASS_CLASSIFIER: 65536,
|
|
|
|
LOAD_FLAGS_FORCE_ALLOW_COOKIES: 131072,
|
|
|
|
|
|
|
|
STOP_NETWORK: 1,
|
|
|
|
STOP_CONTENT: 2,
|
|
|
|
STOP_ALL: 3,
|
|
|
|
|
2010-06-08 12:30:46 -07:00
|
|
|
canGoBack: false,
|
|
|
|
canGoForward: false,
|
2010-06-24 15:13:01 -07:00
|
|
|
goBack: function() { this._sendMessage("WebNavigation:GoBack", {}); },
|
|
|
|
goForward: function() { this._sendMessage("WebNavigation:GoForward", {}); },
|
|
|
|
gotoIndex: function(aIndex) { this._sendMessage("WebNavigation:GotoIndex", {index: aIndex}); },
|
2010-06-08 12:30:46 -07:00
|
|
|
loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
|
2010-07-22 20:55:58 -07:00
|
|
|
try {
|
|
|
|
this._currentURI = this._browser._ios.newURI(aURI, null, null);
|
|
|
|
} catch(e) {}
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser._contentTitle = "";
|
2010-06-24 15:13:01 -07:00
|
|
|
this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
|
2010-06-08 12:30:46 -07:00
|
|
|
},
|
2010-06-24 15:13:01 -07:00
|
|
|
reload: function(aReloadFlags) { this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags}); },
|
|
|
|
stop: function(aStopFlags) { this._sendMessage("WebNavigation:Stop", {flags: aStopFlags}); },
|
2010-06-25 08:28:42 -07:00
|
|
|
get document() { Components.utils.reportError("contentDocument is not available"); return null; },
|
2010-06-08 12:30:46 -07:00
|
|
|
get currentURI() {
|
|
|
|
if (!this._currentURI)
|
|
|
|
this._currentURI = this._browser._ios.newURI("about:blank", null, null);
|
|
|
|
|
|
|
|
return this._currentURI;
|
|
|
|
},
|
|
|
|
set currentURI(aURI) { this.loadURI(aURI.spec, null, null, null); },
|
|
|
|
referringURI: null,
|
2010-07-18 22:27:52 -07:00
|
|
|
get sessionHistory() { return null; },
|
|
|
|
set sessionHistory(aValue) { },
|
2010-06-08 12:30:46 -07:00
|
|
|
|
|
|
|
_currentURI: null,
|
|
|
|
_browser: this,
|
2010-06-24 15:13:01 -07:00
|
|
|
_sendMessage: function(aMessage, aData) {
|
2010-06-08 12:30:46 -07:00
|
|
|
try {
|
|
|
|
this._browser.messageManager.sendAsyncMessage(aMessage, aData);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
Components.utils.reportError(e);
|
|
|
|
}
|
2010-06-29 06:19:50 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface: function(aIID) {
|
|
|
|
if (aIID.equals(Components.interfaces.nsIWebNavigation) || aIID.equals(Components.interfaces.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
2010-06-08 12:30:46 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<property name="webNavigation"
|
|
|
|
onget="return this._webNavigation;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
<field name="_webProgress"><![CDATA[
|
|
|
|
({
|
|
|
|
_listeners: [],
|
|
|
|
_browser: this,
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StateChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:ProgressChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:LocationChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:StatusChange", this);
|
|
|
|
this._browser.messageManager.addMessageListener("WebProgress:SecurityChange", this);
|
|
|
|
},
|
|
|
|
|
|
|
|
addProgressListener: function(aListener, aNotifyFlags) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener == aListener;
|
|
|
|
}
|
2010-06-09 13:07:32 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
if (this._listeners.some(hasFilter))
|
|
|
|
return;
|
2010-06-09 13:07:32 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._listeners.push({
|
|
|
|
listener: aListener,
|
|
|
|
flags: aNotifyFlags
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
removeProgressListener: function(aListener) {
|
|
|
|
function hasFilter(item) {
|
|
|
|
return item.listener != aListener;
|
|
|
|
}
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._listeners = this._listeners.filter(hasFilter);
|
|
|
|
},
|
2010-06-08 08:22:20 -07:00
|
|
|
get DOMWindow() { throw "DOMWindow: Not Remoteable" },
|
2010-06-09 13:07:32 -07:00
|
|
|
get isLoadingDocument() { throw "isLoadingDocument: Not Remoteable"; },
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
receiveMessage: function(aMessage) {
|
|
|
|
let args;
|
2010-06-08 08:22:20 -07:00
|
|
|
let json = aMessage.json;
|
2010-06-07 19:44:06 -07:00
|
|
|
switch (aMessage.name) {
|
|
|
|
case "WebProgress:StateChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.stateFlags,
|
|
|
|
json.status
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-06-08 08:22:20 -07:00
|
|
|
|
|
|
|
this._notify(json.notifyFlags, "onStateChange", args);
|
2010-06-07 19:44:06 -07:00
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:ProgressChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.curSelf,
|
|
|
|
json.maxSelf,
|
|
|
|
json.curTotal,
|
|
|
|
json.maxTotal
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS,
|
|
|
|
"onProgressChange",
|
|
|
|
args);
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:LocationChange":
|
2010-06-09 13:07:32 -07:00
|
|
|
let locationURI = this._browser._ios.newURI(json.location, null, null);
|
|
|
|
this._browser._webNavigation._currentURI = locationURI;
|
2010-06-08 12:30:46 -07:00
|
|
|
this._browser._webNavigation.canGoBack = json.canGoBack;
|
|
|
|
this._browser._webNavigation.canGoForward = json.canGoForward;
|
2010-06-07 19:44:06 -07:00
|
|
|
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-09 13:07:32 -07:00
|
|
|
locationURI
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-09 13:07:32 -07:00
|
|
|
if (this._browser.contentWindowId != json.windowId) {
|
|
|
|
this._browser.contentWindowId = json.windowId;
|
2010-06-08 08:22:20 -07:00
|
|
|
this._browser._documentURI = json.documentURI;
|
|
|
|
this._browser._searchEngines = [];
|
|
|
|
}
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
|
|
|
"onLocationChange",
|
|
|
|
args);
|
|
|
|
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:StatusChange":
|
|
|
|
args = [
|
2010-06-09 13:07:32 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.status,
|
|
|
|
json.message
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_STATUS,
|
|
|
|
"onStatusChange",
|
|
|
|
args);
|
|
|
|
break;
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
case "WebProgress:SecurityChange":
|
|
|
|
args = [
|
2010-06-16 06:53:29 -07:00
|
|
|
{ windowId: json.windowId, browser: this._browser },
|
2010-06-07 19:44:06 -07:00
|
|
|
{},
|
2010-06-08 08:22:20 -07:00
|
|
|
json.state
|
2010-06-07 19:44:06 -07:00
|
|
|
];
|
2010-06-16 06:53:29 -07:00
|
|
|
|
|
|
|
this._browser._securityUI = {
|
|
|
|
SSLStatus: json.SSLStatus,
|
|
|
|
state: json.state
|
|
|
|
}
|
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_SECURITY,
|
|
|
|
"onSecurityChange",
|
|
|
|
args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2010-06-08 08:22:20 -07:00
|
|
|
|
2010-06-07 19:44:06 -07:00
|
|
|
_notify: function(aFlags, aName, aArguments) {
|
|
|
|
this._listeners.forEach(function(item) {
|
|
|
|
if (item.flags & aFlags)
|
|
|
|
item.listener[aName].apply(item.listener, aArguments);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
<property name="contentWindow"
|
|
|
|
readonly="true"
|
2010-06-23 12:23:06 -07:00
|
|
|
onget="return null"/>
|
2010-06-07 19:44:06 -07:00
|
|
|
|
|
|
|
<property name="sessionHistory"
|
2010-06-08 08:22:20 -07:00
|
|
|
onget="throw 'sessionHistory: Not Remoteable'"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="markupDocumentViewer"
|
2010-06-08 08:22:20 -07:00
|
|
|
onget="throw 'markupDocumentViewer: Not Remoteable'"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerEdit"
|
2010-06-08 08:22:20 -07:00
|
|
|
onget="throw 'contentViewerEdit: Not Remoteable'"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerFile"
|
2010-06-08 08:22:20 -07:00
|
|
|
onget="throw 'contentViewerFile: Not Remoteable'"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="documentCharsetInfo"
|
2010-06-08 08:22:20 -07:00
|
|
|
onget="throw 'documentCharsetInfo: Not Remoteable'"
|
2010-06-07 19:44:06 -07:00
|
|
|
readonly="true"/>
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|