| 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 "build/build_config.h" | 7 #include "build/build_config.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/extensions/settings_api_helpers.h" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 #endif | 471 #endif |
| 472 | 472 |
| 473 if (pref && pref->IsManaged()) { | 473 if (pref && pref->IsManaged()) { |
| 474 pref_object->controlled_by = | 474 pref_object->controlled_by = |
| 475 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; | 475 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; |
| 476 pref_object->enforcement = | 476 pref_object->enforcement = |
| 477 settings_private::Enforcement::ENFORCEMENT_ENFORCED; | 477 settings_private::Enforcement::ENFORCEMENT_ENFORCED; |
| 478 return pref_object; | 478 return pref_object; |
| 479 } | 479 } |
| 480 | 480 |
| 481 if (pref && pref->IsRecommended()) { | 481 // A pref is recommended if it has a recommended value, regardless of whether |
| 482 // the current value is set by policy. The UI will test to see whether the |
| 483 // current value matches the recommended value and inform the user. |
| 484 const base::Value* recommended = pref ? pref->GetRecommendedValue() : nullptr; |
| 485 if (recommended) { |
| 482 pref_object->controlled_by = | 486 pref_object->controlled_by = |
| 483 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; | 487 settings_private::ControlledBy::CONTROLLED_BY_USER_POLICY; |
| 484 pref_object->enforcement = | 488 pref_object->enforcement = |
| 485 settings_private::Enforcement::ENFORCEMENT_RECOMMENDED; | 489 settings_private::Enforcement::ENFORCEMENT_RECOMMENDED; |
| 486 pref_object->recommended_value.reset( | 490 pref_object->recommended_value.reset(recommended->DeepCopy()); |
| 487 pref->GetRecommendedValue()->DeepCopy()); | |
| 488 return pref_object; | 491 return pref_object; |
| 489 } | 492 } |
| 490 | 493 |
| 491 #if defined(OS_CHROMEOS) | 494 #if defined(OS_CHROMEOS) |
| 492 if (IsPrefOwnerControlled(name)) { | 495 if (IsPrefOwnerControlled(name)) { |
| 493 // Check for owner controlled after managed checks because if there is a | 496 // Check for owner controlled after managed checks because if there is a |
| 494 // device policy there is no "owner". (In the unlikely case that both | 497 // device policy there is no "owner". (In the unlikely case that both |
| 495 // situations apply, either badge is potentially relevant, so the order | 498 // situations apply, either badge is potentially relevant, so the order |
| 496 // is somewhat arbitrary). | 499 // is somewhat arbitrary). |
| 497 pref_object->controlled_by = | 500 pref_object->controlled_by = |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 772 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
| 770 ->GetExtensionControllingPref(pref_object.key); | 773 ->GetExtensionControllingPref(pref_object.key); |
| 771 if (extension_id.empty()) | 774 if (extension_id.empty()) |
| 772 return nullptr; | 775 return nullptr; |
| 773 | 776 |
| 774 return ExtensionRegistry::Get(profile_)->GetExtensionById( | 777 return ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 775 extension_id, ExtensionRegistry::ENABLED); | 778 extension_id, ExtensionRegistry::ENABLED); |
| 776 } | 779 } |
| 777 | 780 |
| 778 } // namespace extensions | 781 } // namespace extensions |
| OLD | NEW |