Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 // static | 98 // static |
| 99 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, | 99 bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, |
| 100 MasterPrefs* out_prefs) { | 100 MasterPrefs* out_prefs) { |
| 101 DCHECK(!user_data_dir.empty()); | 101 DCHECK(!user_data_dir.empty()); |
| 102 | 102 |
| 103 // The standard location of the master prefs is next to the chrome binary. | 103 // The standard location of the master prefs is next to the chrome binary. |
| 104 FilePath master_prefs; | 104 FilePath master_prefs; |
| 105 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | 105 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
| 106 return true; | 106 return true; |
| 107 master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs); | 107 master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs); |
| 108 | |
| 109 installer::MasterPreferences prefs(master_prefs); | 108 installer::MasterPreferences prefs(master_prefs); |
| 110 if (!prefs.read_from_file()) | 109 if (!prefs.read_from_file()) |
| 111 return true; | 110 return true; |
| 112 | 111 |
| 113 out_prefs->new_tabs = prefs.GetFirstRunTabs(); | 112 out_prefs->new_tabs = prefs.GetFirstRunTabs(); |
| 114 | 113 |
| 115 bool value = false; | 114 bool value = false; |
| 116 | 115 |
| 117 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
| 118 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/ | 117 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/ |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 items = items | importer::SEARCH_ENGINES; | 543 items = items | importer::SEARCH_ENGINES; |
| 545 } | 544 } |
| 546 } else if (import_items & importer::SEARCH_ENGINES) { | 545 } else if (import_items & importer::SEARCH_ENGINES) { |
| 547 items = items | importer::SEARCH_ENGINES; | 546 items = items | importer::SEARCH_ENGINES; |
| 548 } | 547 } |
| 549 | 548 |
| 550 // Bookmarks are never imported, unless turned on in master_preferences. | 549 // Bookmarks are never imported, unless turned on in master_preferences. |
| 551 if (import_items & importer::FAVORITES) | 550 if (import_items & importer::FAVORITES) |
| 552 items = items | importer::FAVORITES; | 551 items = items | importer::FAVORITES; |
| 553 | 552 |
| 553 // Write import preferences to user profile if they are managed by policy | |
| 554 // in order to get the combination of master_preferences and policy, then | |
| 555 // read preferences back out to adjust the items to be imported to reflect | |
| 556 // policy. | |
| 557 PrefService* user_prefs = profile->GetPrefs(); | |
| 558 | |
| 559 if (user_prefs->FindPreference(prefs::kImportBookmarks)->IsManaged()) { | |
| 560 user_prefs->SetBoolean(prefs::kImportBookmarks, | |
| 561 (items & importer::FAVORITES) != 0); | |
|
Mattias Nissler (ping if slow)
2011/07/20 09:28:31
align with previous line, also below
| |
| 562 | |
| 563 if (user_prefs->GetBoolean(prefs::kImportBookmarks)) | |
| 564 items = items | importer::FAVORITES; | |
| 565 else | |
| 566 items = items & (~importer::FAVORITES); | |
| 567 } | |
| 568 | |
| 569 if (user_prefs->FindPreference(prefs::kImportHistory)->IsManaged()) { | |
| 570 user_prefs->SetBoolean(prefs::kImportHistory, | |
| 571 (items & importer::HISTORY) != 0); | |
| 572 | |
| 573 if (user_prefs->GetBoolean(prefs::kImportHistory)) | |
| 574 items = items | importer::HISTORY; | |
| 575 else | |
| 576 items = items & (~importer::HISTORY); | |
| 577 } | |
| 578 | |
| 579 if (user_prefs->FindPreference(prefs::kImportHomepage)->IsManaged()) { | |
| 580 user_prefs->SetBoolean(prefs::kImportHomepage, | |
| 581 (items & importer::HOME_PAGE) != 0); | |
| 582 | |
| 583 if (user_prefs->GetBoolean(prefs::kImportHomepage)) | |
| 584 items = items | importer::HOME_PAGE; | |
| 585 else | |
| 586 items = items & (~importer::HOME_PAGE); | |
| 587 } | |
| 588 | |
| 589 if (user_prefs->FindPreference(prefs::kImportSearchEngine)->IsManaged()) { | |
| 590 user_prefs->SetBoolean(prefs::kImportSearchEngine, | |
| 591 (items & importer::SEARCH_ENGINES) != 0); | |
| 592 | |
| 593 if (user_prefs->GetBoolean(prefs::kImportSearchEngine)) | |
| 594 items = items | importer::SEARCH_ENGINES; | |
| 595 else | |
| 596 items = items & (~importer::SEARCH_ENGINES); | |
| 597 } | |
| 598 | |
| 554 ImportSettings(profile, importer_host, importer_list, items); | 599 ImportSettings(profile, importer_host, importer_list, items); |
| 555 } | 600 } |
| 556 | 601 |
| 557 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 602 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
| 558 | 603 |
| 559 // Launch the search engine dialog only for certain builds, and only if the | 604 // Launch the search engine dialog only for certain builds, and only if the |
| 560 // user has not already set preferences. | 605 // user has not already set preferences. |
| 561 if (IsOrganicFirstRun() && !local_state_file_exists) { | 606 if (IsOrganicFirstRun() && !local_state_file_exists) { |
| 562 // The home page string may be set in the preferences, but the user should | 607 // The home page string may be set in the preferences, but the user should |
| 563 // initially use Chrome with the NTP as home page in organic builds. | 608 // initially use Chrome with the NTP as home page in organic builds. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 if (!observer->ended()) { | 694 if (!observer->ended()) { |
| 650 observer->set_should_quit_message_loop(); | 695 observer->set_should_quit_message_loop(); |
| 651 MessageLoop::current()->Run(); | 696 MessageLoop::current()->Run(); |
| 652 } | 697 } |
| 653 | 698 |
| 654 // Unfortunately there's no success/fail signal in ImporterHost. | 699 // Unfortunately there's no success/fail signal in ImporterHost. |
| 655 return true; | 700 return true; |
| 656 } | 701 } |
| 657 | 702 |
| 658 #endif // OS_POSIX | 703 #endif // OS_POSIX |
| OLD | NEW |