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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 pref_object->type = GetType(name, pref->GetType()); | 210 pref_object->type = GetType(name, pref->GetType()); |
210 pref_object->value.reset(pref->GetValue()->DeepCopy()); | 211 pref_object->value.reset(pref->GetValue()->DeepCopy()); |
211 } | 212 } |
212 | 213 |
213 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
214 if (IsPrefPrimaryUserControlled(name)) { | 215 if (IsPrefPrimaryUserControlled(name)) { |
215 pref_object->policy_source = | 216 pref_object->policy_source = |
216 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; | 217 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; |
217 pref_object->policy_enforcement = | 218 pref_object->policy_enforcement = |
218 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 219 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 220 pref_object->policy_source_name.reset(new std::string( |
| 221 user_manager::UserManager::Get()->GetPrimaryUser()->email())); |
219 return pref_object.Pass(); | 222 return pref_object.Pass(); |
220 } | 223 } |
221 if (IsPrefEnterpriseManaged(name)) { | 224 if (IsPrefEnterpriseManaged(name)) { |
222 // Enterprise managed prefs are treated the same as device policy restricted | 225 // Enterprise managed prefs are treated the same as device policy restricted |
223 // prefs in the UI. | 226 // prefs in the UI. |
224 pref_object->policy_source = | 227 pref_object->policy_source = |
225 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; | 228 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; |
226 pref_object->policy_enforcement = | 229 pref_object->policy_enforcement = |
227 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 230 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
228 return pref_object.Pass(); | 231 return pref_object.Pass(); |
(...skipping 20 matching lines...) Expand all Loading... |
249 #if defined(OS_CHROMEOS) | 252 #if defined(OS_CHROMEOS) |
250 if (IsPrefOwnerControlled(name)) { | 253 if (IsPrefOwnerControlled(name)) { |
251 // Check for owner controlled after managed checks because if there is a | 254 // Check for owner controlled after managed checks because if there is a |
252 // device policy there is no "owner". (In the unlikely case that both | 255 // device policy there is no "owner". (In the unlikely case that both |
253 // situations apply, either badge is potentially relevant, so the order | 256 // situations apply, either badge is potentially relevant, so the order |
254 // is somewhat arbitrary). | 257 // is somewhat arbitrary). |
255 pref_object->policy_source = | 258 pref_object->policy_source = |
256 settings_private::PolicySource::POLICY_SOURCE_OWNER; | 259 settings_private::PolicySource::POLICY_SOURCE_OWNER; |
257 pref_object->policy_enforcement = | 260 pref_object->policy_enforcement = |
258 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 261 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 262 pref_object->policy_source_name.reset( |
| 263 new std::string(user_manager::UserManager::Get()->GetOwnerEmail())); |
259 return pref_object.Pass(); | 264 return pref_object.Pass(); |
260 } | 265 } |
261 #endif | 266 #endif |
262 | 267 |
263 if (pref && pref->IsExtensionControlled()) { | 268 if (pref && pref->IsExtensionControlled()) { |
264 pref_object->policy_source = | |
265 settings_private::PolicySource::POLICY_SOURCE_EXTENSION; | |
266 pref_object->policy_enforcement = | |
267 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | |
268 std::string extension_id = | 269 std::string extension_id = |
269 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 270 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
270 ->GetExtensionControllingPref(pref->name()); | 271 ->GetExtensionControllingPref(pref->name()); |
271 pref_object->extension_id.reset(new std::string(extension_id)); | 272 const Extension* extension = ExtensionRegistry::Get(profile_)-> |
272 return pref_object.Pass(); | 273 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
| 274 if (extension) { |
| 275 pref_object->policy_source = |
| 276 settings_private::PolicySource::POLICY_SOURCE_EXTENSION; |
| 277 pref_object->policy_enforcement = |
| 278 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
| 279 pref_object->extension_id.reset(new std::string(extension_id)); |
| 280 pref_object->policy_source_name.reset(new std::string(extension->name())); |
| 281 return pref_object.Pass(); |
| 282 } |
273 } | 283 } |
274 if (pref && (!pref->IsUserModifiable() || IsPrefSupervisorControlled(name))) { | 284 if (pref && (!pref->IsUserModifiable() || IsPrefSupervisorControlled(name))) { |
275 // TODO(stevenjb): Investigate whether either of these should be badged. | 285 // TODO(stevenjb): Investigate whether either of these should be badged. |
276 pref_object->read_only.reset(new bool(true)); | 286 pref_object->read_only.reset(new bool(true)); |
277 return pref_object.Pass(); | 287 return pref_object.Pass(); |
278 } | 288 } |
279 | 289 |
280 return pref_object.Pass(); | 290 return pref_object.Pass(); |
281 } | 291 } |
282 | 292 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 493 |
484 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 494 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
485 #if defined(OS_CHROMEOS) | 495 #if defined(OS_CHROMEOS) |
486 return CrosSettings::Get()->IsCrosSettings(pref_name); | 496 return CrosSettings::Get()->IsCrosSettings(pref_name); |
487 #else | 497 #else |
488 return false; | 498 return false; |
489 #endif | 499 #endif |
490 } | 500 } |
491 | 501 |
492 } // namespace extensions | 502 } // namespace extensions |
OLD | NEW |