Bug 1414084 - Part 8 - Unify menu item EventDispatcher messages. r=Grisha
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 18 Mar 2018 16:42:57 +0100
changeset 487022 84bac01f3a351b774a556dbc47c3305a62e54153
parent 487021 98ed7d6f8a7ab6b35f7ee73e6f0f7db4393ecf2f
child 487023 eb1ac381e2fb7b750482b48557ace56ef6c026f3
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGrisha
bugs1414084
milestone63.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 1414084 - Part 8 - Unify menu item EventDispatcher messages. r=Grisha As a final step, these can be merged as well. The same reasoning as in the previous patch applies with regards to additional functionality that isn't (yet) used by webextensions. MozReview-Commit-ID: Ezx2mQY0s85
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/modules/BrowserActions.jsm
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -851,19 +851,16 @@ public class BrowserApp extends GeckoApp
             null);
 
         EventDispatcher.getInstance().registerUiThreadListener(this,
             "GeckoView:AccessibilityEnabled",
             "Menu:Open",
             "Menu:Update",
             "Menu:Add",
             "Menu:Remove",
-            "Menu:AddBrowserAction",
-            "Menu:RemoveBrowserAction",
-            "Menu:UpdateBrowserAction",
             "LightweightTheme:Update",
             "Tab:Added",
             "Video:Play",
             "CharEncoding:Data",
             "CharEncoding:State",
             "Settings:Show",
             "Updater:Launch",
             "Sanitize:Finished",
@@ -1590,19 +1587,16 @@ public class BrowserApp extends GeckoApp
             null);
 
         EventDispatcher.getInstance().unregisterUiThreadListener(this,
             "GeckoView:AccessibilityEnabled",
             "Menu:Open",
             "Menu:Update",
             "Menu:Add",
             "Menu:Remove",
-            "Menu:AddBrowserAction",
-            "Menu:RemoveBrowserAction",
-            "Menu:UpdateBrowserAction",
             "LightweightTheme:Update",
             "Tab:Added",
             "Video:Play",
             "CharEncoding:Data",
             "CharEncoding:State",
             "Settings:Show",
             "Updater:Launch",
             "Sanitize:Finished",
@@ -1854,17 +1848,17 @@ public class BrowserApp extends GeckoApp
                     mBrowserToolbar.cancelEdit();
                 }
                 openOptionsMenu();
                 break;
 
             case "Menu:Add":
                 final MenuItemInfo info = new MenuItemInfo();
                 info.label = message.getString("name");
-                if (info.label == null) {
+                if (TextUtils.isEmpty(info.label)) {
                     Log.e(LOGTAG, "Invalid menu item name");
                     return;
                 }
                 info.id = mAddonMenuNextID++;
                 info.uuid = message.getString("uuid");
                 info.checked = message.getBoolean("checked", false);
                 info.enabled = message.getBoolean("enabled", true);
                 info.visible = message.getBoolean("visible", true);
@@ -1887,37 +1881,16 @@ public class BrowserApp extends GeckoApp
                 removeAddonMenuItem(message.getString("uuid"));
                 break;
 
             case "Menu:Update":
                 updateAddonMenuItem(message.getString("uuid"),
                                     message.getBundle("options"));
                 break;
 
-            case "Menu:AddBrowserAction":
-                final MenuItemInfo browserAction = new MenuItemInfo();
-                browserAction.label = message.getString("name");
-                if (TextUtils.isEmpty(browserAction.label)) {
-                    Log.e(LOGTAG, "Invalid browser action name");
-                    return;
-                }
-                browserAction.id = mAddonMenuNextID++;
-                browserAction.uuid = message.getString("uuid");
-                addAddonMenuItem(browserAction);
-                break;
-
-            case "Menu:RemoveBrowserAction":
-                removeAddonMenuItem(message.getString("uuid"));
-                break;
-
-            case "Menu:UpdateBrowserAction":
-                updateAddonMenuItem(message.getString("uuid"),
-                                    message.getBundle("options"));
-                break;
-
             case "LightweightTheme:Update":
                 mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
                 break;
 
             case "Search:Keyword":
                 storeSearchQuery(message.getString("query"));
                 recordSearch(GeckoSharedPrefs.forProfile(this), message.getString("identifier"),
                         TelemetryContract.Method.ACTIONBAR);
--- a/mobile/android/modules/BrowserActions.jsm
+++ b/mobile/android/modules/BrowserActions.jsm
@@ -58,17 +58,17 @@ var BrowserActions = {
   },
 
   /**
    * Registers a new browser action.
    * @param {Object} browserAction The browser action to add.
    */
   register(browserAction) {
     EventDispatcher.instance.sendRequest({
-      type: "Menu:AddBrowserAction",
+      type: "Menu:Add",
       uuid: browserAction.uuid,
       name: browserAction.defaults.name,
     });
 
     this._browserActions[browserAction.uuid] = browserAction;
     this._browserActionTitles[browserAction.uuid] = browserAction.defaults.name;
 
     this._maybeRegisterListeners();
@@ -77,17 +77,17 @@ var BrowserActions = {
   /**
    * Updates the browser action with the specified UUID.
    * @param {string} uuid The UUID of the browser action.
    * @param {Object} options The properties to update.
    */
   update(uuid, options) {
     if (options.name) {
       EventDispatcher.instance.sendRequest({
-        type: "Menu:UpdateBrowserAction",
+        type: "Menu:Update",
         uuid,
         options,
       });
 
       this._browserActionTitles[uuid] = options.name;
     }
   },
 
@@ -127,16 +127,16 @@ var BrowserActions = {
    * @param {string} uuid The UUID of the browser action.
    */
   unregister(uuid) {
     let browserAction = this._browserActions[uuid];
     if (!browserAction) {
       throw new Error(`No BrowserAction with UUID ${uuid} was found`);
     }
     EventDispatcher.instance.sendRequest({
-      type: "Menu:RemoveBrowserAction",
+      type: "Menu:Remove",
       uuid,
     });
     delete this._browserActions[uuid];
     delete this._browserActionTitles[uuid];
     this._maybeUnregisterListeners();
   }
 };