diff options
-rw-r--r-- | content/renderer/pepper/pepper_in_process_resource_creation.cc | 16 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_in_process_resource_creation.h | 3 | ||||
-rw-r--r-- | ppapi/ppapi_internal.gyp | 6 | ||||
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 3 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/browser_font_resource_trusted.cc (renamed from ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc) | 49 | ||||
-rw-r--r-- | ppapi/proxy/browser_font_resource_trusted.h (renamed from ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h) | 41 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 8 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.cc | 13 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.h | 3 |
10 files changed, 71 insertions, 73 deletions
diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.cc b/content/renderer/pepper/pepper_in_process_resource_creation.cc index 37599ff..5fbd426 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.cc +++ b/content/renderer/pepper/pepper_in_process_resource_creation.cc @@ -13,6 +13,7 @@ #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" #include "ppapi/host/ppapi_host.h" +#include "ppapi/proxy/browser_font_resource_trusted.h" #include "ppapi/proxy/file_chooser_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/printing_resource.h" @@ -42,6 +43,21 @@ PepperInProcessResourceCreation::PepperInProcessResourceCreation( PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { } +PP_Resource PepperInProcessResourceCreation::CreateBrowserFont( + PP_Instance instance, + const PP_BrowserFont_Trusted_Description* description) { + if (!ppapi::proxy::BrowserFontResource_Trusted::IsPPFontDescriptionValid( + *description)) + return 0; + ppapi::Preferences prefs( + host_impl_->GetRenderViewForInstance(instance)->GetWebkitPreferences()); + return (new ppapi::proxy::BrowserFontResource_Trusted( + host_impl_->in_process_router()->GetPluginConnection(), + instance, + *description, + prefs))->GetReference(); +} + PP_Resource PepperInProcessResourceCreation::CreateFileChooser( PP_Instance instance, PP_FileChooserMode_Dev mode, diff --git a/content/renderer/pepper/pepper_in_process_resource_creation.h b/content/renderer/pepper/pepper_in_process_resource_creation.h index 8b5374d..e830221 100644 --- a/content/renderer/pepper/pepper_in_process_resource_creation.h +++ b/content/renderer/pepper/pepper_in_process_resource_creation.h @@ -42,6 +42,9 @@ class PepperInProcessResourceCreation virtual ~PepperInProcessResourceCreation(); // ResourceCreation_API implementation. + virtual PP_Resource CreateBrowserFont( + PP_Instance instance, + const PP_BrowserFont_Trusted_Description* description) OVERRIDE; virtual PP_Resource CreateFileChooser( PP_Instance instance, PP_FileChooserMode_Dev mode, diff --git a/ppapi/ppapi_internal.gyp b/ppapi/ppapi_internal.gyp index 6b27526..26a9dbf 100644 --- a/ppapi/ppapi_internal.gyp +++ b/ppapi/ppapi_internal.gyp @@ -110,6 +110,9 @@ '../media/media.gyp:shared_memory_support', '../ipc/ipc.gyp:ipc', '../skia/skia.gyp:skia', + '../third_party/icu/icu.gyp:icuuc', + # TODO(ananta) : The WebKit dependency needs to move to a new target for NACL. + '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', '../ui/surface/surface.gyp:surface', 'ppapi.gyp:ppapi_c', 'ppapi_shared', @@ -143,6 +146,9 @@ '../media/media.gyp:shared_memory_support', '../ipc/ipc.gyp:ipc', '../skia/skia.gyp:skia', + '../third_party/icu/icu.gyp:icuuc', + # TODO(ananta) : The WebKit dependency needs to move to a new target for NACL. + '<(webkit_src_dir)/Source/WebKit/chromium/WebKit.gyp:webkit', '../ui/surface/surface.gyp:surface', 'ppapi.gyp:ppapi_c', 'ppapi_shared', diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 0b856e0..601c021 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -23,6 +23,8 @@ 'proxy/audio_input_resource.h', 'proxy/broker_dispatcher.cc', 'proxy/broker_dispatcher.h', + 'proxy/browser_font_resource_trusted.cc', + 'proxy/browser_font_resource_trusted.h', 'proxy/connection.h', 'proxy/dispatcher.cc', 'proxy/dispatcher.h', @@ -177,6 +179,7 @@ 'sources!': [ 'proxy/audio_input_resource.cc', 'proxy/broker_dispatcher.cc', + 'proxy/browser_font_resource_trusted.cc', 'proxy/flash_clipboard_resource.cc', 'proxy/flash_device_id_resource.cc', 'proxy/flash_font_file_resource.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index c144fef..b8f6a6b 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -113,8 +113,6 @@ 'shared_impl/private/net_address_private_impl.cc', 'shared_impl/private/net_address_private_impl.h', - 'shared_impl/private/ppb_browser_font_trusted_shared.cc', - 'shared_impl/private/ppb_browser_font_trusted_shared.h', 'shared_impl/private/ppb_char_set_shared.cc', 'shared_impl/private/ppb_char_set_shared.h', 'shared_impl/private/ppb_host_resolver_shared.cc', diff --git a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc b/ppapi/proxy/browser_font_resource_trusted.cc index f16154a..3e34199 100644 --- a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc +++ b/ppapi/proxy/browser_font_resource_trusted.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" +#include "ppapi/proxy/browser_font_resource_trusted.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -13,14 +13,14 @@ #include "ppapi/thunk/ppb_image_data_api.h" #include "ppapi/thunk/thunk.h" #include "skia/ext/platform_canvas.h" -#include "third_party/skia/include/core/SkRect.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFont.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFontDescription.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextRun.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFont.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFontDescription.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextRun.h" +#include "third_party/skia/include/core/SkRect.h" #include "unicode/ubidi.h" using ppapi::StringVar; @@ -35,6 +35,7 @@ using WebKit::WebTextRun; using WebKit::WebCanvas; namespace ppapi { +namespace proxy { namespace { @@ -223,7 +224,7 @@ WebFontDescription PPFontDescToWebFontDesc( } // namespace // static -bool PPB_BrowserFont_Trusted_Shared::IsPPFontDescriptionValid( +bool BrowserFontResource_Trusted::IsPPFontDescriptionValid( const PP_BrowserFont_Trusted_Description& desc) { // Check validity of string. We can't check the actual text since we could // be on the wrong thread and don't know if we're in the plugin or the host. @@ -246,37 +247,24 @@ bool PPB_BrowserFont_Trusted_Shared::IsPPFontDescriptionValid( return true; } -// static -PP_Resource PPB_BrowserFont_Trusted_Shared::Create( - ResourceObjectType type, - PP_Instance instance, - const PP_BrowserFont_Trusted_Description& description, - const Preferences& prefs) { - if (!PPB_BrowserFont_Trusted_Shared::IsPPFontDescriptionValid(description)) - return 0; - return (new PPB_BrowserFont_Trusted_Shared(type, instance, - description, - prefs))->GetReference(); -} - -PPB_BrowserFont_Trusted_Shared::PPB_BrowserFont_Trusted_Shared( - ResourceObjectType type, +BrowserFontResource_Trusted::BrowserFontResource_Trusted( + Connection connection, PP_Instance instance, const PP_BrowserFont_Trusted_Description& desc, const Preferences& prefs) - : Resource(type, instance), + : PluginResource(connection, instance), font_(WebFont::create(PPFontDescToWebFontDesc(desc, prefs))) { } -PPB_BrowserFont_Trusted_Shared::~PPB_BrowserFont_Trusted_Shared() { +BrowserFontResource_Trusted::~BrowserFontResource_Trusted() { } thunk::PPB_BrowserFont_Trusted_API* -PPB_BrowserFont_Trusted_Shared::AsPPB_BrowserFont_Trusted_API() { +BrowserFontResource_Trusted::AsPPB_BrowserFont_Trusted_API() { return this; } -PP_Bool PPB_BrowserFont_Trusted_Shared::Describe( +PP_Bool BrowserFontResource_Trusted::Describe( PP_BrowserFont_Trusted_Description* description, PP_BrowserFont_Trusted_Metrics* metrics) { if (description->face.type != PP_VARTYPE_UNDEFINED) @@ -306,7 +294,7 @@ PP_Bool PPB_BrowserFont_Trusted_Shared::Describe( return PP_TRUE; } -PP_Bool PPB_BrowserFont_Trusted_Shared::DrawTextAt( +PP_Bool BrowserFontResource_Trusted::DrawTextAt( PP_Resource image_data, const PP_BrowserFont_Trusted_TextRun* text, const PP_Point* position, @@ -338,7 +326,7 @@ PP_Bool PPB_BrowserFont_Trusted_Shared::DrawTextAt( return PP_TRUE; } -int32_t PPB_BrowserFont_Trusted_Shared::MeasureText( +int32_t BrowserFontResource_Trusted::MeasureText( const PP_BrowserFont_Trusted_TextRun* text) { WebTextRun run; if (!PPTextRunToWebTextRun(*text, &run)) @@ -346,7 +334,7 @@ int32_t PPB_BrowserFont_Trusted_Shared::MeasureText( return font_->calculateWidth(run); } -uint32_t PPB_BrowserFont_Trusted_Shared::CharacterOffsetForPixel( +uint32_t BrowserFontResource_Trusted::CharacterOffsetForPixel( const PP_BrowserFont_Trusted_TextRun* text, int32_t pixel_position) { TextRunCollection runs(*text); @@ -367,7 +355,7 @@ uint32_t PPB_BrowserFont_Trusted_Shared::CharacterOffsetForPixel( return runs.text().size(); } -int32_t PPB_BrowserFont_Trusted_Shared::PixelOffsetForCharacter( +int32_t BrowserFontResource_Trusted::PixelOffsetForCharacter( const PP_BrowserFont_Trusted_TextRun* text, uint32_t char_offset) { TextRunCollection runs(*text); @@ -398,7 +386,7 @@ int32_t PPB_BrowserFont_Trusted_Shared::PixelOffsetForCharacter( return -1; // Requested a char beyond the end. } -void PPB_BrowserFont_Trusted_Shared::DrawTextToCanvas( +void BrowserFontResource_Trusted::DrawTextToCanvas( SkCanvas* destination, const PP_BrowserFont_Trusted_TextRun& text, const PP_Point* position, @@ -437,4 +425,5 @@ void PPB_BrowserFont_Trusted_Shared::DrawTextToCanvas( } } +} // namespace proxy } // namespace ppapi diff --git a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h b/ppapi/proxy/browser_font_resource_trusted.h index fa91ea0..1dc1fa5 100644 --- a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h +++ b/ppapi/proxy/browser_font_resource_trusted.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ -#define PPAPI_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ +#ifndef PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ +#define PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ #include <string> @@ -13,9 +13,9 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/shared_impl/ppapi_preferences.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" -#include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_browser_font_trusted_api.h" class SkCanvas; @@ -25,24 +25,24 @@ class WebFont; } namespace ppapi { +namespace proxy { -class PPAPI_SHARED_EXPORT PPB_BrowserFont_Trusted_Shared - : public Resource, +class PPAPI_PROXY_EXPORT BrowserFontResource_Trusted + : public PluginResource, public thunk::PPB_BrowserFont_Trusted_API { public: + BrowserFontResource_Trusted(Connection connection, + PP_Instance instance, + const PP_BrowserFont_Trusted_Description& desc, + const Preferences& prefs); + + virtual ~BrowserFontResource_Trusted(); + // Validates the parameters in thee description. Can be called on any thread. static bool IsPPFontDescriptionValid( const PP_BrowserFont_Trusted_Description& desc); - virtual ~PPB_BrowserFont_Trusted_Shared(); - - static PP_Resource Create( - ResourceObjectType type, - PP_Instance instance, - const PP_BrowserFont_Trusted_Description& description, - const ::ppapi::Preferences& prefs); - - // Resource. + // Resource override. virtual ::ppapi::thunk::PPB_BrowserFont_Trusted_API* AsPPB_BrowserFont_Trusted_API() OVERRIDE; @@ -65,11 +65,6 @@ class PPAPI_SHARED_EXPORT PPB_BrowserFont_Trusted_Shared uint32_t char_offset) OVERRIDE; private: - PPB_BrowserFont_Trusted_Shared(ResourceObjectType type, - PP_Instance instance, - const PP_BrowserFont_Trusted_Description& desc, - const Preferences& prefs); - // Internal version of DrawTextAt that takes a mapped PlatformCanvas. void DrawTextToCanvas(SkCanvas* destination, const PP_BrowserFont_Trusted_TextRun& text, @@ -78,11 +73,13 @@ class PPAPI_SHARED_EXPORT PPB_BrowserFont_Trusted_Shared const PP_Rect* clip, PP_Bool image_data_is_opaque); + private: scoped_ptr<WebKit::WebFont> font_; - DISALLOW_COPY_AND_ASSIGN(PPB_BrowserFont_Trusted_Shared); + DISALLOW_COPY_AND_ASSIGN(BrowserFontResource_Trusted); }; +} // namespace proxy } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_BROWSER_FONT_TRUSTED_SHARED_H_ +#endif // PPAPI_PROXY_BROWSER_FONT_TRUSTED_RESOURCE_H_ diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 8135caf..17f21fd 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -8,6 +8,7 @@ #include "ppapi/c/pp_size.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" #include "ppapi/proxy/audio_input_resource.h" +#include "ppapi/proxy/browser_font_resource_trusted.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/file_chooser_resource.h" #include "ppapi/proxy/flash_device_id_resource.h" @@ -47,7 +48,6 @@ #include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_resource_array_shared.h" -#include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" @@ -301,8 +301,10 @@ PP_Resource ResourceCreationProxy::CreateBrowserFont( PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) return 0; - return PPB_BrowserFont_Trusted_Shared::Create( - OBJECT_IS_PROXY, instance, *description, dispatcher->preferences()); + if (!BrowserFontResource_Trusted::IsPPFontDescriptionValid(*description)) + return 0; + return (new BrowserFontResource_Trusted(GetConnection(), instance, + *description, dispatcher->preferences()))->GetReference(); } PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 1f6d904..e1f883e 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -6,7 +6,6 @@ #include "ppapi/c/pp_size.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" -#include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_resource_array_shared.h" #include "ppapi/shared_impl/var.h" @@ -77,18 +76,6 @@ PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) { return (new PPB_Broker_Impl(instance))->GetReference(); } -PP_Resource ResourceCreationImpl::CreateBrowserFont( - PP_Instance instance, - const PP_BrowserFont_Trusted_Description* description) { - PluginInstance* plugin_instance = - ResourceHelper::PPInstanceToPluginInstance(instance); - if (!plugin_instance) - return 0; - return ::ppapi::PPB_BrowserFont_Trusted_Shared::Create( - ::ppapi::OBJECT_IS_IMPL, instance, *description, - plugin_instance->delegate()->GetPreferences()); -} - PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance, uint32_t size) { return PPB_Buffer_Impl::Create(instance, size); diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index 8805929..5a6c0c4 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -32,9 +32,6 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl uint32_t sample_frame_count) OVERRIDE; virtual PP_Resource CreateAudioInput(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateBrowserFont( - PP_Instance instance, - const PP_BrowserFont_Trusted_Description* description) OVERRIDE; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) OVERRIDE; virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) OVERRIDE; |