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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 NOTIMPLEMENTED(); | 92 NOTIMPLEMENTED(); |
93 #endif | 93 #endif |
94 } | 94 } |
95 return return_code; | 95 return return_code; |
96 } | 96 } |
97 | 97 |
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 | |
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
Please don't remove white space before comments.
| |
103 // The standard location of the master prefs is next to the chrome binary. | 102 // The standard location of the master prefs is next to the chrome binary. |
104 FilePath master_prefs; | 103 FilePath master_prefs; |
105 if (!PathService::Get(base::DIR_EXE, &master_prefs)) | 104 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
106 return true; | 105 return true; |
107 master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs); | 106 master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs); |
108 | |
109 installer::MasterPreferences prefs(master_prefs); | 107 installer::MasterPreferences prefs(master_prefs); |
110 if (!prefs.read_from_file()) | 108 if (!prefs.read_from_file()) |
111 return true; | 109 return true; |
112 | 110 |
113 out_prefs->new_tabs = prefs.GetFirstRunTabs(); | 111 out_prefs->new_tabs = prefs.GetFirstRunTabs(); |
114 | 112 |
115 bool value = false; | 113 bool value = false; |
116 | 114 |
117 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
118 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/ | 116 // RLZ is currently a Windows-only phenomenon. When it comes to the Mac/ |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 bool search_engine_experiment, | 486 bool search_engine_experiment, |
489 bool randomize_search_engine_experiment, | 487 bool randomize_search_engine_experiment, |
490 bool make_chrome_default, | 488 bool make_chrome_default, |
491 ProcessSingleton* process_singleton) { | 489 ProcessSingleton* process_singleton) { |
492 // We need to avoid dispatching new tabs when we are importing because | 490 // We need to avoid dispatching new tabs when we are importing because |
493 // that will lead to data corruption or a crash. Because there is no UI for | 491 // that will lead to data corruption or a crash. Because there is no UI for |
494 // the import process, we pass NULL as the window to bring to the foreground | 492 // the import process, we pass NULL as the window to bring to the foreground |
495 // when a CopyData message comes in; this causes the message to be silently | 493 // when a CopyData message comes in; this causes the message to be silently |
496 // discarded, which is the correct behavior during the import process. | 494 // discarded, which is the correct behavior during the import process. |
497 process_singleton->Lock(NULL); | 495 process_singleton->Lock(NULL); |
498 | |
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
why did you remove this?
| |
499 PlatformSetup(); | 496 PlatformSetup(); |
500 | |
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
and this?
| |
501 FilePath local_state_path; | 497 FilePath local_state_path; |
502 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 498 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
503 bool local_state_file_exists = file_util::PathExists(local_state_path); | 499 bool local_state_file_exists = file_util::PathExists(local_state_path); |
504 | 500 |
505 scoped_refptr<ImporterHost> importer_host; | 501 scoped_refptr<ImporterHost> importer_host; |
506 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 502 // TODO(csilv,mirandac): Out-of-process import has only been qualified on |
507 // MacOS X, so we will only use it on that platform since it is required. | 503 // MacOS X, so we will only use it on that platform since it is required. |
508 // Remove this conditional logic once oop import is qualified for | 504 // Remove this conditional logic once oop import is qualified for |
509 // Linux/Windows. http://crbug.com/22142 | 505 // Linux/Windows. http://crbug.com/22142 |
510 #if defined(OS_MACOSX) | 506 #if defined(OS_MACOSX) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 !local_state_file_exists) { | 538 !local_state_file_exists) { |
543 items = items | importer::SEARCH_ENGINES; | 539 items = items | importer::SEARCH_ENGINES; |
544 } | 540 } |
545 } else if (import_items & importer::SEARCH_ENGINES) { | 541 } else if (import_items & importer::SEARCH_ENGINES) { |
546 items = items | importer::SEARCH_ENGINES; | 542 items = items | importer::SEARCH_ENGINES; |
547 } | 543 } |
548 | 544 |
549 // Bookmarks are never imported, unless turned on in master_preferences. | 545 // Bookmarks are never imported, unless turned on in master_preferences. |
550 if (import_items & importer::FAVORITES) | 546 if (import_items & importer::FAVORITES) |
551 items = items | importer::FAVORITES; | 547 items = items | importer::FAVORITES; |
552 | 548 |
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
Only one blank line before comments.
| |
549 | |
550 // Write import preferences to user profile if they are not user controlled | |
551 // in order to get the combination of master_preferences and policy, then | |
552 // read preferences back out to adjust the items to be imported to reflect | |
553 // policy | |
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
Missing period.
Mattias Nissler (ping if slow)
2011/07/18 15:02:30
This also means that the default selection in the
simo
2011/07/19 12:24:47
It does select all the checkboxes if the correspon
Mattias Nissler (ping if slow)
2011/07/20 09:28:31
Yes, but what happens if no policy is present? Won
| |
554 PrefService* user_prefs = profile->GetPrefs(); | |
555 | |
556 if (user_prefs->FindPreference(prefs::kImportBookmarks)->IsManaged()) { | |
557 user_prefs->SetBoolean(prefs::kImportBookmarks, | |
558 (items & importer::FAVORITES) != 0); | |
559 | |
560 if (user_prefs->GetBoolean(prefs::kImportBookmarks)) | |
561 items = items | importer::FAVORITES; | |
562 else | |
563 items = items & (~importer::FAVORITES); | |
564 } | |
565 | |
566 if (user_prefs->FindPreference(prefs::kImportHistory)->IsManaged()) { | |
567 user_prefs->SetBoolean(prefs::kImportHistory, | |
568 (items & importer::HISTORY) != 0); | |
569 | |
570 if (user_prefs->GetBoolean(prefs::kImportHistory)) | |
571 items = items | importer::HISTORY; | |
572 else | |
573 items = items & (~importer::HISTORY); | |
574 } | |
575 | |
576 if (user_prefs->FindPreference(prefs::kImportHomepage)->IsManaged()) { | |
577 user_prefs->SetBoolean(prefs::kImportHomepage, | |
578 (items & importer::HOME_PAGE) != 0); | |
579 | |
580 if (user_prefs->GetBoolean(prefs::kImportHomepage)) | |
581 items = items | importer::HOME_PAGE; | |
582 else | |
583 items = items & (~importer::HOME_PAGE); | |
584 } | |
585 | |
586 if (user_prefs->FindPreference(prefs::kImportSearchEngine)->IsManaged()) { | |
587 user_prefs->SetBoolean(prefs::kImportSearchEngine, | |
588 (items & importer::SEARCH_ENGINES) != 0); | |
589 | |
590 if (user_prefs->GetBoolean(prefs::kImportSearchEngine)) | |
591 items = items | importer::SEARCH_ENGINES; | |
592 else | |
593 items = items & (~importer::SEARCH_ENGINES); | |
594 } | |
595 | |
553 ImportSettings(profile, importer_host, importer_list, items); | 596 ImportSettings(profile, importer_host, importer_list, items); |
554 } | 597 } |
555 | 598 |
556 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 599 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
557 | 600 |
558 // Launch the search engine dialog only for certain builds, and only if the | 601 // Launch the search engine dialog only for certain builds, and only if the |
559 // user has not already set preferences. | 602 // user has not already set preferences. |
560 if (IsOrganicFirstRun() && !local_state_file_exists) { | 603 if (IsOrganicFirstRun() && !local_state_file_exists) { |
561 // The home page string may be set in the preferences, but the user should | 604 // The home page string may be set in the preferences, but the user should |
562 // initially use Chrome with the NTP as home page in organic builds. | 605 // 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... | |
648 if (!observer->ended()) { | 691 if (!observer->ended()) { |
649 observer->set_should_quit_message_loop(); | 692 observer->set_should_quit_message_loop(); |
650 MessageLoop::current()->Run(); | 693 MessageLoop::current()->Run(); |
651 } | 694 } |
652 | 695 |
653 // Unfortunately there's no success/fail signal in ImporterHost. | 696 // Unfortunately there's no success/fail signal in ImporterHost. |
654 return true; | 697 return true; |
655 } | 698 } |
656 | 699 |
657 #endif // OS_POSIX | 700 #endif // OS_POSIX |
OLD | NEW |