| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/extensions/updater/extension_updater.h" | 21 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 22 #include "chrome/browser/first_run/first_run_dialog.h" | 22 #include "chrome/browser/first_run/first_run_dialog.h" |
| 23 #include "chrome/browser/first_run/first_run_import_observer.h" | 23 #include "chrome/browser/first_run/first_run_import_observer.h" |
| 24 #include "chrome/browser/first_run/first_run_internal.h" | 24 #include "chrome/browser/first_run/first_run_internal.h" |
| 25 #include "chrome/browser/google/google_util.h" | 25 #include "chrome/browser/google/google_util.h" |
| 26 #include "chrome/browser/importer/external_process_importer_host.h" | 26 #include "chrome/browser/importer/external_process_importer_host.h" |
| 27 #include "chrome/browser/importer/importer_host.h" | 27 #include "chrome/browser/importer/importer_host.h" |
| 28 #include "chrome/browser/importer/importer_list.h" | 28 #include "chrome/browser/importer/importer_list.h" |
| 29 #include "chrome/browser/importer/importer_progress_dialog.h" | 29 #include "chrome/browser/importer/importer_progress_dialog.h" |
| 30 #include "chrome/browser/importer/importer_progress_observer.h" | 30 #include "chrome/browser/importer/importer_progress_observer.h" |
| 31 #include "chrome/browser/process_singleton.h" | |
| 32 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 33 #include "chrome/browser/search_engines/template_url_service.h" | 32 #include "chrome/browser/search_engines/template_url_service.h" |
| 34 #include "chrome/browser/search_engines/template_url_service_factory.h" | 33 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 35 #include "chrome/browser/shell_integration.h" | 34 #include "chrome/browser/shell_integration.h" |
| 36 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
| 37 #include "chrome/browser/ui/browser_finder.h" | 36 #include "chrome/browser/ui/browser_finder.h" |
| 38 #include "chrome/browser/ui/global_error/global_error_service.h" | 37 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 39 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 38 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 39 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 41 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 40 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 618 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
| 620 internal::SetDefaultBrowser(install_prefs.get()); | 619 internal::SetDefaultBrowser(install_prefs.get()); |
| 621 | 620 |
| 622 return DO_FIRST_RUN_TASKS; | 621 return DO_FIRST_RUN_TASKS; |
| 623 } | 622 } |
| 624 | 623 |
| 625 void AutoImport( | 624 void AutoImport( |
| 626 Profile* profile, | 625 Profile* profile, |
| 627 bool homepage_defined, | 626 bool homepage_defined, |
| 628 int import_items, | 627 int import_items, |
| 629 int dont_import_items, | 628 int dont_import_items) { |
| 630 ProcessSingleton* process_singleton) { | |
| 631 #if !defined(USE_AURA) | 629 #if !defined(USE_AURA) |
| 632 // We need to avoid dispatching new tabs when we are importing because | |
| 633 // that will lead to data corruption or a crash. Because there is no UI for | |
| 634 // the import process, we pass NULL as the window to bring to the foreground | |
| 635 // when a CopyData message comes in; this causes the message to be silently | |
| 636 // discarded, which is the correct behavior during the import process. | |
| 637 process_singleton->Lock(NULL); | |
| 638 | |
| 639 scoped_refptr<ImporterHost> importer_host; | 630 scoped_refptr<ImporterHost> importer_host; |
| 640 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 631 // TODO(csilv,mirandac): Out-of-process import has only been qualified on |
| 641 // MacOS X, so we will only use it on that platform since it is required. | 632 // MacOS X, so we will only use it on that platform since it is required. |
| 642 // Remove this conditional logic once oop import is qualified for | 633 // Remove this conditional logic once oop import is qualified for |
| 643 // Linux/Windows. http://crbug.com/22142 | 634 // Linux/Windows. http://crbug.com/22142 |
| 644 #if defined(OS_MACOSX) | 635 #if defined(OS_MACOSX) |
| 645 importer_host = new ExternalProcessImporterHost; | 636 importer_host = new ExternalProcessImporterHost; |
| 646 #else | 637 #else |
| 647 importer_host = new ImporterHost; | 638 importer_host = new ImporterHost; |
| 648 #endif | 639 #endif |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 importer::FAVORITES, | 695 importer::FAVORITES, |
| 705 items); | 696 items); |
| 706 | 697 |
| 707 profile_import_exited_successfully = | 698 profile_import_exited_successfully = |
| 708 internal::ImportSettings(profile, importer_host, importer_list, items); | 699 internal::ImportSettings(profile, importer_host, importer_list, items); |
| 709 DCHECK(profile_import_exited_successfully); | 700 DCHECK(profile_import_exited_successfully); |
| 710 } | 701 } |
| 711 | 702 |
| 712 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 703 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
| 713 | 704 |
| 714 process_singleton->Unlock(); | |
| 715 first_run::CreateSentinel(); | 705 first_run::CreateSentinel(); |
| 716 #endif // !defined(USE_AURA) | 706 #endif // !defined(USE_AURA) |
| 717 did_perform_profile_import = true; | 707 did_perform_profile_import = true; |
| 718 } | 708 } |
| 719 | 709 |
| 720 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 710 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
| 721 if (make_chrome_default && | 711 if (make_chrome_default && |
| 722 ShellIntegration::CanSetAsDefaultBrowser() == | 712 ShellIntegration::CanSetAsDefaultBrowser() == |
| 723 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 713 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
| 724 ShellIntegration::SetAsDefaultBrowser(); | 714 ShellIntegration::SetAsDefaultBrowser(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 747 internal::DoPostImportPlatformSpecificTasks(); | 737 internal::DoPostImportPlatformSpecificTasks(); |
| 748 } | 738 } |
| 749 | 739 |
| 750 bool DidPerformProfileImport(bool* exited_successfully) { | 740 bool DidPerformProfileImport(bool* exited_successfully) { |
| 751 if (exited_successfully) | 741 if (exited_successfully) |
| 752 *exited_successfully = profile_import_exited_successfully; | 742 *exited_successfully = profile_import_exited_successfully; |
| 753 return did_perform_profile_import; | 743 return did_perform_profile_import; |
| 754 } | 744 } |
| 755 | 745 |
| 756 } // namespace first_run | 746 } // namespace first_run |
| OLD | NEW |