| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 // Static | 212 // Static |
| 213 // This task checks the currently running version of Chrome against the | 213 // This task checks the currently running version of Chrome against the |
| 214 // installed version. If the installed version is newer, it calls back | 214 // installed version. If the installed version is newer, it calls back |
| 215 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can | 215 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can |
| 216 // be interrupted from the UI thread. | 216 // be interrupted from the UI thread. |
| 217 void UpgradeDetectorImpl::DetectUpgradeTask( | 217 void UpgradeDetectorImpl::DetectUpgradeTask( |
| 218 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { | 218 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { |
| 219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 220 | 220 |
| 221 base::Version installed_version; | 221 Version installed_version; |
| 222 base::Version critical_update; | 222 Version critical_update; |
| 223 | 223 |
| 224 #if defined(OS_WIN) | 224 #if defined(OS_WIN) |
| 225 // Get the version of the currently *installed* instance of Chrome, | 225 // Get the version of the currently *installed* instance of Chrome, |
| 226 // which might be newer than the *running* instance if we have been | 226 // which might be newer than the *running* instance if we have been |
| 227 // upgraded in the background. | 227 // upgraded in the background. |
| 228 bool system_install = IsSystemInstall(); | 228 bool system_install = IsSystemInstall(); |
| 229 | 229 |
| 230 // TODO(tommi): Check if using the default distribution is always the right | 230 // TODO(tommi): Check if using the default distribution is always the right |
| 231 // thing to do. | 231 // thing to do. |
| 232 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 232 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 233 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); | 233 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); |
| 234 | 234 |
| 235 if (installed_version.IsValid()) { | 235 if (installed_version.IsValid()) { |
| 236 InstallUtil::GetCriticalUpdateVersion(dist, system_install, | 236 InstallUtil::GetCriticalUpdateVersion(dist, system_install, |
| 237 &critical_update); | 237 &critical_update); |
| 238 } | 238 } |
| 239 #elif defined(OS_MACOSX) | 239 #elif defined(OS_MACOSX) |
| 240 installed_version = | 240 installed_version = |
| 241 base::Version(UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); | 241 Version(UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); |
| 242 #elif defined(OS_POSIX) | 242 #elif defined(OS_POSIX) |
| 243 // POSIX but not Mac OS X: Linux, etc. | 243 // POSIX but not Mac OS X: Linux, etc. |
| 244 CommandLine command_line(*CommandLine::ForCurrentProcess()); | 244 CommandLine command_line(*CommandLine::ForCurrentProcess()); |
| 245 command_line.AppendSwitch(switches::kProductVersion); | 245 command_line.AppendSwitch(switches::kProductVersion); |
| 246 std::string reply; | 246 std::string reply; |
| 247 if (!base::GetAppOutput(command_line, &reply)) { | 247 if (!base::GetAppOutput(command_line, &reply)) { |
| 248 DLOG(ERROR) << "Failed to get current file version"; | 248 DLOG(ERROR) << "Failed to get current file version"; |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 | 251 |
| 252 installed_version = base::Version(reply); | 252 installed_version = Version(reply); |
| 253 #endif | 253 #endif |
| 254 | 254 |
| 255 // Get the version of the currently *running* instance of Chrome. | 255 // Get the version of the currently *running* instance of Chrome. |
| 256 chrome::VersionInfo version_info; | 256 chrome::VersionInfo version_info; |
| 257 if (!version_info.is_valid()) { | 257 if (!version_info.is_valid()) { |
| 258 NOTREACHED() << "Failed to get current file version"; | 258 NOTREACHED() << "Failed to get current file version"; |
| 259 return; | 259 return; |
| 260 } | 260 } |
| 261 base::Version running_version(version_info.Version()); | 261 Version running_version(version_info.Version()); |
| 262 if (!running_version.IsValid()) { | 262 if (!running_version.IsValid()) { |
| 263 NOTREACHED(); | 263 NOTREACHED(); |
| 264 return; | 264 return; |
| 265 } | 265 } |
| 266 | 266 |
| 267 // |installed_version| may be NULL when the user downgrades on Linux (by | 267 // |installed_version| may be NULL when the user downgrades on Linux (by |
| 268 // switching from dev to beta channel, for example). The user needs a | 268 // switching from dev to beta channel, for example). The user needs a |
| 269 // restart in this case as well. See http://crbug.com/46547 | 269 // restart in this case as well. See http://crbug.com/46547 |
| 270 if (!installed_version.IsValid() || | 270 if (!installed_version.IsValid() || |
| 271 (installed_version.CompareTo(running_version) > 0)) { | 271 (installed_version.CompareTo(running_version) > 0)) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 // static | 424 // static |
| 425 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 425 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
| 426 return Singleton<UpgradeDetectorImpl>::get(); | 426 return Singleton<UpgradeDetectorImpl>::get(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 // static | 429 // static |
| 430 UpgradeDetector* UpgradeDetector::GetInstance() { | 430 UpgradeDetector* UpgradeDetector::GetInstance() { |
| 431 return UpgradeDetectorImpl::GetInstance(); | 431 return UpgradeDetectorImpl::GetInstance(); |
| 432 } | 432 } |
| OLD | NEW |