| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/app_menu_icon_controller.h" | 5 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_service.h" | 10 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 12 #include "chrome/browser/upgrade_detector.h" | 12 #include "chrome/browser/upgrade_detector.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 16 #include "chrome/browser/win/enumerate_modules_model.h" | 16 #include "chrome/browser/win/enumerate_modules_model.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Maps an upgrade level to a severity level. | 21 // Maps an upgrade level to a severity level. |
| 22 AppMenuIconPainter::Severity SeverityFromUpgradeLevel( | 22 AppMenuIconController::Severity SeverityFromUpgradeLevel( |
| 23 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { | 23 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { |
| 24 switch (level) { | 24 switch (level) { |
| 25 case UpgradeDetector::UPGRADE_ANNOYANCE_NONE: | 25 case UpgradeDetector::UPGRADE_ANNOYANCE_NONE: |
| 26 return AppMenuIconPainter::SEVERITY_NONE; | 26 return AppMenuIconController::Severity::NONE; |
| 27 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: | 27 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: |
| 28 return AppMenuIconPainter::SEVERITY_LOW; | 28 return AppMenuIconController::Severity::LOW; |
| 29 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: | 29 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: |
| 30 return AppMenuIconPainter::SEVERITY_MEDIUM; | 30 return AppMenuIconController::Severity::MEDIUM; |
| 31 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH: | 31 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH: |
| 32 return AppMenuIconPainter::SEVERITY_HIGH; | |
| 33 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: | 32 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: |
| 34 return AppMenuIconPainter::SEVERITY_HIGH; | |
| 35 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: | 33 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: |
| 36 return AppMenuIconPainter::SEVERITY_HIGH; | 34 return AppMenuIconController::Severity::HIGH; |
| 37 } | 35 } |
| 38 NOTREACHED(); | 36 NOTREACHED(); |
| 39 return AppMenuIconPainter::SEVERITY_NONE; | 37 return AppMenuIconController::Severity::NONE; |
| 40 } | 38 } |
| 41 | 39 |
| 42 // Checks if the app menu icon should be animated for the given upgrade level. | 40 // Checks if the app menu icon should be animated for the given upgrade level. |
| 43 bool ShouldAnimateUpgradeLevel( | 41 bool ShouldAnimateUpgradeLevel( |
| 44 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { | 42 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { |
| 45 bool should_animate = true; | 43 bool should_animate = true; |
| 46 if (level == UpgradeDetector::UPGRADE_ANNOYANCE_LOW) { | 44 if (level == UpgradeDetector::UPGRADE_ANNOYANCE_LOW) { |
| 47 // Only animate low severity upgrades once. | 45 // Only animate low severity upgrades once. |
| 48 static bool should_animate_low_severity = true; | 46 static bool should_animate_low_severity = true; |
| 49 should_animate = should_animate_low_severity; | 47 should_animate = should_animate_low_severity; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = | 101 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = |
| 104 UpgradeDetector::GetInstance()->upgrade_notification_stage(); | 102 UpgradeDetector::GetInstance()->upgrade_notification_stage(); |
| 105 delegate_->UpdateSeverity(IconType::UPGRADE_NOTIFICATION, | 103 delegate_->UpdateSeverity(IconType::UPGRADE_NOTIFICATION, |
| 106 SeverityFromUpgradeLevel(level), | 104 SeverityFromUpgradeLevel(level), |
| 107 ShouldAnimateUpgradeLevel(level)); | 105 ShouldAnimateUpgradeLevel(level)); |
| 108 return; | 106 return; |
| 109 } | 107 } |
| 110 | 108 |
| 111 if (ShouldShowIncompatibilityWarning()) { | 109 if (ShouldShowIncompatibilityWarning()) { |
| 112 delegate_->UpdateSeverity(IconType::INCOMPATIBILITY_WARNING, | 110 delegate_->UpdateSeverity(IconType::INCOMPATIBILITY_WARNING, |
| 113 AppMenuIconPainter::SEVERITY_MEDIUM, true); | 111 Severity::MEDIUM, true); |
| 114 return; | 112 return; |
| 115 } | 113 } |
| 116 | 114 |
| 117 if (GlobalErrorServiceFactory::GetForProfile(profile_) | 115 if (GlobalErrorServiceFactory::GetForProfile(profile_) |
| 118 ->GetHighestSeverityGlobalErrorWithAppMenuItem()) { | 116 ->GetHighestSeverityGlobalErrorWithAppMenuItem()) { |
| 119 // If you change the severity here, make sure to also change the menu icon | 117 // If you change the severity here, make sure to also change the menu icon |
| 120 // and the bubble icon. | 118 // and the bubble icon. |
| 121 delegate_->UpdateSeverity(IconType::GLOBAL_ERROR, | 119 delegate_->UpdateSeverity(IconType::GLOBAL_ERROR, |
| 122 AppMenuIconPainter::SEVERITY_MEDIUM, true); | 120 Severity::MEDIUM, true); |
| 123 return; | 121 return; |
| 124 } | 122 } |
| 125 | 123 |
| 126 delegate_->UpdateSeverity(IconType::NONE, | 124 delegate_->UpdateSeverity(IconType::NONE, |
| 127 AppMenuIconPainter::SEVERITY_NONE, true); | 125 Severity::NONE, true); |
| 128 } | 126 } |
| 129 | 127 |
| 130 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 131 void AppMenuIconController::OnScanCompleted() { | 129 void AppMenuIconController::OnScanCompleted() { |
| 132 UpdateDelegate(); | 130 UpdateDelegate(); |
| 133 } | 131 } |
| 134 | 132 |
| 135 void AppMenuIconController::OnConflictsAcknowledged() { | 133 void AppMenuIconController::OnConflictsAcknowledged() { |
| 136 UpdateDelegate(); | 134 UpdateDelegate(); |
| 137 } | 135 } |
| 138 #endif | 136 #endif |
| 139 | 137 |
| 140 void AppMenuIconController::Observe( | 138 void AppMenuIconController::Observe( |
| 141 int type, | 139 int type, |
| 142 const content::NotificationSource& source, | 140 const content::NotificationSource& source, |
| 143 const content::NotificationDetails& details) { | 141 const content::NotificationDetails& details) { |
| 144 UpdateDelegate(); | 142 UpdateDelegate(); |
| 145 } | 143 } |
| OLD | NEW |