| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | 99 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 100 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH)) | 100 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH)) |
| 101 return false; | 101 return false; |
| 102 | 102 |
| 103 bool handled = true; | 103 bool handled = true; |
| 104 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) | 104 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) |
| 105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, | 105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, |
| 106 OnHostMsgSetInstanceAlwaysOnTop) | 106 OnHostMsgSetInstanceAlwaysOnTop) |
| 107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, | 107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, |
| 108 OnHostMsgDrawGlyphs) | 108 OnHostMsgDrawGlyphs) |
| 109 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, | |
| 110 OnHostMsgGetProxyForURL) | |
| 111 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) | 109 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) |
| 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
| 113 OnHostMsgGetLocalTimeZoneOffset) | 111 OnHostMsgGetLocalTimeZoneOffset) |
| 114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
| 115 OnHostMsgIsRectTopmost) | 113 OnHostMsgIsRectTopmost) |
| 116 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, | 114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, |
| 117 OnHostMsgOpenFileRef) | 115 OnHostMsgOpenFileRef) |
| 118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, | 116 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, |
| 119 OnHostMsgQueryFileRef) | 117 OnHostMsgQueryFileRef) |
| 120 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, | 118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 params.glyph_advances.insert(params.glyph_advances.begin(), | 169 params.glyph_advances.insert(params.glyph_advances.begin(), |
| 172 &glyph_advances[0], | 170 &glyph_advances[0], |
| 173 &glyph_advances[glyph_count]); | 171 &glyph_advances[glyph_count]); |
| 174 | 172 |
| 175 PP_Bool result = PP_FALSE; | 173 PP_Bool result = PP_FALSE; |
| 176 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 174 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
| 177 API_ID_PPB_FLASH, instance, params, &result)); | 175 API_ID_PPB_FLASH, instance, params, &result)); |
| 178 return result; | 176 return result; |
| 179 } | 177 } |
| 180 | 178 |
| 181 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { | |
| 182 ReceiveSerializedVarReturnValue result; | |
| 183 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | |
| 184 API_ID_PPB_FLASH, instance, url, &result)); | |
| 185 return result.Return(dispatcher()); | |
| 186 } | |
| 187 | |
| 188 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, | 179 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, |
| 189 PP_Resource request_info, | 180 PP_Resource request_info, |
| 190 const char* target, | 181 const char* target, |
| 191 PP_Bool from_user_action) { | 182 PP_Bool from_user_action) { |
| 192 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter( | 183 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter( |
| 193 request_info, true); | 184 request_info, true); |
| 194 if (enter.failed()) | 185 if (enter.failed()) |
| 195 return PP_ERROR_BADRESOURCE; | 186 return PP_ERROR_BADRESOURCE; |
| 196 return Navigate(instance, enter.object()->GetData(), target, | 187 return Navigate(instance, enter.object()->GetData(), target, |
| 197 from_user_action); | 188 from_user_action); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 245 } |
| 255 | 246 |
| 256 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, | 247 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, |
| 257 const PP_Rect* rect) { | 248 const PP_Rect* rect) { |
| 258 PP_Bool result = PP_FALSE; | 249 PP_Bool result = PP_FALSE; |
| 259 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( | 250 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( |
| 260 API_ID_PPB_FLASH, instance, *rect, &result)); | 251 API_ID_PPB_FLASH, instance, *rect, &result)); |
| 261 return result; | 252 return result; |
| 262 } | 253 } |
| 263 | 254 |
| 264 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { | |
| 265 PluginGlobals::Get()->GetBrowserSender()->Send( | |
| 266 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); | |
| 267 } | |
| 268 | |
| 269 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, | 255 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, |
| 270 PP_FlashSetting setting) { | 256 PP_FlashSetting setting) { |
| 271 PluginDispatcher* plugin_dispatcher = | 257 PluginDispatcher* plugin_dispatcher = |
| 272 static_cast<PluginDispatcher*>(dispatcher()); | 258 static_cast<PluginDispatcher*>(dispatcher()); |
| 273 switch (setting) { | 259 switch (setting) { |
| 274 case PP_FLASHSETTING_3DENABLED: | 260 case PP_FLASHSETTING_3DENABLED: |
| 275 return PP_MakeBool(PP_FromBool( | 261 return PP_MakeBool(PP_FromBool( |
| 276 plugin_dispatcher->preferences().is_3d_supported)); | 262 plugin_dispatcher->preferences().is_3d_supported)); |
| 277 case PP_FLASHSETTING_INCOGNITO: | 263 case PP_FLASHSETTING_INCOGNITO: |
| 278 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); | 264 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); |
| 279 case PP_FLASHSETTING_STAGE3DENABLED: | 265 case PP_FLASHSETTING_STAGE3DENABLED: |
| 280 return PP_MakeBool(PP_FromBool( | 266 return PP_MakeBool(PP_FromBool( |
| 281 plugin_dispatcher->preferences().is_stage3d_supported)); | 267 plugin_dispatcher->preferences().is_stage3d_supported)); |
| 282 case PP_FLASHSETTING_LANGUAGE: | 268 case PP_FLASHSETTING_LANGUAGE: |
| 283 return StringVar::StringToPPVar( | 269 return StringVar::StringToPPVar( |
| 284 PluginGlobals::Get()->GetUILanguage()); | 270 PluginGlobals::Get()->GetUILanguage()); |
| 285 case PP_FLASHSETTING_NUMCORES: | 271 case PP_FLASHSETTING_NUMCORES: |
| 286 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores); | 272 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores); |
| 287 case PP_FLASHSETTING_LSORESTRICTIONS: { | 273 case PP_FLASHSETTING_LSORESTRICTIONS: { |
| 288 ReceiveSerializedVarReturnValue result; | 274 ReceiveSerializedVarReturnValue result; |
| 289 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting( | 275 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting( |
| 290 API_ID_PPB_FLASH, instance, setting, &result)); | 276 API_ID_PPB_FLASH, instance, setting, &result)); |
| 291 return result.Return(dispatcher()); | 277 return result.Return(dispatcher()); |
| 292 } | 278 } |
| 293 } | 279 } |
| 294 return PP_MakeUndefined(); | 280 return PP_MakeUndefined(); |
| 295 } | 281 } |
| 296 | 282 |
| 297 PP_Bool PPB_Flash_Proxy::SetCrashData(PP_Instance instance, | |
| 298 PP_FlashCrashKey key, | |
| 299 PP_Var value) { | |
| 300 switch (key) { | |
| 301 case PP_FLASHCRASHKEY_URL: | |
| 302 StringVar *url_string_var(StringVar::FromPPVar(value)); | |
| 303 if (!url_string_var) | |
| 304 return PP_FALSE; | |
| 305 std::string url_string(url_string_var->value()); | |
| 306 PluginGlobals::Get()->SetActiveURL(url_string); | |
| 307 return PP_TRUE; | |
| 308 } | |
| 309 return PP_FALSE; | |
| 310 } | |
| 311 | |
| 312 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { | 283 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { |
| 313 return true; | 284 return true; |
| 314 } | 285 } |
| 315 | 286 |
| 316 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { | 287 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { |
| 317 } | 288 } |
| 318 | 289 |
| 319 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, | 290 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, |
| 320 const char* path, | 291 const char* path, |
| 321 int32_t mode, | 292 int32_t mode, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 const_cast<float(*)[3]>(params.transformation), | 491 const_cast<float(*)[3]>(params.transformation), |
| 521 params.allow_subpixel_aa, | 492 params.allow_subpixel_aa, |
| 522 static_cast<uint32_t>(params.glyph_indices.size()), | 493 static_cast<uint32_t>(params.glyph_indices.size()), |
| 523 const_cast<uint16_t*>(¶ms.glyph_indices[0]), | 494 const_cast<uint16_t*>(¶ms.glyph_indices[0]), |
| 524 const_cast<PP_Point*>(¶ms.glyph_advances[0])); | 495 const_cast<PP_Point*>(¶ms.glyph_advances[0])); |
| 525 | 496 |
| 526 // SetToPPFontDescription() creates a var which is owned by the caller. | 497 // SetToPPFontDescription() creates a var which is owned by the caller. |
| 527 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face); | 498 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face); |
| 528 } | 499 } |
| 529 | 500 |
| 530 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, | |
| 531 const std::string& url, | |
| 532 SerializedVarReturnValue result) { | |
| 533 EnterInstanceNoLock enter(instance); | |
| 534 if (enter.succeeded()) { | |
| 535 result.Return(dispatcher(), | |
| 536 enter.functions()->GetFlashAPI()->GetProxyForURL( | |
| 537 instance, url.c_str())); | |
| 538 } else { | |
| 539 result.Return(dispatcher(), PP_MakeUndefined()); | |
| 540 } | |
| 541 } | |
| 542 | |
| 543 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, | 501 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, |
| 544 const URLRequestInfoData& data, | 502 const URLRequestInfoData& data, |
| 545 const std::string& target, | 503 const std::string& target, |
| 546 PP_Bool from_user_action, | 504 PP_Bool from_user_action, |
| 547 int32_t* result) { | 505 int32_t* result) { |
| 548 EnterInstanceNoLock enter_instance(instance); | 506 EnterInstanceNoLock enter_instance(instance); |
| 549 if (enter_instance.failed()) { | 507 if (enter_instance.failed()) { |
| 550 *result = PP_ERROR_BADARGUMENT; | 508 *result = PP_ERROR_BADARGUMENT; |
| 551 return; | 509 return; |
| 552 } | 510 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 // It's rarely used enough that we just request this interface when needed. | 602 // It's rarely used enough that we just request this interface when needed. |
| 645 const PPB_Flash_Print_1_0* print_interface = | 603 const PPB_Flash_Print_1_0* print_interface = |
| 646 static_cast<const PPB_Flash_Print_1_0*>( | 604 static_cast<const PPB_Flash_Print_1_0*>( |
| 647 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 605 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
| 648 if (print_interface) | 606 if (print_interface) |
| 649 print_interface->InvokePrinting(instance); | 607 print_interface->InvokePrinting(instance); |
| 650 } | 608 } |
| 651 | 609 |
| 652 } // namespace proxy | 610 } // namespace proxy |
| 653 } // namespace ppapi | 611 } // namespace ppapi |
| OLD | NEW |