--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -764,16 +764,17 @@ public class BrowserApp extends GeckoApp
EventDispatcher.getInstance().registerUiThreadListener(this,
"Accessibility:Enabled",
"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",
@@ -1573,16 +1574,17 @@ public class BrowserApp extends GeckoApp
EventDispatcher.getInstance().unregisterUiThreadListener(this,
"Accessibility:Enabled",
"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",
@@ -1894,16 +1896,21 @@ public class BrowserApp extends GeckoApp
browserAction.uuid = message.getString("uuid");
addBrowserActionMenuItem(browserAction);
break;
case "Menu:RemoveBrowserAction":
removeBrowserActionMenuItem(message.getString("uuid"));
break;
+ case "Menu:UpdateBrowserAction":
+ updateBrowserActionMenuItem(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);
@@ -3333,16 +3340,43 @@ public class BrowserApp extends GeckoApp
}
final MenuItem menuItem = mMenu.findItem(id);
if (menuItem != null) {
mMenu.removeItem(id);
}
}
+ /**
+ * Updates the WebExtension browser action with the specified UUID.
+ */
+ private void updateBrowserActionMenuItem(String uuid, final GeckoBundle options) {
+ int id = -1;
+
+ // Set attribute for the menu item in cache, if available
+ if (mBrowserActionItemsCache != null && !mBrowserActionItemsCache.isEmpty()) {
+ for (BrowserActionItemInfo item : mBrowserActionItemsCache) {
+ if (item.uuid.equals(uuid)) {
+ id = item.id;
+ item.label = options.getString("name", item.label);
+ break;
+ }
+ }
+ }
+
+ if (mMenu == null || id == -1) {
+ return;
+ }
+
+ final MenuItem menuItem = mMenu.findItem(id);
+ if (menuItem != null) {
+ menuItem.setTitle(options.getString("name", menuItem.getTitle().toString()));
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Sets mMenu = menu.
super.onCreateOptionsMenu(menu);
// Inform the menu about the action-items bar.
if (menu instanceof GeckoMenu &&
HardwareUtils.isTablet()) {