OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/upgrade_detector_impl.h" | 5 #include "chrome/browser/upgrade_detector_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "chrome/common/chrome_notification_types.h" | |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
21 #include "chrome/installer/util/browser_distribution.h" | 22 #include "chrome/installer/util/browser_distribution.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_service.h" | |
25 #include "content/public/browser/user_metrics.h" | |
23 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
24 | 27 |
25 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 #include "chrome/installer/util/google_update_settings.h" | |
26 #include "chrome/installer/util/install_util.h" | 30 #include "chrome/installer/util/install_util.h" |
27 #elif defined(OS_MACOSX) | 31 #elif defined(OS_MACOSX) |
28 #include "chrome/browser/mac/keystone_glue.h" | 32 #include "chrome/browser/mac/keystone_glue.h" |
29 #elif defined(OS_POSIX) | 33 #elif defined(OS_POSIX) |
30 #include "base/process_util.h" | 34 #include "base/process_util.h" |
31 #include "base/version.h" | 35 #include "base/version.h" |
32 #endif | 36 #endif |
33 | 37 |
34 using content::BrowserThread; | 38 using content::BrowserThread; |
35 | 39 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 *is_critical_upgrade = | 147 *is_critical_upgrade = |
144 critical_update.IsValid() && | 148 critical_update.IsValid() && |
145 (critical_update.CompareTo(running_version) > 0); | 149 (critical_update.CompareTo(running_version) > 0); |
146 | 150 |
147 // Fire off the upgrade detected task. | 151 // Fire off the upgrade detected task. |
148 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 152 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
149 upgrade_detected_task); | 153 upgrade_detected_task); |
150 } | 154 } |
151 } | 155 } |
152 | 156 |
157 void DetectOutdatedTask() { | |
158 | |
159 } | |
160 | |
Finnur
2013/01/23 10:39:17
remove?
MAD
2013/01/23 20:57:59
Done.
| |
153 } // namespace | 161 } // namespace |
154 | 162 |
155 UpgradeDetectorImpl::UpgradeDetectorImpl() | 163 UpgradeDetectorImpl::UpgradeDetectorImpl() |
156 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 164 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
157 is_unstable_channel_(false) { | 165 is_unstable_channel_(false) { |
158 CommandLine command_line(*CommandLine::ForCurrentProcess()); | 166 CommandLine command_line(*CommandLine::ForCurrentProcess()); |
159 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) | 167 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) |
160 return; | 168 return; |
161 if (command_line.HasSwitch(switches::kSimulateUpgrade)) { | 169 if (command_line.HasSwitch(switches::kSimulateUpgrade)) { |
162 UpgradeDetected(); | 170 UpgradeDetected(); |
163 return; | 171 return; |
164 } | 172 } |
165 // Windows: only enable upgrade notifications for official builds. | 173 // Windows: only enable upgrade notifications for official builds. |
166 // Mac: only enable them if the updater (Keystone) is present. | 174 // Mac: only enable them if the updater (Keystone) is present. |
167 // Linux (and other POSIX): always enable regardless of branding. | 175 // Linux (and other POSIX): always enable regardless of branding. |
168 #if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_POSIX) | 176 #if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_POSIX) |
169 #if defined(OS_MACOSX) | 177 #if defined(OS_MACOSX) |
170 if (keystone_glue::KeystoneEnabled()) | 178 if (keystone_glue::KeystoneEnabled()) |
171 #endif | 179 #endif |
172 { | 180 { |
173 detect_upgrade_timer_.Start(FROM_HERE, | 181 detect_upgrade_timer_.Start(FROM_HERE, |
174 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), | 182 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), |
175 this, &UpgradeDetectorImpl::CheckForUpgrade); | 183 this, &UpgradeDetectorImpl::CheckForUpgrade); |
176 } | 184 } |
177 #endif | 185 #endif |
186 #if defined(OS_WIN) | |
187 | |
188 #else | |
189 | |
190 #endif | |
Finnur
2013/01/23 10:39:17
remove?
MAD
2013/01/23 20:57:59
Done.
| |
178 } | 191 } |
179 | 192 |
180 UpgradeDetectorImpl::~UpgradeDetectorImpl() { | 193 UpgradeDetectorImpl::~UpgradeDetectorImpl() { |
181 } | 194 } |
182 | 195 |
183 void UpgradeDetectorImpl::CheckForUpgrade() { | 196 void UpgradeDetectorImpl::CheckForUpgrade() { |
184 weak_factory_.InvalidateWeakPtrs(); | 197 weak_factory_.InvalidateWeakPtrs(); |
185 base::Closure callback_task = | 198 base::Closure callback_task = |
186 base::Bind(&UpgradeDetectorImpl::UpgradeDetected, | 199 base::Bind(&UpgradeDetectorImpl::UpgradeDetected, |
187 weak_factory_.GetWeakPtr()); | 200 weak_factory_.GetWeakPtr()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 } else if (time_passed >= kLowThreshold) { | 274 } else if (time_passed >= kLowThreshold) { |
262 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW); | 275 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW); |
263 } else { | 276 } else { |
264 return; // Not ready to recommend upgrade. | 277 return; // Not ready to recommend upgrade. |
265 } | 278 } |
266 } | 279 } |
267 | 280 |
268 NotifyUpgradeRecommended(); | 281 NotifyUpgradeRecommended(); |
269 } | 282 } |
270 | 283 |
284 void UpgradeDetectorImpl::NotifyOutdatedChromeVersio() { | |
285 // Stop the recurring timer (that is checking for changes). | |
286 detect_upgrade_timer_.Stop(); | |
287 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_CRITICAL); | |
288 | |
289 content::NotificationService::current()->Notify( | |
290 chrome::NOTIFICATION_OUTDATED_INSTALL, | |
291 content::Source<UpgradeDetector>(this), | |
292 content::NotificationService::NoDetails()); | |
293 | |
294 NotifyUpgradeRecommended(); | |
295 } | |
296 | |
271 // static | 297 // static |
272 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 298 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
273 return Singleton<UpgradeDetectorImpl>::get(); | 299 return Singleton<UpgradeDetectorImpl>::get(); |
274 } | 300 } |
275 | 301 |
276 // static | 302 // static |
277 UpgradeDetector* UpgradeDetector::GetInstance() { | 303 UpgradeDetector* UpgradeDetector::GetInstance() { |
278 return UpgradeDetectorImpl::GetInstance(); | 304 return UpgradeDetectorImpl::GetInstance(); |
279 } | 305 } |
OLD | NEW |