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/build_time.h" | 10 #include "base/build_time.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // We got a valid build date simulation so use it and check for upgrades. | 166 // We got a valid build date simulation so use it and check for upgrades. |
167 build_date_ = maybe_build_time; | 167 build_date_ = maybe_build_time; |
168 StartTimerForUpgradeCheck(); | 168 StartTimerForUpgradeCheck(); |
169 } else { | 169 } else { |
170 // Without a valid date, we simulate that we are already outdated... | 170 // Without a valid date, we simulate that we are already outdated... |
171 UpgradeDetected(UPGRADE_NEEDED_OUTDATED_INSTALL); | 171 UpgradeDetected(UPGRADE_NEEDED_OUTDATED_INSTALL); |
172 } | 172 } |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 // Windows: only enable upgrade notifications for official builds. | |
177 // Mac: only enable them if the updater (Keystone) is present. | |
178 // Linux (and other POSIX): always enable regardless of branding. | |
179 base::Closure start_upgrade_check_timer_task = | 176 base::Closure start_upgrade_check_timer_task = |
180 base::Bind(&UpgradeDetectorImpl::StartTimerForUpgradeCheck, | 177 base::Bind(&UpgradeDetectorImpl::StartTimerForUpgradeCheck, |
181 weak_factory_.GetWeakPtr()); | 178 weak_factory_.GetWeakPtr()); |
182 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 179 |
| 180 #if defined(OS_WIN) |
| 181 // Only enable upgrade notifications for official builds. Chromium has no |
| 182 // upgrade channel. |
| 183 #if defined(GOOGLE_CHROME_BUILD) |
183 // On Windows, there might be a policy preventing updates, so validate | 184 // On Windows, there might be a policy preventing updates, so validate |
184 // updatability, and then call StartTimerForUpgradeCheck appropriately. | 185 // updatability, and then call StartTimerForUpgradeCheck appropriately. |
185 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 186 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
186 base::Bind(&DetectUpdatability, | 187 base::Bind(&DetectUpdatability, |
187 start_upgrade_check_timer_task, | 188 start_upgrade_check_timer_task, |
188 &is_unstable_channel_)); | 189 &is_unstable_channel_)); |
189 return; | 190 #endif |
190 #elif defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD) | 191 #else |
191 return; // Chromium has no upgrade channel. | 192 #if defined(OS_MACOSX) |
192 #elif defined(OS_MACOSX) | 193 // Only enable upgrade notifications if the updater (Keystone) is present. |
193 if (!keystone_glue::KeystoneEnabled()) | 194 if (!keystone_glue::KeystoneEnabled()) |
194 return; // Keystone updater not enabled. | 195 return; |
195 #elif !defined(OS_POSIX) | 196 #elif defined(OS_POSIX) |
| 197 // For Linux and other POSIX, always enable upgrade notifications regardless |
| 198 // of branding. |
| 199 #else |
196 return; | 200 return; |
197 #endif | 201 #endif |
198 | |
199 // Check whether the build is an unstable channel before starting the timer. | 202 // Check whether the build is an unstable channel before starting the timer. |
200 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 203 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
201 base::Bind(&CheckForUnstableChannel, | 204 base::Bind(&CheckForUnstableChannel, |
202 start_upgrade_check_timer_task, | 205 start_upgrade_check_timer_task, |
203 &is_unstable_channel_)); | 206 &is_unstable_channel_)); |
204 | 207 |
205 // Start tracking network time updates. | 208 // Start tracking network time updates. |
206 network_time_tracker_.Start(); | 209 network_time_tracker_.Start(); |
| 210 #endif |
207 } | 211 } |
208 | 212 |
209 UpgradeDetectorImpl::~UpgradeDetectorImpl() { | 213 UpgradeDetectorImpl::~UpgradeDetectorImpl() { |
210 } | 214 } |
211 | 215 |
212 // Static | 216 // Static |
213 // This task checks the currently running version of Chrome against the | 217 // This task checks the currently running version of Chrome against the |
214 // installed version. If the installed version is newer, it calls back | 218 // installed version. If the installed version is newer, it calls back |
215 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can | 219 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can |
216 // be interrupted from the UI thread. | 220 // be interrupted from the UI thread. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 427 |
424 // static | 428 // static |
425 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 429 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
426 return Singleton<UpgradeDetectorImpl>::get(); | 430 return Singleton<UpgradeDetectorImpl>::get(); |
427 } | 431 } |
428 | 432 |
429 // static | 433 // static |
430 UpgradeDetector* UpgradeDetector::GetInstance() { | 434 UpgradeDetector* UpgradeDetector::GetInstance() { |
431 return UpgradeDetectorImpl::GetInstance(); | 435 return UpgradeDetectorImpl::GetInstance(); |
432 } | 436 } |
OLD | NEW |