| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * This Source Code is subject to the terms of the Mozilla Public License |    2  * This Source Code is subject to the terms of the Mozilla Public License | 
|    3  * version 2.0 (the "License"). You can obtain a copy of the License at |    3  * version 2.0 (the "License"). You can obtain a copy of the License at | 
|    4  * http://mozilla.org/MPL/2.0/. |    4  * http://mozilla.org/MPL/2.0/. | 
|    5  */ |    5  */ | 
|    6  |    6  | 
|    7 Cu.import("resource://gre/modules/Services.jsm"); |    7 Cu.import("resource://gre/modules/Services.jsm"); | 
|    8  |    8  | 
|    9 let {Prefs} = require("prefs"); |    9 let {Prefs} = require("prefs"); | 
|   10 let {WindowObserver} = require("windowObserver"); |   10 let {WindowObserver} = require("windowObserver"); | 
|   11  |   11  | 
 |   12 var isAustralis = false; | 
 |   13 try | 
 |   14 { | 
 |   15   Cu.import("resource:///modules/CustomizableUI.jsm", null); | 
 |   16   isAustralis = true; | 
 |   17 } catch(e) {} | 
 |   18  | 
|   12 var WindowFeature = |   19 var WindowFeature = | 
|   13 { |   20 { | 
|   14   observer: null, |   21   observer: null, | 
|   15  |   22  | 
|   16   init: function() |   23   init: function() | 
|   17   { |   24   { | 
|   18     if (!this.observer) |   25     if (!this.observer) | 
|   19       this.observer = new WindowObserver(this, "ready"); |   26       this.observer = new WindowObserver(this, "ready"); | 
|   20   }, |   27   }, | 
|   21  |   28  | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  117   __proto__: StylesheetFeature, |  124   __proto__: StylesheetFeature, | 
|  118   stylesheet: "chrome://abpcustomization/content/oneLineSubscriptions.css" |  125   stylesheet: "chrome://abpcustomization/content/oneLineSubscriptions.css" | 
|  119 }; |  126 }; | 
|  120  |  127  | 
|  121 var RemoveActionsButton = |  128 var RemoveActionsButton = | 
|  122 { |  129 { | 
|  123   __proto__: StylesheetFeature, |  130   __proto__: StylesheetFeature, | 
|  124   stylesheet: "chrome://abpcustomization/content/noActionButton.css" |  131   stylesheet: "chrome://abpcustomization/content/noActionButton.css" | 
|  125 }; |  132 }; | 
|  126  |  133  | 
 |  134 var AddonPageAustralisStyles = | 
 |  135 { | 
 |  136   __proto__: StylesheetFeature, | 
 |  137   stylesheet: "chrome://abpcustomization/content/addonPageAustralisStyles.css" | 
 |  138 }; | 
 |  139  | 
|  127 var ToolbarIconDisplay = |  140 var ToolbarIconDisplay = | 
|  128 { |  141 { | 
|  129   __proto__: StylesheetFeature, |  142   __proto__: StylesheetFeature, | 
|  130   get template() |  143   get template() | 
|  131   { |  144   { | 
|  132     let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(C
     i.nsIXMLHttpRequest); |  145     let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(C
     i.nsIXMLHttpRequest); | 
|  133     request.open("GET", "chrome://abpcustomization/content/toolbarIconDisplay.cs
     s", false); |  146     request.open("GET", "chrome://abpcustomization/content/toolbarIconDisplay.cs
     s", false); | 
|  134     request.overrideMimeType("text/plain"); |  147     request.overrideMimeType("text/plain"); | 
|  135     request.send(); |  148     request.send(); | 
|  136     let result = request.responseText; |  149     let result = request.responseText; | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|  165   stylesheet: "chrome://abpcustomization/content/hideMenus.css" |  178   stylesheet: "chrome://abpcustomization/content/hideMenus.css" | 
|  166 }; |  179 }; | 
|  167  |  180  | 
|  168 let features = |  181 let features = | 
|  169 { |  182 { | 
|  170   "addon-page-styles": AddonPageStyles, |  183   "addon-page-styles": AddonPageStyles, | 
|  171   "vertical-preferences-layout": VerticalPreferencesLayout, |  184   "vertical-preferences-layout": VerticalPreferencesLayout, | 
|  172   "preferences-one-line-subscriptions": OneLineSubscriptions, |  185   "preferences-one-line-subscriptions": OneLineSubscriptions, | 
|  173   "preferences-remove-actions-button": RemoveActionsButton, |  186   "preferences-remove-actions-button": RemoveActionsButton, | 
|  174   "toolbar-icon-display": ToolbarIconDisplay, |  187   "toolbar-icon-display": ToolbarIconDisplay, | 
 |  188   "addon-page-australis-styles": AddonPageAustralisStyles, | 
|  175   "green-icon": GreenIcon, |  189   "green-icon": GreenIcon, | 
|  176   "remove-menus": RemoveMenus |  190   "remove-menus": RemoveMenus | 
|  177 }; |  191 }; | 
|  178  |  192  | 
|  179 function updateFeature(name) |  193 function updateFeature(name) | 
|  180 { |  194 { | 
|  181   if (name in features) |  195   if (name in features) | 
|  182   { |  196   { | 
|  183     let enabled; |  197     let enabled; | 
|  184     if (name == "addon-page-styles") |  198     if (name == "addon-page-styles") | 
|  185       enabled = true; |  199       enabled = true; | 
 |  200     else if (name == "toolbar-icon-display" && isAustralis) | 
 |  201       enabled = false; | 
 |  202     else if (name == "addon-page-australis-styles") | 
 |  203       enabled = isAustralis; | 
|  186     else |  204     else | 
|  187       enabled = Prefs[name]; |  205       enabled = Prefs[name]; | 
|  188  |  206  | 
|  189     if (enabled) |  207     if (enabled) | 
|  190       features[name].init(); |  208       features[name].init(); | 
|  191     else |  209     else | 
|  192       features[name].shutdown(); |  210       features[name].shutdown(); | 
|  193   } |  211   } | 
|  194 } |  212 } | 
|  195  |  213  | 
|  196  |  | 
|  197 // Initialize features and make sure to update them on changes |  214 // Initialize features and make sure to update them on changes | 
|  198 for (let feature in features) |  215 for (let feature in features) | 
|  199   updateFeature(feature); |  216   updateFeature(feature); | 
|  200  |  217  | 
|  201 Prefs.addListener(updateFeature); |  218 Prefs.addListener(updateFeature); | 
| OLD | NEW |