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 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 23 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
25 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 25 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
26 #include "chrome/browser/ui/view_ids.h" | 26 #include "chrome/browser/ui/view_ids.h" |
27 #include "chrome/browser/ui/views/browser_actions_container.h" | 27 #include "chrome/browser/ui/views/browser_actions_container.h" |
28 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h" | 28 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h" |
29 #include "chrome/browser/ui/views/frame/browser_view.h" | 29 #include "chrome/browser/ui/views/frame/browser_view.h" |
30 #include "chrome/browser/ui/views/home_button.h" | 30 #include "chrome/browser/ui/views/home_button.h" |
31 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 31 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
32 #include "chrome/browser/ui/views/location_bar/star_view.h" | 32 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 33 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h" |
33 #include "chrome/browser/ui/views/wrench_menu.h" | 34 #include "chrome/browser/ui/views/wrench_menu.h" |
34 #include "chrome/browser/upgrade_detector.h" | 35 #include "chrome/browser/upgrade_detector.h" |
35 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
37 #include "content/public/browser/browser_accessibility_state.h" | 38 #include "content/public/browser/browser_accessibility_state.h" |
38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
41 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
42 #include "content/public/browser/web_contents_view.h" | 43 #include "content/public/browser/web_contents_view.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? | 183 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
183 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; | 184 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; |
184 | 185 |
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()); |
| 193 // This should only be available on non-Chrome OS desktop platforms. |
| 194 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 195 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 196 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, |
| 197 content::NotificationService::AllSources()); |
| 198 #endif |
192 #if defined(OS_WIN) | 199 #if defined(OS_WIN) |
193 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 200 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
194 content::NotificationService::AllSources()); | 201 content::NotificationService::AllSources()); |
195 #endif | 202 #endif |
196 registrar_.Add(this, | 203 registrar_.Add(this, |
197 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 204 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
198 content::NotificationService::AllSources()); | 205 content::NotificationService::AllSources()); |
199 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 206 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
200 content::Source<Profile>(browser_->profile())); | 207 content::Source<Profile>(browser_->profile())); |
201 } | 208 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 549 |
543 void ToolbarView::Observe(int type, | 550 void ToolbarView::Observe(int type, |
544 const content::NotificationSource& source, | 551 const content::NotificationSource& source, |
545 const content::NotificationDetails& details) { | 552 const content::NotificationDetails& details) { |
546 switch (type) { | 553 switch (type) { |
547 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 554 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
548 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 555 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
549 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 556 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
550 UpdateAppMenuState(); | 557 UpdateAppMenuState(); |
551 break; | 558 break; |
| 559 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 560 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 561 case chrome::NOTIFICATION_OUTDATED_INSTALL: |
| 562 ShowOutdatedInstallNotification(); |
| 563 break; |
| 564 #endif |
552 #if defined(OS_WIN) | 565 #if defined(OS_WIN) |
553 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 566 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
554 ShowCriticalNotification(); | 567 ShowCriticalNotification(); |
555 break; | 568 break; |
556 #endif | 569 #endif |
557 default: | 570 default: |
558 NOTREACHED(); | 571 NOTREACHED(); |
559 } | 572 } |
560 } | 573 } |
561 | 574 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 900 |
888 void ToolbarView::ShowCriticalNotification() { | 901 void ToolbarView::ShowCriticalNotification() { |
889 #if defined(OS_WIN) | 902 #if defined(OS_WIN) |
890 CriticalNotificationBubbleView* bubble_delegate = | 903 CriticalNotificationBubbleView* bubble_delegate = |
891 new CriticalNotificationBubbleView(app_menu_); | 904 new CriticalNotificationBubbleView(app_menu_); |
892 views::BubbleDelegateView::CreateBubble(bubble_delegate); | 905 views::BubbleDelegateView::CreateBubble(bubble_delegate); |
893 bubble_delegate->StartFade(true); | 906 bubble_delegate->StartFade(true); |
894 #endif | 907 #endif |
895 } | 908 } |
896 | 909 |
| 910 void ToolbarView::ShowOutdatedInstallNotification() { |
| 911 // This should only work on non-Chrome OS desktop platforms. |
| 912 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 913 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 914 OutdatedUpgradeBubbleView::ShowBubble(app_menu_, browser_); |
| 915 #endif |
| 916 } |
| 917 |
897 void ToolbarView::UpdateAppMenuState() { | 918 void ToolbarView::UpdateAppMenuState() { |
898 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); | 919 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); |
899 if (ShouldShowUpgradeRecommended()) { | 920 if (ShouldShowUpgradeRecommended()) { |
900 accname_app = l10n_util::GetStringFUTF16( | 921 accname_app = l10n_util::GetStringFUTF16( |
901 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 922 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
902 } | 923 } |
903 app_menu_->SetAccessibleName(accname_app); | 924 app_menu_->SetAccessibleName(accname_app); |
904 | 925 |
905 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); | 926 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); |
906 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); | 927 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); |
907 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); | 928 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); |
908 SchedulePaint(); | 929 SchedulePaint(); |
909 } | 930 } |
910 | 931 |
911 void ToolbarView::OnShowHomeButtonChanged() { | 932 void ToolbarView::OnShowHomeButtonChanged() { |
912 Layout(); | 933 Layout(); |
913 SchedulePaint(); | 934 SchedulePaint(); |
914 } | 935 } |
OLD | NEW |