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

Unified Diff: chrome/browser/extensions/extension_toolbar_model.cc

Issue 684373004: Fix potential edge case crashes in ExtensionToolbarModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_toolbar_fix_incognito_stuff
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_toolbar_model.cc
diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc
index 7c64c1f11755eeeb4da6a38295c15c4e9b823458..d10dc721fbc76818f9d9482366ee13b391a9b3be 100644
--- a/chrome/browser/extensions/extension_toolbar_model.cc
+++ b/chrome/browser/extensions/extension_toolbar_model.cc
@@ -211,6 +211,12 @@ void ExtensionToolbarModel::Observe(
extension_prefs_, extension->id());
// Hiding works differently with the new and old toolbars.
if (include_all_extensions_) {
+ // It's possible that we haven't added this extension yet, if its
+ // visibility was adjusted in the course of its initialization.
+ if (std::find(toolbar_items_.begin(), toolbar_items_.end(), extension) ==
+ toolbar_items_.end())
+ return;
+
int new_size = 0;
int new_index = 0;
if (visible) {
@@ -355,6 +361,10 @@ void ExtensionToolbarModel::RemoveExtension(const Extension* extension) {
if (pos == toolbar_items_.end())
return;
+ // If our visible count is set to the current size, we need to decrement it.
+ if (visible_icon_count_ == static_cast<int>(toolbar_items_.size()))
+ SetVisibleIconCount(toolbar_items_.size() - 1);
+
toolbar_items_.erase(pos);
// If we're in highlight mode, we also have to remove the extension from
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698