summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/installer/util/google_update_constants.cc1
-rw-r--r--chrome/installer/util/google_update_constants.h1
-rw-r--r--chrome/installer/util/google_update_settings.cc17
-rw-r--r--chrome/installer/util/google_update_settings.h4
-rw-r--r--chrome/installer/util/google_update_settings_unittest.cc61
5 files changed, 84 insertions, 0 deletions
diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc
index 7c3c0e5..9f044db 100644
--- a/chrome/installer/util/google_update_constants.cc
+++ b/chrome/installer/util/google_update_constants.cc
@@ -30,6 +30,7 @@ const wchar_t kRegCommandLineField[] = L"CommandLine";
const wchar_t kRegCriticalVersionField[] = L"cpv";
const wchar_t kRegDidRunField[] = L"dr";
const wchar_t kRegEULAAceptedField[] = L"eulaaccepted";
+const wchar_t kRegGoogleUpdateVersion[] = L"version";
const wchar_t kRegLangField[] = L"lang";
const wchar_t kRegLastStartedAUField[] = L"LastStartedAU";
const wchar_t kRegLastCheckedField[] = L"LastChecked";
diff --git a/chrome/installer/util/google_update_constants.h b/chrome/installer/util/google_update_constants.h
index 0bd945e..bb88bb4 100644
--- a/chrome/installer/util/google_update_constants.h
+++ b/chrome/installer/util/google_update_constants.h
@@ -42,6 +42,7 @@ extern const wchar_t kRegCommandLineField[];
extern const wchar_t kRegCriticalVersionField[];
extern const wchar_t kRegDidRunField[];
extern const wchar_t kRegEULAAceptedField[];
+extern const wchar_t kRegGoogleUpdateVersion[];
extern const wchar_t kRegLangField[];
extern const wchar_t kRegLastStartedAUField[];
extern const wchar_t kRegLastCheckedField[];
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index 7671565a..27e2cc7 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -12,6 +12,7 @@
#include "base/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
+#include "base/utf_string_conversions.h"
#include "base/win/registry.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -549,6 +550,22 @@ string16 GoogleUpdateSettings::GetUninstallCommandLine(bool system_install) {
return cmd_line;
}
+Version GoogleUpdateSettings::GetGoogleUpdateVersion(bool system_install) {
+ const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ string16 version;
+ RegKey key;
+
+ if (key.Open(root_key,
+ google_update::kRegPathGoogleUpdate,
+ KEY_QUERY_VALUE) == ERROR_SUCCESS &&
+ key.ReadValue(google_update::kRegGoogleUpdateVersion,
+ &version) == ERROR_SUCCESS) {
+ return Version(UTF16ToUTF8(version));
+ }
+
+ return Version();
+}
+
base::Time GoogleUpdateSettings::GetGoogleUpdateLastStartedAU(
bool system_install) {
const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h
index d7d0288..156ae58 100644
--- a/chrome/installer/util/google_update_settings.h
+++ b/chrome/installer/util/google_update_settings.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/string16.h"
#include "base/time.h"
+#include "base/version.h"
#include "chrome/installer/util/util_constants.h"
class BrowserDistribution;
@@ -220,6 +221,9 @@ class GoogleUpdateSettings {
// is found.
static string16 GetUninstallCommandLine(bool system_install);
+ // Returns the version of Google Update that is installed.
+ static Version GetGoogleUpdateVersion(bool system_install);
+
// Returns the time at which Google Update last started an automatic update
// check, or the null time if this information isn't available.
static base::Time GetGoogleUpdateLastStartedAU(bool system_install);
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index 4eb5d11..cec1421 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/test/test_reg_util_win.h"
+#include "base/utf_string_conversions.h"
#include "base/win/registry.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -615,6 +616,66 @@ TEST_P(GetUninstallCommandLine, TestRealValue) {
INSTANTIATE_TEST_CASE_P(GetUninstallCommandLineAtLevel, GetUninstallCommandLine,
testing::Bool());
+// Test GoogleUpdateSettings::GetGoogleUpdateVersion at system- or user-level,
+// according to the param.
+class GetGoogleUpdateVersion : public GoogleUpdateSettingsTest,
+ public testing::WithParamInterface<bool> {
+ protected:
+ static const wchar_t kDummyVersion[];
+
+ virtual void SetUp() OVERRIDE {
+ GoogleUpdateSettingsTest::SetUp();
+ system_install_ = GetParam();
+ root_key_ = system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+ }
+
+ HKEY root_key_;
+ bool system_install_;
+};
+
+const wchar_t GetGoogleUpdateVersion::kDummyVersion[] = L"1.2.3.4";
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's no
+// Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestNoKey) {
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's no
+// version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestNoValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE);
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns an empty string if there's an
+// empty version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestEmptyValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE)
+ .WriteValue(google_update::kRegGoogleUpdateVersion, L"");
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_).IsValid());
+}
+
+// Tests that GetGoogleUpdateVersion returns the correct string if there's a
+// version value in the Software\Google\Update key.
+TEST_P(GetGoogleUpdateVersion, TestRealValue) {
+ RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE)
+ .WriteValue(google_update::kRegGoogleUpdateVersion, kDummyVersion);
+ Version expected(UTF16ToUTF8(kDummyVersion));
+ EXPECT_TRUE(expected.Equals(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(system_install_)));
+ // Make sure that there's no value in the other level (user or system).
+ EXPECT_FALSE(
+ GoogleUpdateSettings::GetGoogleUpdateVersion(!system_install_)
+ .IsValid());
+}
+
+INSTANTIATE_TEST_CASE_P(GetGoogleUpdateVersionAtLevel, GetGoogleUpdateVersion,
+ testing::Bool());
+
// Test values for use by the CollectStatsConsent test fixture.
class StatsState {
public: