Chromium Code Reviews| 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/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/environment.h" | 12 #include "base/environment.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/json/json_file_value_serializer.h" | |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 17 #include "base/prefs/json_pref_store.h" | 18 #include "base/prefs/json_pref_store.h" |
| 18 #include "base/prefs/scoped_user_pref_update.h" | 19 #include "base/prefs/scoped_user_pref_update.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
| 24 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 prefs::kClearSiteDataOnExit, | 413 prefs::kClearSiteDataOnExit, |
| 413 false, | 414 false, |
| 414 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 415 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 415 } | 416 } |
| 416 | 417 |
| 417 // static | 418 // static |
| 418 void ProfileImpl::InitializePrefHashStoreIfRequired( | 419 void ProfileImpl::InitializePrefHashStoreIfRequired( |
| 419 const base::FilePath& profile_path) { | 420 const base::FilePath& profile_path) { |
| 420 scoped_ptr<PrefHashStoreImpl> pref_hash_store(GetPrefHashStore(profile_path)); | 421 scoped_ptr<PrefHashStoreImpl> pref_hash_store(GetPrefHashStore(profile_path)); |
| 421 if (pref_hash_store && !pref_hash_store->IsInitialized()) { | 422 if (pref_hash_store && !pref_hash_store->IsInitialized()) { |
| 422 chrome_prefs::InitializeHashStoreForPrefFile( | 423 chrome_prefs::InitializeHashStoreFromPrefFile( |
| 423 GetPrefFilePathFromProfilePath(profile_path), | 424 GetPrefFilePathFromProfilePath(profile_path), |
| 424 JsonPrefStore::GetTaskRunnerForFile( | 425 JsonPrefStore::GetTaskRunnerForFile( |
| 425 profile_path, BrowserThread::GetBlockingPool()), | 426 profile_path, BrowserThread::GetBlockingPool()), |
| 426 pref_hash_store.PassAs<PrefHashStore>()); | 427 pref_hash_store.PassAs<PrefHashStore>()); |
| 427 } | 428 } |
| 428 } | 429 } |
| 429 | 430 |
| 430 // static | 431 // static |
| 431 void ProfileImpl::ResetPrefHashStore(const base::FilePath& profile_path) { | 432 void ProfileImpl::ResetPrefHashStore(const base::FilePath& profile_path) { |
| 432 GetPrefHashStore(profile_path)->Reset(); | 433 GetPrefHashStore(profile_path)->Reset(); |
| 433 } | 434 } |
| 434 | 435 |
| 436 // static | |
| 437 bool ProfileImpl::InitializePrefsFromMasterPrefs( | |
|
noms (inactive)
2014/02/04 20:36:35
As discussed offline, these prefs related methods
| |
| 438 const base::FilePath& profile_path, | |
| 439 const base::DictionaryValue& master_prefs) { | |
| 440 // Create the profile directory if it doesn't exist yet (very possible on | |
| 441 // first run). | |
| 442 if (!base::CreateDirectory(profile_path)) | |
| 443 return false; | |
| 444 | |
| 445 JSONFileValueSerializer serializer( | |
| 446 GetPrefFilePathFromProfilePath(profile_path)); | |
| 447 | |
| 448 // Call Serialize (which does IO) on the main thread, which would _normally_ | |
| 449 // be verboten. In this case however, we require this IO to synchronously | |
| 450 // complete before Chrome can start (as master preferences seed the Local | |
| 451 // State and Preferences files). This won't trip ThreadIORestrictions as they | |
| 452 // won't have kicked in yet on the main thread. | |
| 453 bool success = serializer.Serialize(master_prefs); | |
| 454 | |
| 455 if (success) { | |
| 456 scoped_ptr<PrefHashStore> pref_hash_store(GetPrefHashStore(profile_path)); | |
| 457 chrome_prefs::InitializeHashStoreFromMasterPrefs(master_prefs, | |
| 458 pref_hash_store.Pass()); | |
| 459 } | |
| 460 | |
| 461 UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success); | |
| 462 return success; | |
| 463 } | |
| 464 | |
| 435 ProfileImpl::ProfileImpl( | 465 ProfileImpl::ProfileImpl( |
| 436 const base::FilePath& path, | 466 const base::FilePath& path, |
| 437 Delegate* delegate, | 467 Delegate* delegate, |
| 438 CreateMode create_mode, | 468 CreateMode create_mode, |
| 439 base::SequencedTaskRunner* sequenced_task_runner) | 469 base::SequencedTaskRunner* sequenced_task_runner) |
| 440 : path_(path), | 470 : path_(path), |
| 441 pref_registry_(new user_prefs::PrefRegistrySyncable), | 471 pref_registry_(new user_prefs::PrefRegistrySyncable), |
| 442 io_data_(this), | 472 io_data_(this), |
| 443 host_content_settings_map_(NULL), | 473 host_content_settings_map_(NULL), |
| 444 last_session_exit_type_(EXIT_NORMAL), | 474 last_session_exit_type_(EXIT_NORMAL), |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1376 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
| 1347 #if defined(OS_CHROMEOS) | 1377 #if defined(OS_CHROMEOS) |
| 1348 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1378 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 1349 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1379 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 1350 g_browser_process->local_state()); | 1380 g_browser_process->local_state()); |
| 1351 } | 1381 } |
| 1352 #endif // defined(OS_CHROMEOS) | 1382 #endif // defined(OS_CHROMEOS) |
| 1353 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1383 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 1354 GetPrefs(), g_browser_process->local_state()); | 1384 GetPrefs(), g_browser_process->local_state()); |
| 1355 } | 1385 } |
| OLD | NEW |