Bug 958179 - Rename Home.lists API to Home.panels. r=liuche
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 10 Jan 2014 12:57:23 -0800
changeset 162973 cd76ca8799927284e5d1af528e805b95470a0954
parent 162972 eacc67be800176ea59e1a83ca15fada676400c53
child 162974 6520037420c15ce13707f03e0eae38bf2bc70bd4
push id25977
push userttaubert@mozilla.com
push dateSun, 12 Jan 2014 09:26:17 +0000
treeherdermozilla-central@b029e8d3e130 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs958179
milestone29.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 958179 - Rename Home.lists API to Home.panels. r=liuche
mobile/android/base/home/PanelManager.java
mobile/android/modules/Home.jsm
--- a/mobile/android/base/home/PanelManager.java
+++ b/mobile/android/base/home/PanelManager.java
@@ -34,18 +34,18 @@ public class PanelManager implements Gec
         }
     }
 
     private final Context mContext;
 
     public PanelManager(Context context) {
         mContext = context;
 
-        // Add a listener to handle any new lists that are added after the lists have been loaded.
-        GeckoAppShell.getEventDispatcher().registerEventListener("HomeLists:Added", this);
+        // Add a listener to handle any new panels that are added after the panels have been loaded.
+        GeckoAppShell.getEventDispatcher().registerEventListener("HomePanels:Added", this);
     }
 
     /**
      * Reads list info from SharedPreferences. Don't call this on the main thread!
      *
      * @return List<PanelInfo> A list of PanelInfos for each registered list.
      */
     public List<PanelInfo> getPanelInfos() {
@@ -66,17 +66,17 @@ public class PanelManager implements Gec
             } catch (JSONException e) {
                 Log.e(LOGTAG, "Exception getting list info", e);
             }
         }
         return panelInfos;
     }
 
     /**
-     * Listens for "HomeLists:Added"
+     * Listens for "HomePanels:Added"
      */
     @Override
     public void handleMessage(String event, JSONObject message) {
         try {
             final PanelInfo info = new PanelInfo(message.getString("id"), message.getString("title"));
 
             // Do something to update the set of list pages.
 
--- a/mobile/android/modules/Home.jsm
+++ b/mobile/android/modules/Home.jsm
@@ -132,78 +132,79 @@ let HomeBanner = {
     // If there are no more messages, remove the observers.
     if (Object.keys(this._messages).length == 0) {
       Services.obs.removeObserver(this, "HomeBanner:Get");
       Services.obs.removeObserver(this, "HomeBanner:Click");
     }
   }
 };
 
-function List(options) {
+function Panel(options) {
   if ("id" in options)
     this.id = options.id;
 
   if ("title" in options)
     this.title = options.title;
 }
 
-function HomeLists() {
+function HomePanels() {
+  // XXX: Not renaming this because it is going away in bug 958192
   this.PREF_KEY = "home_lists";
 
   this._sharedPrefs = new SharedPreferences();
-  this._lists = {};
+  this._panels = {};
 
   let prefValue = this._sharedPrefs.getCharPref(this.PREF_KEY);
   if (!prefValue) {
     return;
   }
 
   JSON.parse(prefValue).forEach(data => {
-    let list = new List(data);
-    this._lists[list.id] = list;
+    let panel = new Panel(data);
+    this._panels[panel.id] = panel;
   });
 }
 
-HomeLists.prototype = {
+HomePanels.prototype = {
   add: function(options) {
-    let list = new List(options);
-    if (!list.id || !list.title) {
-      throw "Can't create a home list without an id and title!";
+    let panel = new Panel(options);
+    if (!panel.id || !panel.title) {
+      throw "Can't create a home panel without an id and title!";
     }
 
-    // Bail if the list already exists
-    if (list.id in this._lists) {
-      throw "List already exists: " + list.id;
+    // Bail if the panel already exists
+    if (panel.id in this._panels) {
+      throw "Panel already exists: " + panel.id;
     }
 
-    this._lists[list.id] = list;
+    this._panels[panel.id] = panel;
     this._updateSharedPref();
 
     // Send a message to Java to update the home pager if it's currently showing
     sendMessageToJava({
-      type: "HomeLists:Added",
-      id: list.id,
-      title: list.title
+      type: "HomePanels:Added",
+      id: panel.id,
+      title: panel.title
     });
   },
 
   remove: function(id) {
-    delete this._lists[id];
+    delete this._panels[id];
     this._updateSharedPref();
   },
 
-  // Set a shared pref so that Java can know about this list before Gecko is running
+  // Set a shared pref so that Java can know about this panel before Gecko is running
   _updateSharedPref: function() {
-    let lists = [];
-    for (let id in this._lists) {
-      let list = this._lists[id];
-      lists.push({ id: list.id, title: list.title});
+    let panels = [];
+    for (let id in this._panels) {
+      let panel = this._panels[id];
+      panels.push({ id: panel.id, title: panel.title});
     }
-    this._sharedPrefs.setCharPref(this.PREF_KEY, JSON.stringify(lists));
+    this._sharedPrefs.setCharPref(this.PREF_KEY, JSON.stringify(panels));
   }
 
 };
 
 // Public API
 this.Home = {
   banner: HomeBanner,
-  lists: new HomeLists()
+  panels: new HomePanels()
 }