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