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

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 789763004: Fix disappearing page actions bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Significant clean up. Created 6 years 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
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 9be31772fe3b03f571e1213f59b86495cf007f51..9c0d3144da9ba4a2e8111b450d6eee94972240db 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -1081,15 +1081,14 @@ bool LocationBarView::RefreshPageActionViews() {
// On startup we sometimes haven't loaded any extensions. This makes sure
// we catch up when the extensions (and any page actions) load.
- if (page_actions_ != new_page_actions) {
+ if (PageActionsDiffer(new_page_actions)) {
changed = true;
- page_actions_.swap(new_page_actions);
- DeletePageActionViews(); // Delete the old views (if any).
+ DeletePageActionViews();
// Create the page action views.
- for (PageActions::const_iterator i = page_actions_.begin();
- i != page_actions_.end(); ++i) {
+ for (PageActions::const_iterator i = new_page_actions.begin();
+ i != new_page_actions.end(); ++i) {
PageActionWithBadgeView* page_action_view = new PageActionWithBadgeView(
delegate_->CreatePageActionImageView(this, *i));
page_action_view->SetVisible(false);
@@ -1128,6 +1127,20 @@ bool LocationBarView::RefreshPageActionViews() {
return changed;
}
+bool LocationBarView::PageActionsDiffer(
+ const std::vector<ExtensionAction*>& page_actions) {
+ if (page_action_views_.size() != page_actions.size())
+ return true;
+
+ for (size_t index = 0; index < page_actions.size(); ++index) {
+ PageActionWithBadgeView* view = page_action_views_[index];
+ if (view->image_view()->extension_action() != page_actions[index])
+ return true;
+ }
+
+ return false;
+}
+
bool LocationBarView::RefreshZoomView() {
DCHECK(zoom_view_);
WebContents* web_contents = GetWebContents();
@@ -1293,7 +1306,7 @@ void LocationBarView::UpdatePageActions() {
}
void LocationBarView::InvalidatePageActions() {
- DeletePageActionViews();
+ RefreshPageActionViews();
Peter Kasting 2014/12/23 00:20:05 Why not just inline the contents of this method he
erikchen 2014/12/23 00:55:03 1. I renamed InvalidatePageActions->RefreshPageAct
}
void LocationBarView::UpdateBookmarkStarVisibility() {

Powered by Google App Engine
This is Rietveld 408576698