summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 22:01:25 +0000
committerhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 22:01:25 +0000
commit594f4ff352685bb83b71d1402264bc2cf2116e67 (patch)
tree6f1807217f5e8bc50603e5b20008e7160d49dbe7 /chrome/installer
parent26b0f376d66975c03c3d24afd72257f34c9bb5f6 (diff)
downloadchromium_src-594f4ff352685bb83b71d1402264bc2cf2116e67.zip
chromium_src-594f4ff352685bb83b71d1402264bc2cf2116e67.tar.gz
chromium_src-594f4ff352685bb83b71d1402264bc2cf2116e67.tar.bz2
Add import_bookmarks_from_file option to master pref that
sliently import bookmarks from file in first run. BUG=32728 TEST=unit test Review URL: http://codereview.chromium.org/1257001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/util/master_preferences.cc21
-rw-r--r--chrome/installer/util/master_preferences.h7
-rw-r--r--chrome/installer/util/master_preferences_constants.cc2
-rw-r--r--chrome/installer/util/master_preferences_constants.h3
-rw-r--r--chrome/installer/util/master_preferences_unittest.cc11
5 files changed, 44 insertions, 0 deletions
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 2a6a4e7..3406e33 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -65,6 +65,27 @@ bool GetDistroBooleanPreference(const DictionaryValue* prefs,
return true;
}
+bool GetDistroStringPreference(const DictionaryValue* prefs,
+ const std::wstring& name,
+ std::wstring* value) {
+ if (!prefs || !value)
+ return false;
+
+ DictionaryValue* distro = NULL;
+ if (!prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ return false;
+
+ std::wstring str_value;
+ if (!distro->GetString(name, &str_value))
+ return false;
+
+ if (str_value.empty())
+ return false;
+
+ *value = str_value;
+ return true;
+}
+
bool GetDistroIntegerPreference(const DictionaryValue* prefs,
const std::wstring& name,
int* value) {
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index e244e96..8d64be5 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -34,6 +34,12 @@ bool GetDistroBooleanPreference(const DictionaryValue* prefs,
const std::wstring& name,
bool* value);
+// This function gets value of a string preference from master
+// preferences. Returns true if the value is read successfully, otherwise false.
+bool GetDistroStringPreference(const DictionaryValue* prefs,
+ const std::wstring& name,
+ std::wstring* value);
+
// This function gets value of an integer preference from master
// preferences. Returns true if the value is read successfully, otherwise false.
bool GetDistroIntegerPreference(const DictionaryValue* prefs,
@@ -53,6 +59,7 @@ bool GetDistroIntegerPreference(const DictionaryValue* prefs,
// "chrome_shortcut_icon_index": 0,
// "create_all_shortcuts": true,
// "import_bookmarks": false,
+// "import_bookmarks_from_file": "c:\\path",
// "import_history": false,
// "import_home_page": false,
// "import_search_engine": true,
diff --git a/chrome/installer/util/master_preferences_constants.cc b/chrome/installer/util/master_preferences_constants.cc
index 6519e4c..cae9a6d 100644
--- a/chrome/installer/util/master_preferences_constants.cc
+++ b/chrome/installer/util/master_preferences_constants.cc
@@ -11,6 +11,8 @@ namespace master_preferences {
const wchar_t kChromeShortcutIconIndex[] = L"chrome_shortcut_icon_index";
const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts";
const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks";
+ const wchar_t kDistroImportBookmarksFromFilePref[] =
+ L"import_bookmarks_from_file";
const wchar_t kDistroImportHistoryPref[] = L"import_history";
const wchar_t kDistroImportHomePagePref[] = L"import_home_page";
const wchar_t kDistroImportSearchPref[] = L"import_search_engine";
diff --git a/chrome/installer/util/master_preferences_constants.h b/chrome/installer/util/master_preferences_constants.h
index 5bcd5d3..c67d7ab 100644
--- a/chrome/installer/util/master_preferences_constants.h
+++ b/chrome/installer/util/master_preferences_constants.h
@@ -25,6 +25,9 @@ extern const wchar_t kChromeShortcutIconIndex[];
extern const wchar_t kCreateAllShortcuts[];
// Boolean pref that triggers silent import of the default browser bookmarks.
extern const wchar_t kDistroImportBookmarksPref[];
+// String pref that triggers silent import of bookmarks from the html file at
+// given path.
+extern const wchar_t kDistroImportBookmarksFromFilePref[];
// 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.
diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc
index 65fcc6d..ba91cbc 100644
--- a/chrome/installer/util/master_preferences_unittest.cc
+++ b/chrome/installer/util/master_preferences_unittest.cc
@@ -40,6 +40,7 @@ TEST_F(MasterPreferencesTest, ParseDistroParams) {
" \"import_search_engine\": true,\n"
" \"import_history\": true,\n"
" \"import_bookmarks\": true,\n"
+ " \"import_bookmarks_from_file\": \"c:\\\\foo\",\n"
" \"import_home_page\": true,\n"
" \"create_all_shortcuts\": true,\n"
" \"do_not_launch_chrome\": true,\n"
@@ -79,6 +80,11 @@ TEST_F(MasterPreferencesTest, ParseDistroParams) {
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportBookmarksPref, &value) &&
value);
+ std::wstring str_value;
+ EXPECT_TRUE(installer_util::GetDistroStringPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
+ &str_value));
+ EXPECT_STREQ(L"c:\\foo", str_value.c_str());
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportHomePagePref, &value) &&
value);
@@ -130,6 +136,7 @@ TEST_F(MasterPreferencesTest, ParseMissingDistroParams) {
" \"skip_first_run_ui\": true,\n"
" \"import_search_engine\": true,\n"
" \"import_bookmarks\": false,\n"
+ " \"import_bookmarks_from_file\": \"\",\n"
" \"create_all_shortcuts\": true,\n"
" \"do_not_launch_chrome\": true,\n"
" \"chrome_shortcut_icon_index\": \"bac\"\n"
@@ -155,6 +162,10 @@ TEST_F(MasterPreferencesTest, ParseMissingDistroParams) {
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportBookmarksPref, &value));
EXPECT_FALSE(value);
+ std::wstring str_value;
+ EXPECT_FALSE(installer_util::GetDistroStringPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportBookmarksFromFilePref,
+ &str_value));
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportHomePagePref, &value));