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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/google/google_brand.h" | 23 #include "chrome/browser/google/google_brand.h" |
| 24 #include "chrome/common/channel_info.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/chrome_version_info.h" | |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "components/network_time/network_time_tracker.h" | 27 #include "components/network_time/network_time_tracker.h" |
| 28 #include "components/version_info/version_info.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 | 30 |
30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
31 #include "base/win/win_util.h" | 32 #include "base/win/win_util.h" |
32 #include "chrome/installer/util/browser_distribution.h" | 33 #include "chrome/installer/util/browser_distribution.h" |
33 #include "chrome/installer/util/google_update_settings.h" | 34 #include "chrome/installer/util/google_update_settings.h" |
34 #include "chrome/installer/util/helper.h" | 35 #include "chrome/installer/util/helper.h" |
35 #include "chrome/installer/util/install_util.h" | 36 #include "chrome/installer/util/install_util.h" |
36 #elif defined(OS_MACOSX) | 37 #elif defined(OS_MACOSX) |
37 #include "chrome/browser/mac/keystone_glue.h" | 38 #include "chrome/browser/mac/keystone_glue.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 92 } |
92 | 93 |
93 #if !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) | 94 #if !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) |
94 // Return true if the current build is one of the unstable channels. | 95 // Return true if the current build is one of the unstable channels. |
95 bool IsUnstableChannel() { | 96 bool IsUnstableChannel() { |
96 // TODO(mad): Investigate whether we still need to be on the file thread for | 97 // TODO(mad): Investigate whether we still need to be on the file thread for |
97 // this. On Windows, the file thread used to be required for registry access | 98 // this. On Windows, the file thread used to be required for registry access |
98 // but no anymore. But other platform may still need the file thread. | 99 // but no anymore. But other platform may still need the file thread. |
99 // crbug.com/366647. | 100 // crbug.com/366647. |
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
101 version_info::Channel channel = chrome::VersionInfo::GetChannel(); | 102 version_info::Channel channel = chrome::GetChannel(); |
102 return channel == version_info::Channel::DEV || | 103 return channel == version_info::Channel::DEV || |
103 channel == version_info::Channel::CANARY; | 104 channel == version_info::Channel::CANARY; |
104 } | 105 } |
105 #endif // !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) | 106 #endif // !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) |
106 | 107 |
107 #if !defined(OS_WIN) | 108 #if !defined(OS_WIN) |
108 // This task identifies whether we are running an unstable version. And then it | 109 // This task identifies whether we are running an unstable version. And then it |
109 // unconditionally calls back the provided task. | 110 // unconditionally calls back the provided task. |
110 void CheckForUnstableChannel(const base::Closure& callback_task, | 111 void CheckForUnstableChannel(const base::Closure& callback_task, |
111 bool* is_unstable_channel) { | 112 bool* is_unstable_channel) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // be interrupted from the UI thread. | 311 // be interrupted from the UI thread. |
311 void UpgradeDetectorImpl::DetectUpgradeTask( | 312 void UpgradeDetectorImpl::DetectUpgradeTask( |
312 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { | 313 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { |
313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
314 | 315 |
315 Version critical_update; | 316 Version critical_update; |
316 Version installed_version = | 317 Version installed_version = |
317 GetCurrentlyInstalledVersionImpl(&critical_update); | 318 GetCurrentlyInstalledVersionImpl(&critical_update); |
318 | 319 |
319 // Get the version of the currently *running* instance of Chrome. | 320 // Get the version of the currently *running* instance of Chrome. |
320 chrome::VersionInfo version_info; | 321 Version running_version(version_info::GetVersionNumber()); |
321 Version running_version(version_info.Version()); | |
322 if (!running_version.IsValid()) { | 322 if (!running_version.IsValid()) { |
323 NOTREACHED(); | 323 NOTREACHED(); |
324 return; | 324 return; |
325 } | 325 } |
326 | 326 |
327 // |installed_version| may be NULL when the user downgrades on Linux (by | 327 // |installed_version| may be NULL when the user downgrades on Linux (by |
328 // switching from dev to beta channel, for example). The user needs a | 328 // switching from dev to beta channel, for example). The user needs a |
329 // restart in this case as well. See http://crbug.com/46547 | 329 // restart in this case as well. See http://crbug.com/46547 |
330 if (!installed_version.IsValid() || | 330 if (!installed_version.IsValid() || |
331 (installed_version.CompareTo(running_version) > 0)) { | 331 (installed_version.CompareTo(running_version) > 0)) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 511 |
512 // static | 512 // static |
513 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 513 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
514 return Singleton<UpgradeDetectorImpl>::get(); | 514 return Singleton<UpgradeDetectorImpl>::get(); |
515 } | 515 } |
516 | 516 |
517 // static | 517 // static |
518 UpgradeDetector* UpgradeDetector::GetInstance() { | 518 UpgradeDetector* UpgradeDetector::GetInstance() { |
519 return UpgradeDetectorImpl::GetInstance(); | 519 return UpgradeDetectorImpl::GetInstance(); |
520 } | 520 } |
OLD | NEW |