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

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

Issue 23376002: Move ManagedModePolicyProvider functionality to ManagedUserSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 28
29 #if defined(ENABLE_CONFIGURATION_POLICY) 29 #if defined(ENABLE_CONFIGURATION_POLICY)
30 #include "chrome/browser/policy/browser_policy_connector.h" 30 #include "chrome/browser/policy/browser_policy_connector.h"
31 #include "chrome/browser/policy/configuration_policy_pref_store.h" 31 #include "chrome/browser/policy/configuration_policy_pref_store.h"
32 #include "chrome/browser/policy/policy_types.h" 32 #include "chrome/browser/policy/policy_types.h"
33 #endif 33 #endif
34 34
35 #if defined(ENABLE_MANAGED_USERS)
36 #include "chrome/browser/managed_mode/supervised_user_pref_store.h"
37 #endif
38
35 using content::BrowserContext; 39 using content::BrowserContext;
36 using content::BrowserThread; 40 using content::BrowserThread;
37 41
38 namespace { 42 namespace {
39 43
40 // Shows notifications which correspond to PersistentPrefStore's reading errors. 44 // Shows notifications which correspond to PersistentPrefStore's reading errors.
41 void HandleReadError(PersistentPrefStore::PrefReadError error) { 45 void HandleReadError(PersistentPrefStore::PrefReadError error) {
42 // Sample the histogram also for the successful case in order to get a 46 // Sample the histogram also for the successful case in order to get a
43 // baseline on the success rate in addition to the error distribution. 47 // baseline on the success rate in addition to the error distribution.
44 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 48 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error,
(...skipping 20 matching lines...) Expand all
65 // will be displayed. 69 // will be displayed.
66 #endif 70 #endif
67 } 71 }
68 } 72 }
69 73
70 void PrepareBuilder( 74 void PrepareBuilder(
71 PrefServiceSyncableBuilder* builder, 75 PrefServiceSyncableBuilder* builder,
72 const base::FilePath& pref_filename, 76 const base::FilePath& pref_filename,
73 base::SequencedTaskRunner* pref_io_task_runner, 77 base::SequencedTaskRunner* pref_io_task_runner,
74 policy::PolicyService* policy_service, 78 policy::PolicyService* policy_service,
79 ManagedUserSettingsService* managed_user_settings,
75 const scoped_refptr<PrefStore>& extension_prefs, 80 const scoped_refptr<PrefStore>& extension_prefs,
76 bool async) { 81 bool async) {
77 #if defined(OS_LINUX) 82 #if defined(OS_LINUX)
78 // We'd like to see what fraction of our users have the preferences 83 // We'd like to see what fraction of our users have the preferences
79 // stored on a network file system, as we've had no end of troubles 84 // stored on a network file system, as we've had no end of troubles
80 // with NFS/AFS. 85 // with NFS/AFS.
81 // TODO(evanm): remove this once we've collected state. 86 // TODO(evanm): remove this once we've collected state.
82 file_util::FileSystemType fstype; 87 file_util::FileSystemType fstype;
83 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { 88 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) {
84 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", 89 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType",
85 static_cast<int>(fstype), 90 static_cast<int>(fstype),
86 file_util::FILE_SYSTEM_TYPE_COUNT); 91 file_util::FILE_SYSTEM_TYPE_COUNT);
87 } 92 }
88 #endif 93 #endif
89 94
90 #if defined(ENABLE_CONFIGURATION_POLICY) 95 #if defined(ENABLE_CONFIGURATION_POLICY)
91 using policy::ConfigurationPolicyPrefStore; 96 using policy::ConfigurationPolicyPrefStore;
92 builder->WithManagedPrefs(new ConfigurationPolicyPrefStore( 97 builder->WithManagedPrefs(new ConfigurationPolicyPrefStore(
93 policy_service, 98 policy_service,
94 g_browser_process->browser_policy_connector()->GetHandlerList(), 99 g_browser_process->browser_policy_connector()->GetHandlerList(),
95 policy::POLICY_LEVEL_MANDATORY)); 100 policy::POLICY_LEVEL_MANDATORY));
96 builder->WithRecommendedPrefs(new ConfigurationPolicyPrefStore( 101 builder->WithRecommendedPrefs(new ConfigurationPolicyPrefStore(
97 policy_service, 102 policy_service,
98 g_browser_process->browser_policy_connector()->GetHandlerList(), 103 g_browser_process->browser_policy_connector()->GetHandlerList(),
99 policy::POLICY_LEVEL_RECOMMENDED)); 104 policy::POLICY_LEVEL_RECOMMENDED));
100 #endif // ENABLE_CONFIGURATION_POLICY 105 #endif // ENABLE_CONFIGURATION_POLICY
101 106
107 #if defined(ENABLE_MANAGED_USERS)
108 if (managed_user_settings) {
109 builder->WithSupervisedUserPrefs(
110 new SupervisedUserPrefStore(managed_user_settings));
111 }
112 #endif
113
102 builder->WithAsync(async); 114 builder->WithAsync(async);
103 builder->WithExtensionPrefs(extension_prefs.get()); 115 builder->WithExtensionPrefs(extension_prefs.get());
104 builder->WithCommandLinePrefs( 116 builder->WithCommandLinePrefs(
105 new CommandLinePrefStore(CommandLine::ForCurrentProcess())); 117 new CommandLinePrefStore(CommandLine::ForCurrentProcess()));
106 builder->WithReadErrorCallback(base::Bind(&HandleReadError)); 118 builder->WithReadErrorCallback(base::Bind(&HandleReadError));
107 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner)); 119 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner));
108 } 120 }
109 121
110 } // namespace 122 } // namespace
111 123
112 namespace chrome_prefs { 124 namespace chrome_prefs {
113 125
114 PrefService* CreateLocalState( 126 PrefService* CreateLocalState(
115 const base::FilePath& pref_filename, 127 const base::FilePath& pref_filename,
116 base::SequencedTaskRunner* pref_io_task_runner, 128 base::SequencedTaskRunner* pref_io_task_runner,
117 policy::PolicyService* policy_service, 129 policy::PolicyService* policy_service,
118 const scoped_refptr<PrefStore>& extension_prefs,
119 const scoped_refptr<PrefRegistry>& pref_registry, 130 const scoped_refptr<PrefRegistry>& pref_registry,
120 bool async) { 131 bool async) {
121 PrefServiceSyncableBuilder builder; 132 PrefServiceSyncableBuilder builder;
122 PrepareBuilder(&builder, 133 PrepareBuilder(&builder,
123 pref_filename, 134 pref_filename,
124 pref_io_task_runner, 135 pref_io_task_runner,
125 policy_service, 136 policy_service,
126 extension_prefs, 137 NULL,
138 NULL,
127 async); 139 async);
128 return builder.Create(pref_registry.get()); 140 return builder.Create(pref_registry.get());
129 } 141 }
130 142
131 PrefServiceSyncable* CreateProfilePrefs( 143 PrefServiceSyncable* CreateProfilePrefs(
132 const base::FilePath& pref_filename, 144 const base::FilePath& pref_filename,
133 base::SequencedTaskRunner* pref_io_task_runner, 145 base::SequencedTaskRunner* pref_io_task_runner,
134 policy::PolicyService* policy_service, 146 policy::PolicyService* policy_service,
147 ManagedUserSettingsService* managed_user_settings,
135 const scoped_refptr<PrefStore>& extension_prefs, 148 const scoped_refptr<PrefStore>& extension_prefs,
136 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry, 149 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry,
137 bool async) { 150 bool async) {
138 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs"); 151 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs");
139 PrefServiceSyncableBuilder builder; 152 PrefServiceSyncableBuilder builder;
140 PrepareBuilder(&builder, 153 PrepareBuilder(&builder,
141 pref_filename, 154 pref_filename,
142 pref_io_task_runner, 155 pref_io_task_runner,
143 policy_service, 156 policy_service,
157 managed_user_settings,
144 extension_prefs, 158 extension_prefs,
145 async); 159 async);
146 return builder.CreateSyncable(pref_registry.get()); 160 return builder.CreateSyncable(pref_registry.get());
147 } 161 }
148 162
149 } // namespace chrome_prefs 163 } // namespace chrome_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698