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 12 matching lines...) Expand all Loading... | |
| 23 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 23 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 24 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 24 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 26 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 27 #include "chrome/browser/ui/view_ids.h" | 27 #include "chrome/browser/ui/view_ids.h" |
| 28 #include "chrome/browser/ui/views/browser_actions_container.h" | 28 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 29 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h" | 29 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h" |
| 30 #include "chrome/browser/ui/views/frame/browser_view.h" | 30 #include "chrome/browser/ui/views/frame/browser_view.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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? | 182 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
| 182 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; | 183 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; |
| 183 | 184 |
| 184 if (!kPopupBackgroundEdge) { | 185 if (!kPopupBackgroundEdge) { |
| 185 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 186 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 186 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); | 187 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); |
| 187 } | 188 } |
| 188 | 189 |
| 189 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 190 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 190 content::NotificationService::AllSources()); | 191 content::NotificationService::AllSources()); |
| 192 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, | |
| 193 content::NotificationService::AllSources()); | |
| 191 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
| 192 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 195 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
| 193 content::NotificationService::AllSources()); | 196 content::NotificationService::AllSources()); |
| 194 #endif | 197 #endif |
| 195 registrar_.Add(this, | 198 registrar_.Add(this, |
| 196 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 199 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 197 content::NotificationService::AllSources()); | 200 content::NotificationService::AllSources()); |
| 198 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 201 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 199 content::Source<Profile>(browser_->profile())); | 202 content::Source<Profile>(browser_->profile())); |
| 200 } | 203 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 | 544 |
| 542 void ToolbarView::Observe(int type, | 545 void ToolbarView::Observe(int type, |
| 543 const content::NotificationSource& source, | 546 const content::NotificationSource& source, |
| 544 const content::NotificationDetails& details) { | 547 const content::NotificationDetails& details) { |
| 545 switch (type) { | 548 switch (type) { |
| 546 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 549 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 547 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 550 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
| 548 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 551 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 549 UpdateAppMenuState(); | 552 UpdateAppMenuState(); |
| 550 break; | 553 break; |
| 554 case chrome::NOTIFICATION_OUTDATED_INSTALL: | |
| 555 ShowOutdatedInstallNotification(); | |
| 556 break; | |
| 551 #if defined(OS_WIN) | 557 #if defined(OS_WIN) |
| 552 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 558 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
| 553 ShowCriticalNotification(); | 559 ShowCriticalNotification(); |
| 554 break; | 560 break; |
| 555 #endif | 561 #endif |
| 556 default: | 562 default: |
| 557 NOTREACHED(); | 563 NOTREACHED(); |
| 558 } | 564 } |
| 559 } | 565 } |
| 560 | 566 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 | 892 |
| 887 void ToolbarView::ShowCriticalNotification() { | 893 void ToolbarView::ShowCriticalNotification() { |
| 888 #if defined(OS_WIN) | 894 #if defined(OS_WIN) |
| 889 CriticalNotificationBubbleView* bubble_delegate = | 895 CriticalNotificationBubbleView* bubble_delegate = |
| 890 new CriticalNotificationBubbleView(app_menu_); | 896 new CriticalNotificationBubbleView(app_menu_); |
| 891 views::BubbleDelegateView::CreateBubble(bubble_delegate); | 897 views::BubbleDelegateView::CreateBubble(bubble_delegate); |
| 892 bubble_delegate->StartFade(true); | 898 bubble_delegate->StartFade(true); |
| 893 #endif | 899 #endif |
| 894 } | 900 } |
| 895 | 901 |
| 902 void ToolbarView::ShowOutdatedInstallNotification() { | |
| 903 OutdatedUpgradeBubbleView::ShowBubble(app_menu_, browser_); | |
|
Finnur
2013/01/24 10:13:33
This is now included on ChromeOS, which updates di
MAD
2013/01/24 17:29:35
No, wasn't intended, thanks!
Done.
| |
| 904 } | |
| 905 | |
| 896 void ToolbarView::UpdateAppMenuState() { | 906 void ToolbarView::UpdateAppMenuState() { |
| 897 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); | 907 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); |
| 898 if (ShouldShowUpgradeRecommended()) { | 908 if (ShouldShowUpgradeRecommended()) { |
| 899 accname_app = l10n_util::GetStringFUTF16( | 909 accname_app = l10n_util::GetStringFUTF16( |
| 900 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 910 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 901 } | 911 } |
| 902 app_menu_->SetAccessibleName(accname_app); | 912 app_menu_->SetAccessibleName(accname_app); |
| 903 | 913 |
| 904 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); | 914 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); |
| 905 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); | 915 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); |
| 906 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); | 916 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); |
| 907 SchedulePaint(); | 917 SchedulePaint(); |
| 908 } | 918 } |
| 909 | 919 |
| 910 void ToolbarView::OnShowHomeButtonChanged() { | 920 void ToolbarView::OnShowHomeButtonChanged() { |
| 911 Layout(); | 921 Layout(); |
| 912 SchedulePaint(); | 922 SchedulePaint(); |
| 913 } | 923 } |
| OLD | NEW |