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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // upgraded in the background. | 120 // upgraded in the background. |
121 base::FilePath exe_path; | 121 base::FilePath exe_path; |
122 if (!PathService::Get(base::DIR_EXE, &exe_path)) { | 122 if (!PathService::Get(base::DIR_EXE, &exe_path)) { |
123 NOTREACHED() << "Failed to find executable path"; | 123 NOTREACHED() << "Failed to find executable path"; |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 return !InstallUtil::IsPerUserInstall(exe_path.value().c_str()); | 127 return !InstallUtil::IsPerUserInstall(exe_path.value().c_str()); |
128 } | 128 } |
129 | 129 |
130 // This task checks the update policy and calls back the task only if the | 130 // Sets |is_unstable_channel| to true if the current chrome is on the dev or |
131 // system is not enrolled in a domain (i.e., not in an enterprise environment). | 131 // canary channels. Sets |is_auto_update_enabled| to true if Google Update will |
132 // It also identifies if autoupdate is enabled and whether we are running an | 132 // update the current chrome. Unconditionally posts |callback_task| to the UI |
133 // unstable channel. |is_auto_update_enabled| can be NULL. | 133 // thread to continue processing. |
134 void DetectUpdatability(const base::Closure& callback_task, | 134 void DetectUpdatability(const base::Closure& callback_task, |
135 bool* is_unstable_channel, | 135 bool* is_unstable_channel, |
136 bool* is_auto_update_enabled) { | 136 bool* is_auto_update_enabled) { |
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
138 | 138 |
139 base::string16 app_guid = installer::GetAppGuidForUpdates(IsSystemInstall()); | 139 base::string16 app_guid = installer::GetAppGuidForUpdates(IsSystemInstall()); |
140 DCHECK(!app_guid.empty()); | 140 DCHECK(!app_guid.empty()); |
141 // Don't try to turn on autoupdate when we failed previously. | 141 // Don't try to turn on autoupdate when we failed previously. |
142 if (is_auto_update_enabled) { | 142 if (is_auto_update_enabled) { |
143 *is_auto_update_enabled = | 143 *is_auto_update_enabled = |
144 GoogleUpdateSettings::AreAutoupdatesEnabled(app_guid); | 144 GoogleUpdateSettings::AreAutoupdatesEnabled(app_guid); |
145 } | 145 } |
146 *is_unstable_channel = IsUnstableChannel(); | 146 *is_unstable_channel = IsUnstableChannel(); |
147 // Don't show the update bubbles to entreprise users (i.e., on a domain). | 147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); |
148 if (!base::win::IsEnrolledToDomain()) | |
149 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); | |
150 } | 148 } |
151 #endif // defined(OS_WIN) | 149 #endif // defined(OS_WIN) |
152 | 150 |
153 } // namespace | 151 } // namespace |
154 | 152 |
155 UpgradeDetectorImpl::UpgradeDetectorImpl() | 153 UpgradeDetectorImpl::UpgradeDetectorImpl() |
156 : weak_factory_(this), | 154 : weak_factory_(this), |
157 is_unstable_channel_(false), | 155 is_unstable_channel_(false), |
158 is_auto_update_enabled_(true), | 156 is_auto_update_enabled_(true), |
159 build_date_(base::GetBuildTime()) { | 157 build_date_(base::GetBuildTime()) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 bool UpgradeDetectorImpl::DetectOutdatedInstall() { | 358 bool UpgradeDetectorImpl::DetectOutdatedInstall() { |
361 // Don't show the bubble if we have a brand code that is NOT organic, unless | 359 // Don't show the bubble if we have a brand code that is NOT organic, unless |
362 // an outdated build is being simulated by command line switches. | 360 // an outdated build is being simulated by command line switches. |
363 static bool simulate_outdated = SimulatingOutdated(); | 361 static bool simulate_outdated = SimulatingOutdated(); |
364 if (!simulate_outdated) { | 362 if (!simulate_outdated) { |
365 std::string brand; | 363 std::string brand; |
366 if (google_util::GetBrand(&brand) && !google_util::IsOrganic(brand)) | 364 if (google_util::GetBrand(&brand) && !google_util::IsOrganic(brand)) |
367 return false; | 365 return false; |
368 | 366 |
369 #if defined(OS_WIN) | 367 #if defined(OS_WIN) |
| 368 // Don't show the update bubbles to entreprise users (i.e., on a domain). |
| 369 if (base::win::IsEnrolledToDomain()) |
| 370 return false; |
| 371 |
370 // On Windows, we don't want to warn about outdated installs when the | 372 // On Windows, we don't want to warn about outdated installs when the |
371 // machine doesn't support SSE2, it's been deprecated starting with M35. | 373 // machine doesn't support SSE2, it's been deprecated starting with M35. |
372 if (!base::CPU().has_sse2()) | 374 if (!base::CPU().has_sse2()) |
373 return false; | 375 return false; |
374 #endif | 376 #endif |
375 } | 377 } |
376 | 378 |
377 base::Time network_time; | 379 base::Time network_time; |
378 base::TimeDelta uncertainty; | 380 base::TimeDelta uncertainty; |
379 if (!network_time_tracker_.GetNetworkTime(base::TimeTicks::Now(), | 381 if (!network_time_tracker_.GetNetworkTime(base::TimeTicks::Now(), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 480 |
479 // static | 481 // static |
480 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 482 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
481 return Singleton<UpgradeDetectorImpl>::get(); | 483 return Singleton<UpgradeDetectorImpl>::get(); |
482 } | 484 } |
483 | 485 |
484 // static | 486 // static |
485 UpgradeDetector* UpgradeDetector::GetInstance() { | 487 UpgradeDetector* UpgradeDetector::GetInstance() { |
486 return UpgradeDetectorImpl::GetInstance(); | 488 return UpgradeDetectorImpl::GetInstance(); |
487 } | 489 } |
OLD | NEW |