diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 22:31:27 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 22:31:27 +0000 |
commit | 02aae3fac31e8ac28c5ee8c4b70e70dcef599dd0 (patch) | |
tree | 4cf14589dc2c4b4b5e4bdce8fc14bb5ee116df42 /chrome/browser | |
parent | 8341583b5c0488e9521835210f6abdefd9c0fc4e (diff) | |
download | chromium_src-02aae3fac31e8ac28c5ee8c4b70e70dcef599dd0.zip chromium_src-02aae3fac31e8ac28c5ee8c4b70e70dcef599dd0.tar.gz chromium_src-02aae3fac31e8ac28c5ee8c4b70e70dcef599dd0.tar.bz2 |
Add the option of importing bookmarks from file to first run.
BUG=32728
TEST=run with --import-from-file
Review URL: http://codereview.chromium.org/1077007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_main.cc | 6 | ||||
-rw-r--r-- | chrome/browser/first_run.h | 15 | ||||
-rw-r--r-- | chrome/browser/first_run_win.cc | 44 |
3 files changed, 58 insertions, 7 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index c160379..0971b4a 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -495,7 +495,8 @@ int BrowserMain(const MainFunctionParams& parameters) { parsed_command_line.HasSwitch(switches::kFirstRun); scoped_ptr<BrowserProcessImpl> browser_process; - if (parsed_command_line.HasSwitch(switches::kImport)) { + if (parsed_command_line.HasSwitch(switches::kImport) || + parsed_command_line.HasSwitch(switches::kImportFromFile)) { // We use different BrowserProcess when importing so no GoogleURLTracker is // instantiated (as it makes a URLRequest and we don't have an IO thread, // see bug #1292702). @@ -817,7 +818,8 @@ int BrowserMain(const MainFunctionParams& parameters) { // Importing other browser settings is done in a browser-like process // that exits when this task has finished. #if defined(OS_WIN) - if (parsed_command_line.HasSwitch(switches::kImport)) + if (parsed_command_line.HasSwitch(switches::kImport) || + parsed_command_line.HasSwitch(switches::kImportFromFile)) return FirstRun::ImportNow(profile, parsed_command_line); #endif diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h index 2bcecb0..910edf56 100644 --- a/chrome/browser/first_run.h +++ b/chrome/browser/first_run.h @@ -45,10 +45,9 @@ class FirstRun { // Creates the quick launch shortcut to chrome for the current user. Returns // false if it fails. It will overwrite the shortcut if it exists. static bool CreateChromeQuickLaunchShortcut(); - // Import browser items in this process. The browser and the items to - // import are encoded int the command line. This function is paired with - // FirstRun::ImportSettings(). This function might or might not show - // a visible UI depending on the cmdline parameters. + // Import bookmarks and browser items in this process. This function is + // paired with FirstRun::ImportSettings(). This function might or might not + // show a visible UI depending on the cmdline parameters. static int ImportNow(Profile* profile, const CommandLine& cmdline); #endif // OS_WIN @@ -100,6 +99,14 @@ class FirstRun { static bool SetShowWelcomePagePref(); private: +#if defined(OS_WIN) + // Import bookmarks from an html file. The path to the file is provided in + // the command line. + static int ImportFromFile(Profile* profile, const CommandLine& cmdline); + // Import browser items in this process. The browser and the items to + // import are encoded int the command line. + static int ImportFromBrowser(Profile* profile, const CommandLine& cmdline); +#endif // OS_WIN // This class is for scoping purposes. DISALLOW_IMPLICIT_CONSTRUCTORS(FirstRun); }; diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index e3a3b52..e4959e0 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -672,7 +672,36 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); } -int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { +int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { + std::wstring file_path = cmdline.GetSwitchValue(switches::kImportFromFile); + if (file_path.empty()) { + NOTREACHED(); + return false; + } + scoped_refptr<ImporterHost> importer_host = new ImporterHost(); + FirstRunImportObserver observer; + + importer_host->set_headless(); + + ProfileInfo profile_info; + profile_info.browser_type = importer::BOOKMARKS_HTML; + profile_info.source_path = file_path; + + StartImportingWithUI( + NULL, + importer::FAVORITES, + importer_host, + profile_info, + profile, + &observer, + true); + + observer.RunLoop(); + return observer.import_result(); +} + +int FirstRun::ImportFromBrowser(Profile* profile, + const CommandLine& cmdline) { std::wstring import_info = cmdline.GetSwitchValue(switches::kImport); if (import_info.empty()) { NOTREACHED(); @@ -707,6 +736,19 @@ int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { return observer.import_result(); } +int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { + int return_code = true; + if (cmdline.HasSwitch(switches::kImportFromFile)) { + // Silently import preset bookmarks from file. + // This is an OEM scenario. + return_code = ImportFromFile(profile, cmdline); + } + if (cmdline.HasSwitch(switches::kImport)) { + return_code = ImportFromBrowser(profile, cmdline); + } + return return_code; +} + ////////////////////////////////////////////////////////////////////////// namespace { |