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 |