diff options
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/font_list.h | 26 | ||||
-rw-r--r-- | content/common/font_list_gtk.cc | 43 | ||||
-rw-r--r-- | content/common/font_list_mac.mm | 33 | ||||
-rw-r--r-- | content/common/font_list_win.cc | 55 | ||||
-rw-r--r-- | content/common/pepper_plugin_registry.cc | 19 | ||||
-rw-r--r-- | content/common/pepper_plugin_registry.h | 10 |
6 files changed, 160 insertions, 26 deletions
diff --git a/content/common/font_list.h b/content/common/font_list.h new file mode 100644 index 0000000..e4c01a9 --- /dev/null +++ b/content/common/font_list.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_FONT_LIST_H_ +#define CONTENT_COMMON_FONT_LIST_H_ + +class ListValue; + +namespace content { + +// Retrieves the fonts available on the current platform and returns them. +// The caller will own the returned pointer. Each entry will be a list of +// two strings, the first being the font family, and the second being the +// localized name. +// +// This function is potentially slow (the system may do a bunch of I/O) so be +// sure not to call this on a time-critical thread like the UI or I/O threads. +// +// Most callers will want to use the GetFontListAsync function in +// content/browser/font_list_async.h which does an asynchronous call. +ListValue* GetFontList_SlowBlocking(); + +} // namespace content + +#endif // CONTENT_COMMON_FONT_LIST_H_ diff --git a/content/common/font_list_gtk.cc b/content/common/font_list_gtk.cc new file mode 100644 index 0000000..0742bb3 --- /dev/null +++ b/content/common/font_list_gtk.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/font_list.h" + +#include <pango/pango.h> +#include <pango/pangocairo.h> + +#include <set> +#include <string> + +#include "base/values.h" + +namespace content { + +ListValue* GetFontList_SlowBlocking() { + ListValue* font_list = new ListValue; + + PangoFontMap* font_map = ::pango_cairo_font_map_get_default(); + PangoFontFamily** families = NULL; + int num_families = 0; + ::pango_font_map_list_families(font_map, &families, &num_families); + + std::set<std::string> sorted_families; + for (int i = 0; i < num_families; i++) { + sorted_families.insert(::pango_font_family_get_name(families[i])); + } + g_free(families); + + for (std::set<std::string>::const_iterator iter = sorted_families.begin(); + iter != sorted_families.end(); ++iter) { + ListValue* font_item = new ListValue(); + font_item->Append(Value::CreateStringValue(*iter)); + font_item->Append(Value::CreateStringValue(*iter)); // localized name. + // TODO(yusukes): Support localized family names. + font_list->Append(font_item); + } + + return font_list; +} + +} // namespace content diff --git a/content/common/font_list_mac.mm b/content/common/font_list_mac.mm new file mode 100644 index 0000000..08018cf --- /dev/null +++ b/content/common/font_list_mac.mm @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/font_list.h" + +#import <Cocoa/Cocoa.h> + +#include "base/mac/scoped_nsautorelease_pool.h" +#include "base/sys_string_conversions.h" +#include "base/values.h" + +namespace content { + +ListValue* GetFontList_SlowBlocking() { + base::mac::ScopedNSAutoreleasePool autorelease_pool; + ListValue* font_list = new ListValue; + NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease]; + NSArray* fonts = [fontManager availableFontFamilies]; + for (NSString* family_name in fonts) { + NSString* localized_family_name = + [fontManager localizedNameForFamily:family_name face:nil]; + ListValue* font_item = new ListValue(); + string16 family = base::SysNSStringToUTF16(family_name); + font_item->Append(Value::CreateStringValue(family)); + string16 loc_family = base::SysNSStringToUTF16(localized_family_name); + font_item->Append(Value::CreateStringValue(loc_family)); + font_list->Append(font_item); + } + return font_list; +} + +} // namespace content diff --git a/content/common/font_list_win.cc b/content/common/font_list_win.cc new file mode 100644 index 0000000..92428eb --- /dev/null +++ b/content/common/font_list_win.cc @@ -0,0 +1,55 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/common/font_list.h" + +#include <windows.h> + +#include <set> + +#include "base/string16.h" +#include "base/values.h" + +namespace content { + +static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* logical_font, + NEWTEXTMETRICEXW* physical_font, + DWORD font_type, + LPARAM lparam) { + std::set<string16>* font_names = + reinterpret_cast<std::set<string16>*>(lparam); + if (font_names) { + const LOGFONTW& lf = logical_font->elfLogFont; + if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') { + string16 face_name(lf.lfFaceName); + font_names->insert(face_name); + } + } + return 1; +} + +ListValue* GetFontList_SlowBlocking() { + std::set<string16> font_names; + + LOGFONTW logfont; + memset(&logfont, 0, sizeof(logfont)); + logfont.lfCharSet = DEFAULT_CHARSET; + + HDC hdc = ::GetDC(NULL); + ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc, + (LPARAM)&font_names, 0); + ::ReleaseDC(NULL, hdc); + + ListValue* font_list = new ListValue; + std::set<string16>::iterator iter; + for (iter = font_names.begin(); iter != font_names.end(); iter++) { + ListValue* font_item = new ListValue(); + font_item->Append(Value::CreateStringValue(*iter)); + font_item->Append(Value::CreateStringValue(*iter)); + font_list->Append(font_item); + } + return font_list; +} + +} // namespace content diff --git a/content/common/pepper_plugin_registry.cc b/content/common/pepper_plugin_registry.cc index 3966efa..9e68f44 100644 --- a/content/common/pepper_plugin_registry.cc +++ b/content/common/pepper_plugin_registry.cc @@ -229,22 +229,3 @@ base::WaitableEvent* PepperPluginRegistry::GetShutdownEvent() { DCHECK(ChildProcess::current()) << "Must be in the renderer."; return ChildProcess::current()->GetShutDownEvent(); } - -std::set<PP_Instance>* PepperPluginRegistry::GetGloballySeenInstanceIDSet() { - // This function is not needed on the host side of the proxy. - NOTREACHED(); - return NULL; -} - -ppapi::WebKitForwarding* PepperPluginRegistry::GetWebKitForwarding() { - // This function is not needed on the host side of the proxy. - NOTREACHED(); - return NULL; -} - -void PepperPluginRegistry::PostToWebKitThread( - const tracked_objects::Location& from_here, - const base::Closure& task) { - // This function is not needed on the host side of the proxy. - NOTREACHED(); -} diff --git a/content/common/pepper_plugin_registry.h b/content/common/pepper_plugin_registry.h index d6e320f..5e6389e 100644 --- a/content/common/pepper_plugin_registry.h +++ b/content/common/pepper_plugin_registry.h @@ -12,7 +12,7 @@ #include <vector> #include "base/file_path.h" -#include "ppapi/proxy/dispatcher.h" +#include "ppapi/proxy/proxy_channel.h" #include "webkit/plugins/npapi/webplugininfo.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -53,7 +53,7 @@ struct PepperPluginInfo { // not preloaded). class PepperPluginRegistry : public webkit::ppapi::PluginDelegate::ModuleLifetime, - public pp::proxy::Dispatcher::Delegate { + public pp::proxy::ProxyChannel::Delegate { public: ~PepperPluginRegistry(); @@ -96,13 +96,9 @@ class PepperPluginRegistry private: PepperPluginRegistry(); - // Dispatcher::Delegate implementation. + // ProxyChannel::Delegate implementation. virtual base::MessageLoopProxy* GetIPCMessageLoop(); virtual base::WaitableEvent* GetShutdownEvent(); - virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet(); - virtual ppapi::WebKitForwarding* GetWebKitForwarding(); - virtual void PostToWebKitThread(const tracked_objects::Location& from_here, - const base::Closure& task); // All known pepper plugins. std::vector<PepperPluginInfo> plugin_list_; |