Chromium Code Reviews| 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() { |