Bug 974926 - Rename _panels to _registeredPanels in Home.jsm (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Mon, 24 Feb 2014 10:17:05 +0000
changeset 170405 d512121aec7ae2b97afa9ff6e866b288fcb9044d
parent 170133 57db167189218a31943007f5075c8514767451ec
child 170406 9f37968287a7c60360b30a1162066483124e78fa
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmargaret
bugs974926
milestone30.0a1
Bug 974926 - Rename _panels to _registeredPanels in Home.jsm (r=margaret)
mobile/android/modules/Home.jsm
--- a/mobile/android/modules/Home.jsm
+++ b/mobile/android/modules/Home.jsm
@@ -166,35 +166,38 @@ function Panel(options) {
   if ("layout" in options)
     this.layout = options.layout;
 
   if ("views" in options)
     this.views = options.views;
 }
 
 let HomePanels = (function () {
-  // Holds the currrent set of registered panels.
-  let _panels = {};
+  // Holds the current set of registered panels that can be
+  // installed, updated, uninstalled, or unregistered. This
+  // is also used to retrieve the list of available panels
+  // in the system (see HomePanels:Get handler).
+  let _registeredPanels = {};
 
   let _panelToJSON = function(panel) {
     return {
       id: panel.id,
       title: panel.title,
       layout: panel.layout,
       views: panel.views
     };
   };
 
   let _handleGet = function(data) {
     let requestId = data.requestId;
     let ids = data.ids || null;
 
     let panels = [];
-    for (let id in _panels) {
-      let panel = _panels[id];
+    for (let id in _registeredPanels) {
+      let panel = _registeredPanels[id];
 
       // Null ids means we want to fetch all available panels
       if (ids == null || ids.indexOf(panel.id) >= 0) {
         panels.push(_panelToJSON(panel));
       }
     }
 
     sendMessageToJava({
@@ -210,17 +213,17 @@ let HomePanels = (function () {
       if (obj[key] == value) {
         return true;
       }
     }
     return false;
   };
 
   let _assertPanelExists = function(id) {
-    if (!(id in _panels)) {
+    if (!(id in _registeredPanels)) {
       throw "Home.panels: Panel doesn't exist: id = " + id;
     }
   };
 
   return Object.freeze({
     // Valid layouts for a panel.
     Layout: Object.freeze({
       FRAME: "frame"
@@ -243,17 +246,17 @@ let HomePanels = (function () {
       BROWSER: "browser",
       INTENT: "intent"
     }),
 
     register: function(options) {
       let panel = new Panel(options);
 
       // Bail if the panel already exists
-      if (panel.id in _panels) {
+      if (panel.id in _registeredPanels) {
         throw "Home.panels: Panel already exists: id = " + panel.id;
       }
 
       if (!panel.id || !panel.title) {
         throw "Home.panels: Can't create a home panel without an id and title!";
       }
 
       if (!_valueExists(this.Layout, panel.layout)) {
@@ -284,31 +287,31 @@ let HomePanels = (function () {
           throw "Home.panels: Invalid item handler: panel.id = " + panel.id + ", view.itemHandler = " + view.itemHandler;
         }
 
         if (!view.dataset) {
           throw "Home.panels: No dataset provided for view: panel.id = " + panel.id + ", view.type = " + view.type;
         }
       }
 
-      _panels[panel.id] = panel;
+      _registeredPanels[panel.id] = panel;
     },
 
     unregister: function(id) {
       _assertPanelExists(id);
 
-      delete _panels[id];
+      delete _registeredPanels[id];
     },
 
     install: function(id) {
       _assertPanelExists(id);
 
       sendMessageToJava({
         type: "HomePanels:Install",
-        panel: _panelToJSON(_panels[id])
+        panel: _panelToJSON(_registeredPanels[id])
       });
     },
 
     uninstall: function(id) {
       _assertPanelExists(id);
 
       sendMessageToJava({
         type: "HomePanels:Uninstall",
@@ -316,17 +319,17 @@ let HomePanels = (function () {
       });
     },
 
     update: function(id) {
       _assertPanelExists(id);
 
       sendMessageToJava({
         type: "HomePanels:Update",
-        panel: _panelToJSON(_panels[id])
+        panel: _panelToJSON(_registeredPanels[id])
       });
     }
   });
 })();
 
 // Public API
 this.Home = Object.freeze({
   banner: HomeBanner,