Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gesture_config_ui.h" | 5 #include "chrome/browser/ui/webui/gesture_config_ui.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GestureConfigUI::SetPreferenceValue(const base::ListValue* args) { | 102 void GestureConfigUI::SetPreferenceValue(const base::ListValue* args) { |
| 103 std::string pref_name; | 103 std::string pref_name; |
| 104 double value; | 104 double value; |
| 105 | 105 |
| 106 if (!args->GetString(0, &pref_name) || !args->GetDouble(1, &value)) return; | 106 if (!args->GetString(0, &pref_name) || !args->GetDouble(1, &value)) return; |
| 107 | 107 |
| 108 Profile* profile = Profile::FromWebUI(web_ui()); | 108 Profile* profile = Profile::FromWebUI(web_ui()); |
| 109 PrefService* prefs = profile->GetPrefs(); | 109 PrefService* prefs = profile->GetPrefs(); |
| 110 | 110 |
|
mohsen
2013/01/03 15:20:28
The following part is to add the ability to set in
| |
| 111 prefs->SetDouble(pref_name.c_str(), value); | 111 const PrefService::Preference* pref = |
| 112 prefs->FindPreference(pref_name.c_str()); | |
| 113 switch (pref->GetType()) { | |
| 114 case base::Value::TYPE_INTEGER: | |
| 115 prefs->SetInteger(pref_name.c_str(), static_cast<int>(value)); | |
|
rjkroege
2013/01/03 22:42:49
the type conversion would happen implicitly? Is th
mohsen
2013/01/04 16:14:22
The main reason is that I wrote this code similar
| |
| 116 break; | |
| 117 case base::Value::TYPE_DOUBLE: | |
| 118 prefs->SetDouble(pref_name.c_str(), value); | |
| 119 break; | |
| 120 default: | |
| 121 NOTREACHED(); | |
| 122 } | |
| 112 } | 123 } |
| 113 | 124 |
| OLD | NEW |