Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: chrome/browser/extensions/extension_font_settings_api.cc

Issue 9836036: Add getDefaultFontSize and setDefaultFontSize to Font Settings Extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_font_settings_api.cc
diff --git a/chrome/browser/extensions/extension_font_settings_api.cc b/chrome/browser/extensions/extension_font_settings_api.cc
index 3359264e83c0a4c990d6b01ba007a78029aceda6..3f76f8bd4045c7bba9fa585a270b5ab9b6411af9 100644
--- a/chrome/browser/extensions/extension_font_settings_api.cc
+++ b/chrome/browser/extensions/extension_font_settings_api.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_error_utils.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/font_list_async.h"
namespace {
@@ -19,6 +20,7 @@ namespace {
const char kGenericFamilyKey[] = "genericFamily";
const char kFontNameKey[] = "fontName";
const char kLocalizedNameKey[] = "localizedName";
+const char kPixelSizeKey[] = "pixelSize";
const char kScriptKey[] = "script";
// Format for per-script font preference keys.
@@ -35,8 +37,7 @@ const char kWebKitGlobalFontPrefFormat[] =
// Gets the font name preference path from |details| which contains key
// |kGenericFamilyKey| and optionally |kScriptKey|.
-bool GetFontNamePrefPath(DictionaryValue* details, std::string* pref_path)
-{
+bool GetFontNamePrefPath(DictionaryValue* details, std::string* pref_path) {
std::string generic_family;
if (!details->GetString(kGenericFamilyKey, &generic_family))
return false;
@@ -110,8 +111,7 @@ void GetFontListFunction::FontListHasLoaded(scoped_ptr<ListValue> list) {
SendResponse(success);
}
-bool GetFontListFunction::CopyFontsToResult(ListValue* fonts)
-{
+bool GetFontListFunction::CopyFontsToResult(ListValue* fonts) {
scoped_ptr<ListValue> result(new ListValue());
for (ListValue::iterator it = fonts->begin(); it != fonts->end(); ++it) {
ListValue* font_list_value;
@@ -141,3 +141,28 @@ bool GetFontListFunction::CopyFontsToResult(ListValue* fonts)
result_.reset(result.release());
return true;
}
+
+bool GetDefaultFontSizeFunction::RunImpl() {
+ PrefService* prefs = profile_->GetPrefs();
+ int size = prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize);
+
+ DictionaryValue* result = new DictionaryValue();
+ result->SetInteger(kPixelSizeKey, size);
+ result_.reset(result);
+ return true;
+}
+
+bool SetDefaultFontSizeFunction::RunImpl() {
+ DictionaryValue* details = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
+
+ int size;
+ EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kPixelSizeKey, &size));
+
+ ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs();
+ prefs->SetExtensionControlledPref(extension_id(),
+ prefs::kWebKitGlobalDefaultFontSize,
+ kExtensionPrefsScopeRegular,
+ Value::CreateIntegerValue(size));
+ return true;
+}
« no previous file with comments | « chrome/browser/extensions/extension_font_settings_api.h ('k') | chrome/browser/extensions/extension_function_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698