OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/settings_private/prefs_util.h" | 5 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "components/proxy_config/proxy_config_pref_names.h" | 12 #include "components/proxy_config/proxy_config_pref_names.h" |
13 #include "components/url_formatter/url_fixer.h" | 13 #include "components/url_formatter/url_fixer.h" |
14 #include "extensions/browser/extension_pref_value_map.h" | 14 #include "extensions/browser/extension_pref_value_map.h" |
15 #include "extensions/browser/extension_pref_value_map_factory.h" | 15 #include "extensions/browser/extension_pref_value_map_factory.h" |
16 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| 17 #include "extensions/common/extension.h" |
17 | 18 |
18 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
19 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
20 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 21 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 23 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
23 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
24 #include "chromeos/settings/cros_settings_names.h" | 25 #include "chromeos/settings/cros_settings_names.h" |
25 #endif | 26 #endif |
26 | 27 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 pref_object->type = GetType(name, pref->GetType()); | 183 pref_object->type = GetType(name, pref->GetType()); |
183 pref_object->value.reset(pref->GetValue()->DeepCopy()); | 184 pref_object->value.reset(pref->GetValue()->DeepCopy()); |
184 } | 185 } |
185 | 186 |
186 #if defined(OS_CHROMEOS) | 187 #if defined(OS_CHROMEOS) |
187 if (IsPrefPrimaryUserControlled(name)) { | 188 if (IsPrefPrimaryUserControlled(name)) { |
188 pref_object->policy_source = | 189 pref_object->policy_source = |
189 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; | 190 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; |
190 pref_object->policy_enforcement = | 191 pref_object->policy_enforcement = |
191 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 192 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 193 pref_object->policy_source_name.reset(new std::string( |
| 194 user_manager::UserManager::Get()->GetPrimaryUser()->email())); |
192 return pref_object.Pass(); | 195 return pref_object.Pass(); |
193 } | 196 } |
194 if (IsPrefEnterpriseManaged(name)) { | 197 if (IsPrefEnterpriseManaged(name)) { |
195 // Enterprise managed prefs are treated the same as device policy restricted | 198 // Enterprise managed prefs are treated the same as device policy restricted |
196 // prefs in the UI. | 199 // prefs in the UI. |
197 pref_object->policy_source = | 200 pref_object->policy_source = |
198 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; | 201 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; |
199 pref_object->policy_enforcement = | 202 pref_object->policy_enforcement = |
200 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 203 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
201 return pref_object.Pass(); | 204 return pref_object.Pass(); |
(...skipping 20 matching lines...) Expand all Loading... |
222 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
223 if (IsPrefOwnerControlled(name)) { | 226 if (IsPrefOwnerControlled(name)) { |
224 // Check for owner controlled after managed checks because if there is a | 227 // Check for owner controlled after managed checks because if there is a |
225 // device policy there is no "owner". (In the unlikely case that both | 228 // device policy there is no "owner". (In the unlikely case that both |
226 // situations apply, either badge is potentially relevant, so the order | 229 // situations apply, either badge is potentially relevant, so the order |
227 // is somewhat arbitrary). | 230 // is somewhat arbitrary). |
228 pref_object->policy_source = | 231 pref_object->policy_source = |
229 settings_private::PolicySource::POLICY_SOURCE_OWNER; | 232 settings_private::PolicySource::POLICY_SOURCE_OWNER; |
230 pref_object->policy_enforcement = | 233 pref_object->policy_enforcement = |
231 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 234 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 235 pref_object->policy_source_name.reset( |
| 236 new std::string(user_manager::UserManager::Get()->GetOwnerEmail())); |
232 return pref_object.Pass(); | 237 return pref_object.Pass(); |
233 } | 238 } |
234 #endif | 239 #endif |
235 | 240 |
236 if (pref && pref->IsExtensionControlled()) { | 241 if (pref && pref->IsExtensionControlled()) { |
237 pref_object->policy_source = | |
238 settings_private::PolicySource::POLICY_SOURCE_EXTENSION; | |
239 pref_object->policy_enforcement = | |
240 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | |
241 std::string extension_id = | 242 std::string extension_id = |
242 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 243 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
243 ->GetExtensionControllingPref(pref->name()); | 244 ->GetExtensionControllingPref(pref->name()); |
244 pref_object->extension_id.reset(new std::string(extension_id)); | 245 const Extension* extension = ExtensionRegistry::Get(profile_)-> |
245 return pref_object.Pass(); | 246 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
| 247 if (extension) { |
| 248 pref_object->policy_source = |
| 249 settings_private::PolicySource::POLICY_SOURCE_EXTENSION; |
| 250 pref_object->policy_enforcement = |
| 251 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 252 pref_object->extension_id.reset(new std::string(extension_id)); |
| 253 pref_object->policy_source_name.reset(new std::string(extension->name())); |
| 254 return pref_object.Pass(); |
| 255 } |
246 } | 256 } |
247 if (pref && (!pref->IsUserModifiable() || IsPrefSupervisorControlled(name))) { | 257 if (pref && (!pref->IsUserModifiable() || IsPrefSupervisorControlled(name))) { |
248 // TODO(stevenjb): Investigate whether either of these should be badged. | 258 // TODO(stevenjb): Investigate whether either of these should be badged. |
249 pref_object->read_only.reset(new bool(true)); | 259 pref_object->read_only.reset(new bool(true)); |
250 return pref_object.Pass(); | 260 return pref_object.Pass(); |
251 } | 261 } |
252 | 262 |
253 return pref_object.Pass(); | 263 return pref_object.Pass(); |
254 } | 264 } |
255 | 265 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 463 |
454 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 464 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
455 #if defined(OS_CHROMEOS) | 465 #if defined(OS_CHROMEOS) |
456 return CrosSettings::Get()->IsCrosSettings(pref_name); | 466 return CrosSettings::Get()->IsCrosSettings(pref_name); |
457 #else | 467 #else |
458 return false; | 468 return false; |
459 #endif | 469 #endif |
460 } | 470 } |
461 | 471 |
462 } // namespace extensions | 472 } // namespace extensions |
OLD | NEW |