Remove obsolete Channel ID expiration time from site data viewer.
[chromium-blink-merge.git] / content / common / font_list_win.cc
blob775c6f65c309b37037f2f7b0d6774d4677a2ed39
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 #include <windows.h>
9 #include <set>
11 #include "base/string16.h"
12 #include "base/values.h"
14 namespace content {
16 static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font,
17 NEWTEXTMETRICEXW* physical_font,
18 DWORD font_type,
19 LPARAM lparam) {
20 std::set<string16>* font_names =
21 reinterpret_cast<std::set<string16>*>(lparam);
22 if (font_names) {
23 const LOGFONTW& lf = logical_font->elfLogFont;
24 if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') {
25 string16 face_name(lf.lfFaceName);
26 font_names->insert(face_name);
29 return 1;
32 scoped_ptr<base::ListValue> GetFontList_SlowBlocking() {
33 std::set<string16> font_names;
35 LOGFONTW logfont;
36 memset(&logfont, 0, sizeof(logfont));
37 logfont.lfCharSet = DEFAULT_CHARSET;
39 HDC hdc = ::GetDC(NULL);
40 ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc,
41 (LPARAM)&font_names, 0);
42 ::ReleaseDC(NULL, hdc);
44 scoped_ptr<base::ListValue> font_list(new base::ListValue);
45 std::set<string16>::iterator iter;
46 for (iter = font_names.begin(); iter != font_names.end(); ++iter) {
47 base::ListValue* font_item = new base::ListValue();
48 font_item->Append(new base::StringValue(*iter));
49 font_item->Append(new base::StringValue(*iter));
50 font_list->Append(font_item);
52 return font_list.Pass();
55 } // namespace content