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 "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 #if defined(OS_CHROMEOS) | 279 #if defined(OS_CHROMEOS) |
280 if (IsPrefPrimaryUserControlled(name)) { | 280 if (IsPrefPrimaryUserControlled(name)) { |
281 pref_object->policy_source = | 281 pref_object->policy_source = |
282 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; | 282 settings_private::PolicySource::POLICY_SOURCE_PRIMARY_USER; |
283 pref_object->policy_enforcement = | 283 pref_object->policy_enforcement = |
284 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 284 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
285 pref_object->policy_source_name.reset(new std::string( | 285 pref_object->policy_source_name.reset(new std::string( |
286 user_manager::UserManager::Get()->GetPrimaryUser()->email())); | 286 user_manager::UserManager::Get()->GetPrimaryUser()->email())); |
287 return pref_object.Pass(); | 287 return pref_object; |
288 } | 288 } |
289 if (IsPrefEnterpriseManaged(name)) { | 289 if (IsPrefEnterpriseManaged(name)) { |
290 // Enterprise managed prefs are treated the same as device policy restricted | 290 // Enterprise managed prefs are treated the same as device policy restricted |
291 // prefs in the UI. | 291 // prefs in the UI. |
292 pref_object->policy_source = | 292 pref_object->policy_source = |
293 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; | 293 settings_private::PolicySource::POLICY_SOURCE_DEVICE_POLICY; |
294 pref_object->policy_enforcement = | 294 pref_object->policy_enforcement = |
295 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 295 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
296 return pref_object.Pass(); | 296 return pref_object; |
297 } | 297 } |
298 #endif | 298 #endif |
299 | 299 |
300 if (pref && pref->IsManaged()) { | 300 if (pref && pref->IsManaged()) { |
301 pref_object->policy_source = | 301 pref_object->policy_source = |
302 settings_private::PolicySource::POLICY_SOURCE_USER_POLICY; | 302 settings_private::PolicySource::POLICY_SOURCE_USER_POLICY; |
303 pref_object->policy_enforcement = | 303 pref_object->policy_enforcement = |
304 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 304 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
305 return pref_object; | 305 return pref_object; |
306 } | 306 } |
(...skipping 12 matching lines...) Expand all Loading... |
319 // Check for owner controlled after managed checks because if there is a | 319 // Check for owner controlled after managed checks because if there is a |
320 // device policy there is no "owner". (In the unlikely case that both | 320 // device policy there is no "owner". (In the unlikely case that both |
321 // situations apply, either badge is potentially relevant, so the order | 321 // situations apply, either badge is potentially relevant, so the order |
322 // is somewhat arbitrary). | 322 // is somewhat arbitrary). |
323 pref_object->policy_source = | 323 pref_object->policy_source = |
324 settings_private::PolicySource::POLICY_SOURCE_OWNER; | 324 settings_private::PolicySource::POLICY_SOURCE_OWNER; |
325 pref_object->policy_enforcement = | 325 pref_object->policy_enforcement = |
326 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; | 326 settings_private::PolicyEnforcement::POLICY_ENFORCEMENT_ENFORCED; |
327 pref_object->policy_source_name.reset(new std::string( | 327 pref_object->policy_source_name.reset(new std::string( |
328 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); | 328 user_manager::UserManager::Get()->GetOwnerAccountId().GetUserEmail())); |
329 return pref_object.Pass(); | 329 return pref_object; |
330 } | 330 } |
331 #endif | 331 #endif |
332 | 332 |
333 if (pref && pref->IsExtensionControlled()) { | 333 if (pref && pref->IsExtensionControlled()) { |
334 std::string extension_id = | 334 std::string extension_id = |
335 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 335 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
336 ->GetExtensionControllingPref(pref->name()); | 336 ->GetExtensionControllingPref(pref->name()); |
337 const Extension* extension = ExtensionRegistry::Get(profile_)-> | 337 const Extension* extension = ExtensionRegistry::Get(profile_)-> |
338 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 338 GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
339 if (extension) { | 339 if (extension) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 559 |
560 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 560 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
561 #if defined(OS_CHROMEOS) | 561 #if defined(OS_CHROMEOS) |
562 return CrosSettings::Get()->IsCrosSettings(pref_name); | 562 return CrosSettings::Get()->IsCrosSettings(pref_name); |
563 #else | 563 #else |
564 return false; | 564 return false; |
565 #endif | 565 #endif |
566 } | 566 } |
567 | 567 |
568 } // namespace extensions | 568 } // namespace extensions |
OLD | NEW |