| Index: chrome/browser/ui/webui/settings_utils_mac.mm
|
| diff --git a/chrome/browser/ui/webui/settings_utils_mac.mm b/chrome/browser/ui/webui/settings_utils_mac.mm
|
| index 1f68f49dae76f40078fb7fca2922d7fea7b175a3..0611e978343804f94026a3cec9f9940089877779 100644
|
| --- a/chrome/browser/ui/webui/settings_utils_mac.mm
|
| +++ b/chrome/browser/ui/webui/settings_utils_mac.mm
|
| @@ -9,6 +9,28 @@
|
| #include "base/logging.h"
|
| #include "base/mac/mac_logging.h"
|
| #include "base/mac/scoped_aedesc.h"
|
| +#include "base/mac/scoped_nsautorelease_pool.h"
|
| +#include "base/strings/sys_string_conversions.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "components/prefs/pref_service.h"
|
| +
|
| +namespace {
|
| +void ValidateFontFamily(PrefService* prefs, const char* family_pref_name) {
|
| + // The native font settings dialog saved fonts by the font name, rather
|
| + // than the family name. This worked for the old dialog since
|
| + // -[NSFont fontWithName:size] accepted a font or family name, but the
|
| + // behavior was technically wrong. Since we really need the family name for
|
| + // the webui settings window, we will fix the saved preference if necessary.
|
| + NSString* family_name =
|
| + base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
|
| + NSFont* font = [NSFont fontWithName:family_name size:[NSFont systemFontSize]];
|
| + if (font &&
|
| + [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
|
| + std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
|
| + prefs->SetString(family_pref_name, new_family_name);
|
| + }
|
| +}
|
| +} // namespace
|
|
|
| namespace settings_utils {
|
|
|
| @@ -41,4 +63,10 @@ void ShowManageSSLCertificates(content::WebContents* web_contents) {
|
| launchIdentifier:nil];
|
| }
|
|
|
| +void ValidateSavedFonts(PrefService* prefs) {
|
| + ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
|
| + ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
|
| + ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
|
| +}
|
| +
|
| } // namespace settings_utils
|
|
|