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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_utils_mac.mm

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/options/font_settings_utils.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "base/mac/scoped_nsautorelease_pool.h"
10 #include "base/sys_string_conversions.h"
11 #include "base/values.h"
12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/pref_names.h"
14
15 static void ValidateFontFamily(PrefService* prefs,
16 const char* family_pref_name) {
17 // The native font settings dialog saved fonts by the font name, rather
18 // than the family name. This worked for the old dialog since
19 // -[NSFont fontWithName:size] accepted a font or family name, but the
20 // behavior was technically wrong. Since we really need the family name for
21 // the dom-ui options window, we will fix the saved preference if necessary.
22 NSString *family_name =
23 base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
24 NSFont *font = [NSFont fontWithName:family_name
25 size:[NSFont systemFontSize]];
26 if (font &&
27 [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
28 std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
29 prefs->SetString(family_pref_name, new_family_name);
30 }
31 }
32
33 // static
34 void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
35 ValidateFontFamily(prefs, prefs::kWebKitGlobalSerifFontFamily);
36 ValidateFontFamily(prefs, prefs::kWebKitGlobalSansSerifFontFamily);
37 ValidateFontFamily(prefs, prefs::kWebKitGlobalFixedFontFamily);
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698