diff options
-rw-r--r-- | chrome/installer/util/google_chrome_distribution_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences.cc | 81 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences.h | 7 |
3 files changed, 48 insertions, 46 deletions
diff --git a/chrome/installer/util/google_chrome_distribution_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc index 14228dd..92bab77 100644 --- a/chrome/installer/util/google_chrome_distribution_unittest.cc +++ b/chrome/installer/util/google_chrome_distribution_unittest.cc @@ -55,7 +55,7 @@ class GoogleChromeDistributionTest : public testing::Test { RegKey key; std::wstring ap_key_value; std::wstring reg_key = GetApKeyPath(); - if (key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS) && + if (key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS) && key.ReadValue(google_update::kRegApField, &ap_key_value)) { return ap_key_value; } @@ -199,7 +199,8 @@ TEST(MasterPreferences, ParseDistroParams) { " \"make_chrome_default\": true,\n" " \"system_level\": true,\n" " \"verbose_logging\": true,\n" - " \"require_eula\": true\n" + " \"require_eula\": true,\n" + " \"alternate_shortcut_text\": true\n" "},\n" " \"blah\": {\n" " \"import_history\": false\n" @@ -220,6 +221,7 @@ TEST(MasterPreferences, ParseDistroParams) { 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(result & installer_util::MASTER_PROFILE_ALT_SHORTCUT_TXT); EXPECT_TRUE(file_util::Delete(prefs, false)); } diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc index 4a0da2f..2e70120 100644 --- a/chrome/installer/util/master_preferences.cc +++ b/chrome/installer/util/master_preferences.cc @@ -30,39 +30,41 @@ bool GetBooleanPref(const DictionaryValue* prefs, const std::wstring& name) { } // namespace namespace installer_util { +// All the preferences below are expected to be inside the JSON "distribution" +// block. See master_preferences.h for an example. // Boolean pref that triggers skipping the first run dialogs. -const wchar_t kDistroSkipFirstRunPref[] = L"distribution.skip_first_run_ui"; +const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui"; // Boolean pref that triggers loading the welcome page. -const wchar_t kDistroShowWelcomePage[] = L"distribution.show_welcome_page"; +const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page"; // Boolean pref that triggers silent import of the default search engine. -const wchar_t kDistroImportSearchPref[] = L"distribution.import_search_engine"; +const wchar_t kDistroImportSearchPref[] = L"import_search_engine"; // Boolean pref that triggers silent import of the browse history. -const wchar_t kDistroImportHistoryPref[] = L"distribution.import_history"; +const wchar_t kDistroImportHistoryPref[] = L"import_history"; // The following boolean prefs have the same semantics as the corresponding // setup command line switches. See chrome/installer/util/util_constants.cc // for more info. // Create Desktop and QuickLaunch shortcuts. -const wchar_t kCreateAllShortcuts[] = L"distribution.create_all_shortcuts"; +const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts"; // Prevent installer from launching Chrome after a successful first install. -const wchar_t kDoNotLaunchChrome[] = L"distribution.do_not_launch_chrome"; +const wchar_t kDoNotLaunchChrome[] = L"do_not_launch_chrome"; // Register Chrome as default browser on the system. -const wchar_t kMakeChromeDefault[] = L"distribution.make_chrome_default"; +const wchar_t kMakeChromeDefault[] = L"make_chrome_default"; // Install Chrome to system wise location. -const wchar_t kSystemLevel[] = L"distribution.system_level"; +const wchar_t kSystemLevel[] = L"system_level"; // Run installer in verbose mode. -const wchar_t kVerboseLogging[] = L"distribution.verbose_logging"; +const wchar_t kVerboseLogging[] = L"verbose_logging"; // Show EULA dialog and install only if accepted. -const wchar_t kRequireEula[] = L"distribution.require_eula"; +const wchar_t kRequireEula[] = L"require_eula"; +// Use alternate shortcut text for the main shortcut. +const wchar_t kAltShortcutText[] = L"alternate_shortcut_text"; int ParseDistributionPreferences(const std::wstring& master_prefs_path) { - if (!file_util::PathExists(master_prefs_path)) return MASTER_PROFILE_NOT_FOUND; LOG(INFO) << "master profile found"; - std::string json_data; if (!file_util::ReadFileToString(master_prefs_path, &json_data)) return MASTER_PROFILE_ERROR; @@ -73,36 +75,31 @@ int ParseDistributionPreferences(const std::wstring& master_prefs_path) { int parse_result = 0; - if (GetBooleanPref(json_root.get(), kDistroSkipFirstRunPref)) - parse_result |= MASTER_PROFILE_NO_FIRST_RUN_UI; - - if (GetBooleanPref(json_root.get(), kDistroShowWelcomePage)) - parse_result |= MASTER_PROFILE_SHOW_WELCOME; - - if (GetBooleanPref(json_root.get(), kDistroImportSearchPref)) - parse_result |= MASTER_PROFILE_IMPORT_SEARCH_ENGINE; - - if (GetBooleanPref(json_root.get(), kDistroImportHistoryPref)) - parse_result |= MASTER_PROFILE_IMPORT_HISTORY; - - if (GetBooleanPref(json_root.get(), kCreateAllShortcuts)) - parse_result |= MASTER_PROFILE_CREATE_ALL_SHORTCUTS; - - if (GetBooleanPref(json_root.get(), kDoNotLaunchChrome)) - parse_result |= MASTER_PROFILE_DO_NOT_LAUNCH_CHROME; - - if (GetBooleanPref(json_root.get(), kMakeChromeDefault)) - parse_result |= MASTER_PROFILE_MAKE_CHROME_DEFAULT; - - if (GetBooleanPref(json_root.get(), kSystemLevel)) - parse_result |= MASTER_PROFILE_SYSTEM_LEVEL; - - if (GetBooleanPref(json_root.get(), kVerboseLogging)) - parse_result |= MASTER_PROFILE_VERBOSE_LOGGING; - - if (GetBooleanPref(json_root.get(), kRequireEula)) - parse_result |= MASTER_PROFILE_REQUIRE_EULA; - + DictionaryValue* distro = NULL; + if (json_root->GetDictionary(L"distribution", &distro)) { + if (GetBooleanPref(distro, kDistroSkipFirstRunPref)) + parse_result |= MASTER_PROFILE_NO_FIRST_RUN_UI; + if (GetBooleanPref(distro, kDistroShowWelcomePage)) + parse_result |= MASTER_PROFILE_SHOW_WELCOME; + if (GetBooleanPref(distro, kDistroImportSearchPref)) + parse_result |= MASTER_PROFILE_IMPORT_SEARCH_ENGINE; + if (GetBooleanPref(distro, kDistroImportHistoryPref)) + parse_result |= MASTER_PROFILE_IMPORT_HISTORY; + if (GetBooleanPref(distro, kCreateAllShortcuts)) + parse_result |= MASTER_PROFILE_CREATE_ALL_SHORTCUTS; + if (GetBooleanPref(distro, kDoNotLaunchChrome)) + parse_result |= MASTER_PROFILE_DO_NOT_LAUNCH_CHROME; + if (GetBooleanPref(distro, kMakeChromeDefault)) + parse_result |= MASTER_PROFILE_MAKE_CHROME_DEFAULT; + if (GetBooleanPref(distro, kSystemLevel)) + parse_result |= MASTER_PROFILE_SYSTEM_LEVEL; + if (GetBooleanPref(distro, kVerboseLogging)) + parse_result |= MASTER_PROFILE_VERBOSE_LOGGING; + if (GetBooleanPref(distro, kRequireEula)) + parse_result |= MASTER_PROFILE_REQUIRE_EULA; + if (GetBooleanPref(distro, kAltShortcutText)) + parse_result |= MASTER_PROFILE_ALT_SHORTCUT_TXT; + } return parse_result; } diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h index 2ba0b88..c07e3c7 100644 --- a/chrome/installer/util/master_preferences.h +++ b/chrome/installer/util/master_preferences.h @@ -44,7 +44,9 @@ enum MasterPrefResult { // 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 + MASTER_PROFILE_REQUIRE_EULA = 0x1 << 11, + // Use an alternate description text for some shortcuts. + MASTER_PROFILE_ALT_SHORTCUT_TXT = 0x1 << 12 }; // The master preferences is a JSON file with the same entries as the @@ -64,7 +66,8 @@ enum MasterPrefResult { // "make_chrome_default": false, // "system_level": false, // "verbose_logging": true, -// "require_eula": true +// "require_eula": true, +// "alternate_shortcut_text": false // }, // "browser": { // "show_home_button": true |