| 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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "ui/gfx/canvas.h" | 53 #include "ui/gfx/canvas.h" |
| 54 #include "ui/gfx/image/canvas_image_source.h" | 54 #include "ui/gfx/image/canvas_image_source.h" |
| 55 #include "ui/views/controls/button/button_dropdown.h" | 55 #include "ui/views/controls/button/button_dropdown.h" |
| 56 #include "ui/views/controls/menu/menu_listener.h" | 56 #include "ui/views/controls/menu/menu_listener.h" |
| 57 #include "ui/views/focus/view_storage.h" | 57 #include "ui/views/focus/view_storage.h" |
| 58 #include "ui/views/widget/tooltip_manager.h" | 58 #include "ui/views/widget/tooltip_manager.h" |
| 59 #include "ui/views/widget/widget.h" | 59 #include "ui/views/widget/widget.h" |
| 60 #include "ui/views/window/non_client_view.h" | 60 #include "ui/views/window/non_client_view.h" |
| 61 | 61 |
| 62 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 63 #include "base/win/windows_version.h" |
| 63 #include "chrome/browser/enumerate_modules_model_win.h" | 64 #include "chrome/browser/enumerate_modules_model_win.h" |
| 64 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" | 65 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" |
| 66 #include "chrome/browser/ui/views/extensions/conflicting_module_view_win.h" |
| 65 #if !defined(USE_AURA) | 67 #if !defined(USE_AURA) |
| 66 #include "chrome/browser/ui/views/app_menu_button_win.h" | 68 #include "chrome/browser/ui/views/app_menu_button_win.h" |
| 67 #endif | 69 #endif |
| 68 #endif | 70 #endif |
| 69 | 71 |
| 70 #if defined(USE_AURA) | 72 #if defined(USE_AURA) |
| 71 #include "ui/aura/window.h" | 73 #include "ui/aura/window.h" |
| 72 #include "ui/compositor/layer.h" | 74 #include "ui/compositor/layer.h" |
| 73 #include "ui/native_theme/native_theme_aura.h" | 75 #include "ui/native_theme/native_theme_aura.h" |
| 74 #endif | 76 #endif |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 170 |
| 169 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 171 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 170 content::NotificationService::AllSources()); | 172 content::NotificationService::AllSources()); |
| 171 if (OutdatedUpgradeBubbleView::IsAvailable()) { | 173 if (OutdatedUpgradeBubbleView::IsAvailable()) { |
| 172 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, | 174 registrar_.Add(this, chrome::NOTIFICATION_OUTDATED_INSTALL, |
| 173 content::NotificationService::AllSources()); | 175 content::NotificationService::AllSources()); |
| 174 } | 176 } |
| 175 #if defined(OS_WIN) | 177 #if defined(OS_WIN) |
| 176 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 178 registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
| 177 content::NotificationService::AllSources()); | 179 content::NotificationService::AllSources()); |
| 180 // if (base::win::GetVersion() == base::win::VERSION_XP) { // for checkin. |
| 181 if (base::win::GetVersion() == base::win::VERSION_WIN7) { // for testing. |
| 182 registrar_.Add(this, chrome::NOTIFICATION_MODULE_LIST_ENUMERATED, |
| 183 content::NotificationService::AllSources()); |
| 184 } |
| 178 #endif | 185 #endif |
| 179 registrar_.Add(this, | 186 registrar_.Add(this, |
| 180 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, | 187 chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE, |
| 181 content::NotificationService::AllSources()); | 188 content::NotificationService::AllSources()); |
| 182 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 189 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 183 content::Source<Profile>(browser_->profile())); | 190 content::Source<Profile>(browser_->profile())); |
| 184 } | 191 } |
| 185 | 192 |
| 186 ToolbarView::~ToolbarView() { | 193 ToolbarView::~ToolbarView() { |
| 187 // NOTE: Don't remove the command observers here. This object gets destroyed | 194 // NOTE: Don't remove the command observers here. This object gets destroyed |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 //////////////////////////////////////////////////////////////////////////////// | 461 //////////////////////////////////////////////////////////////////////////////// |
| 455 // ToolbarView, content::NotificationObserver implementation: | 462 // ToolbarView, content::NotificationObserver implementation: |
| 456 | 463 |
| 457 void ToolbarView::Observe(int type, | 464 void ToolbarView::Observe(int type, |
| 458 const content::NotificationSource& source, | 465 const content::NotificationSource& source, |
| 459 const content::NotificationDetails& details) { | 466 const content::NotificationDetails& details) { |
| 460 switch (type) { | 467 switch (type) { |
| 461 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: | 468 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: |
| 462 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: | 469 case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE: |
| 463 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 470 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 471 case chrome::NOTIFICATION_MODULE_LIST_ENUMERATED: |
| 464 UpdateAppMenuState(); | 472 UpdateAppMenuState(); |
| 465 break; | 473 break; |
| 466 case chrome::NOTIFICATION_OUTDATED_INSTALL: | 474 case chrome::NOTIFICATION_OUTDATED_INSTALL: |
| 467 ShowOutdatedInstallNotification(); | 475 ShowOutdatedInstallNotification(); |
| 468 break; | 476 break; |
| 469 #if defined(OS_WIN) | 477 #if defined(OS_WIN) |
| 470 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: | 478 case chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED: |
| 471 ShowCriticalNotification(); | 479 ShowCriticalNotification(); |
| 472 break; | 480 break; |
| 473 #endif | 481 #endif |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 789 |
| 782 if (ShouldShowUpgradeRecommended()) { | 790 if (ShouldShowUpgradeRecommended()) { |
| 783 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = | 791 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = |
| 784 UpgradeDetector::GetInstance()->upgrade_notification_stage(); | 792 UpgradeDetector::GetInstance()->upgrade_notification_stage(); |
| 785 app_menu_->SetSeverity(WrenchIconPainter::SeverityFromUpgradeLevel(level), | 793 app_menu_->SetSeverity(WrenchIconPainter::SeverityFromUpgradeLevel(level), |
| 786 WrenchIconPainter::ShouldAnimateUpgradeLevel(level)); | 794 WrenchIconPainter::ShouldAnimateUpgradeLevel(level)); |
| 787 return; | 795 return; |
| 788 } | 796 } |
| 789 | 797 |
| 790 if (ShouldShowIncompatibilityWarning()) { | 798 if (ShouldShowIncompatibilityWarning()) { |
| 791 if (!was_showing) | 799 if (!was_showing) { |
| 792 content::RecordAction(UserMetricsAction("ConflictBadge")); | 800 content::RecordAction(UserMetricsAction("ConflictBadge")); |
| 801 #if defined(OS_WIN) |
| 802 ConflictingModuleView::MaybeShow(browser_, app_menu_); |
| 803 #endif |
| 804 } |
| 793 app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_MEDIUM, true); | 805 app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_MEDIUM, true); |
| 794 incompatibility_badge_showing = true; | 806 incompatibility_badge_showing = true; |
| 795 return; | 807 return; |
| 796 } | 808 } |
| 797 | 809 |
| 798 GlobalErrorService* service = | 810 GlobalErrorService* service = |
| 799 GlobalErrorServiceFactory::GetForProfile(browser_->profile()); | 811 GlobalErrorServiceFactory::GetForProfile(browser_->profile()); |
| 800 GlobalError* error = | 812 GlobalError* error = |
| 801 service->GetHighestSeverityGlobalErrorWithWrenchMenuItem(); | 813 service->GetHighestSeverityGlobalErrorWithWrenchMenuItem(); |
| 802 if (error) { | 814 if (error) { |
| 803 app_menu_->SetSeverity(WrenchIconPainter::GlobalErrorSeverity(), true); | 815 app_menu_->SetSeverity(WrenchIconPainter::GlobalErrorSeverity(), true); |
| 804 return; | 816 return; |
| 805 } | 817 } |
| 806 | 818 |
| 807 app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_NONE, true); | 819 app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_NONE, true); |
| 808 } | 820 } |
| 809 | 821 |
| 810 void ToolbarView::OnShowHomeButtonChanged() { | 822 void ToolbarView::OnShowHomeButtonChanged() { |
| 811 Layout(); | 823 Layout(); |
| 812 SchedulePaint(); | 824 SchedulePaint(); |
| 813 } | 825 } |
| 814 | 826 |
| 815 int ToolbarView::content_shadow_height() const { | 827 int ToolbarView::content_shadow_height() const { |
| 816 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? | 828 return browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH ? |
| 817 kContentShadowHeightAsh : kContentShadowHeight; | 829 kContentShadowHeightAsh : kContentShadowHeight; |
| 818 } | 830 } |
| OLD | NEW |