зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347425 - Part 3: Remove the site-specific user agent service; r=baku,jchen
This used to be the glue layer between DOM and Necko which is no longer being used.
This commit is contained in:
Родитель
30f6ca0075
Коммит
f2a992e41a
|
@ -361,8 +361,6 @@
|
|||
@RESPATH@/components/PeerConnection.js
|
||||
@RESPATH@/components/PeerConnection.manifest
|
||||
#endif
|
||||
@RESPATH@/components/SiteSpecificUserAgent.js
|
||||
@RESPATH@/components/SiteSpecificUserAgent.manifest
|
||||
@RESPATH@/components/storage-json.js
|
||||
@RESPATH@/components/crypto-SDR.js
|
||||
@RESPATH@/components/Downloads.manifest
|
||||
|
|
|
@ -387,8 +387,6 @@
|
|||
@RESPATH@/components/BrowserPageThumbs.manifest
|
||||
@RESPATH@/components/crashmonitor.manifest
|
||||
@RESPATH@/components/nsCrashMonitor.js
|
||||
@RESPATH@/components/SiteSpecificUserAgent.js
|
||||
@RESPATH@/components/SiteSpecificUserAgent.manifest
|
||||
@RESPATH@/components/toolkitsearch.manifest
|
||||
@RESPATH@/components/nsSearchService.js
|
||||
@RESPATH@/components/nsSearchSuggestions.js
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const MAX_CACHE_SIZE = 250;
|
||||
const PREF_UPDATE = "general.useragent.updates.";
|
||||
const PREF_OVERRIDE = "general.useragent.override.";
|
||||
const XPCOM_SHUTDOWN = "xpcom-shutdown";
|
||||
const HTTP_PROTO_HANDLER = Cc["@mozilla.org/network/protocol;1?name=http"]
|
||||
.getService(Ci.nsIHttpProtocolHandler);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsISyncMessageSender");
|
||||
|
||||
function SiteSpecificUserAgent() {
|
||||
this.inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
|
||||
if (this.inParent) {
|
||||
Cu.import("resource://gre/modules/UserAgentOverrides.jsm");
|
||||
} else {
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Services.prefs.addObserver(PREF_OVERRIDE, this, false);
|
||||
Services.prefs.addObserver(PREF_UPDATE, this, false);
|
||||
Services.obs.addObserver(this, XPCOM_SHUTDOWN, false);
|
||||
this.userAgentCache = new Map;
|
||||
}
|
||||
}
|
||||
|
||||
SiteSpecificUserAgent.prototype = {
|
||||
getUserAgentForURIAndWindow: function ssua_getUserAgentForURIAndWindow(aURI, aWindow) {
|
||||
if (this.inParent) {
|
||||
return UserAgentOverrides.getOverrideForURI(aURI) || HTTP_PROTO_HANDLER.userAgent;
|
||||
}
|
||||
|
||||
let host = aURI.asciiHost;
|
||||
let cachedResult = this.userAgentCache.get(host);
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
|
||||
let data = { uri: aURI.spec };
|
||||
let result = cpmm.sendRpcMessage("Useragent:GetOverride", data)[0] || HTTP_PROTO_HANDLER.userAgent;
|
||||
|
||||
if (this.userAgentCache.size >= MAX_CACHE_SIZE) {
|
||||
this.userAgentCache.clear();
|
||||
}
|
||||
|
||||
this.userAgentCache.set(host, result);
|
||||
return result;
|
||||
},
|
||||
|
||||
invalidateCache: function() {
|
||||
this.userAgentCache.clear();
|
||||
},
|
||||
|
||||
clean: function() {
|
||||
this.userAgentCache.clear();
|
||||
if (!this.inParent) {
|
||||
Services.obs.removeObserver(this, XPCOM_SHUTDOWN);
|
||||
Services.prefs.removeObserver(PREF_OVERRIDE, this);
|
||||
Services.prefs.removeObserver(PREF_UPDATE, this);
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "nsPref:changed":
|
||||
this.invalidateCache();
|
||||
break;
|
||||
case XPCOM_SHUTDOWN:
|
||||
this.clean();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
classID: Components.ID("{506c680f-3d1c-4954-b351-2c80afbc37d3}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISiteSpecificUserAgent])
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SiteSpecificUserAgent]);
|
|
@ -1,2 +0,0 @@
|
|||
component {506c680f-3d1c-4954-b351-2c80afbc37d3} SiteSpecificUserAgent.js
|
||||
contract @mozilla.org/dom/site-specific-user-agent;1 {506c680f-3d1c-4954-b351-2c80afbc37d3}
|
|
@ -34,7 +34,6 @@ XPIDL_SOURCES += [
|
|||
'nsISelectionListener.idl',
|
||||
'nsISelectionPrivate.idl',
|
||||
'nsISimpleContentPolicy.idl',
|
||||
'nsISiteSpecificUserAgent.idl',
|
||||
'nsISlowScriptDebug.idl',
|
||||
]
|
||||
|
||||
|
@ -418,13 +417,6 @@ EXTRA_COMPONENTS += [
|
|||
'SlowScriptDebug.manifest',
|
||||
]
|
||||
|
||||
# Firefox for Android provides an alternate version of this component
|
||||
if CONFIG['MOZ_BUILD_APP'] != 'mobile/android':
|
||||
EXTRA_COMPONENTS += [
|
||||
'SiteSpecificUserAgent.js',
|
||||
'SiteSpecificUserAgent.manifest',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'DOMRequestHelper.jsm',
|
||||
'IndexedDBHelper.jsm',
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface mozIDOMWindow;
|
||||
|
||||
/**
|
||||
* nsISiteSpecificUserAgent provides you with site/window-specific User Agent strings.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(0f0ace30-9ab1-4175-9d60-fd26c0324adc)]
|
||||
interface nsISiteSpecificUserAgent : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the User Agent string for a given URI.
|
||||
*
|
||||
* @param aURI is the URI of the page the UA string is used for.
|
||||
*
|
||||
* @param aWindow is the window this UA is being requested for
|
||||
*
|
||||
* @returns the User Agent string for the given URI. If no override applies,
|
||||
* the default User Agent string is used.
|
||||
*/
|
||||
AString getUserAgentForURIAndWindow(in nsIURI aURI, in mozIDOMWindow aWindow);
|
||||
};
|
|
@ -3284,15 +3284,6 @@ var DesktopUserAgent = {
|
|||
return null;
|
||||
},
|
||||
|
||||
getUserAgentForWindow: function ua_getUserAgentForWindow(aWindow) {
|
||||
let tab = BrowserApp.getTabForWindow(aWindow.top);
|
||||
if (tab) {
|
||||
return this.getUserAgentForTab(tab);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getUserAgentForTab: function ua_getUserAgentForTab(aTab) {
|
||||
// Send desktop UA if "Request Desktop Site" is enabled.
|
||||
if (aTab.desktopMode) {
|
||||
|
|
|
@ -90,10 +90,6 @@ component {cbc08081-49b6-4561-9c18-a7707a50bda1} NSSDialogService.js
|
|||
contract @mozilla.org/nsCertificateDialogs;1 {cbc08081-49b6-4561-9c18-a7707a50bda1}
|
||||
contract @mozilla.org/nsClientAuthDialogs;1 {cbc08081-49b6-4561-9c18-a7707a50bda1}
|
||||
|
||||
# SiteSpecificUserAgent.js
|
||||
component {d5234c9d-0ee2-4b3c-9da3-18be9e5cf7e6} SiteSpecificUserAgent.js
|
||||
contract @mozilla.org/dom/site-specific-user-agent;1 {d5234c9d-0ee2-4b3c-9da3-18be9e5cf7e6}
|
||||
|
||||
# FilePicker.js
|
||||
component {18a4e042-7c7c-424b-a583-354e68553a7f} FilePicker.js
|
||||
contract @mozilla.org/filepicker;1 {18a4e042-7c7c-424b-a583-354e68553a7f}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/UserAgentOverrides.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
|
||||
.getService(Ci.nsIHttpProtocolHandler)
|
||||
.userAgent;
|
||||
|
||||
function SiteSpecificUserAgent() {}
|
||||
|
||||
SiteSpecificUserAgent.prototype = {
|
||||
getUserAgentForURIAndWindow: function ssua_getUserAgentForURIAndWindow(aURI, aWindow) {
|
||||
let UA;
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (win && win.DesktopUserAgent) {
|
||||
UA = win.DesktopUserAgent.getUserAgentForWindow(aWindow);
|
||||
}
|
||||
return UA || UserAgentOverrides.getOverrideForURI(aURI) || DEFAULT_UA;
|
||||
},
|
||||
|
||||
classID: Components.ID("{d5234c9d-0ee2-4b3c-9da3-18be9e5cf7e6}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISiteSpecificUserAgent])
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SiteSpecificUserAgent]);
|
|
@ -30,7 +30,6 @@ EXTRA_COMPONENTS += [
|
|||
'PresentationRequestUIGlue.js',
|
||||
'PromptService.js',
|
||||
'SessionStore.js',
|
||||
'SiteSpecificUserAgent.js',
|
||||
'Snippets.js',
|
||||
'TabSource.js',
|
||||
'XPIDialogService.js',
|
||||
|
|
|
@ -530,7 +530,6 @@
|
|||
@BINPATH@/components/PresentationRequestUIGlue.js
|
||||
@BINPATH@/components/PromptService.js
|
||||
@BINPATH@/components/SessionStore.js
|
||||
@BINPATH@/components/SiteSpecificUserAgent.js
|
||||
@BINPATH@/components/Snippets.js
|
||||
|
||||
@BINPATH@/components/XPIDialogService.js
|
||||
|
|
|
@ -13,17 +13,12 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/UserAgentUpdates.jsm");
|
||||
|
||||
const OVERRIDE_MESSAGE = "Useragent:GetOverride";
|
||||
const PREF_OVERRIDES_ENABLED = "general.useragent.site_specific_overrides";
|
||||
const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
|
||||
.getService(Ci.nsIHttpProtocolHandler)
|
||||
.userAgent;
|
||||
const MAX_OVERRIDE_FOR_HOST_CACHE_SIZE = 250;
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager"); // Might have to make this broadcast?
|
||||
|
||||
var gPrefBranch;
|
||||
var gOverrides = new Map;
|
||||
var gUpdatedOverrides;
|
||||
|
@ -42,7 +37,6 @@ this.UserAgentOverrides = {
|
|||
gPrefBranch = Services.prefs.getBranch("general.useragent.override.");
|
||||
gPrefBranch.addObserver("", buildOverrides, false);
|
||||
|
||||
ppmm.addMessageListener(OVERRIDE_MESSAGE, this);
|
||||
Services.prefs.addObserver(PREF_OVERRIDES_ENABLED, buildOverrides, false);
|
||||
|
||||
try {
|
||||
|
@ -119,17 +113,6 @@ this.UserAgentOverrides = {
|
|||
Services.prefs.removeObserver(PREF_OVERRIDES_ENABLED, buildOverrides);
|
||||
|
||||
Services.obs.removeObserver(HTTP_on_useragent_request, "http-on-useragent-request");
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
let name = aMessage.name;
|
||||
switch (name) {
|
||||
case OVERRIDE_MESSAGE:
|
||||
let uri = Services.io.newURI(aMessage.data.uri);
|
||||
return this.getOverrideForURI(uri);
|
||||
default:
|
||||
throw("Wrong Message in UserAgentOverride: " + name);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче