Bug 1347425 - Part 3: Remove the site-specific user agent service; r=baku,jchen
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 25 Mar 2017 14:29:20 -0400
changeset 350290 35a915c6babcb9c9ea287d86dbbfa37c6dcd59d6
parent 350289 c4a14403d17a7b41b9d96ae7e3a563c0d29c9b3a
child 350291 3198833be3b1f3662b292b2dbb934b96b8c88510
push id31570
push userryanvm@gmail.com
push dateWed, 29 Mar 2017 13:42:06 +0000
treeherdermozilla-central@6ea713ccc9ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, jchen
bugs1347425
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/base/SiteSpecificUserAgent.js
dom/base/SiteSpecificUserAgent.manifest
dom/base/moz.build
dom/base/nsISiteSpecificUserAgent.idl
mobile/android/chrome/content/browser.js
mobile/android/components/MobileComponents.manifest
mobile/android/components/SiteSpecificUserAgent.js
mobile/android/components/moz.build
mobile/android/installer/package-manifest.in
netwerk/protocol/http/UserAgentOverrides.jsm
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -356,18 +356,16 @@
 @RESPATH@/components/NetworkGeolocationProvider.manifest
 @RESPATH@/components/NetworkGeolocationProvider.js
 @RESPATH@/components/TVSimulatorService.js
 @RESPATH@/components/TVSimulatorService.manifest
 #ifdef MOZ_WEBRTC
 @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
 @RESPATH@/components/DownloadLegacy.js
 @RESPATH@/components/nsSidebar.manifest
 @RESPATH@/components/nsSidebar.js
 @RESPATH@/components/nsAsyncShutdown.manifest
 @RESPATH@/components/nsAsyncShutdown.js
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -382,18 +382,16 @@
 @RESPATH@/browser/components/browser-newtab.xpt
 @RESPATH@/browser/components/aboutNewTabService.js
 @RESPATH@/browser/components/NewTabComponents.manifest
 @RESPATH@/components/Downloads.manifest
 @RESPATH@/components/DownloadLegacy.js
 @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
 @RESPATH@/components/nsSidebar.js
 @RESPATH@/components/passwordmgr.manifest
 @RESPATH@/components/nsLoginInfo.js
 @RESPATH@/components/nsLoginManager.js
 @RESPATH@/components/nsLoginManagerPrompter.js
deleted file mode 100644
--- a/dom/base/SiteSpecificUserAgent.js
+++ /dev/null
@@ -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]);
deleted file mode 100644
--- a/dom/base/SiteSpecificUserAgent.manifest
+++ /dev/null
@@ -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}
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -29,17 +29,16 @@ XPIDL_SOURCES += [
     'nsIScriptChannel.idl',
     'nsIScriptLoaderObserver.idl',
     'nsISelection.idl',
     'nsISelectionController.idl',
     'nsISelectionDisplay.idl',
     'nsISelectionListener.idl',
     'nsISelectionPrivate.idl',
     'nsISimpleContentPolicy.idl',
-    'nsISiteSpecificUserAgent.idl',
     'nsISlowScriptDebug.idl',
 ]
 
 XPIDL_MODULE = 'dom'
 
 EXPORTS += [
     'AutocompleteFieldList.h',
     'Crypto.h',
@@ -413,23 +412,16 @@ EXTRA_COMPONENTS += [
     'messageWakeupService.js',
     'messageWakeupService.manifest',
     'ProcessSelector.js',
     'ProcessSelector.manifest',
     'SlowScriptDebug.js',
     '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',
 ]
 
 LOCAL_INCLUDES += [
     '../battery',
     '../events',
deleted file mode 100644
--- a/dom/base/nsISiteSpecificUserAgent.idl
+++ /dev/null
@@ -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);
-};
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3279,25 +3279,16 @@ var DesktopUserAgent = {
     let tab = BrowserApp.getTabForWindow(channelWindow);
     if (tab) {
       return this.getUserAgentForTab(tab);
     }
 
     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) {
       return this.DESKTOP_UA;
     }
 
     return null;
   },
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -85,20 +85,16 @@ contract @mozilla.org/login-manager/prom
 component {4e6ea350-b09a-11df-94e2-0800200c9a66} BlocklistPrompt.js
 contract @mozilla.org/addons/blocklist-prompt;1 {4e6ea350-b09a-11df-94e2-0800200c9a66}
 
 # NSSDialogService.js
 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}
 
 # FxAccountsPush.js
 component {d1bbb0fd-1d47-4134-9c12-d7b1be20b721} FxAccountsPush.js
 contract @mozilla.org/fxa-push;1 {d1bbb0fd-1d47-4134-9c12-d7b1be20b721}
 category android-push-service FxAccountsPush @mozilla.org/fxa-push;1
deleted file mode 100644
--- a/mobile/android/components/SiteSpecificUserAgent.js
+++ /dev/null
@@ -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]);
--- a/mobile/android/components/moz.build
+++ b/mobile/android/components/moz.build
@@ -25,17 +25,16 @@ EXTRA_COMPONENTS += [
     'ImageBlockingPolicy.js',
     'LoginManagerPrompter.js',
     'NSSDialogService.js',
     'PersistentNotificationHandler.js',
     'PresentationDevicePrompt.js',
     'PresentationRequestUIGlue.js',
     'PromptService.js',
     'SessionStore.js',
-    'SiteSpecificUserAgent.js',
     'Snippets.js',
     'TabSource.js',
     'XPIDialogService.js',
 ]
 
 # Keep it this way if at all possible.  If you need preprocessing,
 # consider adding fields to AppConstants.jsm.
 EXTRA_PP_COMPONENTS += [
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -525,17 +525,16 @@
 @BINPATH@/components/MobileComponents.manifest
 @BINPATH@/components/MobileComponents.xpt
 @BINPATH@/components/NSSDialogService.js
 @BINPATH@/components/PersistentNotificationHandler.js
 @BINPATH@/components/PresentationDevicePrompt.js
 @BINPATH@/components/PresentationRequestUIGlue.js
 @BINPATH@/components/PromptService.js
 @BINPATH@/components/SessionStore.js
-@BINPATH@/components/SiteSpecificUserAgent.js
 @BINPATH@/components/Snippets.js
 
 @BINPATH@/components/XPIDialogService.js
 
 #ifdef ENABLE_MARIONETTE
 @BINPATH@/chrome/marionette@JAREXT@
 @BINPATH@/chrome/marionette.manifest
 @BINPATH@/components/marionette.manifest
--- a/netwerk/protocol/http/UserAgentOverrides.jsm
+++ b/netwerk/protocol/http/UserAgentOverrides.jsm
@@ -8,27 +8,22 @@ this.EXPORTED_SYMBOLS = [ "UserAgentOver
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 
 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;
 var gOverrideForHostCache = new Map;
 var gInitialized = false;
 var gOverrideFunctions = [
   function (aHttpChannel) { return UserAgentOverrides.getOverrideForURI(aHttpChannel.URI); }
 ];
@@ -37,17 +32,16 @@ var gBuiltUAs = new Map;
 this.UserAgentOverrides = {
   init: function uao_init() {
     if (gInitialized)
       return;
 
     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 {
       Services.obs.addObserver(HTTP_on_useragent_request, "http-on-useragent-request", false);
     } catch (x) {
       // The http-on-useragent-request notification is disallowed in content processes.
     }
 
@@ -114,27 +108,16 @@ this.UserAgentOverrides = {
       return;
     gInitialized = false;
 
     gPrefBranch.removeObserver("", buildOverrides);
 
     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);
-    }
   }
 };
 
 function getUserAgentFromOverride(override)
 {
   let userAgent = gBuiltUAs.get(override);
   if (userAgent !== undefined) {
     return userAgent;