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 "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 Loading... | |
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 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { | 46 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { |
43 #if !defined(OS_CHROMEOS) | 47 #if !defined(OS_CHROMEOS) |
44 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for | 48 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for |
(...skipping 17 matching lines...) Expand all Loading... | |
62 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, | 66 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, |
63 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); | 67 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); |
64 } | 68 } |
65 } | 69 } |
66 | 70 |
67 void PrepareBuilder( | 71 void PrepareBuilder( |
68 PrefServiceSyncableBuilder* builder, | 72 PrefServiceSyncableBuilder* builder, |
69 const base::FilePath& pref_filename, | 73 const base::FilePath& pref_filename, |
70 base::SequencedTaskRunner* pref_io_task_runner, | 74 base::SequencedTaskRunner* pref_io_task_runner, |
71 policy::PolicyService* policy_service, | 75 policy::PolicyService* policy_service, |
76 ManagedUserSettingsService* managed_user_settings, | |
72 const scoped_refptr<PrefStore>& extension_prefs, | 77 const scoped_refptr<PrefStore>& extension_prefs, |
73 bool async) { | 78 bool async) { |
74 #if defined(OS_LINUX) | 79 #if defined(OS_LINUX) |
75 // We'd like to see what fraction of our users have the preferences | 80 // We'd like to see what fraction of our users have the preferences |
76 // stored on a network file system, as we've had no end of troubles | 81 // stored on a network file system, as we've had no end of troubles |
77 // with NFS/AFS. | 82 // with NFS/AFS. |
78 // TODO(evanm): remove this once we've collected state. | 83 // TODO(evanm): remove this once we've collected state. |
79 file_util::FileSystemType fstype; | 84 file_util::FileSystemType fstype; |
80 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { | 85 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { |
81 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", | 86 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", |
82 static_cast<int>(fstype), | 87 static_cast<int>(fstype), |
83 file_util::FILE_SYSTEM_TYPE_COUNT); | 88 file_util::FILE_SYSTEM_TYPE_COUNT); |
84 } | 89 } |
85 #endif | 90 #endif |
86 | 91 |
87 #if defined(ENABLE_CONFIGURATION_POLICY) | 92 #if defined(ENABLE_CONFIGURATION_POLICY) |
88 using policy::ConfigurationPolicyPrefStore; | 93 using policy::ConfigurationPolicyPrefStore; |
89 builder->WithManagedPrefs(new ConfigurationPolicyPrefStore( | 94 builder->WithManagedPrefs(new ConfigurationPolicyPrefStore( |
90 policy_service, | 95 policy_service, |
91 g_browser_process->browser_policy_connector()->GetHandlerList(), | 96 g_browser_process->browser_policy_connector()->GetHandlerList(), |
92 policy::POLICY_LEVEL_MANDATORY)); | 97 policy::POLICY_LEVEL_MANDATORY)); |
93 builder->WithRecommendedPrefs(new ConfigurationPolicyPrefStore( | 98 builder->WithRecommendedPrefs(new ConfigurationPolicyPrefStore( |
94 policy_service, | 99 policy_service, |
95 g_browser_process->browser_policy_connector()->GetHandlerList(), | 100 g_browser_process->browser_policy_connector()->GetHandlerList(), |
96 policy::POLICY_LEVEL_RECOMMENDED)); | 101 policy::POLICY_LEVEL_RECOMMENDED)); |
97 #endif // ENABLE_CONFIGURATION_POLICY | 102 #endif // ENABLE_CONFIGURATION_POLICY |
98 | 103 |
104 #if defined(ENABLE_MANAGED_USERS) | |
105 if (managed_user_settings) { | |
106 builder->WithSupervisedUserPrefs( | |
107 new SupervisedUserPrefStore(managed_user_settings)); | |
108 } | |
109 #endif | |
110 | |
99 builder->WithAsync(async); | 111 builder->WithAsync(async); |
100 builder->WithExtensionPrefs(extension_prefs.get()); | 112 builder->WithExtensionPrefs(extension_prefs.get()); |
101 builder->WithCommandLinePrefs( | 113 builder->WithCommandLinePrefs( |
102 new CommandLinePrefStore(CommandLine::ForCurrentProcess())); | 114 new CommandLinePrefStore(CommandLine::ForCurrentProcess())); |
103 builder->WithReadErrorCallback(base::Bind(&HandleReadError)); | 115 builder->WithReadErrorCallback(base::Bind(&HandleReadError)); |
104 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner)); | 116 builder->WithUserPrefs(new JsonPrefStore(pref_filename, pref_io_task_runner)); |
105 } | 117 } |
106 | 118 |
107 } // namespace | 119 } // namespace |
108 | 120 |
109 namespace chrome_prefs { | 121 namespace chrome_prefs { |
110 | 122 |
111 PrefService* CreateLocalState( | 123 PrefService* CreateLocalState( |
112 const base::FilePath& pref_filename, | 124 const base::FilePath& pref_filename, |
113 base::SequencedTaskRunner* pref_io_task_runner, | 125 base::SequencedTaskRunner* pref_io_task_runner, |
114 policy::PolicyService* policy_service, | 126 policy::PolicyService* policy_service, |
115 const scoped_refptr<PrefStore>& extension_prefs, | |
Pam (message me for reviews)
2013/09/09 15:13:49
No extension prefs in local state anymore? Is this
Bernhard Bauer
2013/09/09 15:31:31
Only related insofar as I was changing the signatu
Pam (message me for reviews)
2013/09/10 14:31:55
Duh, makes sense.
| |
116 const scoped_refptr<PrefRegistry>& pref_registry, | 127 const scoped_refptr<PrefRegistry>& pref_registry, |
117 bool async) { | 128 bool async) { |
118 PrefServiceSyncableBuilder builder; | 129 PrefServiceSyncableBuilder builder; |
119 PrepareBuilder(&builder, | 130 PrepareBuilder(&builder, |
120 pref_filename, | 131 pref_filename, |
121 pref_io_task_runner, | 132 pref_io_task_runner, |
122 policy_service, | 133 policy_service, |
123 extension_prefs, | 134 NULL, |
135 NULL, | |
124 async); | 136 async); |
125 return builder.Create(pref_registry.get()); | 137 return builder.Create(pref_registry.get()); |
126 } | 138 } |
127 | 139 |
128 PrefServiceSyncable* CreateProfilePrefs( | 140 PrefServiceSyncable* CreateProfilePrefs( |
129 const base::FilePath& pref_filename, | 141 const base::FilePath& pref_filename, |
130 base::SequencedTaskRunner* pref_io_task_runner, | 142 base::SequencedTaskRunner* pref_io_task_runner, |
131 policy::PolicyService* policy_service, | 143 policy::PolicyService* policy_service, |
144 ManagedUserSettingsService* managed_user_settings, | |
132 const scoped_refptr<PrefStore>& extension_prefs, | 145 const scoped_refptr<PrefStore>& extension_prefs, |
133 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry, | 146 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry, |
134 bool async) { | 147 bool async) { |
135 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs"); | 148 TRACE_EVENT0("browser", "chrome_prefs::CreateProfilePrefs"); |
136 PrefServiceSyncableBuilder builder; | 149 PrefServiceSyncableBuilder builder; |
137 PrepareBuilder(&builder, | 150 PrepareBuilder(&builder, |
138 pref_filename, | 151 pref_filename, |
139 pref_io_task_runner, | 152 pref_io_task_runner, |
140 policy_service, | 153 policy_service, |
154 managed_user_settings, | |
141 extension_prefs, | 155 extension_prefs, |
142 async); | 156 async); |
143 return builder.CreateSyncable(pref_registry.get()); | 157 return builder.CreateSyncable(pref_registry.get()); |
144 } | 158 } |
145 | 159 |
146 } // namespace chrome_prefs | 160 } // namespace chrome_prefs |
OLD | NEW |