| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 GoogleUpdateSettings::AreAutoupdatesEnabled(); | 147 GoogleUpdateSettings::AreAutoupdatesEnabled(); |
| 148 } | 148 } |
| 149 *is_unstable_channel = IsUnstableChannel(); | 149 *is_unstable_channel = IsUnstableChannel(); |
| 150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); | 150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); |
| 151 } | 151 } |
| 152 #endif // defined(GOOGLE_CHROME_BUILD) | 152 #endif // defined(GOOGLE_CHROME_BUILD) |
| 153 #endif // !defined(OS_WIN) | 153 #endif // !defined(OS_WIN) |
| 154 | 154 |
| 155 // Gets the currently installed version. On Windows, if |critical_update| is not | 155 // Gets the currently installed version. On Windows, if |critical_update| is not |
| 156 // NULL, also retrieves the critical update version info if available. | 156 // NULL, also retrieves the critical update version info if available. |
| 157 base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) { | 157 base::Version GetCurrentlyInstalledVersionImpl(base::Version* critical_update) { |
| 158 base::ThreadRestrictions::AssertIOAllowed(); | 158 base::ThreadRestrictions::AssertIOAllowed(); |
| 159 | 159 |
| 160 Version installed_version; | 160 base::Version installed_version; |
| 161 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
| 162 // Get the version of the currently *installed* instance of Chrome, | 162 // Get the version of the currently *installed* instance of Chrome, |
| 163 // which might be newer than the *running* instance if we have been | 163 // which might be newer than the *running* instance if we have been |
| 164 // upgraded in the background. | 164 // upgraded in the background. |
| 165 bool system_install = IsSystemInstall(); | 165 bool system_install = IsSystemInstall(); |
| 166 | 166 |
| 167 // TODO(tommi): Check if using the default distribution is always the right | 167 // TODO(tommi): Check if using the default distribution is always the right |
| 168 // thing to do. | 168 // thing to do. |
| 169 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 169 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 170 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); | 170 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); |
| 171 if (critical_update && installed_version.IsValid()) { | 171 if (critical_update && installed_version.IsValid()) { |
| 172 InstallUtil::GetCriticalUpdateVersion(dist, system_install, | 172 InstallUtil::GetCriticalUpdateVersion(dist, system_install, |
| 173 critical_update); | 173 critical_update); |
| 174 } | 174 } |
| 175 #elif defined(OS_MACOSX) | 175 #elif defined(OS_MACOSX) |
| 176 installed_version = | 176 installed_version = base::Version( |
| 177 Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); | 177 base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); |
| 178 #elif defined(OS_POSIX) | 178 #elif defined(OS_POSIX) |
| 179 // POSIX but not Mac OS X: Linux, etc. | 179 // POSIX but not Mac OS X: Linux, etc. |
| 180 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); | 180 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); |
| 181 command_line.AppendSwitch(switches::kProductVersion); | 181 command_line.AppendSwitch(switches::kProductVersion); |
| 182 std::string reply; | 182 std::string reply; |
| 183 if (!base::GetAppOutput(command_line, &reply)) { | 183 if (!base::GetAppOutput(command_line, &reply)) { |
| 184 DLOG(ERROR) << "Failed to get current file version"; | 184 DLOG(ERROR) << "Failed to get current file version"; |
| 185 return installed_version; | 185 return installed_version; |
| 186 } | 186 } |
| 187 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply); | 187 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply); |
| 188 | 188 |
| 189 installed_version = Version(reply); | 189 installed_version = base::Version(reply); |
| 190 #endif | 190 #endif |
| 191 return installed_version; | 191 return installed_version; |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace | 194 } // namespace |
| 195 | 195 |
| 196 UpgradeDetectorImpl::UpgradeDetectorImpl() | 196 UpgradeDetectorImpl::UpgradeDetectorImpl() |
| 197 : is_unstable_channel_(false), | 197 : is_unstable_channel_(false), |
| 198 is_auto_update_enabled_(true), | 198 is_auto_update_enabled_(true), |
| 199 build_date_(base::GetBuildTime()), | 199 build_date_(base::GetBuildTime()), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 // static | 310 // static |
| 311 // This task checks the currently running version of Chrome against the | 311 // This task checks the currently running version of Chrome against the |
| 312 // installed version. If the installed version is newer, it calls back | 312 // installed version. If the installed version is newer, it calls back |
| 313 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can | 313 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can |
| 314 // be interrupted from the UI thread. | 314 // be interrupted from the UI thread. |
| 315 void UpgradeDetectorImpl::DetectUpgradeTask( | 315 void UpgradeDetectorImpl::DetectUpgradeTask( |
| 316 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { | 316 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { |
| 317 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 317 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 318 | 318 |
| 319 Version critical_update; | 319 base::Version critical_update; |
| 320 Version installed_version = | 320 base::Version installed_version = |
| 321 GetCurrentlyInstalledVersionImpl(&critical_update); | 321 GetCurrentlyInstalledVersionImpl(&critical_update); |
| 322 | 322 |
| 323 // Get the version of the currently *running* instance of Chrome. | 323 // Get the version of the currently *running* instance of Chrome. |
| 324 Version running_version(version_info::GetVersionNumber()); | 324 base::Version running_version(version_info::GetVersionNumber()); |
| 325 if (!running_version.IsValid()) { | 325 if (!running_version.IsValid()) { |
| 326 NOTREACHED(); | 326 NOTREACHED(); |
| 327 return; | 327 return; |
| 328 } | 328 } |
| 329 | 329 |
| 330 // |installed_version| may be NULL when the user downgrades on Linux (by | 330 // |installed_version| may be NULL when the user downgrades on Linux (by |
| 331 // switching from dev to beta channel, for example). The user needs a | 331 // switching from dev to beta channel, for example). The user needs a |
| 332 // restart in this case as well. See http://crbug.com/46547 | 332 // restart in this case as well. See http://crbug.com/46547 |
| 333 if (!installed_version.IsValid() || | 333 if (!installed_version.IsValid() || |
| 334 (installed_version.CompareTo(running_version) > 0)) { | 334 (installed_version.CompareTo(running_version) > 0)) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 514 |
| 515 // static | 515 // static |
| 516 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 516 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
| 517 return base::Singleton<UpgradeDetectorImpl>::get(); | 517 return base::Singleton<UpgradeDetectorImpl>::get(); |
| 518 } | 518 } |
| 519 | 519 |
| 520 // static | 520 // static |
| 521 UpgradeDetector* UpgradeDetector::GetInstance() { | 521 UpgradeDetector* UpgradeDetector::GetInstance() { |
| 522 return UpgradeDetectorImpl::GetInstance(); | 522 return UpgradeDetectorImpl::GetInstance(); |
| 523 } | 523 } |
| OLD | NEW |