| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | 100 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 101 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH)) | 101 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH)) |
| 102 return false; | 102 return false; |
| 103 | 103 |
| 104 bool handled = true; | 104 bool handled = true; |
| 105 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) | 105 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) |
| 106 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, | 106 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, |
| 107 OnHostMsgSetInstanceAlwaysOnTop) | 107 OnHostMsgSetInstanceAlwaysOnTop) |
| 108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, | 108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, |
| 109 OnHostMsgDrawGlyphs) | 109 OnHostMsgDrawGlyphs) |
| 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, | |
| 111 OnHostMsgGetProxyForURL) | |
| 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) | 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) |
| 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | 111 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
| 114 OnHostMsgGetLocalTimeZoneOffset) | 112 OnHostMsgGetLocalTimeZoneOffset) |
| 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
| 116 OnHostMsgIsRectTopmost) | 114 OnHostMsgIsRectTopmost) |
| 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
| 118 OnHostMsgFlashSetFullscreen) | 116 OnHostMsgFlashSetFullscreen) |
| 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
| 120 OnHostMsgFlashGetScreenSize) | 118 OnHostMsgFlashGetScreenSize) |
| 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, | 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 params.glyph_advances.insert(params.glyph_advances.begin(), | 174 params.glyph_advances.insert(params.glyph_advances.begin(), |
| 177 &glyph_advances[0], | 175 &glyph_advances[0], |
| 178 &glyph_advances[glyph_count]); | 176 &glyph_advances[glyph_count]); |
| 179 | 177 |
| 180 PP_Bool result = PP_FALSE; | 178 PP_Bool result = PP_FALSE; |
| 181 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 179 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
| 182 API_ID_PPB_FLASH, instance, params, &result)); | 180 API_ID_PPB_FLASH, instance, params, &result)); |
| 183 return result; | 181 return result; |
| 184 } | 182 } |
| 185 | 183 |
| 186 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { | |
| 187 ReceiveSerializedVarReturnValue result; | |
| 188 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | |
| 189 API_ID_PPB_FLASH, instance, url, &result)); | |
| 190 return result.Return(dispatcher()); | |
| 191 } | |
| 192 | |
| 193 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, | 184 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, |
| 194 PP_Resource request_info, | 185 PP_Resource request_info, |
| 195 const char* target, | 186 const char* target, |
| 196 PP_Bool from_user_action) { | 187 PP_Bool from_user_action) { |
| 197 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter( | 188 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter( |
| 198 request_info, true); | 189 request_info, true); |
| 199 if (enter.failed()) | 190 if (enter.failed()) |
| 200 return PP_ERROR_BADRESOURCE; | 191 return PP_ERROR_BADRESOURCE; |
| 201 return Navigate(instance, enter.object()->GetData(), target, | 192 return Navigate(instance, enter.object()->GetData(), target, |
| 202 from_user_action); | 193 from_user_action); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 250 } |
| 260 | 251 |
| 261 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, | 252 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, |
| 262 const PP_Rect* rect) { | 253 const PP_Rect* rect) { |
| 263 PP_Bool result = PP_FALSE; | 254 PP_Bool result = PP_FALSE; |
| 264 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( | 255 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( |
| 265 API_ID_PPB_FLASH, instance, *rect, &result)); | 256 API_ID_PPB_FLASH, instance, *rect, &result)); |
| 266 return result; | 257 return result; |
| 267 } | 258 } |
| 268 | 259 |
| 269 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { | |
| 270 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | |
| 271 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); | |
| 272 } | |
| 273 | |
| 274 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, | 260 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, |
| 275 PP_FlashSetting setting) { | 261 PP_FlashSetting setting) { |
| 276 PluginDispatcher* plugin_dispatcher = | 262 PluginDispatcher* plugin_dispatcher = |
| 277 static_cast<PluginDispatcher*>(dispatcher()); | 263 static_cast<PluginDispatcher*>(dispatcher()); |
| 278 switch (setting) { | 264 switch (setting) { |
| 279 case PP_FLASHSETTING_3DENABLED: | 265 case PP_FLASHSETTING_3DENABLED: |
| 280 return PP_MakeBool(PP_FromBool( | 266 return PP_MakeBool(PP_FromBool( |
| 281 plugin_dispatcher->preferences().is_3d_supported)); | 267 plugin_dispatcher->preferences().is_3d_supported)); |
| 282 case PP_FLASHSETTING_INCOGNITO: | 268 case PP_FLASHSETTING_INCOGNITO: |
| 283 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); | 269 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); |
| 284 case PP_FLASHSETTING_STAGE3DENABLED: | 270 case PP_FLASHSETTING_STAGE3DENABLED: |
| 285 return PP_MakeBool(PP_FromBool( | 271 return PP_MakeBool(PP_FromBool( |
| 286 plugin_dispatcher->preferences().is_stage3d_supported)); | 272 plugin_dispatcher->preferences().is_stage3d_supported)); |
| 287 case PP_FLASHSETTING_LANGUAGE: | 273 case PP_FLASHSETTING_LANGUAGE: |
| 288 return StringVar::StringToPPVar( | 274 return StringVar::StringToPPVar( |
| 289 PluginGlobals::Get()->plugin_proxy_delegate()->GetUILanguage()); | 275 PluginGlobals::Get()->plugin_proxy_delegate()->GetUILanguage()); |
| 290 case PP_FLASHSETTING_NUMCORES: | 276 case PP_FLASHSETTING_NUMCORES: |
| 291 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores); | 277 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores); |
| 292 case PP_FLASHSETTING_LSORESTRICTIONS: { | 278 case PP_FLASHSETTING_LSORESTRICTIONS: { |
| 293 ReceiveSerializedVarReturnValue result; | 279 ReceiveSerializedVarReturnValue result; |
| 294 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting( | 280 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting( |
| 295 API_ID_PPB_FLASH, instance, setting, &result)); | 281 API_ID_PPB_FLASH, instance, setting, &result)); |
| 296 return result.Return(dispatcher()); | 282 return result.Return(dispatcher()); |
| 297 } | 283 } |
| 298 } | 284 } |
| 299 return PP_MakeUndefined(); | 285 return PP_MakeUndefined(); |
| 300 } | 286 } |
| 301 | 287 |
| 302 PP_Bool PPB_Flash_Proxy::SetCrashData(PP_Instance instance, | |
| 303 PP_FlashCrashKey key, | |
| 304 PP_Var value) { | |
| 305 switch (key) { | |
| 306 case PP_FLASHCRASHKEY_URL: | |
| 307 StringVar *url_string_var(StringVar::FromPPVar(value)); | |
| 308 if (!url_string_var) | |
| 309 return PP_FALSE; | |
| 310 std::string url_string(url_string_var->value()); | |
| 311 PluginGlobals::Get()->plugin_proxy_delegate()->SetActiveURL(url_string); | |
| 312 return PP_TRUE; | |
| 313 } | |
| 314 return PP_FALSE; | |
| 315 } | |
| 316 | |
| 317 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { | 288 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { |
| 318 return true; | 289 return true; |
| 319 } | 290 } |
| 320 | 291 |
| 321 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { | 292 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { |
| 322 } | 293 } |
| 323 | 294 |
| 324 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, | 295 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, |
| 325 const char* path, | 296 const char* path, |
| 326 int32_t mode, | 297 int32_t mode, |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 const_cast<float(*)[3]>(params.transformation), | 520 const_cast<float(*)[3]>(params.transformation), |
| 550 params.allow_subpixel_aa, | 521 params.allow_subpixel_aa, |
| 551 static_cast<uint32_t>(params.glyph_indices.size()), | 522 static_cast<uint32_t>(params.glyph_indices.size()), |
| 552 const_cast<uint16_t*>(¶ms.glyph_indices[0]), | 523 const_cast<uint16_t*>(¶ms.glyph_indices[0]), |
| 553 const_cast<PP_Point*>(¶ms.glyph_advances[0])); | 524 const_cast<PP_Point*>(¶ms.glyph_advances[0])); |
| 554 | 525 |
| 555 // SetToPPFontDescription() creates a var which is owned by the caller. | 526 // SetToPPFontDescription() creates a var which is owned by the caller. |
| 556 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face); | 527 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face); |
| 557 } | 528 } |
| 558 | 529 |
| 559 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, | |
| 560 const std::string& url, | |
| 561 SerializedVarReturnValue result) { | |
| 562 EnterInstanceNoLock enter(instance); | |
| 563 if (enter.succeeded()) { | |
| 564 result.Return(dispatcher(), | |
| 565 enter.functions()->GetFlashAPI()->GetProxyForURL( | |
| 566 instance, url.c_str())); | |
| 567 } else { | |
| 568 result.Return(dispatcher(), PP_MakeUndefined()); | |
| 569 } | |
| 570 } | |
| 571 | |
| 572 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, | 530 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, |
| 573 const URLRequestInfoData& data, | 531 const URLRequestInfoData& data, |
| 574 const std::string& target, | 532 const std::string& target, |
| 575 PP_Bool from_user_action, | 533 PP_Bool from_user_action, |
| 576 int32_t* result) { | 534 int32_t* result) { |
| 577 EnterInstanceNoLock enter_instance(instance); | 535 EnterInstanceNoLock enter_instance(instance); |
| 578 if (enter_instance.failed()) { | 536 if (enter_instance.failed()) { |
| 579 *result = PP_ERROR_BADARGUMENT; | 537 *result = PP_ERROR_BADARGUMENT; |
| 580 return; | 538 return; |
| 581 } | 539 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // It's rarely used enough that we just request this interface when needed. | 656 // It's rarely used enough that we just request this interface when needed. |
| 699 const PPB_Flash_Print_1_0* print_interface = | 657 const PPB_Flash_Print_1_0* print_interface = |
| 700 static_cast<const PPB_Flash_Print_1_0*>( | 658 static_cast<const PPB_Flash_Print_1_0*>( |
| 701 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 659 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
| 702 if (print_interface) | 660 if (print_interface) |
| 703 print_interface->InvokePrinting(instance); | 661 print_interface->InvokePrinting(instance); |
| 704 } | 662 } |
| 705 | 663 |
| 706 } // namespace proxy | 664 } // namespace proxy |
| 707 } // namespace ppapi | 665 } // namespace ppapi |
| OLD | NEW |