Bug 1460874 - Part 8: Allow setting prefs via GeckoRuntimeSettings in Fennec, too. r=geckoview-reviewers,snorp
☠☠ backed out by cd616c3e3eea ☠ ☠
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 13 Feb 2019 20:10:42 +0000
changeset 458950 17fbff3da236
parent 458949 1026b786e779
child 458951 9fc145133f20
push id35552
push usershindli@mozilla.com
push dateThu, 14 Feb 2019 04:39:44 +0000
treeherdermozilla-central@c6829642e2d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1460874
milestone67.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 1460874 - Part 8: Allow setting prefs via GeckoRuntimeSettings in Fennec, too. r=geckoview-reviewers,snorp Differential Revision: https://phabricator.services.mozilla.com/D17748
mobile/android/components/BrowserCLH.js
mobile/android/components/MobileComponents.manifest
--- a/mobile/android/components/BrowserCLH.js
+++ b/mobile/android/components/BrowserCLH.js
@@ -4,17 +4,19 @@
 "use strict";
 
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   ActorManagerParent: "resource://gre/modules/ActorManagerParent.jsm",
   AppConstants: "resource://gre/modules/AppConstants.jsm",
   DelayedInit: "resource://gre/modules/DelayedInit.jsm",
+  EventDispatcher: "resource://gre/modules/Messaging.jsm",
   GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
+  Preferences: "resource://gre/modules/Preferences.jsm",
   Services: "resource://gre/modules/Services.jsm",
 });
 
 function BrowserCLH() {
   this.wrappedJSObject = this;
 }
 
 BrowserCLH.prototype = {
@@ -169,16 +171,42 @@ BrowserCLH.prototype = {
           name: "ActionBarHandler",
           options: {
             capture: true,
             mozSystemGroup: true,
           },
         });
         break;
       }
+
+      case "profile-after-change": {
+        EventDispatcher.instance.registerListener(this, "GeckoView:SetDefaultPrefs");
+        break;
+      }
+    }
+  },
+
+  onEvent(aEvent, aData, aCallback) {
+    switch (aEvent) {
+      case "GeckoView:SetDefaultPrefs": {
+        // While we want to allow setting certain preferences via GeckoView, we
+        // don't want to let it take over completely the management of those
+        // preferences. Therefore we don't handle the "ResetUserPrefs" message,
+        // and consequently we also apply any pref changes directly, i.e. *not*
+        // on the default branch.
+        const prefs = new Preferences();
+        for (const name of Object.keys(aData)) {
+          try {
+            prefs.set(name, aData[name]);
+          } catch (e) {
+            Cu.reportError(`Failed to set preference ${name}: ${e}`);
+          }
+        }
+        break;
+      }
     }
   },
 
   _initLoginManagerEvents: function(aWindow) {
     if (Services.prefs.getBoolPref("reftest.remote", false)) {
       // XXX known incompatibility between reftest harness and form-fill.
       return;
     }
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -60,16 +60,17 @@ contract @mozilla.org/addons/web-install
 # HelperAppDialog.js
 component {e9d277a0-268a-4ec2-bb8c-10fdf3e44611} HelperAppDialog.js
 contract @mozilla.org/helperapplauncherdialog;1 {e9d277a0-268a-4ec2-bb8c-10fdf3e44611}
 
 # BrowserCLH.js
 component {be623d20-d305-11de-8a39-0800200c9a66} BrowserCLH.js application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
 contract @mozilla.org/browser/browser-clh;1 {be623d20-d305-11de-8a39-0800200c9a66}
 category app-startup BrowserCLH service,@mozilla.org/browser/browser-clh;1
+category profile-after-change BrowserCLH @mozilla.org/browser/browser-clh;1
 
 # ContentDispatchChooser.js
 component {5a072a22-1e66-4100-afc1-07aed8b62fc5} ContentDispatchChooser.js
 contract @mozilla.org/content-dispatch-chooser;1 {5a072a22-1e66-4100-afc1-07aed8b62fc5}
 
 # AddonUpdateService.js
 component {93c8824c-9b87-45ae-bc90-5b82a1e4d877} AddonUpdateService.js
 contract @mozilla.org/browser/addon-update-service;1 {93c8824c-9b87-45ae-bc90-5b82a1e4d877}