Chromium Code Reviews| Index: chrome/browser/first_run_win.cc |
| =================================================================== |
| --- chrome/browser/first_run_win.cc (revision 41958) |
| +++ chrome/browser/first_run_win.cc (working copy) |
| @@ -671,7 +671,37 @@ |
| 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; |
| + } |
| + |
|
cpu_(ooo_6.6-7.5)
2010/03/22 17:21:27
remove empty line so it looks same as lines 717-71
huanr
2010/03/22 17:56:11
Done.
|
| + scoped_refptr<ImporterHost> importer_host = new ImporterHost(); |
| + FirstRunImportObserver observer; |
| + |
| + importer_host->set_headless(); |
| + |
| + ProfileInfo profile_info; |
| + profile_info.browser_type = BOOKMARKS_HTML; |
| + profile_info.source_path = file_path; |
| + |
| + StartImportingWithUI( |
| + NULL, |
| + 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(); |
| @@ -706,6 +736,19 @@ |
| return observer.import_result(); |
| } |
| +int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { |
| + int return_code = true; |
|
cpu_(ooo_6.6-7.5)
2010/03/22 17:21:27
return_code = false ?
huanr
2010/03/22 17:56:11
I meant returning true if no import is needed.
|
| + 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 { |