diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 19:05:28 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 19:05:28 +0000 |
commit | 208aad79d76c5c9a5e05322be674b2d81738cb68 (patch) | |
tree | 6286cbea3bd340d8d5f61af9f6ace0b3d15e236c /ppapi/proxy | |
parent | b6b19e26bb00c8e8bc4ab91b535520352fb009f9 (diff) | |
download | chromium_src-208aad79d76c5c9a5e05322be674b2d81738cb68.zip chromium_src-208aad79d76c5c9a5e05322be674b2d81738cb68.tar.gz chromium_src-208aad79d76c5c9a5e05322be674b2d81738cb68.tar.bz2 |
Use the WebKit default fonts when specifying generic font families.
This pipes through a new preferences object that the font system can use.
It now picks up these faces as well as the default font size.
Clarify this behavior in the interface.
TEST=manual (font example included).
BUG=none
Review URL: http://codereview.chromium.org/7053022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/host_dispatcher.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/host_dispatcher.h | 7 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 18 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.h | 14 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 14 | ||||
-rw-r--r-- | ppapi/proxy/ppb_font_proxy.cc | 5 |
6 files changed, 58 insertions, 4 deletions
diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc index 4658fdb..c00390b 100644 --- a/ppapi/proxy/host_dispatcher.cc +++ b/ppapi/proxy/host_dispatcher.cc @@ -92,9 +92,11 @@ HostDispatcher::~HostDispatcher() { bool HostDispatcher::InitHostWithChannel( Delegate* delegate, const IPC::ChannelHandle& channel_handle, - bool is_client) { + bool is_client, + const ppapi::Preferences& preferences) { if (!Dispatcher::InitWithChannel(delegate, channel_handle, is_client)) return false; + Send(new PpapiMsg_SetPreferences(preferences)); return true; } diff --git a/ppapi/proxy/host_dispatcher.h b/ppapi/proxy/host_dispatcher.h index 608223d..55ba56b 100644 --- a/ppapi/proxy/host_dispatcher.h +++ b/ppapi/proxy/host_dispatcher.h @@ -27,6 +27,10 @@ namespace IPC { class SyncChannel; } +namespace ppapi { +struct Preferences; +} + namespace pp { namespace proxy { @@ -48,7 +52,8 @@ class HostDispatcher : public Dispatcher { // transferred. virtual bool InitHostWithChannel(Delegate* delegate, const IPC::ChannelHandle& channel_handle, - bool is_client); + bool is_client, + const ppapi::Preferences& preferences); // The host side maintains a mapping from PP_Instance to Dispatcher so // that we can send the messages to the right channel. diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index dee2610..4ce47c6 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -40,7 +40,8 @@ InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, GetInterfaceFunc get_interface) : Dispatcher(remote_process_handle, get_interface), - plugin_delegate_(NULL) { + plugin_delegate_(NULL), + received_preferences_(false) { SetSerializationRules(new PluginVarSerializationRules); // As a plugin, we always support the PPP_Class interface. There's no @@ -122,6 +123,7 @@ bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) + IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) IPC_END_MESSAGE_MAP() return handled; } @@ -274,6 +276,20 @@ void PluginDispatcher::OnMsgSupportsInterface( *result = true; } +void PluginDispatcher::OnMsgSetPreferences(const ::ppapi::Preferences& prefs) { + // The renderer may send us preferences more than once (currently this + // happens every time a new plugin instance is created). Since we don't have + // a way to signal to the plugin that the preferences have changed, changing + // the default fonts and such in the middle of a running plugin could be + // confusing to it. As a result, we never allow the preferences to be changed + // once they're set. The user will have to restart to get new font prefs + // propogated to plugins. + if (!received_preferences_) { + received_preferences_ = true; + preferences_ = prefs; + } +} + } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h index 29460fa..1964d94 100644 --- a/ppapi/proxy/plugin_dispatcher.h +++ b/ppapi/proxy/plugin_dispatcher.h @@ -15,6 +15,7 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/proxy/dispatcher.h" #include "ppapi/shared_impl/function_group_base.h" +#include "ppapi/shared_impl/ppapi_preferences.h" class MessageLoop; @@ -22,6 +23,10 @@ namespace base { class WaitableEvent; } +namespace ppapi { +struct Preferences; +} + namespace pp { namespace proxy { @@ -108,6 +113,9 @@ class PluginDispatcher : public Dispatcher { // Returns the WebKitForwarding object used to forward events to WebKit. ppapi::WebKitForwarding* GetWebKitForwarding(); + // Returns the Preferences. + const ppapi::Preferences& preferences() const { return preferences_; } + // Returns the "new-style" function API for the given interface ID, creating // it if necessary. // TODO(brettw) this is in progress. It should be merged with the target @@ -124,6 +132,7 @@ class PluginDispatcher : public Dispatcher { // IPC message handlers. void OnMsgSupportsInterface(const std::string& interface_name, bool* result); + void OnMsgSetPreferences(const ::ppapi::Preferences& prefs); PluginDelegate* plugin_delegate_; @@ -140,6 +149,11 @@ class PluginDispatcher : public Dispatcher { typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; InstanceDataMap instance_map_; + // The preferences sent from the host. We only want to set this once, which + // is what the received_preferences_ indicates. See OnMsgSetPreferences. + bool received_preferences_; + ppapi::Preferences preferences_; + DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); }; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index cd65fe8..49f0045 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -29,6 +29,7 @@ #include "ppapi/proxy/ppapi_param_traits.h" #include "ppapi/proxy/serialized_flash_menu.h" #include "ppapi/proxy/serialized_structs.h" +#include "ppapi/shared_impl/ppapi_preferences.h" #define IPC_MESSAGE_START PpapiMsgStart @@ -47,6 +48,15 @@ IPC_STRUCT_TRAITS_BEGIN(PP_Rect) IPC_STRUCT_TRAITS_MEMBER(size) IPC_STRUCT_TRAITS_END() +IPC_STRUCT_TRAITS_BEGIN(::ppapi::Preferences) + IPC_STRUCT_TRAITS_MEMBER(standard_font_family) + IPC_STRUCT_TRAITS_MEMBER(fixed_font_family) + IPC_STRUCT_TRAITS_MEMBER(serif_font_family) + IPC_STRUCT_TRAITS_MEMBER(sans_serif_font_family) + IPC_STRUCT_TRAITS_MEMBER(default_font_size) + IPC_STRUCT_TRAITS_MEMBER(default_fixed_font_size) +IPC_STRUCT_TRAITS_END() + // These are from the browser to the plugin. // Loads the given plugin. IPC_MESSAGE_CONTROL1(PpapiMsg_LoadPlugin, FilePath /* path */) @@ -75,6 +85,10 @@ IPC_SYNC_MESSAGE_CONTROL1_1(PpapiMsg_ReserveInstanceId, PP_Instance /* instance */, bool /* usable */) +// Passes the WebKit preferences to the plugin. +IPC_MESSAGE_CONTROL1(PpapiMsg_SetPreferences, + ::ppapi::Preferences) + // Sent in both directions to see if the other side supports the given // interface. IPC_SYNC_MESSAGE_CONTROL1_1(PpapiMsg_SupportsInterface, diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index 53eac45..eab4494 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -10,6 +10,7 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/serialized_var.h" +#include "ppapi/shared_impl/ppapi_preferences.h" #include "ppapi/shared_impl/resource_object_base.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" @@ -104,7 +105,9 @@ Font::Font(const HostResource& resource, RunOnWebKitThread(base::Bind(&WebKitForwarding::CreateFontForwarding, base::Unretained(forwarding), &webkit_event_, desc, - face ? *face : std::string(), &result)); + face ? *face : std::string(), + GetDispatcher()->preferences(), + &result)); font_forwarding_.reset(result); } |