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

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

Issue 296983014: Fix issue with browser action toolbar putting all extension icons in overflow once sync happens. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Polish Created 6 years, 7 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/extensions/extension_toolbar_model_browsertest.cc » ('j') | 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 7c9d5bfdd08beba10b31aa2edef74cecebfb399d..bc008d785162cfb619cdcb249b781ba3f95b77f5 100644
--- a/chrome/browser/extensions/extension_toolbar_model.cc
+++ b/chrome/browser/extensions/extension_toolbar_model.cc
@@ -387,28 +387,43 @@ void ExtensionToolbarModel::Populate(const ExtensionIdList& positions,
unsorted.push_back(make_scoped_refptr(extension));
}
- // Erase current icons.
- for (size_t i = 0; i < toolbar_items_.size(); i++) {
+ size_t items_count = toolbar_items_.size();
+ for (size_t i = 0; i < items_count; i++) {
+ const Extension* extension = toolbar_items_.back();
+ toolbar_items_.pop_back();
Finnur 2014/05/23 16:30:44 By popping the extension here (before calling Brow
Devlin 2014/05/23 17:18:26 Good comment. Such a good comment, it should prob
FOR_EACH_OBSERVER(
- Observer, observers_, BrowserActionRemoved(toolbar_items_[i].get()));
+ Observer, observers_, BrowserActionRemoved(extension));
}
- toolbar_items_.clear();
+ DCHECK(toolbar_items_.empty());
// Merge the lists.
toolbar_items_.reserve(sorted.size() + unsorted.size());
+
+ int count = 0;
Devlin 2014/05/23 17:18:26 I wonder if this is worth keeping, even. Isn't co
for (ExtensionList::const_iterator iter = sorted.begin();
- iter != sorted.end(); ++iter) {
+ iter != sorted.end(); ++iter) {
Devlin 2014/05/23 17:18:26 nit: I think the "four-space line continuation" ru
// It's possible for the extension order to contain items that aren't
// actually loaded on this machine. For example, when extension sync is on,
// we sync the extension order as-is but double-check with the user before
// syncing NPAPI-containing extensions, so if one of those is not actually
// synced, we'll get a NULL in the list. This sort of case can also happen
// if some error prevents an extension from loading.
- if (iter->get() != NULL)
+ if (iter->get() != NULL) {
+ toolbar_items_.push_back(*iter);
+ FOR_EACH_OBSERVER(
+ Observer, observers_, BrowserActionAdded(*iter, count));
+ count++;
Devlin 2014/05/23 17:18:26 nit: ++count in chromium, unless there's a specifi
+ }
+ }
+ for (ExtensionList::const_iterator iter = unsorted.begin();
+ iter != unsorted.end(); ++iter) {
+ if (iter->get() != NULL) {
toolbar_items_.push_back(*iter);
+ FOR_EACH_OBSERVER(
+ Observer, observers_, BrowserActionAdded(*iter, count));
+ count++;
+ }
}
- toolbar_items_.insert(toolbar_items_.end(), unsorted.begin(),
- unsorted.end());
UMA_HISTOGRAM_COUNTS_100(
"ExtensionToolbarModel.BrowserActionsPermanentlyHidden", hidden);
@@ -424,12 +439,6 @@ void ExtensionToolbarModel::Populate(const ExtensionIdList& positions,
base::HistogramBase::kSampleType_MAX :
visible_icon_count_);
}
-
- // Inform observers.
- for (size_t i = 0; i < toolbar_items_.size(); i++) {
- FOR_EACH_OBSERVER(
- Observer, observers_, BrowserActionAdded(toolbar_items_[i].get(), i));
- }
}
void ExtensionToolbarModel::UpdatePrefs() {
@@ -589,6 +598,6 @@ void ExtensionToolbarModel::StopHighlighting() {
}
FOR_EACH_OBSERVER(Observer, observers_, HighlightModeChanged(false));
}
-};
+}
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_toolbar_model_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698