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

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

Issue 2441343003: Allow the default generic font family settings to find the first available font (Closed)
Patch Set: msw review Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9d60a6ce23c17cbc85c144732b94ad0bb59283a1..1d3420a82767c8d272d09974cb53cb0bbbfbcd81 100644
--- a/chrome/browser/extensions/api/font_settings/font_settings_api.cc
+++ b/chrome/browser/extensions/api/font_settings/font_settings_api.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/extensions/api/preference/preference_helpers.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/options/font_settings_utils.h"
#include "chrome/common/extensions/api/font_settings.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_names_util.h"
@@ -36,14 +37,10 @@
#include "extensions/browser/extension_system.h"
#include "extensions/common/error_utils.h"
-#if defined(OS_WIN)
-#include "ui/gfx/font.h"
-#include "ui/gfx/platform_font_win.h"
-#endif
-
namespace extensions {
namespace fonts = api::font_settings;
+using options::FontSettingsUtilities;
namespace {
@@ -73,20 +70,6 @@ std::string GetFontNamePrefPath(fonts::GenericFamily generic_family_enum,
script.c_str());
}
-// 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.
-std::string MaybeGetLocalizedFontName(const std::string& font_name) {
-#if defined(OS_WIN)
- if (!font_name.empty()) {
- gfx::Font font(font_name, 12); // dummy font size
- return static_cast<gfx::PlatformFontWin*>(font.platform_font())->
- GetLocalizedFontName();
- }
-#endif
- return font_name;
-}
-
// Registers |obs| to observe per-script font prefs under the path |map_name|.
void RegisterFontFamilyMapObserver(
PrefChangeRegistrar* registrar,
@@ -177,7 +160,7 @@ void FontSettingsEventRouter::OnFontNamePrefChanged(
NOTREACHED();
return;
}
- font_name = MaybeGetLocalizedFontName(font_name);
+ font_name = FontSettingsUtilities::MaybeGetLocalizedFontName(font_name);
base::ListValue args;
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
@@ -263,7 +246,7 @@ ExtensionFunction::ResponseAction FontSettingsGetFontFunction::Run() {
std::string font_name;
EXTENSION_FUNCTION_VALIDATE(
pref && pref->GetValue()->GetAsString(&font_name));
- font_name = MaybeGetLocalizedFontName(font_name);
+ font_name = FontSettingsUtilities::MaybeGetLocalizedFontName(font_name);
// We don't support incognito-specific font prefs, so don't consider them when
// getting level of control.
« no previous file with comments | « no previous file | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698