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.h" | 8 #include "base/timer.h" |
9 #include "chrome/browser/idle.h" | 9 #include "chrome/browser/idle.h" |
10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 // Returns the singleton implementation instance. | 42 // Returns the singleton implementation instance. |
43 static UpgradeDetector* GetInstance(); | 43 static UpgradeDetector* GetInstance(); |
44 | 44 |
45 virtual ~UpgradeDetector(); | 45 virtual ~UpgradeDetector(); |
46 | 46 |
47 static void RegisterPrefs(PrefServiceSimple* prefs); | 47 static void RegisterPrefs(PrefServiceSimple* prefs); |
48 | 48 |
49 // Whether the user should be notified about an upgrade. | 49 // Whether the user should be notified about an upgrade. |
50 bool notify_upgrade() const { return notify_upgrade_; } | 50 bool notify_upgrade() const { return notify_upgrade_; } |
51 | 51 |
52 // Whether the upgrade is a critical upgrade (such as a zero-day update). | 52 // Whether the upgrade is due to Chrome being outdated. |
Finnur
2013/02/01 17:09:15
nit: I would probably inject the word 'recommendat
MAD
2013/02/02 03:55:34
Done.
| |
53 bool is_critical_update() const { return is_critical_upgrade_; } | 53 bool IsOutdatedInstall() const { |
Finnur
2013/02/01 17:09:15
But... this function is still simple, no? Why chan
MAD
2013/02/02 03:55:34
Done.
I thought it was only for accessors, i.e., g
| |
54 return upgrade_required_ == UPGRADE_REQUIRED_OUTDATED; | |
55 } | |
54 | 56 |
55 // Notifify this object that the user has acknowledged the critical update | 57 // Notifify this object that the user has acknowledged the critical update |
56 // so we don't need to complain about it for now. | 58 // so we don't need to complain about it for now. |
57 void acknowledge_critical_update() { | 59 void acknowledge_critical_update() { |
58 critical_update_acknowledged_ = true; | 60 critical_update_acknowledged_ = true; |
59 } | 61 } |
60 | 62 |
61 // Whether the user has acknowledged the critical update. | 63 // Whether the user has acknowledged the critical update. |
62 bool critical_update_acknowledged() const { | 64 bool critical_update_acknowledged() const { |
63 return critical_update_acknowledged_; | 65 return critical_update_acknowledged_; |
(...skipping 21 matching lines...) Expand all Loading... | |
85 // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_. | 87 // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_. |
86 void NotifyUpgradeDetected(); | 88 void NotifyUpgradeDetected(); |
87 | 89 |
88 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. | 90 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. |
89 void NotifyUpgradeRecommended(); | 91 void NotifyUpgradeRecommended(); |
90 | 92 |
91 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { | 93 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { |
92 upgrade_notification_stage_ = stage; | 94 upgrade_notification_stage_ = stage; |
93 } | 95 } |
94 | 96 |
95 // True if a critical update to Chrome has been installed, such as a zero-day | 97 enum UpgradeRequired { |
Finnur
2013/02/01 17:09:15
nit: Required is a bit of a strong word. We only r
MAD
2013/02/02 03:55:34
Done.
| |
96 // fix. | 98 // If no update is available and current install is recent enough. |
97 bool is_critical_upgrade_; | 99 UPGRADE_REQUIRED_NONE, |
100 // If a regular update is available. | |
101 UPGRADE_REQUIRED_REGULAR, | |
102 // If a critical update to Chrome has been installed, such as a zero-day | |
103 // fix. | |
104 UPGRADE_REQUIRED_CRITICAL, | |
105 // If no update to Chrome has been installed for more than the allowed time. | |
Finnur
2013/02/01 17:09:15
nit: s/allowed/recommended/
MAD
2013/02/02 03:55:34
Done.
| |
106 UPGRADE_REQUIRED_OUTDATED, | |
107 } upgrade_required_; | |
98 | 108 |
99 // Whether the user has acknowledged the critical update. | 109 // Whether the user has acknowledged the critical update. |
100 bool critical_update_acknowledged_; | 110 bool critical_update_acknowledged_; |
101 | 111 |
102 private: | 112 private: |
103 // Initiates an Idle check. See IdleCallback below. | 113 // Initiates an Idle check. See IdleCallback below. |
104 void CheckIdle(); | 114 void CheckIdle(); |
105 | 115 |
106 // The callback for the IdleCheck. Tells us whether Chrome has received any | 116 // The callback for the IdleCheck. Tells us whether Chrome has received any |
107 // input events since the specified time. | 117 // input events since the specified time. |
108 void IdleCallback(IdleState state); | 118 void IdleCallback(IdleState state); |
109 | 119 |
110 // When the upgrade was detected. | 120 // When the upgrade was detected. |
111 base::Time upgrade_detected_time_; | 121 base::Time upgrade_detected_time_; |
112 | 122 |
113 // A timer to check to see if we've been idle for long enough to show the | 123 // A timer to check to see if we've been idle for long enough to show the |
114 // critical warning. Should only be set if |is_critical_upgrade_| is true. | 124 // critical warning. Should only be set if |upgrade_required_| is |
125 // UPGRADE_REQUIRED_CRITICAL. | |
115 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; | 126 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; |
116 | 127 |
117 // The stage at which the annoyance level for upgrade notifications is at. | 128 // The stage at which the annoyance level for upgrade notifications is at. |
118 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; | 129 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; |
119 | 130 |
120 // Whether we have waited long enough after detecting an upgrade (to see | 131 // Whether we have waited long enough after detecting an upgrade (to see |
121 // is we should start nagging about upgrading). | 132 // is we should start nagging about upgrading). |
122 bool notify_upgrade_; | 133 bool notify_upgrade_; |
123 | 134 |
124 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); | 135 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); |
125 }; | 136 }; |
126 | 137 |
127 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ | 138 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
OLD | NEW |