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

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

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Fix test failure Created 3 years, 6 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
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/observer_list.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/upgrade_observer.h" 12 #include "chrome/browser/upgrade_observer.h"
14 #include "ui/base/idle/idle.h" 13 #include "ui/base/idle/idle.h"
15 #include "ui/gfx/image/image.h" 14 #include "ui/gfx/image/image.h"
16 15
17 class PrefRegistrySimple; 16 class PrefRegistrySimple;
18 class UpgradeObserver; 17 class UpgradeObserver;
19 18
20 /////////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////////
21 // UpgradeDetector 20 // UpgradeDetector
22 // 21 //
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 gfx::Image GetIcon(); 78 gfx::Image GetIcon();
80 79
81 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const { 80 UpgradeNotificationAnnoyanceLevel upgrade_notification_stage() const {
82 return upgrade_notification_stage_; 81 return upgrade_notification_stage_;
83 } 82 }
84 83
85 void AddObserver(UpgradeObserver* observer); 84 void AddObserver(UpgradeObserver* observer);
86 85
87 void RemoveObserver(UpgradeObserver* observer); 86 void RemoveObserver(UpgradeObserver* observer);
88 87
88 // Notifies that the current install is outdated. No details are expected.
89 void NotifyOutdatedInstall();
sky 2017/06/07 23:01:42 Why do the notify functions need to be public?
weidongg 2017/06/08 02:28:42 browser_commands.cc needs to notify upgrade to the
90
91 // Notifies that the current install is outdated and auto-update (AU) is
sky 2017/06/07 23:01:42 I realize it's long, but go with AutoUpdate. au is
weidongg 2017/06/08 02:28:42 Done.
92 // disabled. No details are expected.
93 void NotifyOutdatedInstallNoAU();
94
89 protected: 95 protected:
90 enum UpgradeAvailable { 96 enum UpgradeAvailable {
91 // If no update is available and current install is recent enough. 97 // If no update is available and current install is recent enough.
92 UPGRADE_AVAILABLE_NONE, 98 UPGRADE_AVAILABLE_NONE,
93 // If a regular update is available. 99 // If a regular update is available.
94 UPGRADE_AVAILABLE_REGULAR, 100 UPGRADE_AVAILABLE_REGULAR,
95 // If a critical update to Chrome has been installed, such as a zero-day 101 // If a critical update to Chrome has been installed, such as a zero-day
96 // fix. 102 // fix.
97 UPGRADE_AVAILABLE_CRITICAL, 103 UPGRADE_AVAILABLE_CRITICAL,
98 // If no update to Chrome has been installed for more than the recommended 104 // If no update to Chrome has been installed for more than the recommended
99 // time. 105 // time.
100 UPGRADE_NEEDED_OUTDATED_INSTALL, 106 UPGRADE_NEEDED_OUTDATED_INSTALL,
101 // If no update to Chrome has been installed for more than the recommended 107 // If no update to Chrome has been installed for more than the recommended
102 // time AND auto-update is turned off. 108 // time AND auto-update is turned off.
103 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU, 109 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU,
104 }; 110 };
105 111
106 UpgradeDetector(); 112 UpgradeDetector();
107 113
108 // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. 114 // Notifies that update is recommended and triggers different actions based
115 // on the update availability.
116 void NotifyUpgrade();
117
118 // Notifies that update is recommended.
109 void NotifyUpgradeRecommended(); 119 void NotifyUpgradeRecommended();
110 120
121 // Notifies that a critical update has been installed. No details are
122 // expected.
123 void NotifyCriticalUpgradeInstalled();
124
111 // The function that sends out a notification that lets the rest of the UI 125 // The function that sends out a notification that lets the rest of the UI
112 // know we should notify the user that a new update is available to download 126 // know we should notify the user that a new update is available to download
113 // over cellular connection. 127 // over cellular connection.
114 void NotifyUpdateOverCellularAvailable(); 128 void NotifyUpdateOverCellularAvailable();
115 129
116 // Triggers a critical update, which starts a timer that checks the machine 130 // Triggers a critical update, which starts a timer that checks the machine
117 // idle state. Protected and virtual so that it could be overridden by tests. 131 // idle state. Protected and virtual so that it could be overridden by tests.
118 virtual void TriggerCriticalUpdate(); 132 virtual void TriggerCriticalUpdate();
119 133
120 UpgradeAvailable upgrade_available() const { return upgrade_available_; } 134 UpgradeAvailable upgrade_available() const { return upgrade_available_; }
(...skipping 28 matching lines...) Expand all
149 FRIEND_TEST_ALL_PREFIXES(AppMenuModelTest, Basics); 163 FRIEND_TEST_ALL_PREFIXES(AppMenuModelTest, Basics);
150 FRIEND_TEST_ALL_PREFIXES(SystemTrayClientTest, UpdateTrayIcon); 164 FRIEND_TEST_ALL_PREFIXES(SystemTrayClientTest, UpdateTrayIcon);
151 165
152 // Initiates an Idle check. See IdleCallback below. 166 // Initiates an Idle check. See IdleCallback below.
153 void CheckIdle(); 167 void CheckIdle();
154 168
155 // The callback for the IdleCheck. Tells us whether Chrome has received any 169 // The callback for the IdleCheck. Tells us whether Chrome has received any
156 // input events since the specified time. 170 // input events since the specified time.
157 void IdleCallback(ui::IdleState state); 171 void IdleCallback(ui::IdleState state);
158 172
159 // Triggers a global notification of the specified |type|.
160 void TriggerNotification(chrome::NotificationType type);
161
162 // Whether any software updates are available (experiment updates are tracked 173 // Whether any software updates are available (experiment updates are tracked
163 // separately via additional member variables below). 174 // separately via additional member variables below).
164 UpgradeAvailable upgrade_available_; 175 UpgradeAvailable upgrade_available_;
165 176
166 // Whether "best effort" experiment updates are available. 177 // Whether "best effort" experiment updates are available.
167 bool best_effort_experiment_updates_available_; 178 bool best_effort_experiment_updates_available_;
168 179
169 // Whether "critical" experiment updates are available. 180 // Whether "critical" experiment updates are available.
170 bool critical_experiment_updates_available_; 181 bool critical_experiment_updates_available_;
171 182
(...skipping 14 matching lines...) Expand all
186 // Whether we have waited long enough after detecting an upgrade (to see 197 // Whether we have waited long enough after detecting an upgrade (to see
187 // is we should start nagging about upgrading). 198 // is we should start nagging about upgrading).
188 bool notify_upgrade_; 199 bool notify_upgrade_;
189 200
190 base::ObserverList<UpgradeObserver> observer_list_; 201 base::ObserverList<UpgradeObserver> observer_list_;
191 202
192 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); 203 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector);
193 }; 204 };
194 205
195 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ 206 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698