Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/first_run.h" | 5 #include "chrome/browser/first_run.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 ImportProcessRunner import_runner(import_process); | 664 ImportProcessRunner import_runner(import_process); |
| 665 | 665 |
| 666 // Import process finished. Reload the prefs, because importer may set | 666 // Import process finished. Reload the prefs, because importer may set |
| 667 // the pref value. | 667 // the pref value. |
| 668 if (profile) | 668 if (profile) |
| 669 profile->GetPrefs()->ReloadPersistentPrefs(); | 669 profile->GetPrefs()->ReloadPersistentPrefs(); |
| 670 | 670 |
| 671 return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); | 671 return (import_runner.exit_code() == ResultCodes::NORMAL_EXIT); |
| 672 } | 672 } |
| 673 | 673 |
| 674 int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { | 674 int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { |
| 675 std::wstring file_path = cmdline.GetSwitchValue(switches::kImportFromFile); | |
| 676 if (file_path.empty()) { | |
| 677 NOTREACHED(); | |
| 678 return false; | |
| 679 } | |
| 680 | |
|
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.
| |
| 681 scoped_refptr<ImporterHost> importer_host = new ImporterHost(); | |
| 682 FirstRunImportObserver observer; | |
| 683 | |
| 684 importer_host->set_headless(); | |
| 685 | |
| 686 ProfileInfo profile_info; | |
| 687 profile_info.browser_type = BOOKMARKS_HTML; | |
| 688 profile_info.source_path = file_path; | |
| 689 | |
| 690 StartImportingWithUI( | |
| 691 NULL, | |
| 692 FAVORITES, | |
| 693 importer_host, | |
| 694 profile_info, | |
| 695 profile, | |
| 696 &observer, | |
| 697 true); | |
| 698 | |
| 699 observer.RunLoop(); | |
| 700 return observer.import_result(); | |
| 701 } | |
| 702 | |
| 703 int FirstRun::ImportFromBrowser(Profile* profile, | |
| 704 const CommandLine& cmdline) { | |
| 675 std::wstring import_info = cmdline.GetSwitchValue(switches::kImport); | 705 std::wstring import_info = cmdline.GetSwitchValue(switches::kImport); |
| 676 if (import_info.empty()) { | 706 if (import_info.empty()) { |
| 677 NOTREACHED(); | 707 NOTREACHED(); |
| 678 return false; | 708 return false; |
| 679 } | 709 } |
| 680 int browser_type = 0; | 710 int browser_type = 0; |
| 681 int items_to_import = 0; | 711 int items_to_import = 0; |
| 682 HWND parent_window = NULL; | 712 HWND parent_window = NULL; |
| 683 if (!DecodeImportParams(import_info, &browser_type, &items_to_import, | 713 if (!DecodeImportParams(import_info, &browser_type, &items_to_import, |
| 684 &parent_window)) { | 714 &parent_window)) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 699 items_to_import, | 729 items_to_import, |
| 700 importer_host, | 730 importer_host, |
| 701 importer_host->GetSourceProfileInfoForBrowserType(browser_type), | 731 importer_host->GetSourceProfileInfoForBrowserType(browser_type), |
| 702 profile, | 732 profile, |
| 703 &observer, | 733 &observer, |
| 704 true); | 734 true); |
| 705 observer.RunLoop(); | 735 observer.RunLoop(); |
| 706 return observer.import_result(); | 736 return observer.import_result(); |
| 707 } | 737 } |
| 708 | 738 |
| 739 int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { | |
| 740 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.
| |
| 741 if (cmdline.HasSwitch(switches::kImportFromFile)) { | |
| 742 // Silently import preset bookmarks from file. | |
| 743 // This is an OEM scenario. | |
| 744 return_code = ImportFromFile(profile, cmdline); | |
| 745 } | |
| 746 if (cmdline.HasSwitch(switches::kImport)) { | |
| 747 return_code = ImportFromBrowser(profile, cmdline); | |
| 748 } | |
| 749 return return_code; | |
| 750 } | |
| 751 | |
| 709 ////////////////////////////////////////////////////////////////////////// | 752 ////////////////////////////////////////////////////////////////////////// |
| 710 | 753 |
| 711 namespace { | 754 namespace { |
| 712 | 755 |
| 713 const wchar_t kHelpCenterUrl[] = | 756 const wchar_t kHelpCenterUrl[] = |
| 714 L"http://www.google.com/support/chrome/bin/answer.py?answer=150752"; | 757 L"http://www.google.com/support/chrome/bin/answer.py?answer=150752"; |
| 715 | 758 |
| 716 // This class displays a modal dialog using the views system. The dialog asks | 759 // This class displays a modal dialog using the views system. The dialog asks |
| 717 // the user to give chrome another try. This class only handles the UI so the | 760 // the user to give chrome another try. This class only handles the UI so the |
| 718 // resulting actions are up to the caller. One version looks like this: | 761 // resulting actions are up to the caller. One version looks like this: |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 | 1018 |
| 976 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { | 1019 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { |
| 977 if (version > 10000) { | 1020 if (version > 10000) { |
| 978 // This is a test value. We want to make sure we exercise | 1021 // This is a test value. We want to make sure we exercise |
| 979 // returning this early. See EarlyReturnTest test harness. | 1022 // returning this early. See EarlyReturnTest test harness. |
| 980 return Upgrade::TD_NOT_NOW; | 1023 return Upgrade::TD_NOT_NOW; |
| 981 } | 1024 } |
| 982 TryChromeDialog td; | 1025 TryChromeDialog td; |
| 983 return td.ShowModal(); | 1026 return td.ShowModal(); |
| 984 } | 1027 } |
| OLD | NEW |