summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/master_preferences.cc
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 02:45:29 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 02:45:29 +0000
commitfba9da17fee049e74c4165ac7ff0ee4793f5d08f (patch)
tree336db297edaddf8086d6290097a36772fa769e90 /chrome/installer/util/master_preferences.cc
parent64da0b93805c9daa14f2a8eb39ac4133e070e69c (diff)
downloadchromium_src-fba9da17fee049e74c4165ac7ff0ee4793f5d08f.zip
chromium_src-fba9da17fee049e74c4165ac7ff0ee4793f5d08f.tar.gz
chromium_src-fba9da17fee049e74c4165ac7ff0ee4793f5d08f.tar.bz2
Added master preference to select the appropiate shortcut text
- Simplified ParseDistributionPreferences a bit - Added test for new pref Review URL: http://codereview.chromium.org/27077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/master_preferences.cc')
-rw-r--r--chrome/installer/util/master_preferences.cc81
1 files changed, 39 insertions, 42 deletions
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;
}