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

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 pkasting. 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..85ca7685c4be8f26657d7f88c94fa2be8ecc8c1b 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 PageActions& 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();
@@ -1286,16 +1299,16 @@ void LocationBarView::UpdateManagePasswordsIconAndBubble() {
}
void LocationBarView::UpdatePageActions() {
+ RefreshPageActions();
+}
+
+void LocationBarView::RefreshPageActions() {
if (RefreshPageActionViews()) { // Changed.
Layout();
SchedulePaint();
}
}
-void LocationBarView::InvalidatePageActions() {
- DeletePageActionViews();
-}
-
void LocationBarView::UpdateBookmarkStarVisibility() {
if (star_view_) {
star_view_->SetVisible(

Powered by Google App Engine
This is Rietveld 408576698