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

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

Issue 2882933002: Add update available icon in system tray (Closed)
Patch Set: Remove duplicate header files. Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.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 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/observer_list.h"
10 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
11 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
12 #include "ui/base/idle/idle.h" 13 #include "ui/base/idle/idle.h"
13 #include "ui/gfx/image/image.h" 14 #include "ui/gfx/image/image.h"
14 15
15 class PrefRegistrySimple; 16 class PrefRegistrySimple;
16 17
17 /////////////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////////////
18 // UpgradeDetector 19 // UpgradeDetector
19 // 20 //
20 // This class is a singleton class that monitors when an upgrade happens in the 21 // This class is a singleton class that monitors when an upgrade happens in the
21 // background. We basically ask Omaha what it thinks the latest version is and 22 // background. We basically ask Omaha what it thinks the latest version is and
22 // if our version is lower we send out a notification upon: 23 // if our version is lower we send out a notification upon:
23 // a) Detecting an upgrade and... 24 // a) Detecting an upgrade and...
24 // b) When we think the user should be notified about the upgrade. 25 // b) When we think the user should be notified about the upgrade.
25 // The latter happens much later, since we don't want to be too annoying. 26 // The latter happens much later, since we don't want to be too annoying.
26 // 27 //
27 class UpgradeDetector { 28 class UpgradeDetector {
28 public: 29 public:
30 class UpgradeObserver {
sky 2017/05/18 23:41:56 Remove this to it's own file (see chromium style g
weidongg 2017/05/19 01:29:53 Done.
31 public:
32 virtual ~UpgradeObserver();
sky 2017/05/18 23:41:56 Move to protected section, also you can inline thi
weidongg 2017/05/19 01:29:53 Done.
33
34 // Triggered when a software update is available, but downloading requires
35 // user's agreement as current connection is cellular.
36 virtual void OnUpdateOverCellularAvailable() = 0;
37 };
38
29 // The Homeland Security Upgrade Advisory System. 39 // The Homeland Security Upgrade Advisory System.
30 enum UpgradeNotificationAnnoyanceLevel { 40 enum UpgradeNotificationAnnoyanceLevel {
31 UPGRADE_ANNOYANCE_NONE = 0, // What? Me worry? 41 UPGRADE_ANNOYANCE_NONE = 0, // What? Me worry?
32 UPGRADE_ANNOYANCE_LOW, // Green. 42 UPGRADE_ANNOYANCE_LOW, // Green.
33 UPGRADE_ANNOYANCE_ELEVATED, // Yellow. 43 UPGRADE_ANNOYANCE_ELEVATED, // Yellow.
34 UPGRADE_ANNOYANCE_HIGH, // Red. 44 UPGRADE_ANNOYANCE_HIGH, // Red.
35 UPGRADE_ANNOYANCE_SEVERE, // Orange. 45 UPGRADE_ANNOYANCE_SEVERE, // Orange.
36 UPGRADE_ANNOYANCE_CRITICAL, // Red exclamation mark. 46 UPGRADE_ANNOYANCE_CRITICAL, // Red exclamation mark.
37 }; 47 };
38 48
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 82
73 // Retrieves the right icon based on the degree of severity (see 83 // Retrieves the right icon based on the degree of severity (see
74 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon 84 // UpgradeNotificationAnnoyanceLevel, each level has an an accompanying icon
75 // to go with it) to display within the app menu. 85 // to go with it) to display within the app menu.
76 gfx::Image GetIcon(); 86 gfx::Image GetIcon();
77 87
78 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const { 88 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const {
79 return upgrade_notification_stage_; 89 return upgrade_notification_stage_;
80 } 90 }
81 91
92 void AddObserver(UpgradeObserver* observer);
93
94 void RemoveObserver(UpgradeObserver* observer);
95
82 protected: 96 protected:
83 enum UpgradeAvailable { 97 enum UpgradeAvailable {
84 // If no update is available and current install is recent enough. 98 // If no update is available and current install is recent enough.
85 UPGRADE_AVAILABLE_NONE, 99 UPGRADE_AVAILABLE_NONE,
86 // If a regular update is available. 100 // If a regular update is available.
87 UPGRADE_AVAILABLE_REGULAR, 101 UPGRADE_AVAILABLE_REGULAR,
88 // If a critical update to Chrome has been installed, such as a zero-day 102 // If a critical update to Chrome has been installed, such as a zero-day
89 // fix. 103 // fix.
90 UPGRADE_AVAILABLE_CRITICAL, 104 UPGRADE_AVAILABLE_CRITICAL,
91 // 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
92 // time. 106 // time.
93 UPGRADE_NEEDED_OUTDATED_INSTALL, 107 UPGRADE_NEEDED_OUTDATED_INSTALL,
94 // If no update to Chrome has been installed for more than the recommended 108 // If no update to Chrome has been installed for more than the recommended
95 // time AND auto-update is turned off. 109 // time AND auto-update is turned off.
96 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU, 110 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU,
97 }; 111 };
98 112
99 UpgradeDetector(); 113 UpgradeDetector();
100 114
101 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. 115 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_.
102 void NotifyUpgradeRecommended(); 116 void NotifyUpgradeRecommended();
103 117
118 // The function that sends out a notification that lets the rest of the UI
119 // know we should notify the user that a new update is available to download
120 // over cellular connection.
121 void NotifyUpdateOverCellularAvailable();
122
104 // Triggers a critical update, which starts a timer that checks the machine 123 // Triggers a critical update, which starts a timer that checks the machine
105 // idle state. Protected and virtual so that it could be overridden by tests. 124 // idle state. Protected and virtual so that it could be overridden by tests.
106 virtual void TriggerCriticalUpdate(); 125 virtual void TriggerCriticalUpdate();
107 126
108 UpgradeAvailable upgrade_available() const { return upgrade_available_; } 127 UpgradeAvailable upgrade_available() const { return upgrade_available_; }
109 void set_upgrade_available(UpgradeAvailable available) { 128 void set_upgrade_available(UpgradeAvailable available) {
110 upgrade_available_ = available; 129 upgrade_available_ = available;
111 } 130 }
112 131
113 void set_best_effort_experiment_updates_available(bool available) { 132 void set_best_effort_experiment_updates_available(bool available) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // UPGRADE_AVAILABLE_CRITICAL. 187 // UPGRADE_AVAILABLE_CRITICAL.
169 base::RepeatingTimer idle_check_timer_; 188 base::RepeatingTimer idle_check_timer_;
170 189
171 // The stage at which the annoyance level for upgrade notifications is at. 190 // The stage at which the annoyance level for upgrade notifications is at.
172 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; 191 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_;
173 192
174 // Whether we have waited long enough after detecting an upgrade (to see 193 // Whether we have waited long enough after detecting an upgrade (to see
175 // is we should start nagging about upgrading). 194 // is we should start nagging about upgrading).
176 bool notify_upgrade_; 195 bool notify_upgrade_;
177 196
197 base::ObserverList<UpgradeObserver> observer_list_;
198
178 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); 199 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector);
179 }; 200 };
180 201
181 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ 202 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.cc ('k') | chrome/browser/upgrade_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698