| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? | 180 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
| 180 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; | 181 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; |
| 181 | 182 |
| 182 if (!kPopupBackgroundEdge) { | 183 if (!kPopupBackgroundEdge) { |
| 183 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 184 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 184 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); | 185 kPopupBackgroundEdge = rb.GetImageSkiaNamed(IDR_LOCATIONBG_POPUPMODE_EDGE); |
| 185 } | 186 } |
| 186 | 187 |
| 187 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 188 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 188 content::NotificationService::AllSources()); | 189 content::NotificationService::AllSources()); |
| 190 if (OutdatedUpgradeBubbleView::IsAvailable()) { |
| 191 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, |
| 192 content::NotificationService::AllSources()); |
| 193 } |
| 189 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
| 190 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 195 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
| 191 content::NotificationService::AllSources()); | 196 content::NotificationService::AllSources()); |
| 192 #endif | 197 #endif |
| 193 registrar_.Add(this, | 198 registrar_.Add(this, |
| 194 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 199 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 195 content::NotificationService::AllSources()); | 200 content::NotificationService::AllSources()); |
| 196 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 201 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 197 content::Source<Profile>(browser_->profile())); | 202 content::Source<Profile>(browser_->profile())); |
| 198 } | 203 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 544 |
| 540 void ToolbarView::Observe(int type, | 545 void ToolbarView::Observe(int type, |
| 541 const content::NotificationSource& source, | 546 const content::NotificationSource& source, |
| 542 const content::NotificationDetails& details) { | 547 const content::NotificationDetails& details) { |
| 543 switch (type) { | 548 switch (type) { |
| 544 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 549 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 545 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 550 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
| 546 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 551 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 547 UpdateAppMenuState(); | 552 UpdateAppMenuState(); |
| 548 break; | 553 break; |
| 554 case chrome::NOTIFICATION_OUTDATED_INSTALL: |
| 555 ShowOutdatedInstallNotification(); |
| 556 break; |
| 549 #if defined(OS_WIN) | 557 #if defined(OS_WIN) |
| 550 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 558 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
| 551 ShowCriticalNotification(); | 559 ShowCriticalNotification(); |
| 552 break; | 560 break; |
| 553 #endif | 561 #endif |
| 554 default: | 562 default: |
| 555 NOTREACHED(); | 563 NOTREACHED(); |
| 556 } | 564 } |
| 557 } | 565 } |
| 558 | 566 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 | 887 |
| 880 void ToolbarView::ShowCriticalNotification() { | 888 void ToolbarView::ShowCriticalNotification() { |
| 881 #if defined(OS_WIN) | 889 #if defined(OS_WIN) |
| 882 CriticalNotificationBubbleView* bubble_delegate = | 890 CriticalNotificationBubbleView* bubble_delegate = |
| 883 new CriticalNotificationBubbleView(app_menu_); | 891 new CriticalNotificationBubbleView(app_menu_); |
| 884 views::BubbleDelegateView::CreateBubble(bubble_delegate); | 892 views::BubbleDelegateView::CreateBubble(bubble_delegate); |
| 885 bubble_delegate->StartFade(true); | 893 bubble_delegate->StartFade(true); |
| 886 #endif | 894 #endif |
| 887 } | 895 } |
| 888 | 896 |
| 897 void ToolbarView::ShowOutdatedInstallNotification() { |
| 898 if (OutdatedUpgradeBubbleView::IsAvailable()) |
| 899 OutdatedUpgradeBubbleView::ShowBubble(app_menu_, browser_); |
| 900 } |
| 901 |
| 889 void ToolbarView::UpdateAppMenuState() { | 902 void ToolbarView::UpdateAppMenuState() { |
| 890 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); | 903 string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP); |
| 891 if (ShouldShowUpgradeRecommended()) { | 904 if (ShouldShowUpgradeRecommended()) { |
| 892 accname_app = l10n_util::GetStringFUTF16( | 905 accname_app = l10n_util::GetStringFUTF16( |
| 893 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 906 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 894 } | 907 } |
| 895 app_menu_->SetAccessibleName(accname_app); | 908 app_menu_->SetAccessibleName(accname_app); |
| 896 | 909 |
| 897 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); | 910 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::STATE_NORMAL)); |
| 898 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); | 911 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::STATE_HOVERED)); |
| 899 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); | 912 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::STATE_PRESSED)); |
| 900 SchedulePaint(); | 913 SchedulePaint(); |
| 901 } | 914 } |
| 902 | 915 |
| 903 void ToolbarView::OnShowHomeButtonChanged() { | 916 void ToolbarView::OnShowHomeButtonChanged() { |
| 904 Layout(); | 917 Layout(); |
| 905 SchedulePaint(); | 918 SchedulePaint(); |
| 906 } | 919 } |
| 907 | 920 |
| 908 int ToolbarView::content_shadow_height() const { | 921 int ToolbarView::content_shadow_height() const { |
| 909 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 922 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
| 910 kContentShadowHeightAsh : kContentShadowHeight; | 923 kContentShadowHeightAsh : kContentShadowHeight; |
| 911 } | 924 } |
| OLD | NEW |