| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 case Value::TYPE_DOUBLE: | 209 case Value::TYPE_DOUBLE: |
| 210 case Value::TYPE_STRING: | 210 case Value::TYPE_STRING: |
| 211 pref_service->Set(pref_name.c_str(), *value); | 211 pref_service->Set(pref_name.c_str(), *value); |
| 212 break; | 212 break; |
| 213 | 213 |
| 214 default: | 214 default: |
| 215 NOTREACHED(); | 215 NOTREACHED(); |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 | 218 |
| 219 pref_service->ScheduleSavePersistentPrefs(); | |
| 220 ProcessUserMetric(value, metric); | 219 ProcessUserMetric(value, metric); |
| 221 } | 220 } |
| 222 | 221 |
| 223 void CoreOptionsHandler::ClearPref(const std::string& pref_name, | 222 void CoreOptionsHandler::ClearPref(const std::string& pref_name, |
| 224 const std::string& metric) { | 223 const std::string& metric) { |
| 225 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); | 224 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); |
| 226 pref_service->ClearPref(pref_name.c_str()); | 225 pref_service->ClearPref(pref_name.c_str()); |
| 227 pref_service->ScheduleSavePersistentPrefs(); | |
| 228 | 226 |
| 229 if (!metric.empty()) | 227 if (!metric.empty()) |
| 230 UserMetrics::RecordComputedAction(metric); | 228 UserMetrics::RecordComputedAction(metric); |
| 231 } | 229 } |
| 232 | 230 |
| 233 void CoreOptionsHandler::ProcessUserMetric(const Value* value, | 231 void CoreOptionsHandler::ProcessUserMetric(const Value* value, |
| 234 const std::string& metric) { | 232 const std::string& metric) { |
| 235 if (metric.empty()) | 233 if (metric.empty()) |
| 236 return; | 234 return; |
| 237 | 235 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 const std::wstring& callback_function = iter->second; | 447 const std::wstring& callback_function = iter->second; |
| 450 ListValue result_value; | 448 ListValue result_value; |
| 451 result_value.Append(Value::CreateStringValue(pref_name->c_str())); | 449 result_value.Append(Value::CreateStringValue(pref_name->c_str())); |
| 452 | 450 |
| 453 result_value.Append(CreateValueForPref(pref_service, pref)); | 451 result_value.Append(CreateValueForPref(pref_service, pref)); |
| 454 | 452 |
| 455 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), | 453 web_ui_->CallJavascriptFunction(WideToASCII(callback_function), |
| 456 result_value); | 454 result_value); |
| 457 } | 455 } |
| 458 } | 456 } |
| OLD | NEW |