Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // Add any necessary icons to the menu item based on the system state. |
|
msw
2016/06/07 01:01:38
nit: Should this be "Set the button icon based on
msw
2016/06/07 16:56:49
ping
| |
| 257 // Do this after |app_menu_button_| has been added as a bubble may be shown | 257 // Do this after |app_menu_button_| has been added as a bubble may be shown |
| 258 // that needs the widget (widget found by way of app_menu_button_-> | 258 // that needs the widget (widget found by way of app_menu_button_-> |
| 259 // GetWidget()). | 259 // GetWidget()). |
| 260 badge_controller_.UpdateDelegate(); | 260 icon_controller_.UpdateDelegate(); |
| 261 | 261 |
| 262 location_bar_->Init(); | 262 location_bar_->Init(); |
| 263 | 263 |
| 264 show_home_button_.Init(prefs::kShowHomeButton, | 264 show_home_button_.Init(prefs::kShowHomeButton, |
| 265 browser_->profile()->GetPrefs(), | 265 browser_->profile()->GetPrefs(), |
| 266 base::Bind(&ToolbarView::OnShowHomeButtonChanged, | 266 base::Bind(&ToolbarView::OnShowHomeButtonChanged, |
| 267 base::Unretained(this))); | 267 base::Unretained(this))); |
| 268 | 268 |
| 269 // Accessibility specific tooltip text. | 269 // Accessibility specific tooltip text. |
| 270 if (content::BrowserAccessibilityState::GetInstance()-> | 270 if (content::BrowserAccessibilityState::GetInstance()-> |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 | 639 |
| 640 // Fall through to the tab strip above us if none of |rect| intersects | 640 // 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 | 641 // with this view (intersection with the top shadow edge does not |
| 642 // count as intersection with this view). | 642 // count as intersection with this view). |
| 643 if (rect.bottom() < content_shadow_height()) | 643 if (rect.bottom() < content_shadow_height()) |
| 644 return false; | 644 return false; |
| 645 // Otherwise let our superclass take care of it. | 645 // Otherwise let our superclass take care of it. |
| 646 return ViewTargeterDelegate::DoesIntersectRect(this, rect); | 646 return ViewTargeterDelegate::DoesIntersectRect(this, rect); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void ToolbarView::UpdateBadgeSeverity(AppMenuBadgeController::BadgeType type, | 649 void ToolbarView::UpdateIconSeverity(AppMenuIconController::IconType type, |
| 650 AppMenuIconPainter::Severity severity, | 650 AppMenuIconPainter::Severity severity, |
| 651 bool animate) { | 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 badge before, so we don't send |
| 669 // multiple UMA events for example when multiple Chrome windows are open. | 669 // multiple UMA events for example when multiple Chrome windows are open. |
| 670 static bool incompatibility_badge_showing = false; | 670 static bool incompatibility_badge_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_badge_showing; |
| 673 incompatibility_badge_showing = false; | 673 incompatibility_badge_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_badge_showing = true; |
| 683 return; | 683 return; |
| 684 } | 684 } |
| 685 } | 685 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 } |
| OLD | NEW |