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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 a critical upgrade (such as a zero-day update). |
53 bool is_critical_update() const { return is_critical_upgrade_; } | 53 bool is_critical_update() const { return is_critical_upgrade_; } |
54 | 54 |
55 // Whether the upgrade is a outdated Chrome (no updates for too long). | |
56 bool IsOutdatedInstall() const { | |
Finnur
2013/01/24 10:13:33
Are you sure we consider one && and one ! so heavy
MAD
2013/01/24 17:29:35
I thought hacker style was just when we return the
| |
57 // Critical upgrade have precedence over outdated because it means we | |
58 // successfully installed a critical upgrade, so no need to reinstall. | |
59 return is_outdated_install_ && !is_critical_upgrade_; | |
60 } | |
61 | |
55 // Notifify this object that the user has acknowledged the critical update | 62 // Notifify this object that the user has acknowledged the critical update |
56 // so we don't need to complain about it for now. | 63 // so we don't need to complain about it for now. |
57 void acknowledge_critical_update() { | 64 void acknowledge_critical_update() { |
58 critical_update_acknowledged_ = true; | 65 critical_update_acknowledged_ = true; |
59 } | 66 } |
60 | 67 |
61 // Whether the user has acknowledged the critical update. | 68 // Whether the user has acknowledged the critical update. |
62 bool critical_update_acknowledged() const { | 69 bool critical_update_acknowledged() const { |
63 return critical_update_acknowledged_; | 70 return critical_update_acknowledged_; |
64 } | 71 } |
(...skipping 24 matching lines...) Expand all Loading... | |
89 void NotifyUpgradeRecommended(); | 96 void NotifyUpgradeRecommended(); |
90 | 97 |
91 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { | 98 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { |
92 upgrade_notification_stage_ = stage; | 99 upgrade_notification_stage_ = stage; |
93 } | 100 } |
94 | 101 |
95 // True if a critical update to Chrome has been installed, such as a zero-day | 102 // True if a critical update to Chrome has been installed, such as a zero-day |
96 // fix. | 103 // fix. |
97 bool is_critical_upgrade_; | 104 bool is_critical_upgrade_; |
98 | 105 |
106 // True if no update to Chrome has been installed for more than the allowed | |
107 // time, which means updating keeps failing, so a reinstall can be suggested. | |
108 bool is_outdated_install_; | |
109 | |
99 // Whether the user has acknowledged the critical update. | 110 // Whether the user has acknowledged the critical update. |
100 bool critical_update_acknowledged_; | 111 bool critical_update_acknowledged_; |
101 | 112 |
102 private: | 113 private: |
103 // Initiates an Idle check. See IdleCallback below. | 114 // Initiates an Idle check. See IdleCallback below. |
104 void CheckIdle(); | 115 void CheckIdle(); |
105 | 116 |
106 // The callback for the IdleCheck. Tells us whether Chrome has received any | 117 // The callback for the IdleCheck. Tells us whether Chrome has received any |
107 // input events since the specified time. | 118 // input events since the specified time. |
108 void IdleCallback(IdleState state); | 119 void IdleCallback(IdleState state); |
109 | 120 |
110 // When the upgrade was detected. | 121 // When the upgrade was detected. |
111 base::Time upgrade_detected_time_; | 122 base::Time upgrade_detected_time_; |
112 | 123 |
113 // A timer to check to see if we've been idle for long enough to show the | 124 // 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. | 125 // critical warning. Should only be set if |is_critical_upgrade_| or |
126 // |is_outdated_install_| is true. | |
115 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; | 127 base::RepeatingTimer<UpgradeDetector> idle_check_timer_; |
116 | 128 |
117 // The stage at which the annoyance level for upgrade notifications is at. | 129 // The stage at which the annoyance level for upgrade notifications is at. |
118 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; | 130 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; |
119 | 131 |
120 // Whether we have waited long enough after detecting an upgrade (to see | 132 // Whether we have waited long enough after detecting an upgrade (to see |
121 // is we should start nagging about upgrading). | 133 // is we should start nagging about upgrading). |
122 bool notify_upgrade_; | 134 bool notify_upgrade_; |
123 | 135 |
124 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); | 136 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); |
125 }; | 137 }; |
126 | 138 |
127 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ | 139 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
OLD | NEW |