Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / prefs / pref_service_syncable_factory.cc
blobea3c2adef76666bbdf33f1ebdb39ab165e40ea92
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/prefs/pref_service_syncable_factory.h"
7 #include "base/debug/trace_event.h"
8 #include "base/prefs/default_pref_store.h"
9 #include "base/prefs/pref_notifier_impl.h"
10 #include "base/prefs/pref_value_store.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/prefs/command_line_pref_store.h"
13 #include "chrome/browser/prefs/pref_service_syncable.h"
14 #include "components/user_prefs/pref_registry_syncable.h"
16 #if defined(ENABLE_CONFIGURATION_POLICY)
17 #include "chrome/browser/policy/browser_policy_connector.h"
18 #include "components/policy/core/browser/configuration_policy_pref_store.h"
19 #include "components/policy/core/common/policy_service.h"
20 #include "components/policy/core/common/policy_types.h"
21 #endif
23 PrefServiceSyncableFactory::PrefServiceSyncableFactory() {
26 PrefServiceSyncableFactory::~PrefServiceSyncableFactory() {
29 #if defined(ENABLE_CONFIGURATION_POLICY)
30 void PrefServiceSyncableFactory::SetManagedPolicies(
31 policy::PolicyService* service) {
32 set_managed_prefs(
33 new policy::ConfigurationPolicyPrefStore(
34 service,
35 g_browser_process->browser_policy_connector()->GetHandlerList(),
36 policy::POLICY_LEVEL_MANDATORY));
39 void PrefServiceSyncableFactory::SetRecommendedPolicies(
40 policy::PolicyService* service) {
41 set_recommended_prefs(
42 new policy::ConfigurationPolicyPrefStore(
43 service,
44 g_browser_process->browser_policy_connector()->GetHandlerList(),
45 policy::POLICY_LEVEL_RECOMMENDED));
47 #endif
49 void PrefServiceSyncableFactory::SetCommandLine(CommandLine* command_line) {
50 set_command_line_prefs(new CommandLinePrefStore(command_line));
53 scoped_ptr<PrefServiceSyncable> PrefServiceSyncableFactory::CreateSyncable(
54 user_prefs::PrefRegistrySyncable* pref_registry) {
55 TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable");
56 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
57 scoped_ptr<PrefServiceSyncable> pref_service(
58 new PrefServiceSyncable(
59 pref_notifier,
60 new PrefValueStore(managed_prefs_.get(),
61 supervised_user_prefs_.get(),
62 extension_prefs_.get(),
63 command_line_prefs_.get(),
64 user_prefs_.get(),
65 recommended_prefs_.get(),
66 pref_registry->defaults().get(),
67 pref_notifier),
68 user_prefs_.get(),
69 pref_registry,
70 read_error_callback_,
71 async_));
72 return pref_service.Pass();