Ticket #10280: 10280.patch

File 10280.patch, 12.3 KB (added by disgleirio, 5 years ago)

Proper UI for hidden pref, with support to TorBrowser security

  • browser/app/profile/000-tor-browser.js

    From dc9d8c21ae62b60d29c497753979b3f1adc37be4 Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 10:56:34 +0000
    Subject: [PATCH 1/6] Update 000-tor-browser.js
    
    Disable to search plugins on first start
    ---
     browser/app/profile/000-tor-browser.js | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/browser/app/profile/000-tor-browser.js b/browser/app/profile/000-tor-browser.js
    index db85aa0..9236ceb 100644
    a b pref("network.protocol-handler.warn-external.mailto", true); 
    111111pref("network.protocol-handler.warn-external.news", true);
    112112pref("network.protocol-handler.warn-external.nntp", true);
    113113pref("network.protocol-handler.warn-external.snews", true);
     114pref("plugin.disable", true); // Disable to search plugins on first start
    114115pref("plugins.click_to_play", true);
    115116pref("plugin.state.flash", 1);
    116117pref("plugins.hide_infobar_for_missing_plugin", true);
  • dom/plugins/base/nsPluginHost.cpp

    From a9e3d695b21a26b10afad8e90476b406f2aad3bb Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 11:02:32 +0000
    Subject: [PATCH 2/6] Update nsPluginHost.cpp
    
    Notify observers about plugins was loaded or unloaded after plugin.disable was changed
    ---
     dom/plugins/base/nsPluginHost.cpp | 11 +++++++++++
     1 file changed, 11 insertions(+)
    
    diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
    index bc6bf72..575dfcd 100644
    a b NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject, 
    31083108    sInst->Release();
    31093109  }
    31103110  if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
     3111    NS_ConvertUTF16toUTF8 prefName(someData);
    31113112    mPluginsDisabled = Preferences::GetBool("plugin.disable", false);
    31123113    mPluginsClickToPlay = Preferences::GetBool("plugins.click_to_play", false);
    31133114    // Unload or load plugins as needed
    NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject, 
    31163117    } else {
    31173118      LoadPlugins();
    31183119    }
     3120    if (prefName.Equals("plugin.disable")) {
     3121      nsCOMPtr<nsIObserverService> obsService =
     3122        mozilla::services::GetObserverService();
     3123      if (obsService) {
     3124        nsAutoString pluginPolicy;
     3125        pluginPolicy = mPluginsDisabled ? NS_LITERAL_STRING("disabled")
     3126                                        : NS_LITERAL_STRING("enabled");
     3127        obsService->NotifyObservers(nullptr, "plugin-policy-changed", pluginPolicy.get());
     3128      }
     3129    }
    31193130  }
    31203131  if (!strcmp("blocklist-updated", aTopic)) {
    31213132    nsPluginTag* plugin = mPlugins;
  • toolkit/mozapps/extensions/AddonManager.jsm

    From 2595cd1f9cab2ab41ea7385fc124180127dfed84 Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 11:04:56 +0000
    Subject: [PATCH 3/6] Update AddonManager.jsm
    
    Add support of callManagerListeners to AddonManagerPrivate
    ---
     toolkit/mozapps/extensions/AddonManager.jsm | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
    index 81f2670..03e5588 100644
    a b this.AddonManagerPrivate = { 
    23642364    AddonManagerInternal.callAddonListeners.apply(AddonManagerInternal, aArgs);
    23652365  },
    23662366
     2367  callManagerListeners: function AMP_callManagerListeners(...aArgs) {
     2368    AddonManagerInternal.callManagerListeners.apply(AddonManagerInternal,
     2369                                                    aArgs);
     2370  },
     2371
    23672372  AddonAuthor: AddonAuthor,
    23682373
    23692374  AddonScreenshot: AddonScreenshot,
  • toolkit/mozapps/extensions/internal/PluginProvider.jsm

    From 5472eba6ff85f304e85dd6172fff4f90a1402a33 Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 11:06:01 +0000
    Subject: [PATCH 4/6] Update PluginProvider.jsm
    
    Update plugin list if plugin-policy-changed and inform add-on manager about it.
    ---
     toolkit/mozapps/extensions/internal/PluginProvider.jsm | 8 ++++++++
     1 file changed, 8 insertions(+)
    
    diff --git a/toolkit/mozapps/extensions/internal/PluginProvider.jsm b/toolkit/mozapps/extensions/internal/PluginProvider.jsm
    index 7b6e335..65d41a7 100644
    a b var PluginProvider = { 
    5252  plugins: null,
    5353
    5454  startup: function PL_startup() {
     55    Services.obs.addObserver(this, "plugin-policy-changed", false);
    5556    Services.obs.addObserver(this, LIST_UPDATED_TOPIC, false);
    5657    Services.obs.addObserver(this, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED, false);
    5758  },
    var PluginProvider = { 
    6465    this.plugins = null;
    6566    Services.obs.removeObserver(this, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
    6667    Services.obs.removeObserver(this, LIST_UPDATED_TOPIC);
     68    Services.obs.removeObserver(this, "plugin-policy-changed");
    6769  },
    6870
    6971  observe: function(aSubject, aTopic, aData) {
    var PluginProvider = { 
    8991      if (this.plugins)
    9092        this.updatePluginList();
    9193      break;
     94    case "plugin-policy-changed":
     95      if (!this.plugins)
     96        this.plugins ={};
     97      this.updatePluginList();
     98      AddonManagerPrivate.callManagerListeners("onPluginPolicyChanged");
     99      break;
    92100    }
    93101  },
    94102
  • toolkit/mozapps/extensions/content/extensions.xul

    From 7bcc92157777caa3257cda2168c9fd10ee506a9f Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 11:07:31 +0000
    Subject: [PATCH 5/6] Update extensions.xul
    
    Add buttons to enabled and to disable loading of plugins.
    ---
     toolkit/mozapps/extensions/content/extensions.xul | 21 +++++++++++++++++++++
     1 file changed, 21 insertions(+)
    
    diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul
    index d247bdf..82440ca 100644
    a b  
    8686    <command id="cmd_forward"/>
    8787    <command id="cmd_enableCheckCompatibility"/>
    8888    <command id="cmd_pluginCheck"/>
     89    <command id="cmd_pluginEnable"/>
     90    <command id="cmd_pluginDisable"/>
    8991    <command id="cmd_enableUpdateSecurity"/>
    9092    <command id="cmd_toggleAutoUpdateDefault"/>
    9193    <command id="cmd_resetAddonAutoUpdate"/>
     
    357359                      command="cmd_pluginCheck"/>
    358360              <spacer flex="5000"/> <!-- Necessary to allow the message to wrap -->
    359361            </hbox>
     362            <vbox id="plugin-disable-button" class="global-info" flex="1"
     363                  align="end">
     364              <button class="button-plugin-disable"
     365                      label="Disable plugins"
     366                      tooltiptext="Click to stop searching and using plugins"
     367                      command="cmd_pluginDisable"/>
     368              <spacer flex="5000"/>
     369            </vbox>
    360370          </hbox>
    361371          <hbox class="view-header global-info-container experiment-info-container">
    362372            <hbox class="global-info" flex="1" align="center">
     
    386396            </vbox>
    387397            <spacer class="alert-spacer-after"/>
    388398          </vbox>
     399          <vbox id="plugin-enable-button" class="alert-container" flex="1"
     400                hidden="true">
     401            <spacer class="alert-spacer-before"/>
     402            <vbox class="alert">
     403              <label value="Click to search for installed plugins"/>
     404              <button class="button-plugin-enable"
     405                      label="Enable plugins"
     406                      command="cmd_pluginEnable"/>
     407            </vbox>
     408            <spacer class="alert-spacer-after"/>
     409          </vbox>
    389410          <richlistbox id="addon-list" class="list" flex="1"/>
    390411        </vbox>
    391412
  • toolkit/mozapps/extensions/content/extensions.js

    From 6a6030c31320433b93a8a16187389cdbed5c1f5f Mon Sep 17 00:00:00 2001
    From: Disgleirio Morgan Wynne <Disgleirio.Wynne@google.com>
    Date: Tue, 24 Mar 2015 11:08:24 +0000
    Subject: [PATCH 6/6] Update extensions.js
    
    Show actual elements for about:addons if plugin.disable pref was changed
    ---
     toolkit/mozapps/extensions/content/extensions.js | 68 ++++++++++++++++++++++++
     1 file changed, 68 insertions(+)
    
    diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js
    index 35d2392..775064e 100644
    a b var gViewController = { 
    820820      }
    821821    },
    822822
     823    cmd_pluginEnable: {
     824      isEnabled: function cmd_pluginEnable_isEnabled() true,
     825      doCommand: function cmd_pluginEnable_doCommand() {
     826        Services.prefs.setBoolPref("plugin.disable", false);
     827      }
     828    },
     829
     830    cmd_pluginDisable: {
     831      isEnabled: function cmd_pluginDisable_isEnabled() true,
     832      doCommand: function cmd_pluginDisable_doCommand() {
     833        Services.prefs.setBoolPref("plugin.disable", true);
     834      }
     835    },
     836
    823837    cmd_toggleAutoUpdateDefault: {
    824838      isEnabled: function cmd_toggleAutoUpdateDefault_isEnabled() true,
    825839      doCommand: function cmd_toggleAutoUpdateDefault_doCommand() {
    var gListView = { 
    25532567  node: null,
    25542568  _listBox: null,
    25552569  _emptyNotice: null,
     2570  _pluginEnableButton: null,
     2571  _pluginHeader: null,
    25562572  _type: null,
    25572573
    25582574  initialize: function gListView_initialize() {
    25592575    this.node = document.getElementById("list-view");
    25602576    this._listBox = document.getElementById("addon-list");
    25612577    this._emptyNotice = document.getElementById("addon-list-empty");
     2578    this._pluginEnableButton = document.getElementById("plugin-enable-button");
     2579    this._pluginHeader = document.getElementsByClassName("plugin-info-container")[0];
    25622580
    25632581    var self = this;
    25642582    this._listBox.addEventListener("keydown", function listbox_onKeydown(aEvent) {
    var gListView = { 
    25702588    }, false);
    25712589  },
    25722590
     2591  shutdown: function gListView_shutdown() {
     2592    AddonManager.removeAddonListener(this);
     2593    AddonManager.removeManagerListener(this);
     2594  },
     2595
    25732596  show: function gListView_show(aType, aRequest) {
    25742597    if (!(aType in AddonManager.addonTypes))
    25752598      throw Components.Exception("Attempting to show unknown type " + aType, Cr.NS_ERROR_INVALID_ARG);
    var gListView = { 
    25772600    this._type = aType;
    25782601    this.node.setAttribute("type", aType);
    25792602    this.showEmptyNotice(false);
     2603    this.showPluginHeader(false);
     2604    this.showPluginEnableButton(false);
    25802605
    25812606    while (this._listBox.itemCount > 0)
    25822607      this._listBox.removeItemAt(0);
    var gListView = { 
    26002625        for (let element of elements)
    26012626          self._listBox.appendChild(element);
    26022627      }
     2628      self.showPluginButton();
    26032629
    26042630      gEventManager.registerInstallListener(self);
    26052631      gViewController.updateCommands();
    26062632      gViewController.notifyViewChanged();
     2633      AddonManager.addAddonListener(self); /* for onUninstalled */
     2634      AddonManager.addManagerListener(self); /* for onPluginPolicyChanged */
    26072635    });
    26082636  },
    26092637
    26102638  hide: function gListView_hide() {
     2639    AddonManager.removeAddonListener(this);
     2640    AddonManager.removeManagerListener(this);
    26112641    gEventManager.unregisterInstallListener(this);
    26122642    doPendingUninstalls(this._listBox);
    26132643  },
    var gListView = { 
    26582688    }
    26592689  },
    26602690
     2691  onUninstalled: function gListView_onUninstalled()  {
     2692    this.showEmptyNotice(this._listBox.itemCount == 0);
     2693  },
     2694
     2695  showPluginEnableButton: function gListView_showPluginEnableButton(aShow) {
     2696    if (this._pluginEnableButton)
     2697      this._pluginEnableButton.hidden = !aShow;
     2698  },
     2699
     2700  showPluginHeader: function gListView_showPluginHeader(aShow) {
     2701    if (this._pluginHeader)
     2702      this._pluginHeader.hidden = !aShow;
     2703  },
     2704
     2705  showPluginButton: function gListView_showPluginButton() {
     2706    if (this._type == "plugin") {
     2707      var plugin_disable = false;
     2708
     2709      try {
     2710        plugin_disable = Services.prefs.getBoolPref("plugin.disable")
     2711      } catch (e) {}
     2712
     2713      if (plugin_disable == true) {
     2714        this.showPluginHeader(false);
     2715        this.showEmptyNotice(false);
     2716        this.showPluginEnableButton(true);
     2717      } else {
     2718        this.showPluginHeader(true);
     2719        this.showEmptyNotice(this._listBox.itemCount == 0);
     2720        this.showPluginEnableButton(false);
     2721      }
     2722    }
     2723  },
     2724
     2725  onPluginPolicyChanged: function gListView_onPluginPolicyChanged() {
     2726    this.showPluginButton();
     2727  },
     2728
    26612729  addItem: function gListView_addItem(aObj, aIsInstall) {
    26622730    if (aObj.type != this._type)
    26632731      return;