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-05-06 00:10:48 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 00:10:48 +0000
commitdf6725ea98d03df12c59cfcaadaf921ff47180c7 (patch)
treeeba747b1415aa994400263a85b2daa113f0b03a1 /chrome/installer/util/master_preferences.cc
parenta5b9781b827724254c9440920db40248a50d6dad (diff)
downloadchromium_src-df6725ea98d03df12c59cfcaadaf921ff47180c7.zip
chromium_src-df6725ea98d03df12c59cfcaadaf921ff47180c7.tar.gz
chromium_src-df6725ea98d03df12c59cfcaadaf921ff47180c7.tar.bz2
Add first_run_tabs to the master prefs file
- Updated unit test BUG=http://code.google.com/p/chromium/issues/detail?id=9706 TEST=none. Unit test included. Review URL: http://codereview.chromium.org/100364 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/master_preferences.cc')
-rw-r--r--chrome/installer/util/master_preferences.cc35
1 files changed, 29 insertions, 6 deletions
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 22dbf08..d376456 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -21,6 +21,13 @@ DictionaryValue* ReadJSONPrefs(const std::string& data) {
return static_cast<DictionaryValue*>(root.release());
}
+DictionaryValue* GetPrefsFromFile(const std::wstring& master_prefs_path) {
+ std::string json_data;
+ if (!file_util::ReadFileToString(master_prefs_path, &json_data))
+ return NULL;
+ return ReadJSONPrefs(json_data);
+}
+
bool GetBooleanPref(const DictionaryValue* prefs, const std::wstring& name) {
bool value = false;
prefs->GetBoolean(name, &value);
@@ -67,18 +74,13 @@ 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;
- scoped_ptr<DictionaryValue> json_root(ReadJSONPrefs(json_data));
+ scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path));
if (!json_root.get())
return MASTER_PROFILE_ERROR;
int parse_result = 0;
-
DictionaryValue* distro = NULL;
if (json_root->GetDictionary(L"distribution", &distro)) {
if (GetBooleanPref(distro, kDistroSkipFirstRunPref))
@@ -111,4 +113,25 @@ int ParseDistributionPreferences(const std::wstring& master_prefs_path) {
return parse_result;
}
+std::vector<std::wstring> ParseFirstRunTabs(
+ const std::wstring& master_prefs_path) {
+ std::vector<std::wstring> launch_tabs;
+ scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path));
+ if (!json_root.get())
+ return launch_tabs;
+ ListValue* tabs_list = NULL;
+ if (!json_root->GetList(L"first_run_tabs", &tabs_list))
+ return launch_tabs;
+ for (size_t i = 0; i < tabs_list->GetSize(); ++i) {
+ Value* entry;
+ std::wstring tab_entry;
+ if (!tabs_list->Get(i, &entry) || !entry->GetAsString(&tab_entry)) {
+ NOTREACHED();
+ break;
+ }
+ launch_tabs.push_back(tab_entry);
+ }
+ return launch_tabs;
+}
+
} // installer_util