Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2338)

Unified Diff: chrome/browser/first_run/first_run.cc

Issue 7390027: Added group policies to enable/disable importing of data from other browsers. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/first_run/first_run.cc
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 51dd75645ea1c44e8f5889e29b635c7a417ae90a..c1fa5fb49225043070e42bf94bee13f641fa7b68 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -99,13 +99,11 @@ int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
MasterPrefs* out_prefs) {
DCHECK(!user_data_dir.empty());
-
Mattias Nissler (ping if slow) 2011/07/18 15:02:30 Please don't remove white space before comments.
// The standard location of the master prefs is next to the chrome binary.
FilePath master_prefs;
if (!PathService::Get(base::DIR_EXE, &master_prefs))
return true;
master_prefs = master_prefs.AppendASCII(installer::kDefaultMasterPrefs);
-
installer::MasterPreferences prefs(master_prefs);
if (!prefs.read_from_file())
return true;
@@ -495,9 +493,7 @@ void FirstRun::AutoImport(
// when a CopyData message comes in; this causes the message to be silently
// discarded, which is the correct behavior during the import process.
process_singleton->Lock(NULL);
-
Mattias Nissler (ping if slow) 2011/07/18 15:02:30 why did you remove this?
PlatformSetup();
-
Mattias Nissler (ping if slow) 2011/07/18 15:02:30 and this?
FilePath local_state_path;
PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
bool local_state_file_exists = file_util::PathExists(local_state_path);
@@ -550,6 +546,53 @@ void FirstRun::AutoImport(
if (import_items & importer::FAVORITES)
items = items | importer::FAVORITES;
Mattias Nissler (ping if slow) 2011/07/18 15:02:30 Only one blank line before comments.
+
+ // Write import preferences to user profile if they are not user controlled
+ // in order to get the combination of master_preferences and policy, then
+ // read preferences back out to adjust the items to be imported to reflect
+ // 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
+ PrefService* user_prefs = profile->GetPrefs();
+
+ if (user_prefs->FindPreference(prefs::kImportBookmarks)->IsManaged()) {
+ user_prefs->SetBoolean(prefs::kImportBookmarks,
+ (items & importer::FAVORITES) != 0);
+
+ if (user_prefs->GetBoolean(prefs::kImportBookmarks))
+ items = items | importer::FAVORITES;
+ else
+ items = items & (~importer::FAVORITES);
+ }
+
+ if (user_prefs->FindPreference(prefs::kImportHistory)->IsManaged()) {
+ user_prefs->SetBoolean(prefs::kImportHistory,
+ (items & importer::HISTORY) != 0);
+
+ if (user_prefs->GetBoolean(prefs::kImportHistory))
+ items = items | importer::HISTORY;
+ else
+ items = items & (~importer::HISTORY);
+ }
+
+ if (user_prefs->FindPreference(prefs::kImportHomepage)->IsManaged()) {
+ user_prefs->SetBoolean(prefs::kImportHomepage,
+ (items & importer::HOME_PAGE) != 0);
+
+ if (user_prefs->GetBoolean(prefs::kImportHomepage))
+ items = items | importer::HOME_PAGE;
+ else
+ items = items & (~importer::HOME_PAGE);
+ }
+
+ if (user_prefs->FindPreference(prefs::kImportSearchEngine)->IsManaged()) {
+ user_prefs->SetBoolean(prefs::kImportSearchEngine,
+ (items & importer::SEARCH_ENGINES) != 0);
+
+ if (user_prefs->GetBoolean(prefs::kImportSearchEngine))
+ items = items | importer::SEARCH_ENGINES;
+ else
+ items = items & (~importer::SEARCH_ENGINES);
+ }
+
ImportSettings(profile, importer_host, importer_list, items);
}

Powered by Google App Engine
This is Rietveld 408576698