Bug 1263571 - Pre: onTabChanged data is always a String, declare it as such r=liuche
authorAndrzej Hunt <ahunt@mozilla.com>
Sat, 23 Apr 2016 10:32:54 +0200
changeset 332371 332bbe886f1159709a787266fc26d3e3c1384a86
parent 332370 f4e12b2ddb63ea198ff141427875f4b2f6cfe2b3
child 332372 9ebb4247d445421ef172c2c8e66c2cd627f2bb91
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1263571
milestone48.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 1263571 - Pre: onTabChanged data is always a String, declare it as such r=liuche We're always using this as a String, we might as well make this explicit to avoid having to cast anywhere. (We very rarely use the parameter, but some new code in the main part of Bug 1263571 would have to cast this to a String. We can avoid that if we just use the correct type.) MozReview-Commit-ID: H8JdMzQtmRI
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/DoorHangerPopup.java
mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
mobile/android/base/java/org/mozilla/gecko/gfx/LayerRenderer.java
mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
mobile/android/base/java/org/mozilla/gecko/gfx/TouchEventHandler.java
mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -312,17 +312,17 @@ public class BrowserApp extends GeckoApp
             view = TabsPanel.createTabsLayout(context, attrs);
         } else {
             view = super.onCreateView(name, context, attrs);
         }
         return view;
     }
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, TabEvents msg, String data) {
         if (tab == null) {
             // Only RESTORED is allowed a null tab: it's the only event that
             // isn't tied to a specific tab.
             if (msg != Tabs.TabEvents.RESTORED) {
                 throw new IllegalArgumentException("onTabChanged:" + msg + " must specify a tab.");
             }
             return;
         }
--- a/mobile/android/base/java/org/mozilla/gecko/DoorHangerPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/DoorHangerPopup.java
@@ -142,18 +142,18 @@ public class DoorHangerPopup extends Anc
             config.setButton(buttonJSON.getString("label"), buttonJSON.getInt("callback"), isPositive);
         }
 
         return config;
     }
 
     // This callback is automatically executed on the UI thread.
     @Override
-    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final Object data) {
-        switch (msg) {
+    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final String data) {
+        switch(msg) {
             case CLOSED:
                 // Remove any doorhangers for a tab when it's closed (make
                 // a temporary set to avoid a ConcurrentModificationException)
                 removeTabDoorHangers(tab.getId(), true);
                 break;
 
             case LOCATION_CHANGE:
                 // Only remove doorhangers if the popup is hidden or if we're navigating to a new URL
--- a/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
+++ b/mobile/android/base/java/org/mozilla/gecko/FilePickerResultHandler.java
@@ -251,17 +251,17 @@ class FilePickerResultHandler implements
 
         @Override
         public void onLoaderReset(Loader<Cursor> loader) { }
 
         /*Tabs.OnTabsChangedListener*/
         // This cleans up our temp file. If it doesn't run, we just hope that Android
         // will eventually does the cleanup for us.
         @Override
-        public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+        public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
             if ((tab == null) || (tab.getId() != tabId)) {
                 return;
             }
 
             if (msg == Tabs.TabEvents.LOCATION_CHANGE ||
                 msg == Tabs.TabEvents.CLOSED) {
                 ThreadUtils.postToBackgroundThread(new Runnable() {
                     @Override
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -269,17 +269,17 @@ public abstract class GeckoApp
     }
 
     @Override
     public FormAssistPopup getFormAssistPopup() {
         return mFormAssistPopup;
     }
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         // When a tab is closed, it is always unselected first.
         // When a tab is unselected, another tab is always selected first.
         switch (msg) {
             case UNSELECTED:
                 hidePlugins(tab);
                 break;
 
             case LOCATION_CHANGE:
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -576,17 +576,17 @@ public class Tabs implements GeckoEventL
                         tab.loadThumbnailFromDB(db);
                     }
                 }
             }
         });
     }
 
     public interface OnTabsChangedListener {
-        public void onTabChanged(Tab tab, TabEvents msg, Object data);
+        void onTabChanged(Tab tab, TabEvents msg, String data);
     }
 
     private static final List<OnTabsChangedListener> TABS_CHANGED_LISTENERS = new CopyOnWriteArrayList<OnTabsChangedListener>();
 
     public static void registerOnTabsChangedListener(OnTabsChangedListener listener) {
         TABS_CHANGED_LISTENERS.add(listener);
     }
 
@@ -619,17 +619,17 @@ public class Tabs implements GeckoEventL
         BOOKMARK_REMOVED,
         AUDIO_PLAYING_CHANGE,
     }
 
     public void notifyListeners(Tab tab, TabEvents msg) {
         notifyListeners(tab, msg, "");
     }
 
-    public void notifyListeners(final Tab tab, final TabEvents msg, final Object data) {
+    public void notifyListeners(final Tab tab, final TabEvents msg, final String data) {
         if (tab == null &&
             msg != TabEvents.RESTORED) {
             throw new IllegalArgumentException("onTabChanged:" + msg + " must specify a tab.");
         }
 
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/BitmapUtils.java
@@ -148,17 +148,17 @@ public final class BitmapUtils {
     }
 
     public static void getThumbnailDrawable(final Context context, final String data, final BitmapLoader loader) {
          int id = Integer.parseInt(data.substring(10), 10);
          final Tab tab = Tabs.getInstance().getTab(id);
          runOnBitmapFoundOnUiThread(loader, tab.getThumbnail());
          Tabs.registerOnTabsChangedListener(new Tabs.OnTabsChangedListener() {
                  @Override
-                 public void onTabChanged(Tab t, Tabs.TabEvents msg, Object data) {
+                 public void onTabChanged(Tab t, Tabs.TabEvents msg, String data) {
                      if (tab == t && msg == Tabs.TabEvents.THUMBNAIL) {
                          Tabs.unregisterOnTabsChangedListener(this);
                          runOnBitmapFoundOnUiThread(loader, t.getThumbnail());
                      }
                  }
              });
          ThumbnailHelper.getInstance().getAndProcessThumbnailFor(tab);
     }
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/LayerRenderer.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/LayerRenderer.java
@@ -650,17 +650,17 @@ public class LayerRenderer implements Ta
                 });
                 mView.setPaintState(LayerView.PAINT_AFTER_FIRST);
             }
             mLastFrameTime = mFrameStartTime;
         }
     }
 
     @Override
-    public void onTabChanged(final Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(final Tab tab, Tabs.TabEvents msg, String data) {
         // Sets the background of the newly selected tab. This background color
         // gets cleared in endDrawing(). This function runs on the UI thread,
         // but other code that touches the paint state is run on the compositor
         // thread, so this may need to be changed if any problems appear.
         if (msg == Tabs.TabEvents.SELECTED) {
             if (mView != null) {
                 mView.setSurfaceBackgroundColor(tab.getBackgroundColor());
                 mView.setPaintState(LayerView.PAINT_START);
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
@@ -697,17 +697,17 @@ public class LayerView extends ScrollVie
         }
     }
 
     public float getSurfaceTranslation() {
         return mSurfaceTranslation;
     }
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab) && mLayerClient != null) {
             setZoomConstraints(tab.getZoomConstraints());
             setIsRTL(tab.getIsRTL());
         }
     }
 
     // Public hooks for dynamic toolbar translation
 
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/TouchEventHandler.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/TouchEventHandler.java
@@ -294,14 +294,14 @@ final class TouchEventHandler implements
             }
             mProcessingBalance++;
         }
     }
 
     // Tabs.OnTabsChangedListener implementation
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         if ((Tabs.getInstance().isSelectedTab(tab) && msg == Tabs.TabEvents.STOP) || msg == Tabs.TabEvents.SELECTED) {
             mWaitForTouchListeners = tab.getHasTouchListeners();
         }
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
@@ -129,17 +129,17 @@ public class TwoLinePageRow extends Line
     }
 
     /**
      * Update the row in response to a tab change event.
      * <p>
      * This method is always invoked on the UI thread.
      */
     @Override
-    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final Object data) {
+    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final String data) {
         // Carefully check if this tab event is relevant to this row.
         final String pageUrl = mPageUrl;
         if (pageUrl == null) {
             return;
         }
         if (tab == null) {
             return;
         }
--- a/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
+++ b/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
@@ -94,17 +94,17 @@ public class AddToHomeScreenPromotion im
         this.isEnabled = true;
 
         this.minimumVisits = minimumVisits;
         this.lastVisitMinimumAgeMs = lastVisitMinimumAgeMs;
         this.lastVisitMaximumAgeMs = lastVisitMaximumAgeMs;
     }
 
     @Override
-    public void onTabChanged(final Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(final Tab tab, Tabs.TabEvents msg, String data) {
         if (tab == null) {
             return;
         }
 
         if (!Tabs.getInstance().isSelectedTab(tab)) {
             // We only ever want to show this promotion for the current tab.
             return;
         }
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
@@ -128,17 +128,17 @@ public class Prompt implements OnClickLi
                 mDialog.show();
             }
         } else {
             mDialog.show();
         }
     }
 
     @Override
-    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final Object data) {
+    public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final String data) {
         if (tab != Tabs.getInstance().getTab(mTabId)) {
             return;
         }
 
         switch (msg) {
             case SELECTED:
                 Log.i(LOGTAG, "Selected");
                 mDialog.show();
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabStrip.java
@@ -102,17 +102,17 @@ public class TabStrip extends ThemedLine
     }
 
     public void setOnTabChangedListener(OnTabAddedOrRemovedListener listener) {
         tabChangedListener = listener;
     }
 
     private class TabsListener implements Tabs.OnTabsChangedListener {
         @Override
-        public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+        public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
             switch (msg) {
                 case RESTORED:
                     tabStripView.restoreTabs();
                     break;
 
                 case ADDED:
                     tabStripView.addTab(tab);
                     if (tabChangedListener != null) {
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsGridLayout.java
@@ -197,17 +197,17 @@ class TabsGridLayout extends GridView
         return true;
     }
 
     private void autoHidePanel() {
         tabsPanel.autoHidePanel();
     }
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         switch (msg) {
             case ADDED:
                 // Refresh only if panel is shown. show() will call refreshTabsData() later again.
                 if (tabsPanel.isShown()) {
                     // Refresh the list to make sure the new tab is added in the right position.
                     refreshTabsData();
                 }
                 break;
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabsListLayout.java
@@ -103,17 +103,17 @@ class TabsListLayout extends TwoWayView
         return isVertical();
     }
 
     private void autoHidePanel() {
         tabsPanel.autoHidePanel();
     }
 
     @Override
-    public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
         switch (msg) {
             case ADDED:
                 // Refresh the list to make sure the new tab is added in the right position.
                 refreshTabsData();
                 break;
 
             case CLOSED:
                 if (tab.isPrivate() == isPrivate && tabsAdapter.getCount() > 0) {
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
@@ -398,17 +398,17 @@ public abstract class BrowserToolbar ext
         if (!isEditing()) {
             throw new IllegalStateException("Expected to be editing");
         }
 
         urlEditLayout.restoreTabEditingState(editingState);
     }
 
     @Override
-    public void onTabChanged(@NonNull Tab tab, Tabs.TabEvents msg, Object data) {
+    public void onTabChanged(@NonNull Tab tab, Tabs.TabEvents msg, String data) {
         Log.d(LOGTAG, "onTabChanged: " + msg);
         final Tabs tabs = Tabs.getInstance();
 
         // These conditions are split into three phases:
         // * Always do first
         // * Handling specific to the selected tab
         // * Always do afterwards.
 
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
@@ -52,17 +52,17 @@ public class testAccessibleCarets extend
         super.testJavascript();
     }
 
     /**
      * Observes tab change events to broadcast to the test script.
      */
     private class TabsListener implements Tabs.OnTabsChangedListener {
         @Override
-        public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
+        public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
             switch (msg) {
                 case STOP:
                     final JSONObject args = new JSONObject();
                     try {
                         args.put("tabId", tab.getId());
                         args.put("event", msg.toString());
                     } catch (JSONException e) {
                         Log.e(LOGTAG, "Error building JSON arguments for " + TAB_CHANGE_EVENT, e);