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/extensions/extension_font_settings_api.h" | 5 #include "chrome/browser/extensions/extension_font_settings_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DictionaryValue* font_name = new DictionaryValue(); | 135 DictionaryValue* font_name = new DictionaryValue(); |
136 font_name->Set(kFontNameKey, Value::CreateStringValue(name)); | 136 font_name->Set(kFontNameKey, Value::CreateStringValue(name)); |
137 font_name->Set(kLocalizedNameKey, Value::CreateStringValue(localized_name)); | 137 font_name->Set(kLocalizedNameKey, Value::CreateStringValue(localized_name)); |
138 result->Append(font_name); | 138 result->Append(font_name); |
139 } | 139 } |
140 | 140 |
141 result_.reset(result.release()); | 141 result_.reset(result.release()); |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 bool GetDefaultFontSizeFunction::RunImpl() { | 145 bool GetFontSizeExtensionFunction::RunImpl() { |
146 PrefService* prefs = profile_->GetPrefs(); | 146 PrefService* prefs = profile_->GetPrefs(); |
147 int size = prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize); | 147 int size = prefs->GetInteger(pref_name()); |
148 | 148 |
149 DictionaryValue* result = new DictionaryValue(); | 149 DictionaryValue* result = new DictionaryValue(); |
150 result->SetInteger(kPixelSizeKey, size); | 150 result->SetInteger(kPixelSizeKey, size); |
151 result_.reset(result); | 151 result_.reset(result); |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 bool SetDefaultFontSizeFunction::RunImpl() { | 155 bool SetFontSizeExtensionFunction::RunImpl() { |
156 DictionaryValue* details = NULL; | 156 DictionaryValue* details = NULL; |
157 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 157 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
158 | 158 |
159 int size; | 159 int size; |
160 EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kPixelSizeKey, &size)); | 160 EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kPixelSizeKey, &size)); |
161 | 161 |
162 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 162 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
163 prefs->SetExtensionControlledPref(extension_id(), | 163 prefs->SetExtensionControlledPref(extension_id(), |
164 prefs::kWebKitGlobalDefaultFontSize, | 164 pref_name(), |
165 kExtensionPrefsScopeRegular, | 165 kExtensionPrefsScopeRegular, |
166 Value::CreateIntegerValue(size)); | 166 Value::CreateIntegerValue(size)); |
167 return true; | 167 return true; |
168 } | 168 } |
| 169 |
| 170 const char* GetDefaultFontSizeFunction::pref_name() { |
| 171 return prefs::kWebKitGlobalDefaultFontSize; |
| 172 } |
| 173 |
| 174 const char* SetDefaultFontSizeFunction::pref_name() { |
| 175 return prefs::kWebKitGlobalDefaultFontSize; |
| 176 } |
| 177 |
| 178 const char* GetDefaultFixedFontSizeFunction::pref_name() { |
| 179 return prefs::kWebKitGlobalDefaultFixedFontSize; |
| 180 } |
| 181 |
| 182 const char* SetDefaultFixedFontSizeFunction::pref_name() { |
| 183 return prefs::kWebKitGlobalDefaultFixedFontSize; |
| 184 } |
| 185 |
| 186 const char* GetMinimumFontSizeFunction::pref_name() { |
| 187 return prefs::kWebKitGlobalMinimumFontSize; |
| 188 } |
| 189 |
| 190 const char* SetMinimumFontSizeFunction::pref_name() { |
| 191 return prefs::kWebKitGlobalMinimumFontSize; |
| 192 } |
OLD | NEW |