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

Side by Side Diff: chrome/browser/prefs/profile_pref_store_manager.cc

Issue 2705113005: Update AutoImport to import nothing by default (in absence of policy and master_prefs). (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/prefs/profile_pref_store_manager.h" 5 #include "chrome/browser/prefs/profile_pref_store_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 base::Bind(&JsonPrefStore::RegisterOnNextSuccessfulWriteReply, 163 base::Bind(&JsonPrefStore::RegisterOnNextSuccessfulWriteReply,
164 protected_pref_store->AsWeakPtr()), 164 protected_pref_store->AsWeakPtr()),
165 GetPrefHashStore(false), GetPrefHashStore(true), 165 GetPrefHashStore(false), GetPrefHashStore(true),
166 raw_unprotected_pref_hash_filter, raw_protected_pref_hash_filter); 166 raw_unprotected_pref_hash_filter, raw_protected_pref_hash_filter);
167 167
168 return new SegregatedPrefStore(unprotected_pref_store, protected_pref_store, 168 return new SegregatedPrefStore(unprotected_pref_store, protected_pref_store,
169 protected_pref_names); 169 protected_pref_names);
170 } 170 }
171 171
172 bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs( 172 bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs(
173 const base::DictionaryValue& master_prefs) { 173 std::unique_ptr<base::DictionaryValue> master_prefs) {
174 // Create the profile directory if it doesn't exist yet (very possible on 174 // Create the profile directory if it doesn't exist yet (very possible on
175 // first run). 175 // first run).
176 if (!base::CreateDirectory(profile_path_)) 176 if (!base::CreateDirectory(profile_path_))
177 return false; 177 return false;
178 178
179 const base::DictionaryValue* to_serialize = &master_prefs;
180 std::unique_ptr<base::DictionaryValue> copy;
181
182 if (kPlatformSupportsPreferenceTracking) { 179 if (kPlatformSupportsPreferenceTracking) {
183 copy.reset(master_prefs.DeepCopy());
184 to_serialize = copy.get();
185 PrefHashFilter(GetPrefHashStore(false), 180 PrefHashFilter(GetPrefHashStore(false),
186 GetExternalVerificationPrefHashStorePair(), 181 GetExternalVerificationPrefHashStorePair(),
187 tracking_configuration_, base::Closure(), NULL, 182 tracking_configuration_, base::Closure(), NULL,
188 reporting_ids_count_, false) 183 reporting_ids_count_, false)
189 .Initialize(copy.get()); 184 .Initialize(master_prefs.get());
190 } 185 }
191 186
192 // This will write out to a single combined file which will be immediately 187 // This will write out to a single combined file which will be immediately
193 // migrated to two files on load. 188 // migrated to two files on load.
194 JSONFileValueSerializer serializer( 189 JSONFileValueSerializer serializer(
195 profile_path_.Append(chrome::kPreferencesFilename)); 190 profile_path_.Append(chrome::kPreferencesFilename));
196 191
197 // Call Serialize (which does IO) on the main thread, which would _normally_ 192 // Call Serialize (which does IO) on the main thread, which would _normally_
198 // be verboten. In this case however, we require this IO to synchronously 193 // be verboten. In this case however, we require this IO to synchronously
199 // complete before Chrome can start (as master preferences seed the Local 194 // complete before Chrome can start (as master preferences seed the Local
200 // State and Preferences files). This won't trip ThreadIORestrictions as they 195 // State and Preferences files). This won't trip ThreadIORestrictions as they
201 // won't have kicked in yet on the main thread. 196 // won't have kicked in yet on the main thread.
202 bool success = serializer.Serialize(*to_serialize); 197 bool success = serializer.Serialize(*master_prefs);
203 198
204 UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success); 199 UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success);
205 return success; 200 return success;
206 } 201 }
207 202
208 std::unique_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore( 203 std::unique_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore(
209 bool use_super_mac) { 204 bool use_super_mac) {
210 DCHECK(kPlatformSupportsPreferenceTracking); 205 DCHECK(kPlatformSupportsPreferenceTracking);
211 206
212 return std::unique_ptr<PrefHashStore>( 207 return std::unique_ptr<PrefHashStore>(
(...skipping 12 matching lines...) Expand all
225 ? base::MakeUnique<RegistryHashStoreContentsWin>( 220 ? base::MakeUnique<RegistryHashStoreContentsWin>(
226 *g_preference_validation_registry_path_for_testing, 221 *g_preference_validation_registry_path_for_testing,
227 profile_path_.BaseName().LossyDisplayName()) 222 profile_path_.BaseName().LossyDisplayName())
228 : base::MakeUnique<RegistryHashStoreContentsWin>( 223 : base::MakeUnique<RegistryHashStoreContentsWin>(
229 BrowserDistribution::GetDistribution()->GetRegistryPath(), 224 BrowserDistribution::GetDistribution()->GetRegistryPath(),
230 profile_path_.BaseName().LossyDisplayName())); 225 profile_path_.BaseName().LossyDisplayName()));
231 #else 226 #else
232 return std::make_pair(nullptr, nullptr); 227 return std::make_pair(nullptr, nullptr);
233 #endif 228 #endif
234 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698