Print Preview: Refactoring print/cancel button and print summary.
[chromium-blink-merge.git] / content / common / font_list_mac.mm
blob08018cf3478108b6dae458b14d439139daee77b8
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.
5 #include "content/common/font_list.h"
7 #import <Cocoa/Cocoa.h>
9 #include "base/mac/scoped_nsautorelease_pool.h"
10 #include "base/sys_string_conversions.h"
11 #include "base/values.h"
13 namespace content {
15 ListValue* GetFontList_SlowBlocking() {
16   base::mac::ScopedNSAutoreleasePool autorelease_pool;
17   ListValue* font_list = new ListValue;
18   NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
19   NSArray* fonts = [fontManager availableFontFamilies];
20   for (NSString* family_name in fonts) {
21     NSString* localized_family_name =
22         [fontManager localizedNameForFamily:family_name face:nil];
23     ListValue* font_item = new ListValue();
24     string16 family = base::SysNSStringToUTF16(family_name);
25     font_item->Append(Value::CreateStringValue(family));
26     string16 loc_family = base::SysNSStringToUTF16(localized_family_name);
27     font_item->Append(Value::CreateStringValue(loc_family));
28     font_list->Append(font_item);
29   }
30   return font_list;
33 }  // namespace content