Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/upgrade_detector.h

Issue 8142028: When critical updates have been installed and the user has been idle for quite some time, show a ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/browser/upgrade_detector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "base/timer.h" 9 #include "base/timer.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 PrefService; 13 class PrefService;
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
19 // if our version is lower we send out a notification upon: 20 // if our version is lower we send out a notification upon:
20 // a) Detecting an upgrade and... 21 // a) Detecting an upgrade and...
21 // b) When we think the user should be notified about the upgrade. 22 // b) When we think the user should be notified about the upgrade.
22 // The latter happens much later, since we don't want to be too annoying. 23 // The latter happens much later, since we don't want to be too annoying.
23 // 24 //
24 class UpgradeDetector { 25 class UpgradeDetector {
25 public: 26 public:
26 // The Homeland Security Upgrade Advisory System. 27 // The Homeland Security Upgrade Advisory System.
27 enum UpgradeNotificationAnnoyanceLevel { 28 enum UpgradeNotificationAnnoyanceLevel {
28 UPGRADE_ANNOYANCE_NONE = 0, // What? Me worry? 29 UPGRADE_ANNOYANCE_NONE = 0, // What? Me worry?
29 UPGRADE_ANNOYANCE_LOW, // Green. 30 UPGRADE_ANNOYANCE_LOW, // Green.
30 UPGRADE_ANNOYANCE_ELEVATED, // Yellow. 31 UPGRADE_ANNOYANCE_ELEVATED, // Yellow.
31 UPGRADE_ANNOYANCE_HIGH, // Red. 32 UPGRADE_ANNOYANCE_HIGH, // Red.
32 UPGRADE_ANNOYANCE_SEVERE, // Orange. 33 UPGRADE_ANNOYANCE_SEVERE, // Orange.
34 UPGRADE_ANNOYANCE_CRITICAL, // Red exclamation mark.
33 }; 35 };
34 36
35 // The two types of icons we know about. 37 // The two types of icons we know about.
36 enum UpgradeNotificationIconType { 38 enum UpgradeNotificationIconType {
37 UPGRADE_ICON_TYPE_BADGE = 0, // For overlay badging of the wrench menu. 39 UPGRADE_ICON_TYPE_BADGE = 0, // For overlay badging of the wrench menu.
38 UPGRADE_ICON_TYPE_MENU_ICON, // For showing in the wrench menu. 40 UPGRADE_ICON_TYPE_MENU_ICON, // For showing in the wrench menu.
39 }; 41 };
40 42
41 // Returns the singleton implementation instance. 43 // Returns the singleton implementation instance.
42 static UpgradeDetector* GetInstance(); 44 static UpgradeDetector* GetInstance();
43 45
44 virtual ~UpgradeDetector(); 46 virtual ~UpgradeDetector();
45 47
46 static void RegisterPrefs(PrefService* prefs); 48 static void RegisterPrefs(PrefService* prefs);
47 49
48 bool notify_upgrade() { return notify_upgrade_; } 50 // Whether the user should be notified about an upgrade.
51 bool notify_upgrade() const { return notify_upgrade_; }
52
53 // Whether the upgrade is a critical upgrade (such as a zero-day update).
54 bool is_critical_update() const { return is_critical_upgrade_; }
55
56 // Notifify this object that the user has acknowledged the critical update
57 // so we don't need to complain about it for now.
58 void acknowledge_critical_update() {
59 critical_update_acknowledged_ = true;
60 }
61
62 // Whether the user has acknowledged the critical update.
63 bool critical_update_acknowledged() const {
64 return critical_update_acknowledged_;
65 }
66
67 // When the last upgrade was detected.
68 const base::Time& upgrade_detected_time() const {
69 return upgrade_detected_time_;
70 }
49 71
50 // Retrieves the right icon ID based on the degree of severity (see 72 // Retrieves the right icon ID based on the degree of severity (see
51 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon 73 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon
52 // to go with it). |type| determines which class of icons the caller wants, 74 // to go with it). |type| determines which class of icons the caller wants,
53 // either an icon appropriate for badging the wrench menu or one to display 75 // either an icon appropriate for badging the wrench menu or one to display
54 // within the wrench menu. 76 // within the wrench menu.
55 int GetIconResourceID(UpgradeNotificationIconType type); 77 int GetIconResourceID(UpgradeNotificationIconType type);
56 78
57 protected: 79 protected:
58 UpgradeDetector(); 80 UpgradeDetector();
59 81
60 // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_. 82 // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_.
61 void NotifyUpgradeDetected(); 83 void NotifyUpgradeDetected();
62 84
63 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. 85 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_.
64 void NotifyUpgradeRecommended(); 86 void NotifyUpgradeRecommended();
65 87
66 // Accessors.
67 const base::Time& upgrade_detected_time() const {
68 return upgrade_detected_time_;
69 }
70
71 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { 88 void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) {
72 upgrade_notification_stage_ = stage; 89 upgrade_notification_stage_ = stage;
73 } 90 }
74 91
92 // True if a critical update to Chrome has been installed, such as a zero-day
93 // fix.
94 bool is_critical_upgrade_;
95
96 // Whether the user has acknowledged the critical update.
97 bool critical_update_acknowledged_;
98
75 private: 99 private:
100 // Initiates an Idle check. See IdleCallback below.
101 void CheckIdle();
102
103 // The callback for the IdleCheck. Tells us whether Chrome has received any
104 // input events since the specified time.
105 void IdleCallback(IdleState state);
106
76 // When the upgrade was detected. 107 // When the upgrade was detected.
77 base::Time upgrade_detected_time_; 108 base::Time upgrade_detected_time_;
78 109
110 // A timer to check to see if we've been idle for long enough to show the
111 // critical warning. Should only be set if |is_critical_upgrade_| is true.
112 base::RepeatingTimer<UpgradeDetector> idle_check_timer_;
113
79 // The stage at which the annoyance level for upgrade notifications is at. 114 // The stage at which the annoyance level for upgrade notifications is at.
80 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; 115 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_;
81 116
82 // Whether we have waited long enough after detecting an upgrade (to see 117 // Whether we have waited long enough after detecting an upgrade (to see
83 // is we should start nagging about upgrading). 118 // is we should start nagging about upgrading).
84 bool notify_upgrade_; 119 bool notify_upgrade_;
85 120
86 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); 121 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector);
87 }; 122 };
88 123
89 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ 124 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/browser/upgrade_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698