| 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 "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 const PrefService::Preference* pref = | 120 const PrefService::Preference* pref = |
| 121 pref_service->FindPreference(pref_name.c_str()); | 121 pref_service->FindPreference(pref_name.c_str()); |
| 122 | 122 |
| 123 return pref ? pref->GetValue()->DeepCopy() : Value::CreateNullValue(); | 123 return pref ? pref->GetValue()->DeepCopy() : Value::CreateNullValue(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { | 126 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { |
| 127 DCHECK(dom_ui_); | 127 DCHECK(dom_ui_); |
| 128 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); | 128 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); |
| 129 | |
| 130 pref_service->AddPrefObserver(pref_name.c_str(), this); | 129 pref_service->AddPrefObserver(pref_name.c_str(), this); |
| 131 } | 130 } |
| 132 | 131 |
| 133 void CoreOptionsHandler::SetPref(const std::string& pref_name, | 132 void CoreOptionsHandler::SetPref(const std::string& pref_name, |
| 134 Value::ValueType pref_type, | 133 Value::ValueType pref_type, |
| 135 const std::string& value_string) { | 134 const std::string& value_string) { |
| 136 DCHECK(dom_ui_); | 135 DCHECK(dom_ui_); |
| 137 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); | 136 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); |
| 138 | 137 |
| 139 switch (pref_type) { | 138 switch (pref_type) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 pref_callback_map_.find(*pref_name); | 277 pref_callback_map_.find(*pref_name); |
| 279 iter != pref_callback_map_.end(); ++iter) { | 278 iter != pref_callback_map_.end(); ++iter) { |
| 280 const std::wstring& callback_function = iter->second; | 279 const std::wstring& callback_function = iter->second; |
| 281 ListValue result_value; | 280 ListValue result_value; |
| 282 result_value.Append(Value::CreateStringValue(pref_name->c_str())); | 281 result_value.Append(Value::CreateStringValue(pref_name->c_str())); |
| 283 result_value.Append(pref->GetValue()->DeepCopy()); | 282 result_value.Append(pref->GetValue()->DeepCopy()); |
| 284 dom_ui_->CallJavascriptFunction(callback_function, result_value); | 283 dom_ui_->CallJavascriptFunction(callback_function, result_value); |
| 285 } | 284 } |
| 286 } | 285 } |
| 287 } | 286 } |
| 287 |
| OLD | NEW |