| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 614 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
| 616 internal::SetDefaultBrowser(install_prefs.get()); | 615 internal::SetDefaultBrowser(install_prefs.get()); |
| 617 | 616 |
| 618 return DO_FIRST_RUN_TASKS; | 617 return DO_FIRST_RUN_TASKS; |
| 619 } | 618 } |
| 620 | 619 |
| 621 void AutoImport( | 620 void AutoImport( |
| 622 Profile* profile, | 621 Profile* profile, |
| 623 bool homepage_defined, | 622 bool homepage_defined, |
| 624 int import_items, | 623 int import_items, |
| 625 int dont_import_items, | 624 int dont_import_items) { |
| 626 ProcessSingleton* process_singleton) { | |
| 627 #if !defined(USE_AURA) | 625 #if !defined(USE_AURA) |
| 628 // We need to avoid dispatching new tabs when we are importing because | |
| 629 // that will lead to data corruption or a crash. Because there is no UI for | |
| 630 // the import process, we pass NULL as the window to bring to the foreground | |
| 631 // when a CopyData message comes in; this causes the message to be silently | |
| 632 // discarded, which is the correct behavior during the import process. | |
| 633 process_singleton->Lock(NULL); | |
| 634 | |
| 635 scoped_refptr<ImporterHost> importer_host; | 626 scoped_refptr<ImporterHost> importer_host; |
| 636 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 627 // TODO(csilv,mirandac): Out-of-process import has only been qualified on |
| 637 // MacOS X, so we will only use it on that platform since it is required. | 628 // MacOS X, so we will only use it on that platform since it is required. |
| 638 // Remove this conditional logic once oop import is qualified for | 629 // Remove this conditional logic once oop import is qualified for |
| 639 // Linux/Windows. http://crbug.com/22142 | 630 // Linux/Windows. http://crbug.com/22142 |
| 640 #if defined(OS_MACOSX) | 631 #if defined(OS_MACOSX) |
| 641 importer_host = new ExternalProcessImporterHost; | 632 importer_host = new ExternalProcessImporterHost; |
| 642 #else | 633 #else |
| 643 importer_host = new ImporterHost; | 634 importer_host = new ImporterHost; |
| 644 #endif | 635 #endif |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 importer::FAVORITES, | 691 importer::FAVORITES, |
| 701 items); | 692 items); |
| 702 | 693 |
| 703 profile_import_exited_successfully = | 694 profile_import_exited_successfully = |
| 704 internal::ImportSettings(profile, importer_host, importer_list, items); | 695 internal::ImportSettings(profile, importer_host, importer_list, items); |
| 705 DCHECK(profile_import_exited_successfully); | 696 DCHECK(profile_import_exited_successfully); |
| 706 } | 697 } |
| 707 | 698 |
| 708 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 699 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
| 709 | 700 |
| 710 process_singleton->Unlock(); | |
| 711 first_run::CreateSentinel(); | 701 first_run::CreateSentinel(); |
| 712 #endif // !defined(USE_AURA) | 702 #endif // !defined(USE_AURA) |
| 713 did_perform_profile_import = true; | 703 did_perform_profile_import = true; |
| 714 } | 704 } |
| 715 | 705 |
| 716 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 706 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
| 717 if (make_chrome_default && | 707 if (make_chrome_default && |
| 718 ShellIntegration::CanSetAsDefaultBrowser() == | 708 ShellIntegration::CanSetAsDefaultBrowser() == |
| 719 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 709 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
| 720 ShellIntegration::SetAsDefaultBrowser(); | 710 ShellIntegration::SetAsDefaultBrowser(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 743 internal::DoPostImportPlatformSpecificTasks(); | 733 internal::DoPostImportPlatformSpecificTasks(); |
| 744 } | 734 } |
| 745 | 735 |
| 746 bool DidPerformProfileImport(bool* exited_successfully) { | 736 bool DidPerformProfileImport(bool* exited_successfully) { |
| 747 if (exited_successfully) | 737 if (exited_successfully) |
| 748 *exited_successfully = profile_import_exited_successfully; | 738 *exited_successfully = profile_import_exited_successfully; |
| 749 return did_perform_profile_import; | 739 return did_perform_profile_import; |
| 750 } | 740 } |
| 751 | 741 |
| 752 } // namespace first_run | 742 } // namespace first_run |
| OLD | NEW |