| Index: chrome/browser/ui/webui/options/core_options_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/core_options_handler.cc b/chrome/browser/ui/webui/options/core_options_handler.cc
|
| index 7a5e2f13b4efa8b7735303d1fae2a12a3f301322..2fdd5cda51af6e5933f44d012250a4228902d240 100644
|
| --- a/chrome/browser/ui/webui/options/core_options_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/core_options_handler.cc
|
| @@ -27,6 +27,22 @@
|
| #include "grit/theme_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| +namespace {
|
| +
|
| +DictionaryValue* CreateValueForPref(const PrefService::Preference* pref) {
|
| + DictionaryValue* dict = new DictionaryValue;
|
| + dict->Set("value", pref->GetValue()->DeepCopy());
|
| + if (pref->IsManaged()) {
|
| + dict->SetString("controlledBy", "policy");
|
| + } else if (pref->IsExtensionControlled()) {
|
| + dict->SetString("controlledBy", "extension");
|
| + }
|
| + dict->SetBoolean("disabled", !pref->IsUserModifiable());
|
| + return dict;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| CoreOptionsHandler::CoreOptionsHandler()
|
| : handlers_host_(NULL) {
|
| }
|
| @@ -48,8 +64,12 @@ void CoreOptionsHandler::GetLocalizedValues(
|
| l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
|
|
|
| // Managed prefs
|
| - localized_strings->SetString("managedPrefsBannerText",
|
| - l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS));
|
| + localized_strings->SetString("policyManagedPrefsBannerText",
|
| + l10n_util::GetStringUTF16(IDS_OPTIONS_POLICY_MANAGED_PREFS));
|
| + localized_strings->SetString("extensionManagedPrefsBannerText",
|
| + l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_MANAGED_PREFS));
|
| + localized_strings->SetString("policyAndExtensionManagedPrefsBannerText",
|
| + l10n_util::GetStringUTF16(IDS_OPTIONS_POLICY_EXTENSION_MANAGED_PREFS));
|
|
|
| // Search
|
| RegisterTitle(localized_strings, "searchPage", IDS_OPTIONS_SEARCH_PAGE_TITLE);
|
| @@ -136,19 +156,10 @@ Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) {
|
|
|
| const PrefService::Preference* pref =
|
| pref_service->FindPreference(pref_name.c_str());
|
| + if (!pref)
|
| + return Value::CreateNullValue();
|
|
|
| - Value* return_value;
|
| - if (pref) {
|
| - DictionaryValue* dict = new DictionaryValue;
|
| - dict->Set("value", pref->GetValue()->DeepCopy());
|
| - dict->SetBoolean("managed", pref->IsManaged());
|
| - dict->SetBoolean("extensionControlled", pref->IsExtensionControlled());
|
| - dict->SetBoolean("disabled", !pref->IsUserModifiable());
|
| - return_value = dict;
|
| - } else {
|
| - return_value = Value::CreateNullValue();
|
| - }
|
| - return return_value;
|
| + return CreateValueForPref(pref);
|
| }
|
|
|
| void CoreOptionsHandler::ObservePref(const std::string& pref_name) {
|
| @@ -369,23 +380,19 @@ void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) {
|
| PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
|
| const PrefService::Preference* pref =
|
| pref_service->FindPreference(pref_name->c_str());
|
| - if (pref) {
|
| - for (PreferenceCallbackMap::const_iterator iter =
|
| - pref_callback_map_.find(*pref_name);
|
| - iter != pref_callback_map_.end(); ++iter) {
|
| - const std::wstring& callback_function = iter->second;
|
| - ListValue result_value;
|
| - result_value.Append(Value::CreateStringValue(pref_name->c_str()));
|
| -
|
| - DictionaryValue* dict = new DictionaryValue;
|
| - dict->Set("value", pref->GetValue()->DeepCopy());
|
| - dict->SetBoolean("managed", pref->IsManaged());
|
| - dict->SetBoolean("extensionControlled", pref->IsExtensionControlled());
|
| - dict->SetBoolean("disabled", !pref->IsUserModifiable());
|
| - result_value.Append(dict);
|
| -
|
| - web_ui_->CallJavascriptFunction(WideToASCII(callback_function),
|
| - result_value);
|
| - }
|
| + if (!pref)
|
| + return;
|
| +
|
| + for (PreferenceCallbackMap::const_iterator iter =
|
| + pref_callback_map_.find(*pref_name);
|
| + iter != pref_callback_map_.end(); ++iter) {
|
| + const std::wstring& callback_function = iter->second;
|
| + ListValue result_value;
|
| + result_value.Append(Value::CreateStringValue(pref_name->c_str()));
|
| +
|
| + result_value.Append(CreateValueForPref(pref));
|
| +
|
| + web_ui_->CallJavascriptFunction(WideToASCII(callback_function),
|
| + result_value);
|
| }
|
| }
|
|
|