OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UPGRADE_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
6 #define CHROME_BROWSER_UPGRADE_DETECTOR_H_ | 6 #define CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
7 | 7 |
8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
9 #include "chrome/browser/chrome_notification_types.h" | |
9 #include "chrome/browser/idle.h" | 10 #include "chrome/browser/idle.h" |
10 #include "ui/gfx/image/image.h" | 11 #include "ui/gfx/image/image.h" |
11 | 12 |
12 class PrefRegistrySimple; | 13 class PrefRegistrySimple; |
13 | 14 |
14 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
15 // UpgradeDetector | 16 // UpgradeDetector |
16 // | 17 // |
17 // This class is a singleton class that monitors when an upgrade happens in the | 18 // This class is a singleton class that monitors when an upgrade happens in the |
18 // background. We basically ask Omaha what it thinks the latest version is and | 19 // background. We basically ask Omaha what it thinks the latest version is and |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 // so we don't need to complain about it for now. | 59 // so we don't need to complain about it for now. |
59 void acknowledge_critical_update() { | 60 void acknowledge_critical_update() { |
60 critical_update_acknowledged_ = true; | 61 critical_update_acknowledged_ = true; |
61 } | 62 } |
62 | 63 |
63 // Whether the user has acknowledged the critical update. | 64 // Whether the user has acknowledged the critical update. |
64 bool critical_update_acknowledged() const { | 65 bool critical_update_acknowledged() const { |
65 return critical_update_acknowledged_; | 66 return critical_update_acknowledged_; |
66 } | 67 } |
67 | 68 |
68 // When the last upgrade was detected. | |
69 const base::Time& upgrade_detected_time() const { | |
70 return upgrade_detected_time_; | |
71 } | |
72 | |
73 // Retrieves the right icon ID based on the degree of severity (see | 69 // Retrieves the right icon ID based on the degree of severity (see |
74 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon | 70 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon |
75 // to go with it) to display within the wrench menu. | 71 // to go with it) to display within the wrench menu. |
76 int GetIconResourceID(); | 72 int GetIconResourceID(); |
77 | 73 |
78 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const { | 74 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const { |
79 return upgrade_notification_stage_; | 75 return upgrade_notification_stage_; |
80 } | 76 } |
81 | 77 |
82 protected: | 78 protected: |
83 UpgradeDetector(); | 79 UpgradeDetector(); |
84 | 80 |
85 // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_. | |
86 void NotifyUpgradeDetected(); | |
87 | |
88 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. | 81 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. |
89 void NotifyUpgradeRecommended(); | 82 void NotifyUpgradeRecommended(); |
90 | 83 |
84 // Triggers a critical update, which starts a timer that checks the machine | |
85 // idle state. Protected and virtual so that it could overridden by tests. | |
MAD
2014/08/01 17:41:30
could "be" overridden.
| |
86 virtual void TriggerCriticalUpdate(); | |
sky
2014/08/04 18:24:07
How about an observer instead of this? The observe
Alexei Svitkine (slow)
2014/08/04 19:43:10
I'm not sure it makes sense in this case. The Trig
| |
87 | |
91 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { | 88 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { |
92 upgrade_notification_stage_ = stage; | 89 upgrade_notification_stage_ = stage; |
93 } | 90 } |
94 | 91 |
92 // Whether any software updates are available (experiment updates are tracked | |
93 // separately via additional member variables below). | |
95 enum UpgradeAvailable { | 94 enum UpgradeAvailable { |
96 // If no update is available and current install is recent enough. | 95 // If no update is available and current install is recent enough. |
97 UPGRADE_AVAILABLE_NONE, | 96 UPGRADE_AVAILABLE_NONE, |
98 // If a regular update is available. | 97 // If a regular update is available. |
99 UPGRADE_AVAILABLE_REGULAR, | 98 UPGRADE_AVAILABLE_REGULAR, |
100 // If a critical update to Chrome has been installed, such as a zero-day | 99 // If a critical update to Chrome has been installed, such as a zero-day |
101 // fix. | 100 // fix. |
102 UPGRADE_AVAILABLE_CRITICAL, | 101 UPGRADE_AVAILABLE_CRITICAL, |
103 // If no update to Chrome has been installed for more than the recommended | 102 // If no update to Chrome has been installed for more than the recommended |
104 // time. | 103 // time. |
105 UPGRADE_NEEDED_OUTDATED_INSTALL, | 104 UPGRADE_NEEDED_OUTDATED_INSTALL, |
106 // If no update to Chrome has been installed for more than the recommended | 105 // If no update to Chrome has been installed for more than the recommended |
107 // time AND auto-update is turned off. | 106 // time AND auto-update is turned off. |
108 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU, | 107 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU, |
109 } upgrade_available_; | 108 } upgrade_available_; |
110 | 109 |
110 // Whether "best effort" experiment updates are available. | |
sky
2014/08/04 18:24:07
Style guide says no protected members.
Alexei Svitkine (slow)
2014/08/04 19:43:10
Indeed, done. There were existing protected member
| |
111 bool best_effort_experiment_updates_available_; | |
112 | |
113 // Whether "critical" experiment updates are available. | |
114 bool critical_experiment_updates_available_; | |
115 | |
111 // Whether the user has acknowledged the critical update. | 116 // Whether the user has acknowledged the critical update. |
112 bool critical_update_acknowledged_; | 117 bool critical_update_acknowledged_; |
113 | 118 |
114 private: | 119 private: |
115 // Initiates an Idle check. See IdleCallback below. | 120 // Initiates an Idle check. See IdleCallback below. |
116 void CheckIdle(); | 121 void CheckIdle(); |
117 | 122 |
118 // The callback for the IdleCheck. Tells us whether Chrome has received any | 123 // The callback for the IdleCheck. Tells us whether Chrome has received any |
119 // input events since the specified time. | 124 // input events since the specified time. |
120 void IdleCallback(IdleState state); | 125 void IdleCallback(IdleState state); |
121 | 126 |
122 // When the upgrade was detected. | 127 // Triggers a global notification of the specified |type|. |
123 base::Time upgrade_detected_time_; | 128 void TriggerNotification(chrome::NotificationType type); |
124 | 129 |
125 // A timer to check to see if we've been idle for long enough to show the | 130 // A timer to check to see if we've been idle for long enough to show the |
126 // critical warning. Should only be set if |upgrade_available_| is | 131 // critical warning. Should only be set if |upgrade_available_| is |
127 // UPGRADE_AVAILABLE_CRITICAL. | 132 // UPGRADE_AVAILABLE_CRITICAL. |
128 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; | 133 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; |
129 | 134 |
130 // The stage at which the annoyance level for upgrade notifications is at. | 135 // The stage at which the annoyance level for upgrade notifications is at. |
131 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; | 136 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; |
132 | 137 |
133 // Whether we have waited long enough after detecting an upgrade (to see | 138 // Whether we have waited long enough after detecting an upgrade (to see |
134 // is we should start nagging about upgrading). | 139 // is we should start nagging about upgrading). |
135 bool notify_upgrade_; | 140 bool notify_upgrade_; |
136 | 141 |
137 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); | 142 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); |
138 }; | 143 }; |
139 | 144 |
140 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ | 145 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
OLD | NEW |