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

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: Comments from wittman. 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
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..aade61986f3b2a64493f54d65e2a759afc6659ef 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);
@@ -1116,18 +1115,30 @@ bool LocationBarView::RefreshPageActionViews() {
AddChildViewAt(*i, GetIndexOf(right_anchor));
}
- if (!page_action_views_.empty() && web_contents) {
- for (PageActionViews::const_iterator i(page_action_views_.begin());
- i != page_action_views_.end(); ++i) {
- bool old_visibility = (*i)->visible();
- (*i)->UpdateVisibility(
- GetToolbarModel()->input_in_progress() ? NULL : web_contents);
- changed |= old_visibility != (*i)->visible();
- }
+ for (PageActionViews::const_iterator i(page_action_views_.begin());
+ i != page_action_views_.end(); ++i) {
+ bool old_visibility = (*i)->visible();
+ (*i)->UpdateVisibility(
+ GetToolbarModel()->input_in_progress() ? NULL : web_contents);
+ changed |= old_visibility != (*i)->visible();
}
return changed;
}
+bool LocationBarView::PageActionsDiffer(
+ const PageActions& page_actions) const {
+ 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();
@@ -1292,10 +1303,6 @@ void LocationBarView::UpdatePageActions() {
}
}
-void LocationBarView::InvalidatePageActions() {
- DeletePageActionViews();
-}
-
void LocationBarView::UpdateBookmarkStarVisibility() {
if (star_view_) {
star_view_->SetVisible(
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698