| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 524 |
| 525 ProcessMasterPreferencesResult ProcessMasterPreferences( | 525 ProcessMasterPreferencesResult ProcessMasterPreferences( |
| 526 const FilePath& user_data_dir, | 526 const FilePath& user_data_dir, |
| 527 MasterPrefs* out_prefs) { | 527 MasterPrefs* out_prefs) { |
| 528 DCHECK(!user_data_dir.empty()); | 528 DCHECK(!user_data_dir.empty()); |
| 529 | 529 |
| 530 #if defined(OS_CHROMEOS) | 530 #if defined(OS_CHROMEOS) |
| 531 // Chrome OS has its own out-of-box-experience code. Create the sentinel to | 531 // Chrome OS has its own out-of-box-experience code. Create the sentinel to |
| 532 // mark the fact that we've run once but skip the full first-run flow. | 532 // mark the fact that we've run once but skip the full first-run flow. |
| 533 CreateSentinel(); | 533 CreateSentinel(); |
| 534 return SKIP_FIRST_RUN; | 534 return SKIP_FIRST_RUN_TASKS; |
| 535 #endif | 535 #endif |
| 536 | 536 |
| 537 FilePath master_prefs_path; | 537 FilePath master_prefs_path; |
| 538 scoped_ptr<installer::MasterPreferences> | 538 scoped_ptr<installer::MasterPreferences> |
| 539 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); | 539 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); |
| 540 if (!install_prefs.get()) | 540 if (!install_prefs.get()) |
| 541 return SHOW_FIRST_RUN; | 541 return DO_FIRST_RUN_TASKS; |
| 542 | 542 |
| 543 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); | 543 out_prefs->new_tabs = install_prefs->GetFirstRunTabs(); |
| 544 | 544 |
| 545 internal::SetRLZPref(out_prefs, install_prefs.get()); | 545 internal::SetRLZPref(out_prefs, install_prefs.get()); |
| 546 | 546 |
| 547 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 547 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
| 548 return EULA_EXIT_NOW; | 548 return EULA_EXIT_NOW; |
| 549 | 549 |
| 550 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 550 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
| 551 return SHOW_FIRST_RUN; | 551 return DO_FIRST_RUN_TASKS; |
| 552 | 552 |
| 553 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 553 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
| 554 | 554 |
| 555 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, | 555 internal::SetupMasterPrefsFromInstallPrefs(out_prefs, |
| 556 install_prefs.get()); | 556 install_prefs.get()); |
| 557 | 557 |
| 558 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | 558 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); |
| 559 internal::SetDefaultBrowser(install_prefs.get()); | 559 internal::SetDefaultBrowser(install_prefs.get()); |
| 560 | 560 |
| 561 return SHOW_FIRST_RUN; | 561 return DO_FIRST_RUN_TASKS; |
| 562 } | 562 } |
| 563 | 563 |
| 564 void AutoImport( | 564 void AutoImport( |
| 565 Profile* profile, | 565 Profile* profile, |
| 566 bool homepage_defined, | 566 bool homepage_defined, |
| 567 int import_items, | 567 int import_items, |
| 568 int dont_import_items, | 568 int dont_import_items, |
| 569 ProcessSingleton* process_singleton) { | 569 ProcessSingleton* process_singleton) { |
| 570 #if !defined(USE_AURA) | 570 #if !defined(USE_AURA) |
| 571 // We need to avoid dispatching new tabs when we are importing because | 571 // 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... |
| 646 internal::ImportSettings(profile, importer_host, importer_list, items); | 646 internal::ImportSettings(profile, importer_host, importer_list, items); |
| 647 } | 647 } |
| 648 | 648 |
| 649 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 649 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
| 650 | 650 |
| 651 process_singleton->Unlock(); | 651 process_singleton->Unlock(); |
| 652 first_run::CreateSentinel(); | 652 first_run::CreateSentinel(); |
| 653 #endif // !defined(USE_AURA) | 653 #endif // !defined(USE_AURA) |
| 654 } | 654 } |
| 655 | 655 |
| 656 void DoFirstRunTasks(Profile* profile, bool make_chrome_default) { | 656 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
| 657 if (make_chrome_default && | 657 if (make_chrome_default && |
| 658 ShellIntegration::CanSetAsDefaultBrowser() == | 658 ShellIntegration::CanSetAsDefaultBrowser() == |
| 659 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 659 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
| 660 ShellIntegration::SetAsDefaultBrowser(); | 660 ShellIntegration::SetAsDefaultBrowser(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 #if !defined(USE_AURA) | 663 #if !defined(USE_AURA) |
| 664 FilePath local_state_path; | 664 FilePath local_state_path; |
| 665 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 665 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
| 666 bool local_state_file_exists = file_util::PathExists(local_state_path); | 666 bool local_state_file_exists = file_util::PathExists(local_state_path); |
| 667 | 667 |
| 668 // Launch the first run dialog only for certain builds, and only if the user | 668 // Launch the first run dialog only for certain builds, and only if the user |
| 669 // has not already set preferences. | 669 // has not already set preferences. |
| 670 if (internal::IsOrganicFirstRun() && !local_state_file_exists) { | 670 if (internal::IsOrganicFirstRun() && !local_state_file_exists) { |
| 671 startup_metric_utils::SetNonBrowserUIDisplayed(); | 671 startup_metric_utils::SetNonBrowserUIDisplayed(); |
| 672 ShowFirstRunDialog(profile); | 672 ShowFirstRunDialog(profile); |
| 673 } | 673 } |
| 674 // Display the first run bubble if there is a default search provider. | 674 // Display the first run bubble if there is a default search provider. |
| 675 TemplateURLService* template_url = | 675 TemplateURLService* template_url = |
| 676 TemplateURLServiceFactory::GetForProfile(profile); | 676 TemplateURLServiceFactory::GetForProfile(profile); |
| 677 if (template_url && template_url->GetDefaultSearchProvider()) | 677 if (template_url && template_url->GetDefaultSearchProvider()) |
| 678 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 678 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
| 679 SetShowWelcomePagePref(); | 679 SetShowWelcomePagePref(); |
| 680 SetPersonalDataManagerFirstRunPref(); | 680 SetPersonalDataManagerFirstRunPref(); |
| 681 #endif // !defined(USE_AURA) | 681 #endif // !defined(USE_AURA) |
| 682 } | 682 } |
| 683 | 683 |
| 684 } // namespace first_run | 684 } // namespace first_run |
| OLD | NEW |