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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 549 |
550 ProcessMasterPreferencesResult ProcessMasterPreferences( | 550 ProcessMasterPreferencesResult ProcessMasterPreferences( |
551 const FilePath& user_data_dir, | 551 const FilePath& user_data_dir, |
552 MasterPrefs* out_prefs) { | 552 MasterPrefs* out_prefs) { |
553 DCHECK(!user_data_dir.empty()); | 553 DCHECK(!user_data_dir.empty()); |
554 | 554 |
555 #if defined(OS_CHROMEOS) | 555 #if defined(OS_CHROMEOS) |
556 // Chrome OS has its own out-of-box-experience code. Create the sentinel to | 556 // Chrome OS has its own out-of-box-experience code. Create the sentinel to |
557 // mark the fact that we've run once but skip the full first-run flow. | 557 // mark the fact that we've run once but skip the full first-run flow. |
558 CreateSentinel(); | 558 CreateSentinel(); |
559 return SKIP_FIRST_RUN; | 559 return SKIP_FIRST_RUN_TASKS; |
560 #endif | 560 #endif |
561 | 561 |
562 FilePath master_prefs_path; | 562 FilePath master_prefs_path; |
563 scoped_ptr<installer::MasterPreferences> | 563 scoped_ptr<installer::MasterPreferences> |
564 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); | 564 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); |
565 if (!install_prefs.get()) | 565 if (!install_prefs.get()) |
566 return SHOW_FIRST_RUN; | 566 return DO_FIRST_RUN_TASKS; |
567 | 567 |
568 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); | 568 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); |
569 | 569 |
570 internal::SetRLZPref(out_prefs, install_prefs.get()); | 570 internal::SetRLZPref(out_prefs, install_prefs.get()); |
571 | 571 |
572 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 572 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
573 return EULA_EXIT_NOW; | 573 return EULA_EXIT_NOW; |
574 | 574 |
575 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 575 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
576 return SHOW_FIRST_RUN; | 576 return DO_FIRST_RUN_TASKS; |
577 | 577 |
578 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 578 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
579 | 579 |
580 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, | 580 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, |
581 install_prefs.get()); | 581 install_prefs.get()); |
582 | 582 |
583 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 583 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
584 internal::SetDefaultBrowser(install_prefs.get()); | 584 internal::SetDefaultBrowser(install_prefs.get()); |
585 | 585 |
586 return SHOW_FIRST_RUN; | 586 return DO_FIRST_RUN_TASKS; |
587 } | 587 } |
588 | 588 |
589 void AutoImport( | 589 void AutoImport( |
590 Profile* profile, | 590 Profile* profile, |
591 bool homepage_defined, | 591 bool homepage_defined, |
592 int import_items, | 592 int import_items, |
593 int dont_import_items, | 593 int dont_import_items, |
594 ProcessSingleton* process_singleton) { | 594 ProcessSingleton* process_singleton) { |
595 #if !defined(USE_AURA) | 595 #if !defined(USE_AURA) |
596 // We need to avoid dispatching new tabs when we are importing because | 596 // We need to avoid dispatching new tabs when we are importing because |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 internal::ImportSettings(profile, importer_host, importer_list, items); | 671 internal::ImportSettings(profile, importer_host, importer_list, items); |
672 } | 672 } |
673 | 673 |
674 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 674 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
675 | 675 |
676 process_singleton->Unlock(); | 676 process_singleton->Unlock(); |
677 first_run::CreateSentinel(); | 677 first_run::CreateSentinel(); |
678 #endif // !defined(USE_AURA) | 678 #endif // !defined(USE_AURA) |
679 } | 679 } |
680 | 680 |
681 void DoFirstRunTasks(Profile* profile, bool make_chrome_default) { | 681 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
682 if (make_chrome_default && | 682 if (make_chrome_default && |
683 ShellIntegration::CanSetAsDefaultBrowser() == | 683 ShellIntegration::CanSetAsDefaultBrowser() == |
684 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 684 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
685 ShellIntegration::SetAsDefaultBrowser(); | 685 ShellIntegration::SetAsDefaultBrowser(); |
686 } | 686 } |
687 | 687 |
688 #if !defined(USE_AURA) | 688 #if !defined(USE_AURA) |
689 FilePath local_state_path; | 689 FilePath local_state_path; |
690 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 690 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
691 bool local_state_file_exists = file_util::PathExists(local_state_path); | 691 bool local_state_file_exists = file_util::PathExists(local_state_path); |
692 | 692 |
693 // Launch the first run dialog only for certain builds, and only if the user | 693 // Launch the first run dialog only for certain builds, and only if the user |
694 // has not already set preferences. | 694 // has not already set preferences. |
695 if (internal::IsOrganicFirstRun() && !local_state_file_exists) { | 695 if (internal::IsOrganicFirstRun() && !local_state_file_exists) { |
696 startup_metric_utils::SetNonBrowserUIDisplayed(); | 696 startup_metric_utils::SetNonBrowserUIDisplayed(); |
697 ShowFirstRunDialog(profile); | 697 ShowFirstRunDialog(profile); |
698 } | 698 } |
699 // Display the first run bubble if there is a default search provider. | 699 // Display the first run bubble if there is a default search provider. |
700 TemplateURLService* template_url = | 700 TemplateURLService* template_url = |
701 TemplateURLServiceFactory::GetForProfile(profile); | 701 TemplateURLServiceFactory::GetForProfile(profile); |
702 if (template_url && template_url->GetDefaultSearchProvider()) | 702 if (template_url && template_url->GetDefaultSearchProvider()) |
703 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 703 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
704 SetShowWelcomePagePref(); | 704 SetShowWelcomePagePref(); |
705 SetPersonalDataManagerFirstRunPref(); | 705 SetPersonalDataManagerFirstRunPref(); |
706 #endif // !defined(USE_AURA) | 706 #endif // !defined(USE_AURA) |
| 707 |
| 708 internal::DoPostImportPlatformSpecificTasks(); |
707 } | 709 } |
708 | 710 |
709 } // namespace first_run | 711 } // namespace first_run |
OLD | NEW |