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

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: Renamed identifiers in Cocoa file 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 app_menu_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 app_menu_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 // AppMenuIconController::Delegate:
650 AppMenuIconPainter::Severity severity, 649 void ToolbarView::UpdateSeverity(AppMenuIconController::IconType type,
651 bool animate) { 650 AppMenuIconPainter::Severity severity,
651 bool animate) {
652 // There's no app menu in tabless windows. 652 // There's no app menu in tabless windows.
653 if (!app_menu_button_) 653 if (!app_menu_button_)
654 return; 654 return;
655 655
656 // Showing the bubble requires |app_menu_button_| to be in a widget. See 656 // Showing the bubble requires |app_menu_button_| to be in a widget. See
657 // comment in ConflictingModuleView for details. 657 // comment in ConflictingModuleView for details.
658 DCHECK(app_menu_button_->GetWidget()); 658 DCHECK(app_menu_button_->GetWidget());
659 659
660 base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); 660 base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
661 if (type == AppMenuBadgeController::BadgeType::UPGRADE_NOTIFICATION) { 661 if (type == AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
662 accname_app = l10n_util::GetStringFUTF16( 662 accname_app = l10n_util::GetStringFUTF16(
663 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); 663 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
664 } 664 }
665 app_menu_button_->SetAccessibleName(accname_app); 665 app_menu_button_->SetAccessibleName(accname_app);
666 app_menu_button_->SetSeverity(type, severity, animate); 666 app_menu_button_->SetSeverity(type, severity, animate);
667 667
668 // Keep track of whether we were showing the badge before, so we don't send 668 // Keep track of whether we were showing the incompatibility icon before,
669 // multiple UMA events for example when multiple Chrome windows are open. 669 // so we don't send multiple UMA events for example when multiple Chrome
670 static bool incompatibility_badge_showing = false; 670 // windows are open.
671 static bool incompatibility_warning_showing = false;
671 // Save the old value before resetting it. 672 // Save the old value before resetting it.
672 bool was_showing = incompatibility_badge_showing; 673 bool was_showing = incompatibility_warning_showing;
673 incompatibility_badge_showing = false; 674 incompatibility_warning_showing = false;
674 675
675 if (type == AppMenuBadgeController::BadgeType::INCOMPATIBILITY_WARNING) { 676 if (type == AppMenuIconController::IconType::INCOMPATIBILITY_WARNING) {
676 if (!was_showing) { 677 if (!was_showing) {
677 content::RecordAction(UserMetricsAction("ConflictBadge")); 678 content::RecordAction(UserMetricsAction("ConflictBadge"));
678 #if defined(OS_WIN) 679 #if defined(OS_WIN)
679 ConflictingModuleView::MaybeShow(browser_, app_menu_button_); 680 ConflictingModuleView::MaybeShow(browser_, app_menu_button_);
680 #endif 681 #endif
681 } 682 }
682 incompatibility_badge_showing = true; 683 incompatibility_warning_showing = true;
683 return; 684 return;
684 } 685 }
685 } 686 }
686 687
687 gfx::Size ToolbarView::GetSizeInternal( 688 gfx::Size ToolbarView::GetSizeInternal(
688 gfx::Size (View::*get_size)() const) const { 689 gfx::Size (View::*get_size)() const) const {
689 gfx::Size size((location_bar_->*get_size)()); 690 gfx::Size size((location_bar_->*get_size)());
690 if (is_display_mode_normal()) { 691 if (is_display_mode_normal()) {
691 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING); 692 const int element_padding = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
692 const int browser_actions_width = 693 const int browser_actions_width =
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 SchedulePaint(); 797 SchedulePaint();
797 } 798 }
798 799
799 int ToolbarView::content_shadow_height() const { 800 int ToolbarView::content_shadow_height() const {
800 #if defined(USE_ASH) 801 #if defined(USE_ASH)
801 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH); 802 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH);
802 #else 803 #else
803 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT); 804 return GetLayoutConstant(TOOLBAR_CONTENT_SHADOW_HEIGHT);
804 #endif 805 #endif
805 } 806 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698