Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "ui/views/controls/button/button_dropdown.h" | 54 #include "ui/views/controls/button/button_dropdown.h" |
| 55 #include "ui/views/controls/menu/menu_listener.h" | 55 #include "ui/views/controls/menu/menu_listener.h" |
| 56 #include "ui/views/focus/view_storage.h" | 56 #include "ui/views/focus/view_storage.h" |
| 57 #include "ui/views/widget/tooltip_manager.h" | 57 #include "ui/views/widget/tooltip_manager.h" |
| 58 #include "ui/views/widget/widget.h" | 58 #include "ui/views/widget/widget.h" |
| 59 #include "ui/views/window/non_client_view.h" | 59 #include "ui/views/window/non_client_view.h" |
| 60 | 60 |
| 61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 62 #include "chrome/browser/enumerate_modules_model_win.h" | 62 #include "chrome/browser/enumerate_modules_model_win.h" |
| 63 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" | 63 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" |
| 64 #include "chrome/browser/ui/views/upgrade_bubble_view.h" | |
| 64 #if !defined(USE_AURA) | 65 #if !defined(USE_AURA) |
| 65 #include "chrome/browser/ui/views/app_menu_button_win.h" | 66 #include "chrome/browser/ui/views/app_menu_button_win.h" |
| 66 #endif | 67 #endif |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 #if defined(USE_AURA) | 70 #if defined(USE_AURA) |
| 70 #include "ui/aura/window.h" | 71 #include "ui/aura/window.h" |
| 71 #include "ui/compositor/layer.h" | 72 #include "ui/compositor/layer.h" |
| 72 #include "ui/native_theme/native_theme_aura.h" | 73 #include "ui/native_theme/native_theme_aura.h" |
| 73 #endif | 74 #endif |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 if (!kPopupBackgroundEdge) { | 186 if (!kPopupBackgroundEdge) { |
| 186 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 187 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 187 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); | 188 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); |
| 188 } | 189 } |
| 189 | 190 |
| 190 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 191 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 191 content::NotificationService::AllSources()); | 192 content::NotificationService::AllSources()); |
| 192 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
| 193 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 194 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
| 194 content::NotificationService::AllSources()); | 195 content::NotificationService::AllSources()); |
| 196 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, | |
| 197 content::NotificationService::AllSources()); | |
| 195 #endif | 198 #endif |
| 196 registrar_.Add(this, | 199 registrar_.Add(this, |
| 197 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 200 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 198 content::NotificationService::AllSources()); | 201 content::NotificationService::AllSources()); |
| 199 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 202 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 200 content::Source<Profile>(browser_->profile())); | 203 content::Source<Profile>(browser_->profile())); |
| 201 } | 204 } |
| 202 | 205 |
| 203 ToolbarView::~ToolbarView() { | 206 ToolbarView::~ToolbarView() { |
| 204 // NOTE: Don't remove the command observers here. This object gets destroyed | 207 // NOTE: Don't remove the command observers here. This object gets destroyed |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 switch (type) { | 549 switch (type) { |
| 547 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 550 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 548 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 551 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
| 549 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 552 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 550 UpdateAppMenuState(); | 553 UpdateAppMenuState(); |
| 551 break; | 554 break; |
| 552 #if defined(OS_WIN) | 555 #if defined(OS_WIN) |
| 553 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 556 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
| 554 ShowCriticalNotification(); | 557 ShowCriticalNotification(); |
| 555 break; | 558 break; |
| 559 case chrome::NOTIFICATION_OUTDATED_INSTALL: | |
| 560 ShowOutdatedInstallNotification(); | |
|
Finnur
2012/12/06 19:53:16
So... Are we certain that we can not have both thi
MAD
2013/01/22 15:18:29
Thanks, I asked the PMs, but I guess the outdated
| |
| 561 break; | |
| 556 #endif | 562 #endif |
| 557 default: | 563 default: |
| 558 NOTREACHED(); | 564 NOTREACHED(); |
| 559 } | 565 } |
| 560 } | 566 } |
| 561 | 567 |
| 562 //////////////////////////////////////////////////////////////////////////////// | 568 //////////////////////////////////////////////////////////////////////////////// |
| 563 // ToolbarView, ui::AcceleratorProvider implementation: | 569 // ToolbarView, ui::AcceleratorProvider implementation: |
| 564 | 570 |
| 565 bool ToolbarView::GetAcceleratorForCommandId(int command_id, | 571 bool ToolbarView::GetAcceleratorForCommandId(int command_id, |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 | 889 |
| 884 void ToolbarView::ShowCriticalNotification() { | 890 void ToolbarView::ShowCriticalNotification() { |
| 885 #if defined(OS_WIN) | 891 #if defined(OS_WIN) |
| 886 CriticalNotificationBubbleView* bubble_delegate = | 892 CriticalNotificationBubbleView* bubble_delegate = |
| 887 new CriticalNotificationBubbleView(app_menu_); | 893 new CriticalNotificationBubbleView(app_menu_); |
| 888 views::BubbleDelegateView::CreateBubble(bubble_delegate); | 894 views::BubbleDelegateView::CreateBubble(bubble_delegate); |
| 889 bubble_delegate->StartFade(true); | 895 bubble_delegate->StartFade(true); |
| 890 #endif | 896 #endif |
| 891 } | 897 } |
| 892 | 898 |
| 899 void ToolbarView::ShowOutdatedInstallNotification() { | |
| 900 #if defined(OS_WIN) | |
| 901 UpgradeBubbleView::ShowBubble(app_menu_, browser_); | |
| 902 #endif | |
| 903 } | |
| 904 | |
| 893 void ToolbarView::UpdateAppMenuState() { | 905 void ToolbarView::UpdateAppMenuState() { |
| 894 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); | 906 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); |
| 895 if (ShouldShowUpgradeRecommended()) { | 907 if (ShouldShowUpgradeRecommended()) { |
| 896 accname_app = l10n_util::GetStringFUTF16( | 908 accname_app = l10n_util::GetStringFUTF16( |
| 897 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 909 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 898 } | 910 } |
| 899 app_menu_->SetAccessibleName(accname_app); | 911 app_menu_->SetAccessibleName(accname_app); |
| 900 | 912 |
| 901 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); | 913 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); |
| 902 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); | 914 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); |
| 903 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); | 915 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); |
| 904 SchedulePaint(); | 916 SchedulePaint(); |
| 905 } | 917 } |
| 906 | 918 |
| 907 void ToolbarView::OnShowHomeButtonChanged() { | 919 void ToolbarView::OnShowHomeButtonChanged() { |
| 908 Layout(); | 920 Layout(); |
| 909 SchedulePaint(); | 921 SchedulePaint(); |
| 910 } | 922 } |
| OLD | NEW |