OLD | NEW |
---|---|
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 29 matching lines...) Expand all Loading... | |
40 UpdateClearPluginLSOData(); | 40 UpdateClearPluginLSOData(); |
41 } | 41 } |
42 | 42 |
43 void CoreOptionsHandler::GetLocalizedValues( | 43 void CoreOptionsHandler::GetLocalizedValues( |
44 DictionaryValue* localized_strings) { | 44 DictionaryValue* localized_strings) { |
45 DCHECK(localized_strings); | 45 DCHECK(localized_strings); |
46 // Main | 46 // Main |
47 localized_strings->SetString("title", | 47 localized_strings->SetString("title", |
48 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); | 48 l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE)); |
49 | 49 |
50 string16 options_term = l10n_util::GetStringUTF16(IDS_OPTIONS_PREFS_TERM); | |
51 | |
50 // Managed prefs | 52 // Managed prefs |
51 localized_strings->SetString("managedPrefsBannerText", | 53 localized_strings->SetString("policyManagedPrefsBannerText", |
Mattias Nissler (ping if slow)
2011/07/13 12:07:58
Not sure whether it's mandatory, but I personally
Evan Stade
2011/07/13 17:06:04
no it is not mandatory, both styles are acceptable
| |
52 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS)); | 54 l10n_util::GetStringFUTF16(IDS_OPTIONS_POLICY_MANAGED_PREFS, |
55 options_term)); | |
56 localized_strings->SetString("extensionManagedPrefsBannerText", | |
57 l10n_util::GetStringFUTF16(IDS_OPTIONS_EXTENSION_MANAGED_PREFS, | |
58 options_term)); | |
59 localized_strings->SetString("policyAndExtensionManagedPrefsBannerText", | |
60 l10n_util::GetStringFUTF16(IDS_OPTIONS_POLICY_EXTENSION_MANAGED_PREFS, | |
61 options_term)); | |
53 | 62 |
54 // Search | 63 // Search |
55 RegisterTitle(localized_strings, "searchPage", IDS_OPTIONS_SEARCH_PAGE_TITLE); | 64 RegisterTitle(localized_strings, "searchPage", IDS_OPTIONS_SEARCH_PAGE_TITLE); |
56 localized_strings->SetString("searchPlaceholder", | 65 localized_strings->SetString("searchPlaceholder", |
57 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PLACEHOLDER)); | 66 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PLACEHOLDER)); |
58 localized_strings->SetString("searchPageNoMatches", | 67 localized_strings->SetString("searchPageNoMatches", |
59 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES)); | 68 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES)); |
60 localized_strings->SetString("searchPageHelpLabel", | 69 localized_strings->SetString("searchPageHelpLabel", |
61 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL)); | 70 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL)); |
62 localized_strings->SetString("searchPageHelpTitle", | 71 localized_strings->SetString("searchPageHelpTitle", |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { | 143 Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { |
135 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); | 144 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); |
136 | 145 |
137 const PrefService::Preference* pref = | 146 const PrefService::Preference* pref = |
138 pref_service->FindPreference(pref_name.c_str()); | 147 pref_service->FindPreference(pref_name.c_str()); |
139 | 148 |
140 Value* return_value; | 149 Value* return_value; |
141 if (pref) { | 150 if (pref) { |
142 DictionaryValue* dict = new DictionaryValue; | 151 DictionaryValue* dict = new DictionaryValue; |
143 dict->Set("value", pref->GetValue()->DeepCopy()); | 152 dict->Set("value", pref->GetValue()->DeepCopy()); |
144 dict->SetBoolean("managed", pref->IsManaged()); | 153 if (pref->IsManaged()) { |
Evan Stade
2011/07/13 17:06:04
no curlies
Bernhard Bauer
2011/07/13 22:15:12
Done.
| |
145 dict->SetBoolean("extensionControlled", pref->IsExtensionControlled()); | 154 dict->SetString("controlledBy", "policy"); |
155 } else if (pref->IsExtensionControlled()) { | |
156 dict->SetString("controlledBy", "extension"); | |
157 } | |
Joao da Silva
2011/07/13 17:35:17
The code here that creates the DictionaryValue is
Bernhard Bauer
2011/07/13 22:15:12
Good idea. Done.
| |
146 dict->SetBoolean("disabled", !pref->IsUserModifiable()); | 158 dict->SetBoolean("disabled", !pref->IsUserModifiable()); |
147 return_value = dict; | 159 return_value = dict; |
148 } else { | 160 } else { |
149 return_value = Value::CreateNullValue(); | 161 return_value = Value::CreateNullValue(); |
150 } | 162 } |
151 return return_value; | 163 return return_value; |
152 } | 164 } |
153 | 165 |
154 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { | 166 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { |
155 registrar_.Add(pref_name.c_str(), this); | 167 registrar_.Add(pref_name.c_str(), this); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 if (pref) { | 384 if (pref) { |
373 for (PreferenceCallbackMap::const_iterator iter = | 385 for (PreferenceCallbackMap::const_iterator iter = |
374 pref_callback_map_.find(*pref_name); | 386 pref_callback_map_.find(*pref_name); |
375 iter != pref_callback_map_.end(); ++iter) { | 387 iter != pref_callback_map_.end(); ++iter) { |
376 const std::wstring& callback_function = iter->second; | 388 const std::wstring& callback_function = iter->second; |
377 ListValue result_value; | 389 ListValue result_value; |
378 result_value.Append(Value::CreateStringValue(pref_name->c_str())); | 390 result_value.Append(Value::CreateStringValue(pref_name->c_str())); |
379 | 391 |
380 DictionaryValue* dict = new DictionaryValue; | 392 DictionaryValue* dict = new DictionaryValue; |
381 dict->Set("value", pref->GetValue()->DeepCopy()); | 393 dict->Set("value", pref->GetValue()->DeepCopy()); |
382 dict->SetBoolean("managed", pref->IsManaged()); | 394 if (pref->IsManaged()) { |
383 dict->SetBoolean("extensionControlled", pref->IsExtensionControlled()); | 395 dict->SetString("controlledBy", "policy"); |
396 } else if (pref->IsExtensionControlled()) { | |
397 dict->SetString("controlledBy", "extension"); | |
398 } | |
Joao da Silva
2011/07/13 17:35:17
See comment above.
Bernhard Bauer
2011/07/13 22:15:12
Done.
| |
384 dict->SetBoolean("disabled", !pref->IsUserModifiable()); | 399 dict->SetBoolean("disabled", !pref->IsUserModifiable()); |
385 result_value.Append(dict); | 400 result_value.Append(dict); |
386 | 401 |
387 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), | 402 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), |
388 result_value); | 403 result_value); |
389 } | 404 } |
390 } | 405 } |
391 } | 406 } |
OLD | NEW |