| 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 "ppapi/proxy/ppb_font_proxy.h" | 5 #include "ppapi/proxy/ppb_font_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ppapi/c/dev/ppb_font_dev.h" | 8 #include "ppapi/c/dev/ppb_font_dev.h" |
| 9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/proxy/ppb_image_data_proxy.h" | 11 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 12 #include "ppapi/proxy/serialized_var.h" |
| 12 #include "ppapi/shared_impl/resource_object_base.h" | 13 #include "ppapi/shared_impl/resource_object_base.h" |
| 14 #include "ppapi/thunk/enter.h" |
| 13 #include "ppapi/thunk/ppb_image_data_api.h" | 15 #include "ppapi/thunk/ppb_image_data_api.h" |
| 14 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
| 15 | 17 |
| 16 using ppapi::thunk::PPB_ImageData_API; | 18 using ppapi::thunk::PPB_ImageData_API; |
| 17 using ppapi::WebKitForwarding; | 19 using ppapi::WebKitForwarding; |
| 18 | 20 |
| 19 namespace pp { | 21 namespace pp { |
| 20 namespace proxy { | 22 namespace proxy { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 static const Info info = { | 56 static const Info info = { |
| 55 ::ppapi::thunk::GetPPB_Font_Thunk(), | 57 ::ppapi::thunk::GetPPB_Font_Thunk(), |
| 56 PPB_FONT_DEV_INTERFACE, | 58 PPB_FONT_DEV_INTERFACE, |
| 57 INTERFACE_ID_PPB_FONT, | 59 INTERFACE_ID_PPB_FONT, |
| 58 false, | 60 false, |
| 59 &CreateFontProxy, | 61 &CreateFontProxy, |
| 60 }; | 62 }; |
| 61 return &info; | 63 return &info; |
| 62 } | 64 } |
| 63 | 65 |
| 66 ::ppapi::thunk::PPB_Font_FunctionAPI* PPB_Font_Proxy::AsFont_FunctionAPI() { |
| 67 return this; |
| 68 } |
| 69 |
| 70 PP_Var PPB_Font_Proxy::GetFontFamilies(PP_Instance instance) { |
| 71 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 72 if (!dispatcher) |
| 73 return PP_MakeUndefined(); |
| 74 |
| 75 // Assume the font families don't change, so we can cache the result globally. |
| 76 static std::string families; |
| 77 if (families.empty()) { |
| 78 dispatcher->SendToBrowser( |
| 79 new PpapiHostMsg_PPBFont_GetFontFamilies(&families)); |
| 80 } |
| 81 |
| 82 PP_Var result; |
| 83 result.type = PP_VARTYPE_STRING; |
| 84 result.value.as_id = PluginVarTracker::GetInstance()->MakeString(families); |
| 85 return result; |
| 86 } |
| 87 |
| 64 bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { | 88 bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 65 // There aren't any font messages. | 89 // There aren't any font messages. |
| 66 NOTREACHED(); | 90 NOTREACHED(); |
| 67 return false; | 91 return false; |
| 68 } | 92 } |
| 69 | 93 |
| 70 Font::Font(const HostResource& resource, | 94 Font::Font(const HostResource& resource, |
| 71 const PP_FontDescription_Dev& desc) | 95 const PP_FontDescription_Dev& desc) |
| 72 : PluginResource(resource), | 96 : PluginResource(resource), |
| 73 webkit_event_(false, false) { | 97 webkit_event_(false, false) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return result; | 217 return result; |
| 194 } | 218 } |
| 195 | 219 |
| 196 void Font::RunOnWebKitThread(const base::Closure& task) { | 220 void Font::RunOnWebKitThread(const base::Closure& task) { |
| 197 GetDispatcher()->PostToWebKitThread(FROM_HERE, task); | 221 GetDispatcher()->PostToWebKitThread(FROM_HERE, task); |
| 198 webkit_event_.Wait(); | 222 webkit_event_.Wait(); |
| 199 } | 223 } |
| 200 | 224 |
| 201 } // namespace proxy | 225 } // namespace proxy |
| 202 } // namespace pp | 226 } // namespace pp |
| OLD | NEW |