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

Side by Side Diff: ppapi/proxy/ppb_flash_proxy.cc

Issue 7844018: Revert 100748 - This patch tries to remove most of the manual registration for Pepper interfaces,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_flash_tcp_socket_proxy.h » ('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 "ppapi/proxy/ppb_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
11 #include "ppapi/c/dev/ppb_var_deprecated.h" 11 #include "ppapi/c/dev/ppb_var_deprecated.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/pp_resource.h" 13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/private/ppb_flash.h" 14 #include "ppapi/c/private/ppb_flash.h"
15 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/proxy/proxy_module.h" 19 #include "ppapi/proxy/proxy_module.h"
20 #include "ppapi/proxy/serialized_var.h" 20 #include "ppapi/proxy/serialized_var.h"
21 #include "ppapi/shared_impl/resource.h" 21 #include "ppapi/shared_impl/resource.h"
22 #include "ppapi/shared_impl/scoped_pp_resource.h" 22 #include "ppapi/shared_impl/scoped_pp_resource.h"
23 #include "ppapi/shared_impl/var.h"
24 #include "ppapi/thunk/enter.h" 23 #include "ppapi/thunk/enter.h"
25 #include "ppapi/thunk/ppb_url_request_info_api.h" 24 #include "ppapi/thunk/ppb_url_request_info_api.h"
26 #include "ppapi/thunk/resource_creation_api.h" 25 #include "ppapi/thunk/resource_creation_api.h"
27 26
28 namespace ppapi { 27 namespace ppapi {
29 namespace proxy { 28 namespace proxy {
30 29
31 namespace { 30 namespace {
32 31
33 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { 32 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // 145 //
147 // On Linux, it would be better to go directly to the browser process for 146 // On Linux, it would be better to go directly to the browser process for
148 // this message rather than proxy it through some instance in a renderer. 147 // this message rather than proxy it through some instance in a renderer.
149 double result = 0; 148 double result = 0;
150 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( 149 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset(
151 INTERFACE_ID_PPB_FLASH, instance, t, &result)); 150 INTERFACE_ID_PPB_FLASH, instance, t, &result));
152 return result; 151 return result;
153 } 152 }
154 153
155 PP_Var GetCommandLineArgs(PP_Module pp_module) { 154 PP_Var GetCommandLineArgs(PP_Module pp_module) {
155 const PPB_Var_Deprecated* var_deprecated =
156 static_cast<const PPB_Var_Deprecated*>(
157 PluginDispatcher::GetInterfaceFromDispatcher(
158 PPB_VAR_DEPRECATED_INTERFACE));
156 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); 159 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs();
157 return StringVar::StringToPPVar(pp_module, args); 160 return var_deprecated->VarFromUtf8(pp_module, args.data(), args.length());
158 } 161 }
159 162
160 const PPB_Flash flash_interface = { 163 const PPB_Flash flash_interface = {
161 &SetInstanceAlwaysOnTop, 164 &SetInstanceAlwaysOnTop,
162 &DrawGlyphs, 165 &DrawGlyphs,
163 &GetProxyForURL, 166 &GetProxyForURL,
164 &Navigate, 167 &Navigate,
165 &RunMessageLoop, 168 &RunMessageLoop,
166 &QuitMessageLoop, 169 &QuitMessageLoop,
167 &GetLocalTimeZoneOffset, 170 &GetLocalTimeZoneOffset,
168 &GetCommandLineArgs 171 &GetCommandLineArgs
169 }; 172 };
170 173
171 InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher) { 174 InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher,
172 return new PPB_Flash_Proxy(dispatcher); 175 const void* target_interface) {
176 return new PPB_Flash_Proxy(dispatcher, target_interface);
173 } 177 }
174 178
175 } // namespace 179 } // namespace
176 180
177 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) 181 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher,
178 : InterfaceProxy(dispatcher), 182 const void* target_interface)
179 ppb_flash_impl_(NULL) { 183 : InterfaceProxy(dispatcher, target_interface) {
180 if (!dispatcher->IsPlugin())
181 ppb_flash_impl_ = static_cast<const PPB_Flash*>(
182 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE));
183 } 184 }
184 185
185 PPB_Flash_Proxy::~PPB_Flash_Proxy() { 186 PPB_Flash_Proxy::~PPB_Flash_Proxy() {
186 } 187 }
187 188
188 // static 189 // static
189 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() { 190 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() {
190 static const Info info = { 191 static const Info info = {
191 &flash_interface, 192 &flash_interface,
192 PPB_FLASH_INTERFACE, 193 PPB_FLASH_INTERFACE,
(...skipping 27 matching lines...) Expand all
220 OnMsgGetLocalTimeZoneOffset) 221 OnMsgGetLocalTimeZoneOffset)
221 IPC_MESSAGE_UNHANDLED(handled = false) 222 IPC_MESSAGE_UNHANDLED(handled = false)
222 IPC_END_MESSAGE_MAP() 223 IPC_END_MESSAGE_MAP()
223 // TODO(brettw) handle bad messages! 224 // TODO(brettw) handle bad messages!
224 return handled; 225 return handled;
225 } 226 }
226 227
227 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( 228 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
228 PP_Instance instance, 229 PP_Instance instance,
229 PP_Bool on_top) { 230 PP_Bool on_top) {
230 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); 231 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top);
231 } 232 }
232 233
233 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, 234 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params,
234 PP_Bool* result) { 235 PP_Bool* result) {
235 *result = PP_FALSE; 236 *result = PP_FALSE;
236 237
237 PP_FontDescription_Dev font_desc; 238 PP_FontDescription_Dev font_desc;
238 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); 239 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false);
239 240
240 if (params.glyph_indices.size() != params.glyph_advances.size() || 241 if (params.glyph_indices.size() != params.glyph_advances.size() ||
241 params.glyph_indices.empty()) 242 params.glyph_indices.empty())
242 return; 243 return;
243 244
244 *result = ppb_flash_impl_->DrawGlyphs( 245 *result = ppb_flash_target()->DrawGlyphs(
245 0, // Unused instance param. 246 0, // Unused instance param.
246 params.image_data.host_resource(), &font_desc, 247 params.image_data.host_resource(), &font_desc,
247 params.color, params.position, params.clip, 248 params.color, params.position, params.clip,
248 const_cast<float(*)[3]>(params.transformation), 249 const_cast<float(*)[3]>(params.transformation),
249 static_cast<uint32_t>(params.glyph_indices.size()), 250 static_cast<uint32_t>(params.glyph_indices.size()),
250 const_cast<uint16_t*>(&params.glyph_indices[0]), 251 const_cast<uint16_t*>(&params.glyph_indices[0]),
251 const_cast<PP_Point*>(&params.glyph_advances[0])); 252 const_cast<PP_Point*>(&params.glyph_advances[0]));
252 } 253 }
253 254
254 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, 255 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance,
255 const std::string& url, 256 const std::string& url,
256 SerializedVarReturnValue result) { 257 SerializedVarReturnValue result) {
257 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( 258 result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL(
258 instance, url.c_str())); 259 instance, url.c_str()));
259 } 260 }
260 261
261 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance, 262 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance,
262 const PPB_URLRequestInfo_Data& data, 263 const PPB_URLRequestInfo_Data& data,
263 const std::string& target, 264 const std::string& target,
264 bool from_user_action, 265 bool from_user_action,
265 int32_t* result) { 266 int32_t* result) {
266 DCHECK(!dispatcher()->IsPlugin()); 267 DCHECK(!dispatcher()->IsPlugin());
267 268
(...skipping 16 matching lines...) Expand all
284 // Make a temporary request resource. 285 // Make a temporary request resource.
285 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true); 286 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true);
286 if (enter.failed()) { 287 if (enter.failed()) {
287 *result = PP_ERROR_FAILED; 288 *result = PP_ERROR_FAILED;
288 return; 289 return;
289 } 290 }
290 ScopedPPResource request_resource( 291 ScopedPPResource request_resource(
291 ScopedPPResource::PassRef(), 292 ScopedPPResource::PassRef(),
292 enter.functions()->CreateURLRequestInfo(instance, data)); 293 enter.functions()->CreateURLRequestInfo(instance, data));
293 294
294 *result = ppb_flash_impl_->Navigate(request_resource, 295 *result = ppb_flash_target()->Navigate(request_resource,
295 target.c_str(), 296 target.c_str(),
296 from_user_action); 297 from_user_action);
297 } 298 }
298 299
299 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { 300 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) {
300 ppb_flash_impl_->RunMessageLoop(instance); 301 ppb_flash_target()->RunMessageLoop(instance);
301 } 302 }
302 303
303 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { 304 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) {
304 ppb_flash_impl_->QuitMessageLoop(instance); 305 ppb_flash_target()->QuitMessageLoop(instance);
305 } 306 }
306 307
307 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, 308 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance,
308 PP_Time t, 309 PP_Time t,
309 double* result) { 310 double* result) {
310 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); 311 *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t);
311 } 312 }
312 313
313 } // namespace proxy 314 } // namespace proxy
314 } // namespace ppapi 315 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_flash_tcp_socket_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698