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

Side by Side Diff: chrome/browser/ui/webui/options/core_options_handler.cc

Issue 7310003: Disable chrome://options UI elements if the corresponding preference is not user-modifiable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/options/core_options_handler.h" 5 #include "chrome/browser/ui/webui/options/core_options_handler.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 void CoreOptionsHandler::GetLocalizedValues( 42 void CoreOptionsHandler::GetLocalizedValues(
43 DictionaryValue* localized_strings) { 43 DictionaryValue* localized_strings) {
44 DCHECK(localized_strings); 44 DCHECK(localized_strings);
45 // Main 45 // Main
46 localized_strings->SetString("title", 46 localized_strings->SetString("title",
47 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); 47 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
48 48
49 // Managed prefs 49 // Managed prefs
50 localized_strings->SetString("managedPrefsBannerText", 50 localized_strings->SetString("managedPrefsBannerText",
51 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS)); 51 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS));
52 localized_strings->SetString("extensionManagedPrefsTitle",
53 l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_MANAGED_PREFS));
52 54
53 // Search 55 // Search
54 RegisterTitle(localized_strings, "searchPage", IDS_OPTIONS_SEARCH_PAGE_TITLE); 56 RegisterTitle(localized_strings, "searchPage", IDS_OPTIONS_SEARCH_PAGE_TITLE);
55 localized_strings->SetString("searchPlaceholder", 57 localized_strings->SetString("searchPlaceholder",
56 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PLACEHOLDER)); 58 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PLACEHOLDER));
57 localized_strings->SetString("searchPageNoMatches", 59 localized_strings->SetString("searchPageNoMatches",
58 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES)); 60 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES));
59 localized_strings->SetString("searchPageHelpLabel", 61 localized_strings->SetString("searchPageHelpLabel",
60 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL)); 62 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL));
61 localized_strings->SetString("searchPageHelpTitle", 63 localized_strings->SetString("searchPageHelpTitle",
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); 136 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
135 137
136 const PrefService::Preference* pref = 138 const PrefService::Preference* pref =
137 pref_service->FindPreference(pref_name.c_str()); 139 pref_service->FindPreference(pref_name.c_str());
138 140
139 Value* return_value; 141 Value* return_value;
140 if (pref) { 142 if (pref) {
141 DictionaryValue* dict = new DictionaryValue; 143 DictionaryValue* dict = new DictionaryValue;
142 dict->Set("value", pref->GetValue()->DeepCopy()); 144 dict->Set("value", pref->GetValue()->DeepCopy());
143 dict->SetBoolean("managed", pref->IsManaged()); 145 dict->SetBoolean("managed", pref->IsManaged());
146 dict->SetBoolean("extensionControlled", pref->IsExtensionControlled());
147 dict->SetBoolean("disabled", !pref->IsUserModifiable());
144 return_value = dict; 148 return_value = dict;
145 } else { 149 } else {
146 return_value = Value::CreateNullValue(); 150 return_value = Value::CreateNullValue();
147 } 151 }
148 return return_value; 152 return return_value;
149 } 153 }
150 154
151 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { 155 void CoreOptionsHandler::ObservePref(const std::string& pref_name) {
152 registrar_.Add(pref_name.c_str(), this); 156 registrar_.Add(pref_name.c_str(), this);
153 } 157 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 for (PreferenceCallbackMap::const_iterator iter = 374 for (PreferenceCallbackMap::const_iterator iter =
371 pref_callback_map_.find(*pref_name); 375 pref_callback_map_.find(*pref_name);
372 iter != pref_callback_map_.end(); ++iter) { 376 iter != pref_callback_map_.end(); ++iter) {
373 const std::wstring& callback_function = iter->second; 377 const std::wstring& callback_function = iter->second;
374 ListValue result_value; 378 ListValue result_value;
375 result_value.Append(Value::CreateStringValue(pref_name->c_str())); 379 result_value.Append(Value::CreateStringValue(pref_name->c_str()));
376 380
377 DictionaryValue* dict = new DictionaryValue; 381 DictionaryValue* dict = new DictionaryValue;
378 dict->Set("value", pref->GetValue()->DeepCopy()); 382 dict->Set("value", pref->GetValue()->DeepCopy());
379 dict->SetBoolean("managed", pref->IsManaged()); 383 dict->SetBoolean("managed", pref->IsManaged());
384 dict->SetBoolean("extensionControlled", pref->IsExtensionControlled());
385 dict->SetBoolean("disabled", !pref->IsUserModifiable());
380 result_value.Append(dict); 386 result_value.Append(dict);
381 387
382 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), 388 web_ui_->CallJavascriptFunction(WideToASCII(callback_function),
383 result_value); 389 result_value);
384 } 390 }
385 } 391 }
386 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698