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

Unified Diff: chrome/browser/extensions/api/font_settings/font_settings_api.cc

Issue 11336008: When a font family pref changes to the empty string, pass it to WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add unit test Created 8 years, 2 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/api/font_settings/font_settings_api.cc
diff --git a/chrome/browser/extensions/api/font_settings/font_settings_api.cc b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
index 93d6a9c32cebb19b224cd6c64026b000495df5f1..d40a09703c901e28ceb56cd8f1e2ece9df428d45 100644
--- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc
+++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
@@ -20,6 +20,7 @@
#include "chrome/common/extensions/api/font_settings.h"
#include "chrome/common/extensions/extension_error_utils.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_names_util.h"
#include "content/public/browser/font_list_async.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@@ -55,7 +56,6 @@ const char kOnMinimumFontSizeChanged[] =
// Format for font name preference paths.
const char kWebKitFontPrefFormat[] = "webkit.webprefs.fonts.%s.%s";
-const char kWebKitFontPrefPrefix[] = "webkit.webprefs.fonts.";
// Gets the font name preference path for |generic_family| and |script|. If
// |script| is NULL, uses prefs::kWebKitCommonScript.
@@ -70,22 +70,6 @@ std::string GetFontNamePrefPath(fonts::GenericFamily generic_family_enum,
script.c_str());
}
-// Extracts the generic family and script from font name pref path |pref_path|.
-bool ParseFontNamePrefPath(std::string pref_path,
- std::string* generic_family,
- std::string* script) {
- if (!StartsWithASCII(pref_path, kWebKitFontPrefPrefix, true))
- return false;
-
- size_t start = strlen(kWebKitFontPrefPrefix);
- size_t pos = pref_path.find('.', start);
- if (pos == std::string::npos || pos + 1 == pref_path.length())
- return false;
- *generic_family = pref_path.substr(start, pos - start);
- *script = pref_path.substr(pos + 1);
- return true;
-}
-
// Returns the localized name of a font so that it can be matched within the
// list of system fonts. On Windows, the list of system fonts has names only
// for the system locale, but the pref value may be in the English name.
@@ -180,7 +164,8 @@ void FontSettingsEventRouter::Observe(
std::string generic_family;
std::string script;
- if (ParseFontNamePrefPath(*pref_name, &generic_family, &script)) {
+ if (pref_names_util::ParseFontNamePrefPath(*pref_name, &generic_family,
+ &script)) {
OnFontNamePrefChanged(pref_service, *pref_name, generic_family, script,
incognito);
return;
« no previous file with comments | « no previous file | chrome/browser/ui/prefs/prefs_tab_helper.h » ('j') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698