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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_view.cc

Issue 2039403002: Renamed AppMenuBadgeController to AppMenuIconController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reword comment Created 4 years, 6 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 ToolbarView::ToolbarView(Browser* browser) 123 ToolbarView::ToolbarView(Browser* browser)
124 : back_(nullptr), 124 : back_(nullptr),
125 forward_(nullptr), 125 forward_(nullptr),
126 reload_(nullptr), 126 reload_(nullptr),
127 home_(nullptr), 127 home_(nullptr),
128 location_bar_(nullptr), 128 location_bar_(nullptr),
129 browser_actions_(nullptr), 129 browser_actions_(nullptr),
130 app_menu_button_(nullptr), 130 app_menu_button_(nullptr),
131 browser_(browser), 131 browser_(browser),
132 badge_controller_(browser->profile(), this), 132 icon_controller_(browser->profile(), this),
133 display_mode_(browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) 133 display_mode_(browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)
134 ? DISPLAYMODE_NORMAL 134 ? DISPLAYMODE_NORMAL
135 : DISPLAYMODE_LOCATION) { 135 : DISPLAYMODE_LOCATION) {
136 set_id(VIEW_ID_TOOLBAR); 136 set_id(VIEW_ID_TOOLBAR);
137 137
138 SetEventTargeter( 138 SetEventTargeter(
139 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 139 std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
140 140
141 chrome::AddCommandObserver(browser_, IDC_BACK, this); 141 chrome::AddCommandObserver(browser_, IDC_BACK, this);
142 chrome::AddCommandObserver(browser_, IDC_FORWARD, this); 142 chrome::AddCommandObserver(browser_, IDC_FORWARD, this);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 AddChildView(back_); 232 AddChildView(back_);
233 AddChildView(forward_); 233 AddChildView(forward_);
234 AddChildView(reload_); 234 AddChildView(reload_);
235 AddChildView(home_); 235 AddChildView(home_);
236 AddChildView(location_bar_); 236 AddChildView(location_bar_);
237 AddChildView(browser_actions_); 237 AddChildView(browser_actions_);
238 AddChildView(app_menu_button_); 238 AddChildView(app_menu_button_);
239 239
240 LoadImages(); 240 LoadImages();
241 241
242 // Start global error services now so we badge the menu correctly. 242 // Start global error services now so we set the icon on the menu correctly.
243 #if !defined(OS_CHROMEOS) 243 #if !defined(OS_CHROMEOS)
244 if (!HasAshShell()) { 244 if (!HasAshShell()) {
245 SigninGlobalErrorFactory::GetForProfile(browser_->profile()); 245 SigninGlobalErrorFactory::GetForProfile(browser_->profile());
246 #if !defined(OS_ANDROID) 246 #if !defined(OS_ANDROID)
247 SyncGlobalErrorFactory::GetForProfile(browser_->profile()); 247 SyncGlobalErrorFactory::GetForProfile(browser_->profile());
248 #endif 248 #endif
249 } 249 }
250 250
251 #if defined(OS_WIN) 251 #if defined(OS_WIN)
252 RecoveryInstallGlobalErrorFactory::GetForProfile(browser_->profile()); 252 RecoveryInstallGlobalErrorFactory::GetForProfile(browser_->profile());
253 #endif 253 #endif
254 #endif // OS_CHROMEOS 254 #endif // OS_CHROMEOS
255 255
256 // Add any necessary badges to the menu item based on the system state. 256 // Set the button icon based on the system state. Do this after
257 // Do this after |app_menu_button_| has been added as a bubble may be shown 257 // |app_menu_button_| has been added as a bubble may be shown that needs
258 // that needs the widget (widget found by way of app_menu_button_-> 258 // the widget (widget found by way of app_menu_button_->GetWidget()).
259 // GetWidget()). 259 icon_controller_.UpdateDelegate();
260 badge_controller_.UpdateDelegate();
261 260
262 location_bar_->Init(); 261 location_bar_->Init();
263 262
264 show_home_button_.Init(prefs::kShowHomeButton, 263 show_home_button_.Init(prefs::kShowHomeButton,
265 browser_->profile()->GetPrefs(), 264 browser_->profile()->GetPrefs(),
266 base::Bind(&ToolbarView::OnShowHomeButtonChanged, 265 base::Bind(&ToolbarView::OnShowHomeButtonChanged,
267 base::Unretained(this))); 266 base::Unretained(this)));
268 267
269 // Accessibility specific tooltip text. 268 // Accessibility specific tooltip text.
270 if (content::BrowserAccessibilityState::GetInstance()-> 269 if (content::BrowserAccessibilityState::GetInstance()->
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 638
640 // Fall through to the tab strip above us if none of |rect| intersects 639 // Fall through to the tab strip above us if none of |rect| intersects
641 // with this view (intersection with the top shadow edge does not 640 // with this view (intersection with the top shadow edge does not
642 // count as intersection with this view). 641 // count as intersection with this view).
643 if (rect.bottom() < content_shadow_height()) 642 if (rect.bottom() < content_shadow_height())
644 return false; 643 return false;
645 // Otherwise let our superclass take care of it. 644 // Otherwise let our superclass take care of it.
646 return ViewTargeterDelegate::DoesIntersectRect(this, rect); 645 return ViewTargeterDelegate::DoesIntersectRect(this, rect);
647 } 646 }
648 647
649 void ToolbarView::UpdateBadgeSeverity(AppMenuBadgeController::BadgeType type, 648 void ToolbarView::UpdateIconSeverity(AppMenuIconController::IconType type,
Evan Stade 2016/06/10 18:01:57 nit: would be easier to grok if you copied the pat
kylix_rd 2016/06/10 19:08:53 Could you be a little more specific about what you
Evan Stade 2016/06/10 19:38:58 it seems you figured it out :)
650 AppMenuIconPainter::Severity severity, 649 AppMenuIconPainter::Severity severity,
651 bool animate) { 650 bool animate) {
652 // There's no app menu in tabless windows. 651 // There's no app menu in tabless windows.
653 if (!app_menu_button_) 652 if (!app_menu_button_)
654 return; 653 return;
655 654
656 // Showing the bubble requires |app_menu_button_| to be in a widget. See 655 // Showing the bubble requires |app_menu_button_| to be in a widget. See
657 // comment in ConflictingModuleView for details. 656 // comment in ConflictingModuleView for details.
658 DCHECK(app_menu_button_->GetWidget()); 657 DCHECK(app_menu_button_->GetWidget());
659 658
660 base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); 659 base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
661 if (type == AppMenuBadgeController::BadgeType::UPGRADE_NOTIFICATION) { 660 if (type == AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
662 accname_app = l10n_util::GetStringFUTF16( 661 accname_app = l10n_util::GetStringFUTF16(
663 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); 662 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
664 } 663 }
665 app_menu_button_->SetAccessibleName(accname_app); 664 app_menu_button_->SetAccessibleName(accname_app);
666 app_menu_button_->SetSeverity(type, severity, animate); 665 app_menu_button_->SetSeverity(type, severity, animate);
667 666
668 // Keep track of whether we were showing the badge before, so we don't send 667 // Keep track of whether we were showing the incompatibility icon before,
669 // multiple UMA events for example when multiple Chrome windows are open. 668 // so we don't send multiple UMA events for example when multiple Chrome
670 static bool incompatibility_badge_showing = false; 669 // windows are open.
670 static bool incompatibility_icon_showing = false;
671 // Save the old value before resetting it. 671 // Save the old value before resetting it.
672 bool was_showing = incompatibility_badge_showing; 672 bool was_showing = incompatibility_icon_showing;
673 incompatibility_badge_showing = false; 673 incompatibility_icon_showing = false;
674 674
675 if (type == AppMenuBadgeController::BadgeType::INCOMPATIBILITY_WARNING) { 675 if (type == AppMenuIconController::IconType::INCOMPATIBILITY_WARNING) {
676 if (!was_showing) { 676 if (!was_showing) {
677 content::RecordAction(UserMetricsAction("ConflictBadge")); 677 content::RecordAction(UserMetricsAction("ConflictBadge"));
678 #if defined(OS_WIN) 678 #if defined(OS_WIN)
679 ConflictingModuleView::MaybeShow(browser_, app_menu_button_); 679 ConflictingModuleView::MaybeShow(browser_, app_menu_button_);
680 #endif 680 #endif
681 } 681 }
682 incompatibility_badge_showing = true; 682 incompatibility_icon_showing = true;
Evan Stade 2016/06/10 18:01:57 I would call this the more generic/logical "incomp
kylix_rd 2016/06/10 19:08:53 Done.
683 return; 683 return;
684 } 684 }
685 } 685 }
686 686
687 gfx::Size ToolbarView::GetSizeInternal( 687 gfx::Size ToolbarView::GetSizeInternal(
688 gfx::Size (View::*get_size)() const) const { 688 gfx::Size (View::*get_size)() const) const {
689 gfx::Size size((location_bar_->*get_size)()); 689 gfx::Size size((location_bar_->*get_size)());
690 if (is_display_mode_normal()) { 690 if (is_display_mode_normal()) {
691 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); 691 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
692 const int browser_actions_width = 692 const int browser_actions_width =
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 SchedulePaint(); 796 SchedulePaint();
797 } 797 }
798 798
799 int ToolbarView::content_shadow_height() const { 799 int ToolbarView::content_shadow_height() const {
800 #if defined(USE_ASH) 800 #if defined(USE_ASH)
801 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH); 801 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH);
802 #else 802 #else
803 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT); 803 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT);
804 #endif 804 #endif
805 } 805 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698