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/prefs/chrome_pref_service_factory.h" | 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
49 | 49 |
50 #if defined(ENABLE_CONFIGURATION_POLICY) | 50 #if defined(ENABLE_CONFIGURATION_POLICY) |
51 #include "components/policy/core/browser/browser_policy_connector.h" | 51 #include "components/policy/core/browser/browser_policy_connector.h" |
52 #include "components/policy/core/browser/configuration_policy_pref_store.h" | 52 #include "components/policy/core/browser/configuration_policy_pref_store.h" |
53 #include "components/policy/core/common/policy_types.h" | 53 #include "components/policy/core/common/policy_types.h" |
54 #endif | 54 #endif |
55 | 55 |
56 #if defined(ENABLE_MANAGED_USERS) | 56 #if defined(ENABLE_MANAGED_USERS) |
57 #include "chrome/browser/managed_mode/supervised_user_pref_store.h" | 57 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
58 #endif | 58 #endif |
59 | 59 |
60 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
61 #include "base/win/win_util.h" | 61 #include "base/win/win_util.h" |
62 #if defined(ENABLE_RLZ) | 62 #if defined(ENABLE_RLZ) |
63 #include "rlz/lib/machine_id.h" | 63 #include "rlz/lib/machine_id.h" |
64 #endif // defined(ENABLE_RLZ) | 64 #endif // defined(ENABLE_RLZ) |
65 #endif // defined(OS_WIN) | 65 #endif // defined(OS_WIN) |
66 | 66 |
67 using content::BrowserContext; | 67 using content::BrowserContext; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 ResourceBundle::GetSharedInstance() | 340 ResourceBundle::GetSharedInstance() |
341 .GetRawDataResource(IDR_PREF_HASH_SEED_BIN) | 341 .GetRawDataResource(IDR_PREF_HASH_SEED_BIN) |
342 .as_string(), | 342 .as_string(), |
343 device_id, | 343 device_id, |
344 g_browser_process->local_state())); | 344 g_browser_process->local_state())); |
345 } | 345 } |
346 | 346 |
347 void PrepareFactory( | 347 void PrepareFactory( |
348 PrefServiceSyncableFactory* factory, | 348 PrefServiceSyncableFactory* factory, |
349 policy::PolicyService* policy_service, | 349 policy::PolicyService* policy_service, |
350 ManagedUserSettingsService* managed_user_settings, | 350 SupervisedUserSettingsService* supervised_user_settings, |
351 scoped_refptr<PersistentPrefStore> user_pref_store, | 351 scoped_refptr<PersistentPrefStore> user_pref_store, |
352 const scoped_refptr<PrefStore>& extension_prefs, | 352 const scoped_refptr<PrefStore>& extension_prefs, |
353 bool async) { | 353 bool async) { |
354 #if defined(ENABLE_CONFIGURATION_POLICY) | 354 #if defined(ENABLE_CONFIGURATION_POLICY) |
355 using policy::ConfigurationPolicyPrefStore; | 355 using policy::ConfigurationPolicyPrefStore; |
356 factory->set_managed_prefs( | 356 factory->set_managed_prefs( |
357 make_scoped_refptr(new ConfigurationPolicyPrefStore( | 357 make_scoped_refptr(new ConfigurationPolicyPrefStore( |
358 policy_service, | 358 policy_service, |
359 g_browser_process->browser_policy_connector()->GetHandlerList(), | 359 g_browser_process->browser_policy_connector()->GetHandlerList(), |
360 policy::POLICY_LEVEL_MANDATORY))); | 360 policy::POLICY_LEVEL_MANDATORY))); |
361 factory->set_recommended_prefs( | 361 factory->set_recommended_prefs( |
362 make_scoped_refptr(new ConfigurationPolicyPrefStore( | 362 make_scoped_refptr(new ConfigurationPolicyPrefStore( |
363 policy_service, | 363 policy_service, |
364 g_browser_process->browser_policy_connector()->GetHandlerList(), | 364 g_browser_process->browser_policy_connector()->GetHandlerList(), |
365 policy::POLICY_LEVEL_RECOMMENDED))); | 365 policy::POLICY_LEVEL_RECOMMENDED))); |
366 #endif // ENABLE_CONFIGURATION_POLICY | 366 #endif // ENABLE_CONFIGURATION_POLICY |
367 | 367 |
368 #if defined(ENABLE_MANAGED_USERS) | 368 #if defined(ENABLE_MANAGED_USERS) |
369 if (managed_user_settings) { | 369 if (supervised_user_settings) { |
370 factory->set_supervised_user_prefs( | 370 factory->set_supervised_user_prefs( |
371 make_scoped_refptr(new SupervisedUserPrefStore(managed_user_settings))); | 371 make_scoped_refptr( |
| 372 new SupervisedUserPrefStore(supervised_user_settings))); |
372 } | 373 } |
373 #endif | 374 #endif |
374 | 375 |
375 factory->set_async(async); | 376 factory->set_async(async); |
376 factory->set_extension_prefs(extension_prefs); | 377 factory->set_extension_prefs(extension_prefs); |
377 factory->set_command_line_prefs( | 378 factory->set_command_line_prefs( |
378 make_scoped_refptr( | 379 make_scoped_refptr( |
379 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); | 380 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); |
380 factory->set_read_error_callback(base::Bind(&HandleReadError)); | 381 factory->set_read_error_callback(base::Bind(&HandleReadError)); |
381 factory->set_user_prefs(user_pref_store); | 382 factory->set_user_prefs(user_pref_store); |
(...skipping 18 matching lines...) Expand all Loading... |
400 scoped_ptr<PrefService> CreateLocalState( | 401 scoped_ptr<PrefService> CreateLocalState( |
401 const base::FilePath& pref_filename, | 402 const base::FilePath& pref_filename, |
402 base::SequencedTaskRunner* pref_io_task_runner, | 403 base::SequencedTaskRunner* pref_io_task_runner, |
403 policy::PolicyService* policy_service, | 404 policy::PolicyService* policy_service, |
404 const scoped_refptr<PrefRegistry>& pref_registry, | 405 const scoped_refptr<PrefRegistry>& pref_registry, |
405 bool async) { | 406 bool async) { |
406 PrefServiceSyncableFactory factory; | 407 PrefServiceSyncableFactory factory; |
407 PrepareFactory( | 408 PrepareFactory( |
408 &factory, | 409 &factory, |
409 policy_service, | 410 policy_service, |
410 NULL, // managed_user_settings | 411 NULL, // supervised_user_settings |
411 new JsonPrefStore( | 412 new JsonPrefStore( |
412 pref_filename, pref_io_task_runner, scoped_ptr<PrefFilter>()), | 413 pref_filename, pref_io_task_runner, scoped_ptr<PrefFilter>()), |
413 NULL, // extension_prefs | 414 NULL, // extension_prefs |
414 async); | 415 async); |
415 return factory.Create(pref_registry.get()); | 416 return factory.Create(pref_registry.get()); |
416 } | 417 } |
417 | 418 |
418 scoped_ptr<PrefServiceSyncable> CreateProfilePrefs( | 419 scoped_ptr<PrefServiceSyncable> CreateProfilePrefs( |
419 const base::FilePath& profile_path, | 420 const base::FilePath& profile_path, |
420 base::SequencedTaskRunner* pref_io_task_runner, | 421 base::SequencedTaskRunner* pref_io_task_runner, |
421 TrackedPreferenceValidationDelegate* validation_delegate, | 422 TrackedPreferenceValidationDelegate* validation_delegate, |
422 policy::PolicyService* policy_service, | 423 policy::PolicyService* policy_service, |
423 ManagedUserSettingsService* managed_user_settings, | 424 SupervisedUserSettingsService* supervised_user_settings, |
424 const scoped_refptr<PrefStore>& extension_prefs, | 425 const scoped_refptr<PrefStore>& extension_prefs, |
425 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry, | 426 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry, |
426 bool async) { | 427 bool async) { |
427 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs"); | 428 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs"); |
428 PrefServiceSyncableFactory factory; | 429 PrefServiceSyncableFactory factory; |
429 PrepareFactory( | 430 PrepareFactory( |
430 &factory, | 431 &factory, |
431 policy_service, | 432 policy_service, |
432 managed_user_settings, | 433 supervised_user_settings, |
433 scoped_refptr<PersistentPrefStore>( | 434 scoped_refptr<PersistentPrefStore>( |
434 CreateProfilePrefStoreManager(profile_path)->CreateProfilePrefStore( | 435 CreateProfilePrefStoreManager(profile_path)->CreateProfilePrefStore( |
435 pref_io_task_runner, validation_delegate)), | 436 pref_io_task_runner, validation_delegate)), |
436 extension_prefs, | 437 extension_prefs, |
437 async); | 438 async); |
438 scoped_ptr<PrefServiceSyncable> pref_service = | 439 scoped_ptr<PrefServiceSyncable> pref_service = |
439 factory.CreateSyncable(pref_registry.get()); | 440 factory.CreateSyncable(pref_registry.get()); |
440 | 441 |
441 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); | 442 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); |
442 | 443 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 480 |
480 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 481 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
481 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 482 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
482 } | 483 } |
483 | 484 |
484 void RegisterPrefs(PrefRegistrySimple* registry) { | 485 void RegisterPrefs(PrefRegistrySimple* registry) { |
485 ProfilePrefStoreManager::RegisterPrefs(registry); | 486 ProfilePrefStoreManager::RegisterPrefs(registry); |
486 } | 487 } |
487 | 488 |
488 } // namespace chrome_prefs | 489 } // namespace chrome_prefs |
OLD | NEW |