Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(877)

Side by Side Diff: chrome/browser/upgrade_detector_impl.cc

Issue 1281313003: base: Remove using:: declaration from version.h header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 GoogleUpdateSettings::AreAutoupdatesEnabled(); 144 GoogleUpdateSettings::AreAutoupdatesEnabled();
145 } 145 }
146 *is_unstable_channel = IsUnstableChannel(); 146 *is_unstable_channel = IsUnstableChannel();
147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); 147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task);
148 } 148 }
149 #endif // defined(GOOGLE_CHROME_BUILD) 149 #endif // defined(GOOGLE_CHROME_BUILD)
150 #endif // !defined(OS_WIN) 150 #endif // !defined(OS_WIN)
151 151
152 // Gets the currently installed version. On Windows, if |critical_update| is not 152 // Gets the currently installed version. On Windows, if |critical_update| is not
153 // NULL, also retrieves the critical update version info if available. 153 // NULL, also retrieves the critical update version info if available.
154 base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) { 154 base::Version GetCurrentlyInstalledVersionImpl(base::Version* critical_update) {
155 base::ThreadRestrictions::AssertIOAllowed(); 155 base::ThreadRestrictions::AssertIOAllowed();
156 156
157 Version installed_version; 157 base::Version installed_version;
158 #if defined(OS_WIN) 158 #if defined(OS_WIN)
159 // Get the version of the currently *installed* instance of Chrome, 159 // Get the version of the currently *installed* instance of Chrome,
160 // which might be newer than the *running* instance if we have been 160 // which might be newer than the *running* instance if we have been
161 // upgraded in the background. 161 // upgraded in the background.
162 bool system_install = IsSystemInstall(); 162 bool system_install = IsSystemInstall();
163 163
164 // TODO(tommi): Check if using the default distribution is always the right 164 // TODO(tommi): Check if using the default distribution is always the right
165 // thing to do. 165 // thing to do.
166 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 166 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
167 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); 167 InstallUtil::GetChromeVersion(dist, system_install, &installed_version);
168 if (critical_update && installed_version.IsValid()) { 168 if (critical_update && installed_version.IsValid()) {
169 InstallUtil::GetCriticalUpdateVersion(dist, system_install, 169 InstallUtil::GetCriticalUpdateVersion(dist, system_install,
170 critical_update); 170 critical_update);
171 } 171 }
172 #elif defined(OS_MACOSX) 172 #elif defined(OS_MACOSX)
173 installed_version = 173 installed_version = base::Version(
174 Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); 174 base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion()));
175 #elif defined(OS_POSIX) 175 #elif defined(OS_POSIX)
176 // POSIX but not Mac OS X: Linux, etc. 176 // POSIX but not Mac OS X: Linux, etc.
177 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); 177 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
178 command_line.AppendSwitch(switches::kProductVersion); 178 command_line.AppendSwitch(switches::kProductVersion);
179 std::string reply; 179 std::string reply;
180 if (!base::GetAppOutput(command_line, &reply)) { 180 if (!base::GetAppOutput(command_line, &reply)) {
181 DLOG(ERROR) << "Failed to get current file version"; 181 DLOG(ERROR) << "Failed to get current file version";
182 return installed_version; 182 return installed_version;
183 } 183 }
184 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply); 184 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply);
185 185
186 installed_version = Version(reply); 186 installed_version = base::Version(reply);
187 #endif 187 #endif
188 return installed_version; 188 return installed_version;
189 } 189 }
190 190
191 } // namespace 191 } // namespace
192 192
193 UpgradeDetectorImpl::UpgradeDetectorImpl() 193 UpgradeDetectorImpl::UpgradeDetectorImpl()
194 : is_unstable_channel_(false), 194 : is_unstable_channel_(false),
195 is_auto_update_enabled_(true), 195 is_auto_update_enabled_(true),
196 build_date_(base::GetBuildTime()), 196 build_date_(base::GetBuildTime()),
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 // static 307 // static
308 // This task checks the currently running version of Chrome against the 308 // This task checks the currently running version of Chrome against the
309 // installed version. If the installed version is newer, it calls back 309 // installed version. If the installed version is newer, it calls back
310 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can 310 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can
311 // be interrupted from the UI thread. 311 // be interrupted from the UI thread.
312 void UpgradeDetectorImpl::DetectUpgradeTask( 312 void UpgradeDetectorImpl::DetectUpgradeTask(
313 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { 313 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) {
314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
315 315
316 Version critical_update; 316 base::Version critical_update;
317 Version installed_version = 317 base::Version installed_version =
318 GetCurrentlyInstalledVersionImpl(&critical_update); 318 GetCurrentlyInstalledVersionImpl(&critical_update);
319 319
320 // Get the version of the currently *running* instance of Chrome. 320 // Get the version of the currently *running* instance of Chrome.
321 Version running_version(version_info::GetVersionNumber()); 321 base::Version running_version(version_info::GetVersionNumber());
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/default_browser_prompt.cc ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698