Files
roytam1 8c12bb3492 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1155923 - Removing moz prefix from RTC interfaces, r=jesup,smaug (db1bd2fe68)
- Bug 1155923 - Temporarily restoring moz-prefixed interface, r=jesup,smaug (e1e9ecd7eb)
- Bug 1203167 - stop serializing user-installed engines to XML files, r=adw. (e1f85fcf16)
- Bug 1178453 - Change logging in storage-json.js to avoid string concatenation. r=MattN (06f78f0f57)
- No bug - Password manager: Modernize the style of storage-json.js. (42fb046b66)
- Bug 1166961 - Show click to play button on Fennec when autoplay is blocked. r=mfinkle (322b8670f1)
- Bug 1217082 - Remove for-each from toolkit/. r=Gijs (b98cb95f9b)
- Bug 1203167 - Keep user-installed engines when refreshing an outdated cache, r=adw. (c2c74e49cb)
- Bug 1124605 - Execute dragStateChanged(false) before the element is hidden. r=jaws (056b585257)
- bit of  Bug 1141661 - No need to manually convert this URI anymore. r=mossop (a22910d350)
- Bug 862148 - stop parsing Sherlock plugins, r=adw. (4e75933ad5)
- Bug 862148 - remove the _parseAsOpenSearch method, r=adw. (bf6266c9de)
2023-01-27 10:35:59 +08:00

91 lines
3.5 KiB
JavaScript

/* 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/. */
"use strict";
const { utils: Cu, interfaces: Ci, classes: Cc, results: Cr } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
function MainProcessSingleton() {}
MainProcessSingleton.prototype = {
classID: Components.ID("{0636a680-45cb-11e4-916c-0800200c9a66}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
logConsoleMessage: function(message) {
let logMsg = message.data;
logMsg.wrappedJSObject = logMsg;
Services.obs.notifyObservers(logMsg, "console-api-log-event", null);
},
// Called when a webpage calls window.external.AddSearchProvider
addSearchEngine: function({ target: browser, data: { pageURL, engineURL } }) {
pageURL = NetUtil.newURI(pageURL);
engineURL = NetUtil.newURI(engineURL, null, pageURL);
let iconURL;
let tabbrowser = browser.getTabBrowser();
if (browser.mIconURL && (!tabbrowser || tabbrowser.shouldLoadFavIcon(pageURL)))
iconURL = NetUtil.newURI(browser.mIconURL);
try {
// Make sure the URLs are HTTP, HTTPS, or FTP.
let isWeb = ["https", "http", "ftp"];
if (isWeb.indexOf(engineURL.scheme) < 0)
throw "Unsupported search engine URL: " + engineURL;
if (iconURL && isWeb.indexOf(iconURL.scheme) < 0)
throw "Unsupported search icon URL: " + iconURL;
}
catch(ex) {
Cu.reportError("Invalid argument passed to window.external.AddSearchProvider: " + ex);
var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var brandName = brandBundle.GetStringFromName("brandShortName");
var title = searchBundle.GetStringFromName("error_invalid_engine_title");
var msg = searchBundle.formatStringFromName("error_invalid_engine_msg",
[brandName], 1);
Services.ww.getNewPrompter(browser.ownerDocument.defaultView).alert(title, msg);
return;
}
Services.search.init(function(status) {
if (status != Cr.NS_OK)
return;
Services.search.addEngine(engineURL.spec, null, iconURL ? iconURL.spec : null, true);
})
},
observe: function(subject, topic, data) {
switch (topic) {
case "app-startup": {
Services.obs.addObserver(this, "xpcom-shutdown", false);
// Load this script early so that console.* is initialized
// before other frame scripts.
Services.mm.loadFrameScript("chrome://global/content/browser-content.js", true);
Services.ppmm.loadProcessScript("chrome://global/content/process-content.js", true);
Services.ppmm.addMessageListener("Console:Log", this.logConsoleMessage);
Services.mm.addMessageListener("Search:AddEngine", this.addSearchEngine);
break;
}
case "xpcom-shutdown":
Services.ppmm.removeMessageListener("Console:Log", this.logConsoleMessage);
Services.mm.removeMessageListener("Search:AddEngine", this.addSearchEngine);
break;
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MainProcessSingleton]);