diff options
author | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-22 18:29:07 +0000 |
---|---|---|
committer | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-22 18:29:07 +0000 |
commit | 44ba935029f27b22fdd5633218bbb9f860a32588 (patch) | |
tree | 1b9933427a84928bc9c09ef6b6d56d658bb09f8e | |
parent | 64350dada9cbde0a6179e6d6d4a5c7a0b457c124 (diff) | |
download | chromium_src-44ba935029f27b22fdd5633218bbb9f860a32588.zip chromium_src-44ba935029f27b22fdd5633218bbb9f860a32588.tar.gz chromium_src-44ba935029f27b22fdd5633218bbb9f860a32588.tar.bz2 |
Add the EULA distro param
- Add basic tests for distro params parsing
Review URL: http://codereview.chromium.org/18470
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8477 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/installer/util/google_chrome_distribution_unittest.cc | 41 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences.cc | 5 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences.h | 12 |
3 files changed, 53 insertions, 5 deletions
diff --git a/chrome/installer/util/google_chrome_distribution_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc index 4752b17..9bb3be8 100644 --- a/chrome/installer/util/google_chrome_distribution_unittest.cc +++ b/chrome/installer/util/google_chrome_distribution_unittest.cc @@ -8,9 +8,11 @@ #include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/file_util.h" #include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_chrome_distribution.h" +#include "chrome/installer/util/master_preferences.h" #include "chrome/installer/util/work_item_list.h" #include "testing/gtest/include/gtest/gtest.h" @@ -182,3 +184,42 @@ TEST_F(GoogleChromeDistributionTest, UpdateDiffInstallStatusTest) { } #endif +TEST(MasterPreferences, ParseDistroParams) { + FilePath prefs; + ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs)); + const char text[] = + "{ \n" + " \"distribution\": { \n" + " \"skip_first_run_ui\": true,\n" + " \"show_welcome_page\": true,\n" + " \"import_search_engine\": true,\n" + " \"import_history\": true,\n" + " \"create_all_shortcuts\": true,\n" + " \"do_not_launch_chrome\": true,\n" + " \"make_chrome_default\": true,\n" + " \"system_level\": true,\n" + " \"verbose_logging\": true,\n" + " \"require_eula\": true\n" + "},\n" + " \"blah\": {\n" + " \"import_history\": false\n" + " }\n" + "} \n"; + + EXPECT_TRUE(file_util::WriteFile(prefs.value(), text, sizeof(text))); + int result = installer_util::ParseDistributionPreferences(prefs.value()); + EXPECT_FALSE(result & installer_util::MASTER_PROFILE_NOT_FOUND); + EXPECT_FALSE(result & installer_util::MASTER_PROFILE_ERROR); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_NO_FIRST_RUN_UI); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SHOW_WELCOME); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_SEARCH_ENGINE); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_HISTORY); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SYSTEM_LEVEL); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_VERBOSE_LOGGING); + EXPECT_TRUE(result & installer_util::MASTER_PROFILE_REQUIRE_EULA); + EXPECT_TRUE(file_util::Delete(prefs, false)); +} + diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc index 21c74dd..4a0da2f 100644 --- a/chrome/installer/util/master_preferences.cc +++ b/chrome/installer/util/master_preferences.cc @@ -52,6 +52,8 @@ const wchar_t kMakeChromeDefault[] = L"distribution.make_chrome_default"; const wchar_t kSystemLevel[] = L"distribution.system_level"; // Run installer in verbose mode. const wchar_t kVerboseLogging[] = L"distribution.verbose_logging"; +// Show EULA dialog and install only if accepted. +const wchar_t kRequireEula[] = L"distribution.require_eula"; int ParseDistributionPreferences(const std::wstring& master_prefs_path) { @@ -98,6 +100,9 @@ int ParseDistributionPreferences(const std::wstring& master_prefs_path) { if (GetBooleanPref(json_root.get(), kVerboseLogging)) parse_result |= MASTER_PROFILE_VERBOSE_LOGGING; + if (GetBooleanPref(json_root.get(), kRequireEula)) + parse_result |= MASTER_PROFILE_REQUIRE_EULA; + return parse_result; } diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h index e53ba87..2ba0b88 100644 --- a/chrome/installer/util/master_preferences.h +++ b/chrome/installer/util/master_preferences.h @@ -26,9 +26,9 @@ enum MasterPrefResult { MASTER_PROFILE_NO_FIRST_RUN_UI = 0x1 << 2, // Show welcome page. MASTER_PROFILE_SHOW_WELCOME = 0x1 << 3, - // Improt search engine setting from the default browser. + // Import search engine setting from the default browser. MASTER_PROFILE_IMPORT_SEARCH_ENGINE = 0x1 << 4, - // Improt history from the default browser. + // Import history from the default browser. MASTER_PROFILE_IMPORT_HISTORY = 0x1 << 5, // The following boolean prefs have the same semantics as the corresponding // setup command line switches. See chrome/installer/util/util_constants.cc @@ -43,7 +43,8 @@ enum MasterPrefResult { MASTER_PROFILE_SYSTEM_LEVEL = 0x1 << 9, // Run installer in verbose mode. MASTER_PROFILE_VERBOSE_LOGGING = 0x1 << 10, - + // Show the EULA and do not install if not accepted. + MASTER_PROFILE_REQUIRE_EULA = 0x1 << 11 }; // The master preferences is a JSON file with the same entries as the @@ -57,12 +58,13 @@ enum MasterPrefResult { // "skip_first_run_ui": true, // "show_welcome_page": true, // "import_search_engine": true, -// "import_history": false +// "import_history": false, // "create_all_shortcuts": true, // "do_not_launch_chrome": false, // "make_chrome_default": false, // "system_level": false, -// "verbose_logging": true +// "verbose_logging": true, +// "require_eula": true // }, // "browser": { // "show_home_button": true |