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

Side by Side 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: Minor rename. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 i != content_setting_views_.end(); ++i) { 1049 i != content_setting_views_.end(); ++i) {
1050 const bool was_visible = (*i)->visible(); 1050 const bool was_visible = (*i)->visible();
1051 (*i)->Update(GetToolbarModel()->input_in_progress() ? 1051 (*i)->Update(GetToolbarModel()->input_in_progress() ?
1052 NULL : GetWebContents()); 1052 NULL : GetWebContents());
1053 if (was_visible != (*i)->visible()) 1053 if (was_visible != (*i)->visible())
1054 visibility_changed = true; 1054 visibility_changed = true;
1055 } 1055 }
1056 return visibility_changed; 1056 return visibility_changed;
1057 } 1057 }
1058 1058
1059 void LocationBarView::DeletePageActionViews() { 1059 void LocationBarView::DeletePageActionsAndViews() {
1060 for (PageActionViews::const_iterator i(page_action_views_.begin()); 1060 for (PageActionViews::const_iterator i(page_action_views_.begin());
1061 i != page_action_views_.end(); ++i) 1061 i != page_action_views_.end(); ++i)
1062 RemoveChildView(*i); 1062 RemoveChildView(*i);
1063 STLDeleteElements(&page_action_views_); 1063 STLDeleteElements(&page_action_views_);
1064 STLDeleteElements(&page_actions_);
1064 } 1065 }
1065 1066
1066 bool LocationBarView::RefreshPageActionViews() { 1067 bool LocationBarView::RefreshPageActionViews() {
1067 if (is_popup_mode_) 1068 if (is_popup_mode_)
1068 return false; 1069 return false;
1069 1070
1070 bool changed = false; 1071 bool changed = false;
1071 PageActions new_page_actions; 1072 PageActions new_page_actions;
1072 1073
1073 WebContents* web_contents = GetWebContents(); 1074 WebContents* web_contents = GetWebContents();
1074 if (web_contents) { 1075 if (web_contents) {
1075 extensions::TabHelper* extensions_tab_helper = 1076 extensions::TabHelper* extensions_tab_helper =
1076 extensions::TabHelper::FromWebContents(web_contents); 1077 extensions::TabHelper::FromWebContents(web_contents);
1077 extensions::LocationBarController* controller = 1078 extensions::LocationBarController* controller =
1078 extensions_tab_helper->location_bar_controller(); 1079 extensions_tab_helper->location_bar_controller();
1079 new_page_actions = controller->GetCurrentActions(); 1080 new_page_actions = controller->GetCurrentActions();
1080 } 1081 }
1081 1082
1082 // On startup we sometimes haven't loaded any extensions. This makes sure 1083 // On startup we sometimes haven't loaded any extensions. This makes sure
1083 // we catch up when the extensions (and any page actions) load. 1084 // we catch up when the extensions (and any page actions) load.
1084 if (page_actions_ != new_page_actions) { 1085 if (page_actions_ != new_page_actions) {
1085 changed = true; 1086 changed = true;
1086 1087
1087 page_actions_.swap(new_page_actions); 1088 page_actions_.swap(new_page_actions);
1088 DeletePageActionViews(); // Delete the old views (if any). 1089 page_action_views.clear();
danduong 2014/12/20 03:09:22 This should be page_action_views_. Also we need to
erikchen 2014/12/22 20:39:43 Done.
1089 1090
1090 // Create the page action views. 1091 // Create the page action views.
1091 for (PageActions::const_iterator i = page_actions_.begin(); 1092 for (PageActions::const_iterator i = page_actions_.begin();
1092 i != page_actions_.end(); ++i) { 1093 i != page_actions_.end(); ++i) {
1093 PageActionWithBadgeView* page_action_view = new PageActionWithBadgeView( 1094 PageActionWithBadgeView* page_action_view = new PageActionWithBadgeView(
1094 delegate_->CreatePageActionImageView(this, *i)); 1095 delegate_->CreatePageActionImageView(this, *i));
1095 page_action_view->SetVisible(false); 1096 page_action_view->SetVisible(false);
1096 page_action_views_.push_back(page_action_view); 1097 page_action_views_.push_back(page_action_view);
1097 } 1098 }
1098 1099
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 } 1287 }
1287 1288
1288 void LocationBarView::UpdatePageActions() { 1289 void LocationBarView::UpdatePageActions() {
1289 if (RefreshPageActionViews()) { // Changed. 1290 if (RefreshPageActionViews()) { // Changed.
1290 Layout(); 1291 Layout();
1291 SchedulePaint(); 1292 SchedulePaint();
1292 } 1293 }
1293 } 1294 }
1294 1295
1295 void LocationBarView::InvalidatePageActions() { 1296 void LocationBarView::InvalidatePageActions() {
1296 DeletePageActionViews(); 1297 DeletePageActionsAndViews();
danduong 2014/12/20 04:28:40 Hah! I think the bug is actually here. This proba
danduong 2014/12/20 04:59:04 I just realized that you commented on this in the
erikchen 2014/12/22 20:39:43 We should be calling Refresh. This is another bug.
1297 } 1298 }
1298 1299
1299 void LocationBarView::UpdateBookmarkStarVisibility() { 1300 void LocationBarView::UpdateBookmarkStarVisibility() {
1300 if (star_view_) { 1301 if (star_view_) {
1301 star_view_->SetVisible( 1302 star_view_->SetVisible(
1302 browser_defaults::bookmarks_enabled && !is_popup_mode_ && 1303 browser_defaults::bookmarks_enabled && !is_popup_mode_ &&
1303 !GetToolbarModel()->input_in_progress() && 1304 !GetToolbarModel()->input_in_progress() &&
1304 edit_bookmarks_enabled_.GetValue() && 1305 edit_bookmarks_enabled_.GetValue() &&
1305 !IsBookmarkStarHiddenByExtension()); 1306 !IsBookmarkStarHiddenByExtension());
1306 } 1307 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 1666
1666 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1667 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1667 const SearchModel::State& new_state) { 1668 const SearchModel::State& new_state) {
1668 const bool visible = !GetToolbarModel()->input_in_progress() && 1669 const bool visible = !GetToolbarModel()->input_in_progress() &&
1669 new_state.voice_search_supported; 1670 new_state.voice_search_supported;
1670 if (mic_search_view_->visible() != visible) { 1671 if (mic_search_view_->visible() != visible) {
1671 mic_search_view_->SetVisible(visible); 1672 mic_search_view_->SetVisible(visible);
1672 Layout(); 1673 Layout();
1673 } 1674 }
1674 } 1675 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698