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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: | 33 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: |
34 return AppMenuIconController::Severity::HIGH; | 34 return AppMenuIconController::Severity::HIGH; |
35 } | 35 } |
36 NOTREACHED(); | 36 NOTREACHED(); |
37 return AppMenuIconController::Severity::NONE; | 37 return AppMenuIconController::Severity::NONE; |
38 } | 38 } |
39 | 39 |
40 // 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. |
41 bool ShouldAnimateUpgradeLevel( | 41 bool ShouldAnimateUpgradeLevel( |
42 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { | 42 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level) { |
43 bool should_animate = true; | 43 return level != UpgradeDetector::UPGRADE_ANNOYANCE_NONE; |
44 if (level == UpgradeDetector::UPGRADE_ANNOYANCE_LOW) { | |
45 // Only animate low severity upgrades once. | |
46 static bool should_animate_low_severity = true; | |
47 should_animate = should_animate_low_severity; | |
48 should_animate_low_severity = false; | |
49 } | |
50 return should_animate; | |
51 } | 44 } |
52 | 45 |
53 // Returns true if we should show the upgrade recommended icon. | 46 // Returns true if we should show the upgrade recommended icon. |
54 bool ShouldShowUpgradeRecommended() { | 47 bool ShouldShowUpgradeRecommended() { |
55 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
56 // In chromeos, the update recommendation is shown in the system tray. So it | 49 // In chromeos, the update recommendation is shown in the system tray. So it |
57 // should not be displayed in the app menu. | 50 // should not be displayed in the app menu. |
58 return false; | 51 return false; |
59 #else | 52 #else |
60 return UpgradeDetector::GetInstance()->notify_upgrade(); | 53 return UpgradeDetector::GetInstance()->notify_upgrade(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 107 |
115 if (GlobalErrorServiceFactory::GetForProfile(profile_) | 108 if (GlobalErrorServiceFactory::GetForProfile(profile_) |
116 ->GetHighestSeverityGlobalErrorWithAppMenuItem()) { | 109 ->GetHighestSeverityGlobalErrorWithAppMenuItem()) { |
117 // If you change the severity here, make sure to also change the menu icon | 110 // If you change the severity here, make sure to also change the menu icon |
118 // and the bubble icon. | 111 // and the bubble icon. |
119 delegate_->UpdateSeverity(IconType::GLOBAL_ERROR, | 112 delegate_->UpdateSeverity(IconType::GLOBAL_ERROR, |
120 Severity::MEDIUM, true); | 113 Severity::MEDIUM, true); |
121 return; | 114 return; |
122 } | 115 } |
123 | 116 |
124 delegate_->UpdateSeverity(IconType::NONE, | 117 delegate_->UpdateSeverity(IconType::NONE, Severity::NONE, false); |
125 Severity::NONE, true); | |
126 } | 118 } |
127 | 119 |
128 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
129 void AppMenuIconController::OnScanCompleted() { | 121 void AppMenuIconController::OnScanCompleted() { |
130 UpdateDelegate(); | 122 UpdateDelegate(); |
131 } | 123 } |
132 | 124 |
133 void AppMenuIconController::OnConflictsAcknowledged() { | 125 void AppMenuIconController::OnConflictsAcknowledged() { |
134 UpdateDelegate(); | 126 UpdateDelegate(); |
135 } | 127 } |
136 #endif | 128 #endif |
137 | 129 |
138 void AppMenuIconController::Observe( | 130 void AppMenuIconController::Observe( |
139 int type, | 131 int type, |
140 const content::NotificationSource& source, | 132 const content::NotificationSource& source, |
141 const content::NotificationDetails& details) { | 133 const content::NotificationDetails& details) { |
142 UpdateDelegate(); | 134 UpdateDelegate(); |
143 } | 135 } |
OLD | NEW |