| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/core_options_handler.h" | 5 #include "chrome/browser/dom_ui/core_options_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 l10n_util::GetString(IDS_OPTIONS_CONTENT_TAB_LABEL)); | 50 l10n_util::GetString(IDS_OPTIONS_CONTENT_TAB_LABEL)); |
| 51 localized_strings->SetString(L"advancedPage", | 51 localized_strings->SetString(L"advancedPage", |
| 52 l10n_util::GetString(IDS_OPTIONS_ADVANCED_TAB_LABEL)); | 52 l10n_util::GetString(IDS_OPTIONS_ADVANCED_TAB_LABEL)); |
| 53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
| 54 localized_strings->SetString(L"internetPage", | 54 localized_strings->SetString(L"internetPage", |
| 55 l10n_util::GetString(IDS_OPTIONS_INTERNET_TAB_LABEL)); | 55 l10n_util::GetString(IDS_OPTIONS_INTERNET_TAB_LABEL)); |
| 56 localized_strings->SetString(L"languageHangulPage", | 56 localized_strings->SetString(L"languageHangulPage", |
| 57 l10n_util::GetString( | 57 l10n_util::GetString( |
| 58 IDS_OPTIONS_SETTINGS_LANGUAGES_HANGUL_SETTINGS_TITLE)); | 58 IDS_OPTIONS_SETTINGS_LANGUAGES_HANGUL_SETTINGS_TITLE)); |
| 59 #endif | 59 #endif |
| 60 |
| 61 localized_strings->SetString(L"ok", |
| 62 l10n_util::GetString(IDS_OK)); |
| 63 localized_strings->SetString(L"cancel", |
| 64 l10n_util::GetString(IDS_CANCEL)); |
| 65 localized_strings->SetString(L"delete", |
| 66 l10n_util::GetString(IDS_DELETE)); |
| 67 localized_strings->SetString(L"edit", |
| 68 l10n_util::GetString(IDS_EDIT)); |
| 69 localized_strings->SetString(L"learnMore", |
| 70 l10n_util::GetString(IDS_LEARN_MORE)); |
| 71 localized_strings->SetString(L"abort", |
| 72 l10n_util::GetString(IDS_ABORT)); |
| 73 localized_strings->SetString(L"close", |
| 74 l10n_util::GetString(IDS_CLOSE)); |
| 75 localized_strings->SetString(L"done", |
| 76 l10n_util::GetString(IDS_DONE)); |
| 60 } | 77 } |
| 61 | 78 |
| 62 void CoreOptionsHandler::Observe(NotificationType type, | 79 void CoreOptionsHandler::Observe(NotificationType type, |
| 63 const NotificationSource& source, | 80 const NotificationSource& source, |
| 64 const NotificationDetails& details) { | 81 const NotificationDetails& details) { |
| 65 if (type == NotificationType::PREF_CHANGED) | 82 if (type == NotificationType::PREF_CHANGED) |
| 66 NotifyPrefChanged(Details<std::wstring>(details).ptr()); | 83 NotifyPrefChanged(Details<std::wstring>(details).ptr()); |
| 67 } | 84 } |
| 68 | 85 |
| 69 void CoreOptionsHandler::RegisterMessages() { | 86 void CoreOptionsHandler::RegisterMessages() { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return; | 149 return; |
| 133 | 150 |
| 134 const ListValue* param_values = static_cast<const ListValue*>(value); | 151 const ListValue* param_values = static_cast<const ListValue*>(value); |
| 135 | 152 |
| 136 // First param is name of callback function, so, there needs to be at least | 153 // First param is name of callback function, so, there needs to be at least |
| 137 // one more element for the actual preference identifier. | 154 // one more element for the actual preference identifier. |
| 138 const size_t kMinFetchPrefsParamCount = 2; | 155 const size_t kMinFetchPrefsParamCount = 2; |
| 139 if (param_values->GetSize() < kMinFetchPrefsParamCount) | 156 if (param_values->GetSize() < kMinFetchPrefsParamCount) |
| 140 return; | 157 return; |
| 141 | 158 |
| 142 size_t idx = param_values->GetSize(); | |
| 143 LOG(INFO) << "param_values->GetSize() = " << idx; | |
| 144 // Get callback JS function name. | 159 // Get callback JS function name. |
| 145 Value* callback; | 160 Value* callback; |
| 146 if (!param_values->Get(0, &callback) || !callback->IsType(Value::TYPE_STRING)) | 161 if (!param_values->Get(0, &callback) || !callback->IsType(Value::TYPE_STRING)) |
| 147 return; | 162 return; |
| 148 | 163 |
| 149 std::wstring callback_function; | 164 std::wstring callback_function; |
| 150 if (!callback->GetAsString(&callback_function)) | 165 if (!callback->GetAsString(&callback_function)) |
| 151 return; | 166 return; |
| 152 | 167 |
| 153 // Get the list of name for prefs to build the response dictionary. | 168 // Get the list of name for prefs to build the response dictionary. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 237 |
| 223 void CoreOptionsHandler::HandleSetObjectPref(const Value* value) { | 238 void CoreOptionsHandler::HandleSetObjectPref(const Value* value) { |
| 224 HandleSetPref(value, Value::TYPE_NULL); | 239 HandleSetPref(value, Value::TYPE_NULL); |
| 225 } | 240 } |
| 226 | 241 |
| 227 void CoreOptionsHandler::HandleSetPref(const Value* value, | 242 void CoreOptionsHandler::HandleSetPref(const Value* value, |
| 228 Value::ValueType type) { | 243 Value::ValueType type) { |
| 229 if (!value || !value->IsType(Value::TYPE_LIST)) | 244 if (!value || !value->IsType(Value::TYPE_LIST)) |
| 230 return; | 245 return; |
| 231 const ListValue* param_values = static_cast<const ListValue*>(value); | 246 const ListValue* param_values = static_cast<const ListValue*>(value); |
| 232 size_t size = param_values->GetSize(); | |
| 233 LOG(INFO) << "Array size = " << size; | |
| 234 if (param_values->GetSize() != 2) | 247 if (param_values->GetSize() != 2) |
| 235 return; | 248 return; |
| 236 | 249 |
| 237 std::wstring pref_name; | 250 std::wstring pref_name; |
| 238 if (!param_values->GetString(0, &pref_name)) | 251 if (!param_values->GetString(0, &pref_name)) |
| 239 return; | 252 return; |
| 240 | 253 |
| 241 std::string value_string; | 254 std::string value_string; |
| 242 if (!param_values->GetString(1, &value_string)) | 255 if (!param_values->GetString(1, &value_string)) |
| 243 return; | 256 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 256 pref_callback_map_.find(*pref_name); | 269 pref_callback_map_.find(*pref_name); |
| 257 iter != pref_callback_map_.end(); ++iter) { | 270 iter != pref_callback_map_.end(); ++iter) { |
| 258 const std::wstring& callback_function = iter->second; | 271 const std::wstring& callback_function = iter->second; |
| 259 ListValue result_value; | 272 ListValue result_value; |
| 260 result_value.Append(Value::CreateStringValue(pref_name->c_str())); | 273 result_value.Append(Value::CreateStringValue(pref_name->c_str())); |
| 261 result_value.Append(pref->GetValue()->DeepCopy()); | 274 result_value.Append(pref->GetValue()->DeepCopy()); |
| 262 dom_ui_->CallJavascriptFunction(callback_function, result_value); | 275 dom_ui_->CallJavascriptFunction(callback_function, result_value); |
| 263 } | 276 } |
| 264 } | 277 } |
| 265 } | 278 } |
| OLD | NEW |