diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 22:01:25 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 22:01:25 +0000 |
commit | 594f4ff352685bb83b71d1402264bc2cf2116e67 (patch) | |
tree | 6f1807217f5e8bc50603e5b20008e7160d49dbe7 /chrome/browser/first_run_win.cc | |
parent | 26b0f376d66975c03c3d24afd72257f34c9bb5f6 (diff) | |
download | chromium_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/browser/first_run_win.cc')
-rw-r--r-- | chrome/browser/first_run_win.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index e4959e0..0e0925d 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -355,13 +355,18 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, value) import_items += importer::HOME_PAGE; - if (import_items) { + std::wstring import_bookmarks_path; + installer_util::GetDistroStringPreference(prefs.get(), + installer_util::master_preferences::kDistroImportBookmarksFromFilePref, + &import_bookmarks_path); + + if (import_items || !import_bookmarks_path.empty()) { // There is something to import from the default browser. This launches // the importer process and blocks until done or until it fails. scoped_refptr<ImporterHost> importer_host = new ImporterHost(); if (!FirstRun::ImportSettings(NULL, importer_host->GetSourceProfileInfoAt(0).browser_type, - import_items, NULL)) { + import_items, import_bookmarks_path, NULL)) { LOG(WARNING) << "silent import failed"; } } @@ -625,7 +630,9 @@ bool DecodeImportParams(const std::wstring& encoded, } // namespace bool FirstRun::ImportSettings(Profile* profile, int browser_type, - int items_to_import, HWND parent_window) { + int items_to_import, + const std::wstring& import_bookmarks_path, + HWND parent_window) { const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); CommandLine import_cmd(cmdline.GetProgram()); // Propagate user data directory switch. @@ -642,8 +649,15 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, switches::kLang, ASCIIToWide(g_browser_process->GetApplicationLocale())); - import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, - EncodeImportParams(browser_type, items_to_import, parent_window)); + if (items_to_import) { + import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, + EncodeImportParams(browser_type, items_to_import, parent_window)); + } + + if (!import_bookmarks_path.empty()) { + import_cmd.CommandLine::AppendSwitchWithValue( + switches::kImportFromFile, import_bookmarks_path.c_str()); + } if (cmdline.HasSwitch(switches::kChromeFrame)) { import_cmd.AppendSwitch(switches::kChromeFrame); @@ -672,6 +686,13 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); } +bool FirstRun::ImportSettings(Profile* profile, int browser_type, + int items_to_import, + HWND parent_window) { + return ImportSettings(profile, browser_type, items_to_import, + std::wstring(), parent_window); +} + int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { std::wstring file_path = cmdline.GetSwitchValue(switches::kImportFromFile); if (file_path.empty()) { |