diff options
author | stevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 21:19:20 +0000 |
---|---|---|
committer | stevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-10 21:19:20 +0000 |
commit | da891ec5fa5ae55ab6972246482798c7ef5678cd (patch) | |
tree | 8bafa8a79a414fb50ee1d988296529a3e36b86dd /chrome | |
parent | 8f0e33c93d1ebea278ebca880e2e91db75f91446 (diff) | |
download | chromium_src-da891ec5fa5ae55ab6972246482798c7ef5678cd.zip chromium_src-da891ec5fa5ae55ab6972246482798c7ef5678cd.tar.gz chromium_src-da891ec5fa5ae55ab6972246482798c7ef5678cd.tar.bz2 |
Add a method to read the Omaha experiment_labels value.
This includes updated unit tests.
BUG=160251
Review URL: https://chromiumcodereview.appspot.com/11826028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/installer/util/google_update_settings.cc | 20 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.h | 8 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 9 |
3 files changed, 36 insertions, 1 deletions
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index a53b61e..2bdc55e5 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -668,3 +668,23 @@ bool GoogleUpdateSettings::SetExperimentLabels( return success; } + +bool GoogleUpdateSettings::ReadExperimentLabels( + bool system_install, + string16* experiment_labels) { + HKEY reg_root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + + // If this distribution does not set the experiment labels, don't bother + // reading. + bool success = false; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + if (dist->ShouldSetExperimentLabels()) { + string16 client_state_path( + system_install ? dist->GetStateMediumKey() : dist->GetStateKey()); + RegKey client_state(reg_root, client_state_path.c_str(), KEY_QUERY_VALUE); + success = client_state.ReadValue(google_update::kExperimentLabels, + experiment_labels) == ERROR_SUCCESS; + } + + return success; +} diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index 533d0bb..0cab154 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -257,6 +257,14 @@ class GoogleUpdateSettings { static bool SetExperimentLabels(bool system_install, const string16& experiment_labels); + // Reads the Omaha experiment_labels value in the ClientState key for this + // Chrome product and writes it into |experiment_labels|. If this distribution + // of Chrome does not set the experiment_labels value, this will do nothing to + // |experiment_labels|. This will return true if the label was successfully + // read. + static bool ReadExperimentLabels(bool system_install, + string16* experiment_labels); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(GoogleUpdateSettings); }; diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index 4e1fba2..f00dd04 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -119,6 +119,7 @@ class GoogleUpdateSettingsTest : public testing::Test { BrowserDistribution* chrome = BrowserDistribution::GetSpecificDistribution( BrowserDistribution::CHROME_BROWSER); + std::wstring value; #if defined(GOOGLE_CHROME_BUILD) EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); @@ -127,7 +128,6 @@ class GoogleUpdateSettingsTest : public testing::Test { // Validate that something is written. Only worry about the label itself. RegKey key; - std::wstring value; HKEY root = install == SYSTEM_INSTALL ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; string16 state_key = install == SYSTEM_INSTALL ? @@ -138,6 +138,9 @@ class GoogleUpdateSettingsTest : public testing::Test { EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(google_update::kExperimentLabels, &value)); EXPECT_EQ(kTestExperimentLabel, value); + EXPECT_TRUE(GoogleUpdateSettings::ReadExperimentLabels( + install == SYSTEM_INSTALL, &value)); + EXPECT_EQ(kTestExperimentLabel, value); key.Close(); // Now that the label is set, test the delete functionality. An empty label @@ -148,9 +151,13 @@ class GoogleUpdateSettingsTest : public testing::Test { key.Open(root, state_key.c_str(), KEY_QUERY_VALUE)); EXPECT_EQ(ERROR_FILE_NOT_FOUND, key.ReadValue(google_update::kExperimentLabels, &value)); + EXPECT_FALSE(GoogleUpdateSettings::ReadExperimentLabels( + install == SYSTEM_INSTALL, &value)); key.Close(); #else EXPECT_FALSE(chrome->ShouldSetExperimentLabels()); + EXPECT_FALSE(GoogleUpdateSettings::ReadExperimentLabels( + install == SYSTEM_INSTALL, &value)); #endif // GOOGLE_CHROME_BUILD } |