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

Unified Diff: chrome/browser/upgrade_detector_impl.cc

Issue 333313003: Simulate variation seeds using installed version string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector_impl.cc
===================================================================
--- chrome/browser/upgrade_detector_impl.cc (revision 278434)
+++ chrome/browser/upgrade_detector_impl.cc (working copy)
@@ -20,7 +20,6 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
-#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/common/chrome_switches.h"
@@ -149,6 +148,44 @@
}
#endif // defined(OS_WIN)
+// Gets the currently installed version. On Windows, if |critical_update| is not
+// NULL, also retrieves the critical update version info if available.
+base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
+ Version installed_version;
+#if defined(OS_WIN)
+ // Get the version of the currently *installed* instance of Chrome,
+ // which might be newer than the *running* instance if we have been
+ // upgraded in the background.
+ bool system_install = IsSystemInstall();
+
+ // TODO(tommi): Check if using the default distribution is always the right
+ // thing to do.
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ InstallUtil::GetChromeVersion(dist, system_install, &installed_version);
+ if (critical_update && installed_version.IsValid()) {
+ InstallUtil::GetCriticalUpdateVersion(dist, system_install,
+ critical_update);
+ }
+#elif defined(OS_MACOSX)
+ installed_version =
+ Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion()));
+#elif defined(OS_POSIX)
+ // POSIX but not Mac OS X: Linux, etc.
+ CommandLine command_line(*CommandLine::ForCurrentProcess());
+ command_line.AppendSwitch(switches::kProductVersion);
+ std::string reply;
+ if (!base::GetAppOutput(command_line, &reply)) {
+ DLOG(ERROR) << "Failed to get current file version";
+ return installed_version;
+ }
+
+ installed_version = Version(reply);
+#endif
+ return installed_version;
+}
+
} // namespace
UpgradeDetectorImpl::UpgradeDetectorImpl()
@@ -252,7 +289,12 @@
UpgradeDetectorImpl::~UpgradeDetectorImpl() {
}
-// Static
+// static
+base::Version UpgradeDetectorImpl::GetCurrentlyInstalledVersion() {
+ return GetCurrentlyInstalledVersionImpl(NULL);
+}
+
+// static
// This task checks the currently running version of Chrome against the
// installed version. If the installed version is newer, it calls back
// UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can
@@ -261,40 +303,10 @@
base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- Version installed_version;
Version critical_update;
+ Version installed_version =
+ GetCurrentlyInstalledVersionImpl(&critical_update);
-#if defined(OS_WIN)
- // Get the version of the currently *installed* instance of Chrome,
- // which might be newer than the *running* instance if we have been
- // upgraded in the background.
- bool system_install = IsSystemInstall();
-
- // TODO(tommi): Check if using the default distribution is always the right
- // thing to do.
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- InstallUtil::GetChromeVersion(dist, system_install, &installed_version);
-
- if (installed_version.IsValid()) {
- InstallUtil::GetCriticalUpdateVersion(dist, system_install,
- &critical_update);
- }
-#elif defined(OS_MACOSX)
- installed_version =
- Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion()));
-#elif defined(OS_POSIX)
- // POSIX but not Mac OS X: Linux, etc.
- CommandLine command_line(*CommandLine::ForCurrentProcess());
- command_line.AppendSwitch(switches::kProductVersion);
- std::string reply;
- if (!base::GetAppOutput(command_line, &reply)) {
- DLOG(ERROR) << "Failed to get current file version";
- return;
- }
-
- installed_version = Version(reply);
-#endif
-
// Get the version of the currently *running* instance of Chrome.
chrome::VersionInfo version_info;
if (!version_info.is_valid()) {
@@ -436,9 +448,9 @@
// second.
const int kUnstableThreshold = 1;
- if (is_critical_or_outdated)
+ if (is_critical_or_outdated) {
set_upgrade_notification_stage(UPGRADE_ANNOYANCE_CRITICAL);
- else if (time_passed >= kUnstableThreshold) {
+ } else if (time_passed >= kUnstableThreshold) {
set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW);
// That's as high as it goes.
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698