2013-04-25 05:29:31 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
let Cc = Components.classes;
|
|
|
|
let Ci = Components.interfaces;
|
|
|
|
let Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
2014-07-15 05:10:06 +00:00
|
|
|
Cu.import("resource://gre/modules/RemoteAddonsChild.jsm");
|
2013-12-07 00:02:05 +00:00
|
|
|
Cu.import("resource://gre/modules/Timer.jsm");
|
2013-04-25 05:29:31 +00:00
|
|
|
|
2014-10-18 14:09:32 +00:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "PageThumbUtils",
|
|
|
|
"resource://gre/modules/PageThumbUtils.jsm");
|
2014-10-18 14:09:32 +00:00
|
|
|
|
2014-05-17 16:39:14 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
|
|
|
|
"@mozilla.org/xre/app-info;1",
|
|
|
|
"nsICrashReporter");
|
|
|
|
#endif
|
|
|
|
|
2014-05-16 23:40:37 +00:00
|
|
|
let FocusSyncHandler = {
|
2013-11-19 21:20:15 +00:00
|
|
|
init: function() {
|
|
|
|
sendAsyncMessage("SetSyncHandler", {}, {handler: this});
|
|
|
|
},
|
|
|
|
|
|
|
|
getFocusedElementAndWindow: function() {
|
|
|
|
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
|
|
|
|
|
|
|
let focusedWindow = {};
|
|
|
|
let elt = fm.getFocusedElementForWindow(content, true, focusedWindow);
|
|
|
|
return [elt, focusedWindow.value];
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2014-05-16 23:40:37 +00:00
|
|
|
FocusSyncHandler.init();
|
2013-11-19 21:20:15 +00:00
|
|
|
|
2013-04-25 05:29:31 +00:00
|
|
|
let WebProgressListener = {
|
|
|
|
init: function() {
|
|
|
|
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebProgress);
|
|
|
|
webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_ALL);
|
|
|
|
},
|
|
|
|
|
2014-09-25 03:34:47 +00:00
|
|
|
_requestSpec: function (aRequest, aPropertyName) {
|
2013-04-25 05:29:31 +00:00
|
|
|
if (!aRequest || !(aRequest instanceof Ci.nsIChannel))
|
|
|
|
return null;
|
2014-09-25 03:34:47 +00:00
|
|
|
return aRequest.QueryInterface(Ci.nsIChannel)[aPropertyName].spec;
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_setupJSON: function setupJSON(aWebProgress, aRequest) {
|
|
|
|
return {
|
|
|
|
isTopLevel: aWebProgress.isTopLevel,
|
2013-07-29 15:03:41 +00:00
|
|
|
isLoadingDocument: aWebProgress.isLoadingDocument,
|
2014-09-25 03:34:47 +00:00
|
|
|
requestURI: this._requestSpec(aRequest, "URI"),
|
|
|
|
originalRequestURI: this._requestSpec(aRequest, "originalURI"),
|
2014-03-12 03:13:41 +00:00
|
|
|
loadType: aWebProgress.loadType,
|
|
|
|
documentContentType: content.document && content.document.contentType
|
2013-04-25 05:29:31 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2013-07-17 13:27:49 +00:00
|
|
|
_setupObjects: function setupObjects(aWebProgress) {
|
|
|
|
return {
|
2013-11-19 21:20:15 +00:00
|
|
|
contentWindow: content,
|
2013-07-17 13:27:49 +00:00
|
|
|
// DOMWindow is not necessarily the content-window with subframes.
|
|
|
|
DOMWindow: aWebProgress.DOMWindow
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2013-04-25 05:29:31 +00:00
|
|
|
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
|
|
|
let json = this._setupJSON(aWebProgress, aRequest);
|
2013-07-17 13:27:49 +00:00
|
|
|
let objects = this._setupObjects(aWebProgress);
|
|
|
|
|
2013-04-25 05:29:31 +00:00
|
|
|
json.stateFlags = aStateFlags;
|
|
|
|
json.status = aStatus;
|
|
|
|
|
2013-07-17 13:27:49 +00:00
|
|
|
sendAsyncMessage("Content:StateChange", json, objects);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
|
|
|
|
},
|
|
|
|
|
|
|
|
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) {
|
|
|
|
let json = this._setupJSON(aWebProgress, aRequest);
|
2013-07-17 13:27:49 +00:00
|
|
|
let objects = this._setupObjects(aWebProgress);
|
|
|
|
|
2013-09-05 23:24:29 +00:00
|
|
|
json.location = aLocationURI ? aLocationURI.spec : "";
|
2013-11-22 06:39:05 +00:00
|
|
|
json.flags = aFlags;
|
2013-09-05 23:24:29 +00:00
|
|
|
|
2014-08-28 20:37:16 +00:00
|
|
|
// These properties can change even for a sub-frame navigation.
|
|
|
|
json.canGoBack = docShell.canGoBack;
|
|
|
|
json.canGoForward = docShell.canGoForward;
|
|
|
|
|
2013-09-05 23:24:29 +00:00
|
|
|
if (json.isTopLevel) {
|
|
|
|
json.documentURI = content.document.documentURIObject.spec;
|
|
|
|
json.charset = content.document.characterSet;
|
2014-08-13 17:29:00 +00:00
|
|
|
json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
|
2014-09-18 23:26:50 +00:00
|
|
|
json.principal = content.document.nodePrincipal;
|
2013-09-05 23:24:29 +00:00
|
|
|
}
|
2013-04-25 05:29:31 +00:00
|
|
|
|
2013-07-17 13:27:49 +00:00
|
|
|
sendAsyncMessage("Content:LocationChange", json, objects);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
|
|
|
|
let json = this._setupJSON(aWebProgress, aRequest);
|
2013-07-17 13:27:49 +00:00
|
|
|
let objects = this._setupObjects(aWebProgress);
|
|
|
|
|
2013-04-25 05:29:31 +00:00
|
|
|
json.status = aStatus;
|
|
|
|
json.message = aMessage;
|
|
|
|
|
2013-07-17 13:27:49 +00:00
|
|
|
sendAsyncMessage("Content:StatusChange", json, objects);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onSecurityChange: function onSecurityChange(aWebProgress, aRequest, aState) {
|
|
|
|
let json = this._setupJSON(aWebProgress, aRequest);
|
2013-07-17 13:27:49 +00:00
|
|
|
let objects = this._setupObjects(aWebProgress);
|
|
|
|
|
2013-04-25 05:29:31 +00:00
|
|
|
json.state = aState;
|
2013-07-10 02:45:07 +00:00
|
|
|
json.status = SecurityUI.getSSLStatusAsString();
|
2013-04-25 05:29:31 +00:00
|
|
|
|
2013-07-17 13:27:49 +00:00
|
|
|
sendAsyncMessage("Content:SecurityChange", json, objects);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface: function QueryInterface(aIID) {
|
|
|
|
if (aIID.equals(Ci.nsIWebProgressListener) ||
|
|
|
|
aIID.equals(Ci.nsISupportsWeakReference) ||
|
|
|
|
aIID.equals(Ci.nsISupports)) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
WebProgressListener.init();
|
|
|
|
|
|
|
|
let WebNavigation = {
|
|
|
|
init: function() {
|
|
|
|
addMessageListener("WebNavigation:GoBack", this);
|
|
|
|
addMessageListener("WebNavigation:GoForward", this);
|
|
|
|
addMessageListener("WebNavigation:GotoIndex", this);
|
|
|
|
addMessageListener("WebNavigation:LoadURI", this);
|
|
|
|
addMessageListener("WebNavigation:Reload", this);
|
|
|
|
addMessageListener("WebNavigation:Stop", this);
|
2013-10-28 19:24:51 +00:00
|
|
|
|
2014-05-16 23:40:37 +00:00
|
|
|
this._webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
|
|
|
this._sessionHistory = this._webNavigation.sessionHistory;
|
|
|
|
|
|
|
|
// Send a CPOW for the sessionHistory object. We need to make sure
|
|
|
|
// it stays alive as long as the content script since CPOWs are
|
|
|
|
// weakly held.
|
|
|
|
let history = this._sessionHistory;
|
2013-10-28 19:24:51 +00:00
|
|
|
sendAsyncMessage("WebNavigation:setHistory", {}, {history: history});
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
receiveMessage: function(message) {
|
|
|
|
switch (message.name) {
|
|
|
|
case "WebNavigation:GoBack":
|
|
|
|
this.goBack();
|
|
|
|
break;
|
|
|
|
case "WebNavigation:GoForward":
|
|
|
|
this.goForward();
|
|
|
|
break;
|
|
|
|
case "WebNavigation:GotoIndex":
|
2013-10-28 19:24:51 +00:00
|
|
|
this.gotoIndex(message.data.index);
|
2013-04-25 05:29:31 +00:00
|
|
|
break;
|
|
|
|
case "WebNavigation:LoadURI":
|
2013-10-28 19:24:51 +00:00
|
|
|
this.loadURI(message.data.uri, message.data.flags);
|
2013-04-25 05:29:31 +00:00
|
|
|
break;
|
|
|
|
case "WebNavigation:Reload":
|
2013-10-28 19:24:51 +00:00
|
|
|
this.reload(message.data.flags);
|
2013-04-25 05:29:31 +00:00
|
|
|
break;
|
|
|
|
case "WebNavigation:Stop":
|
2013-10-28 19:24:51 +00:00
|
|
|
this.stop(message.data.flags);
|
2013-04-25 05:29:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
goBack: function() {
|
2014-08-28 20:37:16 +00:00
|
|
|
if (this._webNavigation.canGoBack) {
|
2013-04-25 05:29:31 +00:00
|
|
|
this._webNavigation.goBack();
|
2014-08-28 20:37:16 +00:00
|
|
|
}
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
goForward: function() {
|
|
|
|
if (this._webNavigation.canGoForward)
|
|
|
|
this._webNavigation.goForward();
|
|
|
|
},
|
|
|
|
|
2013-10-28 19:24:51 +00:00
|
|
|
gotoIndex: function(index) {
|
|
|
|
this._webNavigation.gotoIndex(index);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
2013-10-28 19:24:51 +00:00
|
|
|
loadURI: function(uri, flags) {
|
2014-05-17 16:39:14 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
if (CrashReporter.enabled)
|
|
|
|
CrashReporter.annotateCrashReport("URL", uri);
|
|
|
|
#endif
|
2013-10-28 19:24:51 +00:00
|
|
|
this._webNavigation.loadURI(uri, flags, null, null, null);
|
2013-04-25 05:29:31 +00:00
|
|
|
},
|
|
|
|
|
2013-10-28 19:24:51 +00:00
|
|
|
reload: function(flags) {
|
2013-04-25 05:29:31 +00:00
|
|
|
this._webNavigation.reload(flags);
|
|
|
|
},
|
|
|
|
|
2013-10-28 19:24:51 +00:00
|
|
|
stop: function(flags) {
|
2013-04-25 05:29:31 +00:00
|
|
|
this._webNavigation.stop(flags);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
WebNavigation.init();
|
2013-04-25 05:29:39 +00:00
|
|
|
|
2013-07-10 02:45:07 +00:00
|
|
|
let SecurityUI = {
|
|
|
|
getSSLStatusAsString: function() {
|
|
|
|
let status = docShell.securityUI.QueryInterface(Ci.nsISSLStatusProvider).SSLStatus;
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
let helper = Cc["@mozilla.org/network/serialization-helper;1"]
|
|
|
|
.getService(Ci.nsISerializationHelper);
|
|
|
|
|
|
|
|
status.QueryInterface(Ci.nsISerializable);
|
|
|
|
return helper.serializeToString(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-08-21 17:24:53 +00:00
|
|
|
let ControllerCommands = {
|
|
|
|
init: function () {
|
|
|
|
addMessageListener("ControllerCommands:Do", this);
|
|
|
|
},
|
|
|
|
|
|
|
|
receiveMessage: function(message) {
|
|
|
|
switch(message.name) {
|
|
|
|
case "ControllerCommands:Do":
|
|
|
|
if (docShell.isCommandEnabled(message.data))
|
|
|
|
docShell.doCommand(message.data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerCommands.init()
|
|
|
|
|
2013-04-25 05:29:39 +00:00
|
|
|
addEventListener("DOMTitleChanged", function (aEvent) {
|
|
|
|
let document = content.document;
|
|
|
|
switch (aEvent.type) {
|
|
|
|
case "DOMTitleChanged":
|
|
|
|
if (!aEvent.isTrusted || aEvent.target.defaultView != content)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sendAsyncMessage("DOMTitleChanged", { title: document.title });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}, false);
|
2013-07-29 15:03:41 +00:00
|
|
|
|
2014-03-18 14:58:02 +00:00
|
|
|
addEventListener("DOMWindowClose", function (aEvent) {
|
|
|
|
if (!aEvent.isTrusted)
|
|
|
|
return;
|
|
|
|
sendAsyncMessage("DOMWindowClose");
|
2014-03-20 21:26:47 +00:00
|
|
|
aEvent.preventDefault();
|
2014-03-18 14:58:02 +00:00
|
|
|
}, false);
|
|
|
|
|
2013-07-29 15:03:41 +00:00
|
|
|
addEventListener("ImageContentLoaded", function (aEvent) {
|
|
|
|
if (content.document instanceof Ci.nsIImageDocument) {
|
|
|
|
let req = content.document.imageRequest;
|
|
|
|
if (!req.image)
|
|
|
|
return;
|
|
|
|
sendAsyncMessage("ImageDocumentLoaded", { width: req.image.width,
|
|
|
|
height: req.image.height });
|
|
|
|
}
|
2013-08-29 04:43:00 +00:00
|
|
|
}, false);
|
|
|
|
|
2014-02-05 02:16:56 +00:00
|
|
|
let DocumentObserver = {
|
|
|
|
init: function() {
|
|
|
|
Services.obs.addObserver(this, "document-element-inserted", false);
|
|
|
|
addEventListener("unload", () => {
|
|
|
|
Services.obs.removeObserver(this, "document-element-inserted");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
|
|
if (aSubject == content.document) {
|
|
|
|
sendAsyncMessage("DocumentInserted", {synthetic: aSubject.mozSyntheticDocument});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
DocumentObserver.init();
|
2014-01-13 17:36:26 +00:00
|
|
|
|
2014-03-19 09:25:13 +00:00
|
|
|
const ZoomManager = {
|
|
|
|
get fullZoom() {
|
|
|
|
return this._cache.fullZoom;
|
|
|
|
},
|
|
|
|
|
|
|
|
get textZoom() {
|
|
|
|
return this._cache.textZoom;
|
|
|
|
},
|
|
|
|
|
|
|
|
set fullZoom(value) {
|
|
|
|
this._cache.fullZoom = value;
|
|
|
|
this._markupViewer.fullZoom = value;
|
|
|
|
},
|
|
|
|
|
|
|
|
set textZoom(value) {
|
|
|
|
this._cache.textZoom = value;
|
|
|
|
this._markupViewer.textZoom = value;
|
|
|
|
},
|
|
|
|
|
|
|
|
refreshFullZoom: function() {
|
|
|
|
return this._refreshZoomValue('fullZoom');
|
|
|
|
},
|
|
|
|
|
|
|
|
refreshTextZoom: function() {
|
|
|
|
return this._refreshZoomValue('textZoom');
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves specified zoom property value from markupViewer and refreshes
|
|
|
|
* cache if needed.
|
|
|
|
* @param valueName Either 'fullZoom' or 'textZoom'.
|
|
|
|
* @returns Returns true if cached value was actually refreshed.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_refreshZoomValue: function(valueName) {
|
|
|
|
let actualZoomValue = this._markupViewer[valueName];
|
|
|
|
if (actualZoomValue != this._cache[valueName]) {
|
|
|
|
this._cache[valueName] = actualZoomValue;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
get _markupViewer() {
|
2014-07-09 21:27:49 +00:00
|
|
|
return docShell.contentViewer;
|
2014-03-19 09:25:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_cache: {
|
|
|
|
fullZoom: NaN,
|
|
|
|
textZoom: NaN
|
|
|
|
}
|
|
|
|
};
|
2014-01-13 17:36:26 +00:00
|
|
|
|
|
|
|
addMessageListener("FullZoom", function (aMessage) {
|
2014-03-19 09:25:13 +00:00
|
|
|
ZoomManager.fullZoom = aMessage.data.value;
|
2014-01-13 17:36:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
addMessageListener("TextZoom", function (aMessage) {
|
2014-03-19 09:25:13 +00:00
|
|
|
ZoomManager.textZoom = aMessage.data.value;
|
2014-01-13 17:36:26 +00:00
|
|
|
});
|
|
|
|
|
2014-03-19 09:25:13 +00:00
|
|
|
addEventListener("FullZoomChange", function () {
|
|
|
|
if (ZoomManager.refreshFullZoom()) {
|
|
|
|
sendAsyncMessage("FullZoomChange", { value: ZoomManager.fullZoom});
|
|
|
|
}
|
2014-01-13 17:36:26 +00:00
|
|
|
}, false);
|
|
|
|
|
|
|
|
addEventListener("TextZoomChange", function (aEvent) {
|
2014-03-19 09:25:13 +00:00
|
|
|
if (ZoomManager.refreshTextZoom()) {
|
|
|
|
sendAsyncMessage("TextZoomChange", { value: ZoomManager.textZoom});
|
|
|
|
}
|
2014-01-13 17:36:26 +00:00
|
|
|
}, false);
|
|
|
|
|
2014-08-20 15:13:35 +00:00
|
|
|
addEventListener("ZoomChangeUsingMouseWheel", function () {
|
|
|
|
sendAsyncMessage("ZoomChangeUsingMouseWheel", {});
|
|
|
|
}, false);
|
|
|
|
|
2014-08-13 17:29:00 +00:00
|
|
|
addMessageListener("UpdateCharacterSet", function (aMessage) {
|
|
|
|
docShell.charset = aMessage.data.value;
|
|
|
|
docShell.gatherCharsetMenuTelemetry();
|
|
|
|
});
|
|
|
|
|
2014-10-18 14:09:32 +00:00
|
|
|
/**
|
|
|
|
* Remote thumbnail request handler for PageThumbs thumbnails.
|
|
|
|
*/
|
|
|
|
addMessageListener("Browser:Thumbnail:Request", function (aMessage) {
|
2014-10-18 14:09:32 +00:00
|
|
|
let thumbnail = content.document.createElementNS(PageThumbUtils.HTML_NAMESPACE,
|
|
|
|
"canvas");
|
2014-10-18 14:09:32 +00:00
|
|
|
thumbnail.mozOpaque = true;
|
|
|
|
thumbnail.mozImageSmoothingEnabled = true;
|
|
|
|
|
2014-10-18 14:09:32 +00:00
|
|
|
thumbnail.width = aMessage.data.canvasWidth;
|
|
|
|
thumbnail.height = aMessage.data.canvasHeight;
|
|
|
|
|
|
|
|
let [width, height, scale] =
|
|
|
|
PageThumbUtils.determineCropSize(content, thumbnail);
|
2014-10-18 14:09:32 +00:00
|
|
|
|
|
|
|
let ctx = thumbnail.getContext("2d");
|
|
|
|
ctx.save();
|
2014-10-18 14:09:32 +00:00
|
|
|
ctx.scale(scale, scale);
|
2014-10-18 14:09:32 +00:00
|
|
|
ctx.drawWindow(content, 0, 0, width, height,
|
|
|
|
aMessage.data.background,
|
|
|
|
ctx.DRAWWINDOW_DO_NOT_FLUSH);
|
|
|
|
ctx.restore();
|
|
|
|
|
|
|
|
thumbnail.toBlob(function (aBlob) {
|
|
|
|
sendAsyncMessage("Browser:Thumbnail:Response", {
|
|
|
|
thumbnail: aBlob,
|
|
|
|
id: aMessage.data.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-07-16 18:13:33 +00:00
|
|
|
// The AddonsChild needs to be rooted so that it stays alive as long as
|
|
|
|
// the tab.
|
|
|
|
let AddonsChild;
|
2014-09-10 18:53:55 +00:00
|
|
|
if (Services.appinfo.browserTabsRemoteAutostart) {
|
2014-07-16 18:13:33 +00:00
|
|
|
// Currently, the addon shims are only supported when autostarting
|
|
|
|
// with remote tabs.
|
|
|
|
AddonsChild = RemoteAddonsChild.init(this);
|
2014-09-15 23:42:27 +00:00
|
|
|
|
|
|
|
addEventListener("unload", () => {
|
|
|
|
RemoteAddonsChild.uninit(AddonsChild);
|
|
|
|
});
|
2014-07-16 18:13:33 +00:00
|
|
|
}
|
2014-07-15 05:10:06 +00:00
|
|
|
|
2014-03-12 03:13:48 +00:00
|
|
|
addMessageListener("NetworkPrioritizer:AdjustPriority", (msg) => {
|
|
|
|
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
|
|
|
|
let loadGroup = webNav.QueryInterface(Ci.nsIDocumentLoader)
|
|
|
|
.loadGroup.QueryInterface(Ci.nsISupportsPriority);
|
|
|
|
loadGroup.adjustPriority(msg.data.adjustment);
|
|
|
|
});
|
|
|
|
|
2014-08-19 20:58:00 +00:00
|
|
|
let DOMFullscreenManager = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
|
|
|
Ci.nsISupportsWeakReference]),
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
Services.obs.addObserver(this, "ask-parent-to-exit-fullscreen", false);
|
|
|
|
Services.obs.addObserver(this, "ask-parent-to-rollback-fullscreen", false);
|
|
|
|
addMessageListener("DOMFullscreen:ChildrenMustExit", () => {
|
|
|
|
let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindowUtils);
|
|
|
|
utils.exitFullscreen();
|
|
|
|
});
|
|
|
|
addEventListener("unload", () => {
|
|
|
|
Services.obs.removeObserver(this, "ask-parent-to-exit-fullscreen");
|
|
|
|
Services.obs.removeObserver(this, "ask-parent-to-rollback-fullscreen");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
|
|
// Observer notifications are global, which means that these notifications
|
|
|
|
// might be coming from elements that are not actually children within this
|
|
|
|
// windows' content. We should ignore those. This will not be necessary once
|
|
|
|
// we fix bug 1053413 and stop using observer notifications for this stuff.
|
|
|
|
if (aSubject.defaultView.top !== content) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aTopic) {
|
|
|
|
case "ask-parent-to-exit-fullscreen": {
|
|
|
|
sendAsyncMessage("DOMFullscreen:RequestExit");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "ask-parent-to-rollback-fullscreen": {
|
|
|
|
sendAsyncMessage("DOMFullscreen:RequestRollback");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
DOMFullscreenManager.init();
|
|
|
|
|
2013-12-07 00:02:05 +00:00
|
|
|
let AutoCompletePopup = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompletePopup]),
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
// Hook up the form fill autocomplete controller.
|
|
|
|
let controller = Cc["@mozilla.org/satchel/form-fill-controller;1"]
|
|
|
|
.getService(Ci.nsIFormFillController);
|
|
|
|
|
|
|
|
controller.attachToBrowser(docShell, this.QueryInterface(Ci.nsIAutoCompletePopup));
|
|
|
|
|
|
|
|
this._input = null;
|
|
|
|
this._popupOpen = false;
|
|
|
|
|
|
|
|
addMessageListener("FormAutoComplete:HandleEnter", message => {
|
|
|
|
this.selectedIndex = message.data.selectedIndex;
|
|
|
|
|
|
|
|
let controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
|
|
|
|
getService(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
controller.handleEnter(message.data.isPopupSelection);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
get input () { return this._input; },
|
|
|
|
get overrideValue () { return null; },
|
|
|
|
set selectedIndex (index) { },
|
|
|
|
get selectedIndex () {
|
|
|
|
// selectedIndex getter must be synchronous because we need the
|
|
|
|
// correct value when the controller is in controller::HandleEnter.
|
|
|
|
// We can't easily just let the parent inform us the new value every
|
|
|
|
// time it changes because not every action that can change the
|
|
|
|
// selectedIndex is trivial to catch (e.g. moving the mouse over the
|
|
|
|
// list).
|
|
|
|
return sendSyncMessage("FormAutoComplete:GetSelectedIndex", {});
|
|
|
|
},
|
|
|
|
get popupOpen () {
|
|
|
|
return this._popupOpen;
|
|
|
|
},
|
|
|
|
|
|
|
|
openAutocompletePopup: function (input, element) {
|
|
|
|
this._input = input;
|
|
|
|
this._popupOpen = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
closePopup: function () {
|
|
|
|
this._popupOpen = false;
|
|
|
|
sendAsyncMessage("FormAutoComplete:ClosePopup", {});
|
|
|
|
},
|
|
|
|
|
|
|
|
invalidate: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
selectBy: function(reverse, page) {
|
|
|
|
this._index = sendSyncMessage("FormAutoComplete:SelectBy", {
|
|
|
|
reverse: reverse,
|
|
|
|
page: page
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 22:48:58 +00:00
|
|
|
// We may not get any responses to Browser:Init if the browser element
|
|
|
|
// is torn down too quickly.
|
|
|
|
let initData = sendSyncMessage("Browser:Init");
|
|
|
|
if (initData.length) {
|
|
|
|
docShell.useGlobalHistory = initData[0].useGlobalHistory;
|
|
|
|
if (initData[0].initPopup) {
|
|
|
|
setTimeout(() => AutoCompletePopup.init(), 0);
|
|
|
|
}
|
2014-03-12 03:13:52 +00:00
|
|
|
}
|