Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6861)

Unified Diff: chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc

Issue 10834109: Consistently decorate pref values sent to the settings UI code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Silly me, made a CrOS-only change and tested it on a desktop build... Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc
diff --git a/chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc b/chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc
index 77961b80096b2ac7d93379e026d9ee9c165e8d4d..50c1c7b381e434318fafd1b7744df7750a28a47d 100644
--- a/chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handler.cc
@@ -44,19 +44,6 @@ bool IsSettingOwnerOnly(const std::string& pref) {
return std::find(kNonOwnerSettings, end, pref) == end;
}
-// Create a settings value with "managed" and "disabled" property.
-// "managed" property is true if the setting is managed by administrator.
-// "disabled" property is true if the UI for the setting should be disabled.
-base::Value* CreateSettingsValue(base::Value *value,
- bool managed,
- bool disabled) {
- DictionaryValue* dict = new DictionaryValue;
- dict->Set("value", value);
- dict->Set("managed", base::Value::CreateBooleanValue(managed));
- dict->Set("disabled", base::Value::CreateBooleanValue(disabled));
- return dict;
-}
-
// Returns true if |username| is the logged-in owner.
bool IsLoggedInOwner(const std::string& username) {
UserManager* user_manager = UserManager::Get();
@@ -157,20 +144,18 @@ base::Value* CoreChromeOSOptionsHandler::FetchPref(
if (!pref_value)
return base::Value::CreateNullValue();
- // Lists don't get the standard pref decoration.
- if (pref_value->GetType() == base::Value::TYPE_LIST) {
- if (pref_name == kAccountsPrefUsers)
- return CreateUsersWhitelist(pref_value);
- // Return a copy because the UI will take ownership of this object.
- return pref_value->DeepCopy();
- }
- // All other prefs are decorated the same way.
- bool enabled = (UserManager::Get()->IsCurrentUserOwner() ||
- !IsSettingOwnerOnly(pref_name));
- return CreateSettingsValue(
- pref_value->DeepCopy(), // The copy will be owned by the dictionary.
- g_browser_process->browser_policy_connector()->IsEnterpriseManaged(),
- !enabled);
+ // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does.
+ DictionaryValue* dict = new DictionaryValue;
+ if (pref_name == kAccountsPrefUsers)
+ dict->Set("value", CreateUsersWhitelist(pref_value));
+ else
+ dict->Set("value", pref_value->DeepCopy());
+ if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged())
+ dict->SetString("controlledBy", "policy");
+ dict->SetBoolean("disabled",
+ IsSettingOwnerOnly(pref_name) &&
+ !UserManager::Get()->IsCurrentUserOwner());
+ return dict;
}
void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) {
« no previous file with comments | « chrome/browser/resources/options2/pref_ui.js ('k') | chrome/browser/ui/webui/options2/preferences_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698