Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2637)

Unified Diff: chrome/browser/ui/toolbar/toolbar_actions_model.cc

Issue 1861943002: [Extensions UI] Don't pop out an overflowed action on item uninstall (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/toolbar/toolbar_actions_model.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_model.cc b/chrome/browser/ui/toolbar/toolbar_actions_model.cc
index d0941201c8687a9ce7ed060f6dc1e7d3321012ad..7c8d51315a9de60782587d2c7fe4e11377c99a94 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_model.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_model.cc
@@ -227,7 +227,19 @@ void ToolbarActionsModel::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) {
+ size_t index = 0u;
+ while (toolbar_items().size() > index &&
+ toolbar_items()[index].id != extension->id())
+ ++index;
+ bool was_visible_and_has_overflow =
+ index < visible_icon_count() && !all_icons_visible();
Finnur 2016/04/07 10:14:13 Nit: I wonder if this should be a private util fun
Devlin 2016/04/07 17:16:48 Since it's only used here (that I saw), I think it
RemoveExtension(extension);
+ // If the extension was previously visible and there are overflowed
+ // extensions, and this extension is being uninstalled, we reduce the visible
+ // count so that we don't pop out a previously-hidden extension.
+ if (was_visible_and_has_overflow &&
+ reason == extensions::UnloadedExtensionInfo::REASON_UNINSTALL)
+ SetVisibleIconCount(visible_icon_count() - 1);
}
void ToolbarActionsModel::OnExtensionUninstalled(
« no previous file with comments | « no previous file | chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698