diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:58:41 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:58:41 +0000 |
commit | d1572f4a4eddfb0a94e6548c8987aa76f75a2863 (patch) | |
tree | 493ec32f3a3bb7484c06e6db34c28024e73b9c62 /chrome/installer/util | |
parent | 7086d56e3fde7f710347d7f58ee998a901754744 (diff) | |
download | chromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.zip chromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.tar.gz chromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.tar.bz2 |
cleanup
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util')
-rw-r--r-- | chrome/installer/util/master_preferences.cc | 81 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences.h | 86 |
2 files changed, 72 insertions, 95 deletions
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc index eb62aa5..47123b8 100644 --- a/chrome/installer/util/master_preferences.cc +++ b/chrome/installer/util/master_preferences.cc @@ -10,6 +10,9 @@ #include "chrome/common/json_value_serializer.h" namespace { + +const wchar_t* kDistroDict = L"distribution"; + DictionaryValue* GetPrefsFromFile(const FilePath& master_prefs_path) { std::string json_data; if (!file_util::ReadFileToString(master_prefs_path, &json_data)) @@ -30,62 +33,49 @@ DictionaryValue* GetPrefsFromFile(const FilePath& master_prefs_path) { namespace installer_util { namespace master_preferences { -// Boolean pref that triggers skipping the first run dialogs. -const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui"; -// Boolean pref that triggers loading the 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"import_search_engine"; -// Boolean pref that triggers silent import of the default browser history. -const wchar_t kDistroImportHistoryPref[] = L"import_history"; -// Boolean pref that triggers silent import of the default browser bookmarks. +const wchar_t kAltFirstRunBubble[] = L"oem_bubble"; +const wchar_t kAltShortcutText[] = L"alternate_shortcut_text"; +const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts"; const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks"; -// RLZ ping delay in seconds +const wchar_t kDistroImportHistoryPref[] = L"import_history"; +const wchar_t kDistroImportHomePagePref[] = L"import_home_page"; +const wchar_t kDistroImportSearchPref[] = L"import_search_engine"; const wchar_t kDistroPingDelay[] = L"ping_delay"; -// Register Chrome as default browser for the current user. -const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user"; -// 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"create_all_shortcuts"; -// Prevent installer from launching Chrome after a successful first install. +const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page"; +const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui"; const wchar_t kDoNotLaunchChrome[] = L"do_not_launch_chrome"; -// Register Chrome as default browser on the system. const wchar_t kMakeChromeDefault[] = L"make_chrome_default"; -// Install Chrome to system wise location. +const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user"; +const wchar_t kMasterPreferencesValid[] = L"master_preferencs_valid"; +const wchar_t kRequireEula[] = L"require_eula"; const wchar_t kSystemLevel[] = L"system_level"; -// Run installer in verbose mode. const wchar_t kVerboseLogging[] = L"verbose_logging"; -// Show EULA dialog and install only if accepted. -const wchar_t kRequireEula[] = L"require_eula"; -// Use alternate shortcut text for the main shortcut. -const wchar_t kAltShortcutText[] = L"alternate_shortcut_text"; -// Use alternate smaller first run info bubble. -const wchar_t kAltFirstRunBubble[] = L"oem_bubble"; -// Boolean pref that triggers silent import of the default browser homepage. -const wchar_t kDistroImportHomePagePref[] = L"import_home_page"; - -const wchar_t kMasterPreferencesValid[] = L"master_preferencs_valid"; } -bool GetBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name) {
+bool GetDistroBooleanPreference(const DictionaryValue* prefs,
+ const std::wstring& name) {
+ bool value = false;
- if (!prefs || !prefs->GetBoolean(name, &value))
- return false;
+ DictionaryValue* distro = NULL; + if (prefs && prefs->GetDictionary(kDistroDict, &distro) && distro)
+ distro->GetBoolean(name, &value);
return value;
} bool GetDistributionPingDelay(const DictionaryValue* prefs, int* ping_delay) { - if (!prefs || !ping_delay) + if (!ping_delay) return false; // 90 seconds is the default that we want to use in case master preferences // is missing or corrupt. *ping_delay = 90; - if (!prefs->GetInteger(master_preferences::kDistroPingDelay, ping_delay)) + + DictionaryValue* distro = NULL; + if (!prefs || !prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ return false;
+ + if (!distro->GetInteger(master_preferences::kDistroPingDelay, ping_delay)) return false; return true; @@ -99,23 +89,10 @@ DictionaryValue* ParseDistributionPreferences( return NULL; } - scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path)); - if (!json_root.get()) { - LOG(WARNING) << "Failed to parse preferences file: " - << master_prefs_path.value(); - return NULL; - } - - DictionaryValue* distro = NULL; - if (!json_root->GetDictionary(L"distribution", &distro)) { - LOG(WARNING) << "Failed to get distriubtion params: " - << master_prefs_path.value(); - return NULL; - } - return distro; + return GetPrefsFromFile(master_prefs_path); } -std::vector<std::wstring> ParseFirstRunTabs(const DictionaryValue* prefs) { +std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs) { std::vector<std::wstring> launch_tabs; if (!prefs) return launch_tabs; diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h index 103605a..44d099c 100644 --- a/chrome/installer/util/master_preferences.h +++ b/chrome/installer/util/master_preferences.h @@ -15,53 +15,52 @@ namespace installer_util { namespace master_preferences { // All the preferences below are expected to be inside the JSON "distribution" -// block. +// block. Some of them also have equivalent command line option. If same option +// is specified in master preference as well as command line, the commnd line +// value takes precedence. -// Boolean pref that triggers skipping the first run dialogs. -extern const wchar_t kDistroSkipFirstRunPref[]; -// Boolean pref that triggers loading the welcome page. -extern const wchar_t kDistroShowWelcomePage[]; -// Boolean pref that triggers silent import of the default search engine. -extern const wchar_t kDistroImportSearchPref[]; -// Boolean pref that triggers silent import of the default browser history. -extern const wchar_t kDistroImportHistoryPref[]; +// Boolean. Use alternate text for the shortcut. Cmd line override present. +extern const wchar_t kAltShortcutText[]; +// Boolean. Use alternate smaller first run info bubble. +extern const wchar_t kAltFirstRunBubble[]; +// Boolean. Create Desktop and QuickLaunch shortcuts. Cmd line override present. +extern const wchar_t kCreateAllShortcuts[]; // Boolean pref that triggers silent import of the default browser bookmarks. extern const wchar_t kDistroImportBookmarksPref[]; -// RLZ ping delay in seconds +// Boolean pref that triggers silent import of the default browser history. +extern const wchar_t kDistroImportHistoryPref[]; +// Boolean pref that triggers silent import of the default browser homepage. +extern const wchar_t kDistroImportHomePagePref[]; +// Boolean pref that triggers silent import of the default search engine. +extern const wchar_t kDistroImportSearchPref[]; +// Integer. RLZ ping delay in seconds. extern const wchar_t kDistroPingDelay[]; -// Register Chrome as default browser for the current user. -extern const wchar_t kMakeChromeDefaultForUser[]; -// 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. -extern const wchar_t kCreateAllShortcuts[]; -// Prevent installer from launching Chrome after a successful first install. +// Boolean pref that triggers loading the welcome page. +extern const wchar_t kDistroShowWelcomePage[]; +// Boolean pref that triggers skipping the first run dialogs. +extern const wchar_t kDistroSkipFirstRunPref[]; +// Boolean. Do not launch Chrome after first install. Cmd line override present. extern const wchar_t kDoNotLaunchChrome[]; -// Register Chrome as default browser on the system. +// Boolean. Register Chrome as default browser. Cmd line override present. extern const wchar_t kMakeChromeDefault[]; -// Install Chrome to system wise location. +// Boolean. Register Chrome as default browser for the current user. +extern const wchar_t kMakeChromeDefaultForUser[]; +// Boolean but only meant to be used for internal purposes. +extern const wchar_t kMasterPreferencesValid[]; +// Boolean. Show EULA dialog before install. +extern const wchar_t kRequireEula[]; +// Boolean. Install Chrome to system wise location. Cmd line override present. extern const wchar_t kSystemLevel[]; -// Run installer in verbose mode. +// Boolean. Run installer in verbose mode. Cmd line override present. extern const wchar_t kVerboseLogging[]; -// Show EULA dialog and install only if accepted. -extern const wchar_t kRequireEula[]; -// Use alternate shortcut text for the main shortcut. -extern const wchar_t kAltShortcutText[]; -// Use alternate smaller first run info bubble. -extern const wchar_t kAltFirstRunBubble[]; -// Boolean pref that triggers silent import of the default browser homepage. -extern const wchar_t kDistroImportHomePagePref[]; - -extern const wchar_t kMasterPreferencesValid[]; } // This is the default name for the master preferences file used to pre-set // values in the user profile at first run. const wchar_t kDefaultMasterPrefs[] = L"master_preferences"; -bool GetBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name);
+bool GetDistroBooleanPreference(const DictionaryValue* prefs,
+ const std::wstring& name);
// This function gets ping delay (ping_delay in the sample above) from master // preferences. @@ -76,21 +75,22 @@ bool GetDistributionPingDelay(const DictionaryValue* prefs, // // { // "distribution": { -// "skip_first_run_ui": true, -// "show_welcome_page": true, -// "import_search_engine": true, -// "import_history": false, +// "alternate_shortcut_text": false, +// "oem_bubble": false, +// "create_all_shortcuts": true, // "import_bookmarks": false, +// "import_history": false, // "import_home_page": false, -// "create_all_shortcuts": true, +// "import_search_engine": true, +// "ping_delay": 40, +// "show_welcome_page": true, +// "skip_first_run_ui": true, // "do_not_launch_chrome": false, // "make_chrome_default": false, // "make_chrome_default_for_user": true, -// "system_level": false, -// "verbose_logging": true, // "require_eula": true, -// "alternate_shortcut_text": false, -// "ping_delay": 40 +// "system_level": false, +// "verbose_logging": true // }, // "browser": { // "show_home_button": true @@ -127,7 +127,7 @@ DictionaryValue* ParseDistributionPreferences( // // This function retuns the list as a vector of strings. If the master // preferences file does not contain such list the vector is empty. -std::vector<std::wstring> ParseFirstRunTabs(const DictionaryValue* prefs); +std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs); } #endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_ |