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 #include <memory> | |
grt (UTC plus 2)
2017/02/23 14:05:48
nit: still needed for std::unique_ptr
gab
2017/02/23 20:37:40
Hmm, right, and this is adding it..?!
grt (UTC plus 2)
2017/02/23 21:19:01
Wow. My brain swapped adding and removing. Guess I
| |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
14 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 192 |
192 void DoDelayedInstallExtensionsIfNeeded( | 193 void DoDelayedInstallExtensionsIfNeeded( |
193 installer::MasterPreferences* install_prefs) { | 194 installer::MasterPreferences* install_prefs) { |
194 base::DictionaryValue* extensions = 0; | 195 base::DictionaryValue* extensions = 0; |
195 if (install_prefs->GetExtensionsBlock(&extensions)) { | 196 if (install_prefs->GetExtensionsBlock(&extensions)) { |
196 DVLOG(1) << "Extensions block found in master preferences"; | 197 DVLOG(1) << "Extensions block found in master preferences"; |
197 DoDelayedInstallExtensions(); | 198 DoDelayedInstallExtensions(); |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 // Sets the |items| bitfield according to whether the import data specified by | |
202 // |import_type| should be be auto imported or not. | |
203 void SetImportItem(PrefService* user_prefs, | |
204 const char* pref_path, | |
205 int import_items, | |
206 int dont_import_items, | |
207 importer::ImportItem import_type, | |
208 int* items) { | |
209 // Work out whether an item is to be imported according to what is specified | |
210 // in master preferences. | |
211 bool should_import = false; | |
212 bool master_pref_set = | |
213 ((import_items | dont_import_items) & import_type) != 0; | |
214 bool master_pref = ((import_items & ~dont_import_items) & import_type) != 0; | |
215 | |
216 if (import_type == importer::HISTORY || | |
217 (import_type != importer::FAVORITES && | |
218 first_run::internal::IsOrganicFirstRun())) { | |
219 // History is always imported unless turned off in master_preferences. | |
220 // Search engines and home page are imported in organic builds only | |
221 // unless turned off in master_preferences. | |
222 should_import = !master_pref_set || master_pref; | |
223 } else { | |
224 // Bookmarks are never imported, unless turned on in master_preferences. | |
225 // Search engine and home page import behaviour is similar in non organic | |
226 // builds. | |
227 should_import = master_pref_set && master_pref; | |
228 } | |
229 | |
230 // If an import policy is set, import items according to policy. If no master | |
231 // preference is set, but a corresponding recommended policy is set, import | |
232 // item according to recommended policy. If both a master preference and a | |
233 // recommended policy is set, the master preference wins. If neither | |
234 // recommended nor managed policies are set, import item according to what we | |
235 // worked out above. | |
236 if (master_pref_set) | |
237 user_prefs->SetBoolean(pref_path, should_import); | |
238 | |
239 if (!user_prefs->FindPreference(pref_path)->IsDefaultValue()) { | |
240 if (user_prefs->GetBoolean(pref_path)) | |
241 *items |= import_type; | |
242 } else { | |
243 // no policy (recommended or managed) is set | |
244 if (should_import) | |
245 *items |= import_type; | |
246 } | |
247 | |
248 user_prefs->ClearPref(pref_path); | |
249 } | |
250 | |
251 // Launches the import, via |importer_host|, from |source_profile| into | 202 // Launches the import, via |importer_host|, from |source_profile| into |
252 // |target_profile| for the items specified in the |items_to_import| bitfield. | 203 // |target_profile| for the items specified in the |items_to_import| bitfield. |
253 // This may be done in a separate process depending on the platform, but it will | 204 // This may be done in a separate process depending on the platform, but it will |
254 // always block until done. | 205 // always block until done. |
255 void ImportFromSourceProfile(const importer::SourceProfile& source_profile, | 206 void ImportFromSourceProfile(const importer::SourceProfile& source_profile, |
256 Profile* target_profile, | 207 Profile* target_profile, |
257 uint16_t items_to_import) { | 208 uint16_t items_to_import) { |
258 // Deletes itself. | 209 // Deletes itself. |
259 ExternalProcessImporterHost* importer_host = | 210 ExternalProcessImporterHost* importer_host = |
260 new ExternalProcessImporterHost; | 211 new ExternalProcessImporterHost; |
(...skipping 30 matching lines...) Expand all Loading... | |
291 #endif | 242 #endif |
292 source_profile.source_path = base::FilePath(import_bookmarks_path_str); | 243 source_profile.source_path = base::FilePath(import_bookmarks_path_str); |
293 | 244 |
294 ImportFromSourceProfile(source_profile, profile, importer::FAVORITES); | 245 ImportFromSourceProfile(source_profile, profile, importer::FAVORITES); |
295 g_auto_import_state |= first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED; | 246 g_auto_import_state |= first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED; |
296 } | 247 } |
297 | 248 |
298 // Imports settings from the first profile in |importer_list|. | 249 // Imports settings from the first profile in |importer_list|. |
299 void ImportSettings(Profile* profile, | 250 void ImportSettings(Profile* profile, |
300 std::unique_ptr<ImporterList> importer_list, | 251 std::unique_ptr<ImporterList> importer_list, |
301 int items_to_import) { | 252 uint16_t items_to_import) { |
253 DCHECK(items_to_import); | |
302 const importer::SourceProfile& source_profile = | 254 const importer::SourceProfile& source_profile = |
303 importer_list->GetSourceProfileAt(0); | 255 importer_list->GetSourceProfileAt(0); |
304 // If no items to import then skip entirely. | |
305 if (!items_to_import) | |
306 return; | |
307 | 256 |
308 // Ensure that importers aren't requested to import items that they do not | 257 // Ensure that importers aren't requested to import items that they do not |
309 // support. If there is no overlap, skip. | 258 // support. If there is no overlap, skip. |
310 items_to_import &= source_profile.services_supported; | 259 items_to_import &= source_profile.services_supported; |
311 if (items_to_import) { | 260 if (items_to_import) |
312 ImportFromSourceProfile(source_profile, profile, items_to_import); | 261 ImportFromSourceProfile(source_profile, profile, items_to_import); |
313 } | |
314 | 262 |
315 g_auto_import_state |= first_run::AUTO_IMPORT_PROFILE_IMPORTED; | 263 g_auto_import_state |= first_run::AUTO_IMPORT_PROFILE_IMPORTED; |
316 } | 264 } |
317 | 265 |
318 GURL UrlFromString(const std::string& in) { | 266 GURL UrlFromString(const std::string& in) { |
319 return GURL(in); | 267 return GURL(in); |
320 } | 268 } |
321 | 269 |
322 void ConvertStringVectorToGURLVector( | 270 void ConvertStringVectorToGURLVector( |
323 const std::vector<std::string>& src, | 271 const std::vector<std::string>& src, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 if (g_browser_process->local_state()->GetBoolean( | 424 if (g_browser_process->local_state()->GetBoolean( |
477 prefs::kDefaultBrowserSettingEnabled)) { | 425 prefs::kDefaultBrowserSettingEnabled)) { |
478 shell_integration::SetAsDefaultBrowser(); | 426 shell_integration::SetAsDefaultBrowser(); |
479 } | 427 } |
480 } else if (make_chrome_default_for_user) { | 428 } else if (make_chrome_default_for_user) { |
481 shell_integration::SetAsDefaultBrowser(); | 429 shell_integration::SetAsDefaultBrowser(); |
482 } | 430 } |
483 } | 431 } |
484 } | 432 } |
485 | 433 |
434 void MapLegacyDistroPrefs(base::DictionaryValue* master_prefs_dict) { | |
grt (UTC plus 2)
2017/02/23 14:05:48
MasterPreferences::EnforceLegacyPreferences does s
gab
2017/02/23 20:37:40
Done.
| |
435 const base::DictionaryValue* distro_dict; | |
436 if (!master_prefs_dict->GetDictionary( | |
437 installer::master_preferences::kDistroDict, &distro_dict)) { | |
438 return; | |
439 } | |
440 | |
441 struct LegacyDistroPrefMapping { | |
grt (UTC plus 2)
2017/02/23 14:05:48
static constexpr struct {... (see comment below)
gab
2017/02/23 20:37:40
Done.
| |
442 const char* old_distro_pref_path; | |
443 const char* modern_pref_path; | |
444 } static constexpr kLegacyDistroPrefMappings[] = { | |
445 {installer::master_preferences::kDistroImportHistoryPref, | |
446 prefs::kImportHistory}, | |
447 {installer::master_preferences::kDistroImportHomePagePref, | |
448 prefs::kImportHomepage}, | |
449 {installer::master_preferences::kDistroImportSearchPref, | |
450 prefs::kImportSearchEngine}, | |
451 {installer::master_preferences::kDistroImportBookmarksPref, | |
452 prefs::kImportBookmarks}, | |
453 }; | |
454 | |
455 for (const auto& mapping : kLegacyDistroPrefMappings) { | |
456 const base::Value* value; | |
457 if (distro_dict->Get(mapping.old_distro_pref_path, &value)) { | |
458 bool bool_value = false; | |
459 bool success = value->GetAsBoolean(&bool_value); | |
460 DCHECK(success) << "This method assumes boolean mappings"; | |
461 master_prefs_dict->SetBoolean(mapping.modern_pref_path, bool_value); | |
462 } | |
463 } | |
464 } | |
465 | |
486 } // namespace | 466 } // namespace |
487 | 467 |
488 namespace first_run { | 468 namespace first_run { |
489 namespace internal { | 469 namespace internal { |
490 | 470 |
491 void SetupMasterPrefsFromInstallPrefs( | 471 void SetupMasterPrefsFromInstallPrefs( |
492 const installer::MasterPreferences& install_prefs, | 472 const installer::MasterPreferences& install_prefs, |
493 MasterPrefs* out_prefs) { | 473 MasterPrefs* out_prefs) { |
494 ConvertStringVectorToGURLVector( | 474 ConvertStringVectorToGURLVector( |
495 install_prefs.GetFirstRunTabs(), &out_prefs->new_tabs); | 475 install_prefs.GetFirstRunTabs(), &out_prefs->new_tabs); |
496 | 476 |
497 install_prefs.GetInt(installer::master_preferences::kDistroPingDelay, | 477 install_prefs.GetInt(installer::master_preferences::kDistroPingDelay, |
498 &out_prefs->ping_delay); | 478 &out_prefs->ping_delay); |
499 | 479 |
500 bool value = false; | |
501 if (install_prefs.GetBool( | |
502 installer::master_preferences::kDistroImportSearchPref, &value)) { | |
503 if (value) { | |
504 out_prefs->do_import_items |= importer::SEARCH_ENGINES; | |
505 } else { | |
506 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; | |
507 } | |
508 } | |
509 | |
510 // If we're suppressing the first-run bubble, set that preference now. | 480 // If we're suppressing the first-run bubble, set that preference now. |
511 // Otherwise, wait until the user has completed first run to set it, so the | 481 // Otherwise, wait until the user has completed first run to set it, so the |
512 // user is guaranteed to see the bubble iff they have completed the first run | 482 // user is guaranteed to see the bubble iff they have completed the first run |
513 // process. | 483 // process. |
484 bool value = false; | |
514 if (install_prefs.GetBool( | 485 if (install_prefs.GetBool( |
515 installer::master_preferences::kDistroSuppressFirstRunBubble, | 486 installer::master_preferences::kDistroSuppressFirstRunBubble, |
516 &value) && value) | 487 &value) && |
488 value) { | |
517 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SUPPRESS); | 489 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SUPPRESS); |
518 | |
519 if (install_prefs.GetBool( | |
520 installer::master_preferences::kDistroImportHistoryPref, | |
521 &value)) { | |
522 if (value) { | |
523 out_prefs->do_import_items |= importer::HISTORY; | |
524 } else { | |
525 out_prefs->dont_import_items |= importer::HISTORY; | |
526 } | |
527 } | |
528 | |
529 std::string not_used; | |
530 out_prefs->homepage_defined = install_prefs.GetString( | |
531 prefs::kHomePage, ¬_used); | |
532 | |
533 if (install_prefs.GetBool( | |
534 installer::master_preferences::kDistroImportHomePagePref, | |
535 &value)) { | |
536 if (value) { | |
537 out_prefs->do_import_items |= importer::HOME_PAGE; | |
538 } else { | |
539 out_prefs->dont_import_items |= importer::HOME_PAGE; | |
540 } | |
541 } | |
542 | |
543 // Bookmarks are never imported unless specifically turned on. | |
544 if (install_prefs.GetBool( | |
545 installer::master_preferences::kDistroImportBookmarksPref, | |
546 &value)) { | |
547 if (value) | |
548 out_prefs->do_import_items |= importer::FAVORITES; | |
549 else | |
550 out_prefs->dont_import_items |= importer::FAVORITES; | |
551 } | 490 } |
552 | 491 |
553 if (install_prefs.GetBool( | 492 if (install_prefs.GetBool( |
554 installer::master_preferences::kMakeChromeDefaultForUser, | 493 installer::master_preferences::kMakeChromeDefaultForUser, |
555 &value) && value) { | 494 &value) && value) { |
556 out_prefs->make_chrome_default_for_user = true; | 495 out_prefs->make_chrome_default_for_user = true; |
557 } | 496 } |
558 | 497 |
559 if (install_prefs.GetBool( | 498 if (install_prefs.GetBool( |
560 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 499 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 bool no_first_run) { | 552 bool no_first_run) { |
614 return (force_first_run || (!has_sentinel && !no_first_run)) | 553 return (force_first_run || (!has_sentinel && !no_first_run)) |
615 ? FIRST_RUN_TRUE | 554 ? FIRST_RUN_TRUE |
616 : FIRST_RUN_FALSE; | 555 : FIRST_RUN_FALSE; |
617 } | 556 } |
618 | 557 |
619 } // namespace internal | 558 } // namespace internal |
620 | 559 |
621 MasterPrefs::MasterPrefs() | 560 MasterPrefs::MasterPrefs() |
622 : ping_delay(0), | 561 : ping_delay(0), |
623 homepage_defined(false), | |
624 do_import_items(0), | |
625 dont_import_items(0), | |
626 make_chrome_default_for_user(false), | 562 make_chrome_default_for_user(false), |
627 suppress_first_run_default_browser_prompt(false), | 563 suppress_first_run_default_browser_prompt(false), |
628 welcome_page_on_os_upgrade_enabled(true) { | 564 welcome_page_on_os_upgrade_enabled(true) { |
629 } | 565 } |
630 | 566 |
631 MasterPrefs::~MasterPrefs() {} | 567 MasterPrefs::~MasterPrefs() {} |
632 | 568 |
633 bool IsChromeFirstRun() { | 569 bool IsChromeFirstRun() { |
634 if (g_first_run == internal::FIRST_RUN_UNKNOWN) { | 570 if (g_first_run == internal::FIRST_RUN_UNKNOWN) { |
635 const base::CommandLine* command_line = | 571 const base::CommandLine* command_line = |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 std::unique_ptr<installer::MasterPreferences> install_prefs( | 678 std::unique_ptr<installer::MasterPreferences> install_prefs( |
743 LoadMasterPrefs()); | 679 LoadMasterPrefs()); |
744 | 680 |
745 // Default value in case master preferences is missing or corrupt, or | 681 // Default value in case master preferences is missing or corrupt, or |
746 // ping_delay is missing. | 682 // ping_delay is missing. |
747 out_prefs->ping_delay = 90; | 683 out_prefs->ping_delay = 90; |
748 if (install_prefs.get()) { | 684 if (install_prefs.get()) { |
749 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 685 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
750 return EULA_EXIT_NOW; | 686 return EULA_EXIT_NOW; |
751 | 687 |
688 std::unique_ptr<base::DictionaryValue> master_prefs_dict = | |
689 install_prefs->master_dictionary().CreateDeepCopy(); | |
690 MapLegacyDistroPrefs(master_prefs_dict.get()); | |
691 | |
752 if (!chrome_prefs::InitializePrefsFromMasterPrefs( | 692 if (!chrome_prefs::InitializePrefsFromMasterPrefs( |
753 profiles::GetDefaultProfileDir(user_data_dir), | 693 profiles::GetDefaultProfileDir(user_data_dir), |
754 install_prefs->master_dictionary())) { | 694 std::move(master_prefs_dict))) { |
755 DLOG(ERROR) << "Failed to initialize from master_preferences."; | 695 DLOG(ERROR) << "Failed to initialize from master_preferences."; |
756 } | 696 } |
757 | 697 |
758 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 698 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
759 | 699 |
760 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); | 700 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
761 } | 701 } |
762 | 702 |
763 return FIRST_RUN_PROCEED; | 703 return FIRST_RUN_PROCEED; |
764 } | 704 } |
765 | 705 |
766 void AutoImport( | 706 void AutoImport( |
767 Profile* profile, | 707 Profile* profile, |
768 bool homepage_defined, | |
769 int import_items, | |
770 int dont_import_items, | |
771 const std::string& import_bookmarks_path) { | 708 const std::string& import_bookmarks_path) { |
772 base::FilePath local_state_path; | 709 g_auto_import_state |= AUTO_IMPORT_CALLED; |
773 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | |
774 bool local_state_file_exists = base::PathExists(local_state_path); | |
775 | 710 |
776 // It may be possible to do the if block below asynchronously. In which case, | 711 // Use |profile|'s PrefService to determine what to import. It will reflect in |
777 // get rid of this RunLoop. http://crbug.com/366116. | 712 // order: |
778 base::RunLoop run_loop; | 713 // 1) Policies. |
779 std::unique_ptr<ImporterList> importer_list(new ImporterList()); | 714 // 2) Master preferences (used to initialize user prefs in |
780 importer_list->DetectSourceProfiles( | 715 // ProcessMasterPreferences()). |
781 g_browser_process->GetApplicationLocale(), | 716 // 3) Recommended policies. |
782 false, // include_interactive_profiles? | 717 // 4) Registered default. |
783 run_loop.QuitClosure()); | 718 PrefService* prefs = profile->GetPrefs(); |
784 run_loop.Run(); | 719 uint16_t items_to_import = 0; |
720 struct ImportItems { | |
721 const char* pref_path; | |
722 importer::ImportItem bit; | |
723 } static constexpr kImportItems[] = { | |
grt (UTC plus 2)
2017/02/23 14:05:48
nit: "static constexpr" should come first, and thi
gab
2017/02/23 20:37:40
Done.
| |
724 {prefs::kImportHistory, importer::HISTORY}, | |
grt (UTC plus 2)
2017/02/23 14:05:48
the pedant in me would like to see this sorted eit
gab
2017/02/23 20:37:40
Done.
| |
725 {prefs::kImportHomepage, importer::HOME_PAGE}, | |
726 {prefs::kImportSearchEngine, importer::SEARCH_ENGINES}, | |
727 {prefs::kImportBookmarks, importer::FAVORITES}, | |
728 }; | |
grt (UTC plus 2)
2017/02/23 14:05:48
prefs::kImportAutofillFormData and prefs::kImportS
gab
2017/02/23 20:37:40
Interesting, I guess it probably is =D (though in
| |
785 | 729 |
786 // Do import if there is an available profile for us to import. | 730 for (const auto& import_item : kImportItems) { |
787 if (importer_list->count() > 0) { | 731 if (prefs->GetBoolean(import_item.pref_path)) |
788 if (internal::IsOrganicFirstRun()) { | 732 items_to_import |= import_item.bit; |
789 // Home page is imported in organic builds only unless turned off or | |
790 // defined in master_preferences. | |
791 if (homepage_defined) { | |
792 dont_import_items |= importer::HOME_PAGE; | |
793 if (import_items & importer::HOME_PAGE) | |
794 import_items &= ~importer::HOME_PAGE; | |
795 } | |
796 // Search engines are not imported automatically in organic builds if the | |
797 // user already has a user preferences directory. | |
798 if (local_state_file_exists) { | |
799 dont_import_items |= importer::SEARCH_ENGINES; | |
800 if (import_items & importer::SEARCH_ENGINES) | |
801 import_items &= ~importer::SEARCH_ENGINES; | |
802 } | |
803 } | |
804 | |
805 PrefService* user_prefs = profile->GetPrefs(); | |
806 int items = 0; | |
807 | |
808 SetImportItem(user_prefs, | |
809 prefs::kImportHistory, | |
810 import_items, | |
811 dont_import_items, | |
812 importer::HISTORY, | |
813 &items); | |
814 SetImportItem(user_prefs, | |
815 prefs::kImportHomepage, | |
816 import_items, | |
817 dont_import_items, | |
818 importer::HOME_PAGE, | |
819 &items); | |
820 SetImportItem(user_prefs, | |
821 prefs::kImportSearchEngine, | |
822 import_items, | |
823 dont_import_items, | |
824 importer::SEARCH_ENGINES, | |
825 &items); | |
826 SetImportItem(user_prefs, | |
827 prefs::kImportBookmarks, | |
828 import_items, | |
829 dont_import_items, | |
830 importer::FAVORITES, | |
831 &items); | |
832 | |
833 importer::LogImporterUseToMetrics( | |
834 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); | |
835 | |
836 ImportSettings(profile, std::move(importer_list), items); | |
837 } | 733 } |
838 | 734 |
839 if (!import_bookmarks_path.empty()) { | 735 if (items_to_import) { |
840 ImportFromFile(profile, import_bookmarks_path); | 736 // It may be possible to do the if block below asynchronously. In which |
737 // case, get rid of this RunLoop. http://crbug.com/366116. | |
738 base::RunLoop run_loop; | |
739 std::unique_ptr<ImporterList> importer_list(new ImporterList()); | |
grt (UTC plus 2)
2017/02/23 14:05:48
nit:
auto importer_list = base::MakeUnique<Imp
gab
2017/02/23 20:37:40
this was cut-paste from above but why not :)
| |
740 importer_list->DetectSourceProfiles( | |
741 g_browser_process->GetApplicationLocale(), | |
742 false, // include_interactive_profiles? | |
743 run_loop.QuitClosure()); | |
744 run_loop.Run(); | |
745 | |
746 if (importer_list->count() > 0) { | |
747 importer::LogImporterUseToMetrics( | |
748 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); | |
749 | |
750 ImportSettings(profile, std::move(importer_list), items_to_import); | |
751 } | |
841 } | 752 } |
842 | 753 |
843 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 754 if (!import_bookmarks_path.empty()) |
844 | 755 ImportFromFile(profile, import_bookmarks_path); |
845 g_auto_import_state |= AUTO_IMPORT_CALLED; | |
846 } | 756 } |
847 | 757 |
848 void DoPostImportTasks(Profile* profile, bool make_chrome_default_for_user) { | 758 void DoPostImportTasks(Profile* profile, bool make_chrome_default_for_user) { |
849 // Only set default browser after import as auto import relies on the current | 759 // Only set default browser after import as auto import relies on the current |
850 // default browser to know what to import from. | 760 // default browser to know what to import from. |
851 ProcessDefaultBrowserPolicy(make_chrome_default_for_user); | 761 ProcessDefaultBrowserPolicy(make_chrome_default_for_user); |
852 | 762 |
853 // Display the first run bubble if there is a default search provider. | 763 // Display the first run bubble if there is a default search provider. |
854 TemplateURLService* template_url = | 764 TemplateURLService* template_url = |
855 TemplateURLServiceFactory::GetForProfile(profile); | 765 TemplateURLServiceFactory::GetForProfile(profile); |
856 if (template_url && template_url->GetDefaultSearchProvider()) | 766 if (template_url && template_url->GetDefaultSearchProvider()) |
857 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 767 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
858 SetShouldShowWelcomePage(); | 768 SetShouldShowWelcomePage(); |
859 SetShouldDoPersonalDataManagerFirstRun(); | 769 SetShouldDoPersonalDataManagerFirstRun(); |
860 | 770 |
861 internal::DoPostImportPlatformSpecificTasks(profile); | 771 internal::DoPostImportPlatformSpecificTasks(profile); |
862 } | 772 } |
863 | 773 |
864 uint16_t auto_import_state() { | 774 uint16_t auto_import_state() { |
865 return g_auto_import_state; | 775 return g_auto_import_state; |
866 } | 776 } |
867 | 777 |
868 } // namespace first_run | 778 } // namespace first_run |
OLD | NEW |