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

Side by Side Diff: content/common/font_list_x11.cc

Issue 9500008: Move font_list_async.h to content/public. Switch to Pass() goodness to simplify code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix clang 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
« no previous file with comments | « content/common/font_list_win.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <pango/pango.h> 7 #include <pango/pango.h>
8 #include <pango/pangocairo.h> 8 #include <pango/pangocairo.h>
9 9
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/values.h" 13 #include "base/values.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 ListValue* GetFontList_SlowBlocking() { 17 scoped_ptr<ListValue> GetFontList_SlowBlocking() {
18 ListValue* font_list = new ListValue; 18 scoped_ptr<ListValue> font_list(new ListValue);
19 19
20 PangoFontMap* font_map = ::pango_cairo_font_map_get_default(); 20 PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
21 PangoFontFamily** families = NULL; 21 PangoFontFamily** families = NULL;
22 int num_families = 0; 22 int num_families = 0;
23 ::pango_font_map_list_families(font_map, &families, &num_families); 23 ::pango_font_map_list_families(font_map, &families, &num_families);
24 24
25 std::set<std::string> sorted_families; 25 std::set<std::string> sorted_families;
26 for (int i = 0; i < num_families; i++) { 26 for (int i = 0; i < num_families; i++) {
27 sorted_families.insert(::pango_font_family_get_name(families[i])); 27 sorted_families.insert(::pango_font_family_get_name(families[i]));
28 } 28 }
29 g_free(families); 29 g_free(families);
30 30
31 for (std::set<std::string>::const_iterator iter = sorted_families.begin(); 31 for (std::set<std::string>::const_iterator iter = sorted_families.begin();
32 iter != sorted_families.end(); ++iter) { 32 iter != sorted_families.end(); ++iter) {
33 ListValue* font_item = new ListValue(); 33 ListValue* font_item = new ListValue();
34 font_item->Append(Value::CreateStringValue(*iter)); 34 font_item->Append(Value::CreateStringValue(*iter));
35 font_item->Append(Value::CreateStringValue(*iter)); // localized name. 35 font_item->Append(Value::CreateStringValue(*iter)); // localized name.
36 // TODO(yusukes): Support localized family names. 36 // TODO(yusukes): Support localized family names.
37 font_list->Append(font_item); 37 font_list->Append(font_item);
38 } 38 }
39 39
40 return font_list; 40 return font_list.Pass();
41 } 41 }
42 42
43 } // namespace content 43 } // namespace content
OLDNEW
« no previous file with comments | « content/common/font_list_win.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698