OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/font_list.h" | 5 #include "content/common/font_list.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
| 11 #include <utility> |
11 | 12 |
| 13 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 | 18 |
17 static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font, | 19 static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font, |
18 NEWTEXTMETRICEXW* physical_font, | 20 NEWTEXTMETRICEXW* physical_font, |
19 DWORD font_type, | 21 DWORD font_type, |
20 LPARAM lparam) { | 22 LPARAM lparam) { |
21 std::set<base::string16>* font_names = | 23 std::set<base::string16>* font_names = |
(...skipping 16 matching lines...) Expand all Loading... |
38 logfont.lfCharSet = DEFAULT_CHARSET; | 40 logfont.lfCharSet = DEFAULT_CHARSET; |
39 | 41 |
40 HDC hdc = ::GetDC(NULL); | 42 HDC hdc = ::GetDC(NULL); |
41 ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc, | 43 ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc, |
42 (LPARAM)&font_names, 0); | 44 (LPARAM)&font_names, 0); |
43 ::ReleaseDC(NULL, hdc); | 45 ::ReleaseDC(NULL, hdc); |
44 | 46 |
45 std::unique_ptr<base::ListValue> font_list(new base::ListValue); | 47 std::unique_ptr<base::ListValue> font_list(new base::ListValue); |
46 std::set<base::string16>::iterator iter; | 48 std::set<base::string16>::iterator iter; |
47 for (iter = font_names.begin(); iter != font_names.end(); ++iter) { | 49 for (iter = font_names.begin(); iter != font_names.end(); ++iter) { |
48 base::ListValue* font_item = new base::ListValue(); | 50 auto font_item = base::MakeUnique<base::ListValue>(); |
49 font_item->Append(new base::Value(*iter)); | 51 font_item->AppendString(*iter); |
50 font_item->Append(new base::Value(*iter)); | 52 font_item->AppendString(*iter); |
51 font_list->Append(font_item); | 53 font_list->Append(std::move(font_item)); |
52 } | 54 } |
53 return font_list; | 55 return font_list; |
54 } | 56 } |
55 | 57 |
56 } // namespace content | 58 } // namespace content |
OLD | NEW |