| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, |
| 111 OnHostMsgGetProxyForURL) | 111 OnHostMsgGetProxyForURL) |
| 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) | 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) |
| 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop, | |
| 114 OnHostMsgRunMessageLoop) | |
| 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | |
| 116 OnHostMsgQuitMessageLoop) | |
| 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
| 118 OnHostMsgGetLocalTimeZoneOffset) | 114 OnHostMsgGetLocalTimeZoneOffset) |
| 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
| 120 OnHostMsgIsRectTopmost) | 116 OnHostMsgIsRectTopmost) |
| 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
| 122 OnHostMsgFlashSetFullscreen) | 118 OnHostMsgFlashSetFullscreen) |
| 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
| 124 OnHostMsgFlashGetScreenSize) | 120 OnHostMsgFlashGetScreenSize) |
| 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, | 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, |
| 126 OnHostMsgOpenFileRef) | 122 OnHostMsgOpenFileRef) |
| 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, | 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, |
| 128 OnHostMsgQueryFileRef) | 124 OnHostMsgQueryFileRef) |
| 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, | |
| 130 OnHostMsgGetDeviceID) | |
| 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, | 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, |
| 132 OnHostMsgInvokePrinting) | 126 OnHostMsgInvokePrinting) |
| 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting, | 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting, |
| 134 OnHostMsgGetSetting) | 128 OnHostMsgGetSetting) |
| 135 IPC_MESSAGE_UNHANDLED(handled = false) | 129 IPC_MESSAGE_UNHANDLED(handled = false) |
| 136 IPC_END_MESSAGE_MAP() | 130 IPC_END_MESSAGE_MAP() |
| 137 // TODO(brettw) handle bad messages! | 131 // TODO(brettw) handle bad messages! |
| 138 return handled; | 132 return handled; |
| 139 } | 133 } |
| 140 | 134 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, | 205 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, |
| 212 const URLRequestInfoData& data, | 206 const URLRequestInfoData& data, |
| 213 const char* target, | 207 const char* target, |
| 214 PP_Bool from_user_action) { | 208 PP_Bool from_user_action) { |
| 215 int32_t result = PP_ERROR_FAILED; | 209 int32_t result = PP_ERROR_FAILED; |
| 216 dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( | 210 dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( |
| 217 API_ID_PPB_FLASH, instance, data, target, from_user_action, &result)); | 211 API_ID_PPB_FLASH, instance, data, target, from_user_action, &result)); |
| 218 return result; | 212 return result; |
| 219 } | 213 } |
| 220 | 214 |
| 221 void PPB_Flash_Proxy::RunMessageLoop(PP_Instance instance) { | |
| 222 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( | |
| 223 API_ID_PPB_FLASH, instance); | |
| 224 msg->EnableMessagePumping(); | |
| 225 dispatcher()->Send(msg); | |
| 226 } | |
| 227 | |
| 228 void PPB_Flash_Proxy::QuitMessageLoop(PP_Instance instance) { | |
| 229 dispatcher()->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( | |
| 230 API_ID_PPB_FLASH, instance)); | |
| 231 } | |
| 232 | |
| 233 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, | 215 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, |
| 234 PP_Time t) { | 216 PP_Time t) { |
| 235 static double s_cached_t = 0.0; | 217 static double s_cached_t = 0.0; |
| 236 static double s_cached_local_offset = 0.0; | 218 static double s_cached_local_offset = 0.0; |
| 237 static int64 s_last_updated = std::numeric_limits<int64>::min(); | 219 static int64 s_last_updated = std::numeric_limits<int64>::min(); |
| 238 | 220 |
| 239 // Cache the local offset for ten seconds, since it's slow on XP and Linux. | 221 // Cache the local offset for ten seconds, since it's slow on XP and Linux. |
| 240 const int64 kMaxCachedLocalOffsetAgeInSeconds = 10; | 222 const int64 kMaxCachedLocalOffsetAgeInSeconds = 10; |
| 241 base::TimeTicks now = base::TimeTicks::Now(); | 223 base::TimeTicks now = base::TimeTicks::Now(); |
| 242 base::TimeTicks expiration = | 224 base::TimeTicks expiration = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( | 264 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( |
| 283 API_ID_PPB_FLASH, instance, *rect, &result)); | 265 API_ID_PPB_FLASH, instance, *rect, &result)); |
| 284 return result; | 266 return result; |
| 285 } | 267 } |
| 286 | 268 |
| 287 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { | 269 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { |
| 288 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 270 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
| 289 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); | 271 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); |
| 290 } | 272 } |
| 291 | 273 |
| 292 PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) { | |
| 293 ReceiveSerializedVarReturnValue result; | |
| 294 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetDeviceID( | |
| 295 API_ID_PPB_FLASH, instance, &result)); | |
| 296 return result.Return(dispatcher()); | |
| 297 } | |
| 298 | |
| 299 int32_t PPB_Flash_Proxy::GetSettingInt(PP_Instance instance, | |
| 300 PP_FlashSetting setting) { | |
| 301 // Note: Don't add support for any more settings here. This method is | |
| 302 // deprecated. | |
| 303 switch (setting) { | |
| 304 case PP_FLASHSETTING_3DENABLED: | |
| 305 return static_cast<PluginDispatcher*>(dispatcher())->preferences(). | |
| 306 is_3d_supported; | |
| 307 case PP_FLASHSETTING_INCOGNITO: | |
| 308 return static_cast<PluginDispatcher*>(dispatcher())->incognito(); | |
| 309 case PP_FLASHSETTING_STAGE3DENABLED: | |
| 310 return static_cast<PluginDispatcher*>(dispatcher())->preferences(). | |
| 311 is_stage3d_supported; | |
| 312 default: | |
| 313 return -1; | |
| 314 } | |
| 315 } | |
| 316 | |
| 317 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, | 274 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, |
| 318 PP_FlashSetting setting) { | 275 PP_FlashSetting setting) { |
| 319 PluginDispatcher* plugin_dispatcher = | 276 PluginDispatcher* plugin_dispatcher = |
| 320 static_cast<PluginDispatcher*>(dispatcher()); | 277 static_cast<PluginDispatcher*>(dispatcher()); |
| 321 switch (setting) { | 278 switch (setting) { |
| 322 case PP_FLASHSETTING_3DENABLED: | 279 case PP_FLASHSETTING_3DENABLED: |
| 323 return PP_MakeBool(PP_FromBool( | 280 return PP_MakeBool(PP_FromBool( |
| 324 plugin_dispatcher->preferences().is_3d_supported)); | 281 plugin_dispatcher->preferences().is_3d_supported)); |
| 325 case PP_FLASHSETTING_INCOGNITO: | 282 case PP_FLASHSETTING_INCOGNITO: |
| 326 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); | 283 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 // We need to allow re-entrancy here, because this may call into Javascript | 593 // We need to allow re-entrancy here, because this may call into Javascript |
| 637 // (e.g. with a "javascript:" URL), or do things like navigate away from the | 594 // (e.g. with a "javascript:" URL), or do things like navigate away from the |
| 638 // page, either one of which will need to re-enter into the plugin. | 595 // page, either one of which will need to re-enter into the plugin. |
| 639 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash | 596 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash |
| 640 // would expect re-entrancy. When running in-process, it does re-enter here. | 597 // would expect re-entrancy. When running in-process, it does re-enter here. |
| 641 host_dispatcher->set_allow_plugin_reentrancy(); | 598 host_dispatcher->set_allow_plugin_reentrancy(); |
| 642 *result = enter_instance.functions()->GetFlashAPI()->Navigate( | 599 *result = enter_instance.functions()->GetFlashAPI()->Navigate( |
| 643 instance, data, target.c_str(), from_user_action); | 600 instance, data, target.c_str(), from_user_action); |
| 644 } | 601 } |
| 645 | 602 |
| 646 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { | |
| 647 EnterInstanceNoLock enter(instance); | |
| 648 if (enter.succeeded()) | |
| 649 enter.functions()->GetFlashAPI()->RunMessageLoop(instance); | |
| 650 } | |
| 651 | |
| 652 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { | |
| 653 EnterInstanceNoLock enter(instance); | |
| 654 if (enter.succeeded()) | |
| 655 enter.functions()->GetFlashAPI()->QuitMessageLoop(instance); | |
| 656 } | |
| 657 | |
| 658 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, | 603 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, |
| 659 PP_Time t, | 604 PP_Time t, |
| 660 double* result) { | 605 double* result) { |
| 661 EnterInstanceNoLock enter(instance); | 606 EnterInstanceNoLock enter(instance); |
| 662 if (enter.succeeded()) { | 607 if (enter.succeeded()) { |
| 663 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset( | 608 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset( |
| 664 instance, t); | 609 instance, t); |
| 665 } else { | 610 } else { |
| 666 *result = 0.0; | 611 *result = 0.0; |
| 667 } | 612 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 EnterInstanceNoLock enter(instance); | 686 EnterInstanceNoLock enter(instance); |
| 742 if (enter.succeeded()) { | 687 if (enter.succeeded()) { |
| 743 id.Return(dispatcher(), | 688 id.Return(dispatcher(), |
| 744 enter.functions()->GetFlashAPI()->GetSetting( | 689 enter.functions()->GetFlashAPI()->GetSetting( |
| 745 instance, setting)); | 690 instance, setting)); |
| 746 } else { | 691 } else { |
| 747 id.Return(dispatcher(), PP_MakeUndefined()); | 692 id.Return(dispatcher(), PP_MakeUndefined()); |
| 748 } | 693 } |
| 749 } | 694 } |
| 750 | 695 |
| 751 void PPB_Flash_Proxy::OnHostMsgGetDeviceID(PP_Instance instance, | |
| 752 SerializedVarReturnValue id) { | |
| 753 EnterInstanceNoLock enter(instance); | |
| 754 if (enter.succeeded()) { | |
| 755 id.Return(dispatcher(), | |
| 756 enter.functions()->GetFlashAPI()->GetDeviceID( | |
| 757 instance)); | |
| 758 } else { | |
| 759 id.Return(dispatcher(), PP_MakeUndefined()); | |
| 760 } | |
| 761 } | |
| 762 | |
| 763 void PPB_Flash_Proxy::OnHostMsgInvokePrinting(PP_Instance instance) { | 696 void PPB_Flash_Proxy::OnHostMsgInvokePrinting(PP_Instance instance) { |
| 764 // This function is actually implemented in the PPB_Flash_Print interface. | 697 // This function is actually implemented in the PPB_Flash_Print interface. |
| 765 // It's rarely used enough that we just request this interface when needed. | 698 // It's rarely used enough that we just request this interface when needed. |
| 766 const PPB_Flash_Print_1_0* print_interface = | 699 const PPB_Flash_Print_1_0* print_interface = |
| 767 static_cast<const PPB_Flash_Print_1_0*>( | 700 static_cast<const PPB_Flash_Print_1_0*>( |
| 768 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 701 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
| 769 if (print_interface) | 702 if (print_interface) |
| 770 print_interface->InvokePrinting(instance); | 703 print_interface->InvokePrinting(instance); |
| 771 } | 704 } |
| 772 | 705 |
| 773 } // namespace proxy | 706 } // namespace proxy |
| 774 } // namespace ppapi | 707 } // namespace ppapi |
| OLD | NEW |