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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // TODO(mad): Investigate whether we still need to be on the file thread for | 95 // TODO(mad): Investigate whether we still need to be on the file thread for |
96 // this. On Windows, the file thread used to be required for registry access | 96 // this. On Windows, the file thread used to be required for registry access |
97 // but no anymore. But other platform may still need the file thread. | 97 // but no anymore. But other platform may still need the file thread. |
98 // crbug.com/366647. | 98 // crbug.com/366647. |
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
100 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 100 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
101 return channel == chrome::VersionInfo::CHANNEL_DEV || | 101 return channel == chrome::VersionInfo::CHANNEL_DEV || |
102 channel == chrome::VersionInfo::CHANNEL_CANARY; | 102 channel == chrome::VersionInfo::CHANNEL_CANARY; |
103 } | 103 } |
104 | 104 |
| 105 #if !defined(OS_WIN) |
105 // This task identifies whether we are running an unstable version. And then it | 106 // This task identifies whether we are running an unstable version. And then it |
106 // unconditionally calls back the provided task. | 107 // unconditionally calls back the provided task. |
107 void CheckForUnstableChannel(const base::Closure& callback_task, | 108 void CheckForUnstableChannel(const base::Closure& callback_task, |
108 bool* is_unstable_channel) { | 109 bool* is_unstable_channel) { |
109 *is_unstable_channel = IsUnstableChannel(); | 110 *is_unstable_channel = IsUnstableChannel(); |
110 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); | 111 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); |
111 } | 112 } |
112 | 113 #else |
113 #if defined(OS_WIN) | |
114 // Return true if the currently running Chrome is a system install. | 114 // Return true if the currently running Chrome is a system install. |
115 bool IsSystemInstall() { | 115 bool IsSystemInstall() { |
116 // Get the version of the currently *installed* instance of Chrome, | 116 // Get the version of the currently *installed* instance of Chrome, |
117 // which might be newer than the *running* instance if we have been | 117 // which might be newer than the *running* instance if we have been |
118 // upgraded in the background. | 118 // upgraded in the background. |
119 base::FilePath exe_path; | 119 base::FilePath exe_path; |
120 if (!PathService::Get(base::DIR_EXE, &exe_path)) { | 120 if (!PathService::Get(base::DIR_EXE, &exe_path)) { |
121 NOTREACHED() << "Failed to find executable path"; | 121 NOTREACHED() << "Failed to find executable path"; |
122 return false; | 122 return false; |
123 } | 123 } |
124 | 124 |
125 return !InstallUtil::IsPerUserInstall(exe_path); | 125 return !InstallUtil::IsPerUserInstall(exe_path); |
126 } | 126 } |
127 | 127 |
| 128 #if defined(GOOGLE_CHROME_BUILD) |
128 // Sets |is_unstable_channel| to true if the current chrome is on the dev or | 129 // Sets |is_unstable_channel| to true if the current chrome is on the dev or |
129 // canary channels. Sets |is_auto_update_enabled| to true if Google Update will | 130 // canary channels. Sets |is_auto_update_enabled| to true if Google Update will |
130 // update the current chrome. Unconditionally posts |callback_task| to the UI | 131 // update the current chrome. Unconditionally posts |callback_task| to the UI |
131 // thread to continue processing. | 132 // thread to continue processing. |
132 void DetectUpdatability(const base::Closure& callback_task, | 133 void DetectUpdatability(const base::Closure& callback_task, |
133 bool* is_unstable_channel, | 134 bool* is_unstable_channel, |
134 bool* is_auto_update_enabled) { | 135 bool* is_auto_update_enabled) { |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
136 | 137 |
137 // Don't try to turn on autoupdate when we failed previously. | 138 // Don't try to turn on autoupdate when we failed previously. |
138 if (is_auto_update_enabled) { | 139 if (is_auto_update_enabled) { |
139 *is_auto_update_enabled = | 140 *is_auto_update_enabled = |
140 GoogleUpdateSettings::AreAutoupdatesEnabled(); | 141 GoogleUpdateSettings::AreAutoupdatesEnabled(); |
141 } | 142 } |
142 *is_unstable_channel = IsUnstableChannel(); | 143 *is_unstable_channel = IsUnstableChannel(); |
143 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); | 144 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); |
144 } | 145 } |
145 #endif // defined(OS_WIN) | 146 #endif // defined(GOOGLE_CHROME_BUILD) |
| 147 #endif // !defined(OS_WIN) |
146 | 148 |
147 // Gets the currently installed version. On Windows, if |critical_update| is not | 149 // Gets the currently installed version. On Windows, if |critical_update| is not |
148 // NULL, also retrieves the critical update version info if available. | 150 // NULL, also retrieves the critical update version info if available. |
149 base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) { | 151 base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) { |
150 base::ThreadRestrictions::AssertIOAllowed(); | 152 base::ThreadRestrictions::AssertIOAllowed(); |
151 | 153 |
152 Version installed_version; | 154 Version installed_version; |
153 #if defined(OS_WIN) | 155 #if defined(OS_WIN) |
154 // Get the version of the currently *installed* instance of Chrome, | 156 // Get the version of the currently *installed* instance of Chrome, |
155 // which might be newer than the *running* instance if we have been | 157 // which might be newer than the *running* instance if we have been |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 509 |
508 // static | 510 // static |
509 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 511 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
510 return Singleton<UpgradeDetectorImpl>::get(); | 512 return Singleton<UpgradeDetectorImpl>::get(); |
511 } | 513 } |
512 | 514 |
513 // static | 515 // static |
514 UpgradeDetector* UpgradeDetector::GetInstance() { | 516 UpgradeDetector* UpgradeDetector::GetInstance() { |
515 return UpgradeDetectorImpl::GetInstance(); | 517 return UpgradeDetectorImpl::GetInstance(); |
516 } | 518 } |
OLD | NEW |