| 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 "webkit/plugins/ppapi/ppb_flash_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "ppapi/c/private/ppb_flash.h" | 12 #include "ppapi/c/private/ppb_flash.h" |
| 13 #include "ppapi/shared_impl/time_conversion.h" | 13 #include "ppapi/shared_impl/time_conversion.h" |
| 14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
| 15 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 16 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
| 17 #include "webkit/plugins/ppapi/host_globals.h" |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
| 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 20 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" |
| 21 #include "webkit/plugins/ppapi/resource_helper.h" | 22 #include "webkit/plugins/ppapi/resource_helper.h" |
| 22 #include "webkit/plugins/ppapi/resource_tracker.h" | 23 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 23 | 24 |
| 24 using ppapi::PPTimeToTime; | 25 using ppapi::PPTimeToTime; |
| 25 using ppapi::StringVar; | 26 using ppapi::StringVar; |
| 26 using ppapi::thunk::EnterResource; | 27 using ppapi::thunk::EnterResource; |
| 27 using ppapi::thunk::PPB_URLRequestInfo_API; | 28 using ppapi::thunk::PPB_URLRequestInfo_API; |
| 28 | 29 |
| 29 namespace webkit { | 30 namespace webkit { |
| 30 namespace ppapi { | 31 namespace ppapi { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { | 35 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { |
| 35 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 36 PluginInstance* instance = |
| 37 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
| 36 if (!instance) | 38 if (!instance) |
| 37 return; | 39 return; |
| 38 instance->set_always_on_top(PPBoolToBool(on_top)); | 40 instance->set_always_on_top(PPBoolToBool(on_top)); |
| 39 } | 41 } |
| 40 | 42 |
| 41 PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { | 43 PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { |
| 42 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 44 PluginInstance* instance = |
| 45 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
| 43 if (!instance) | 46 if (!instance) |
| 44 return PP_MakeUndefined(); | 47 return PP_MakeUndefined(); |
| 45 | 48 |
| 46 GURL gurl(url); | 49 GURL gurl(url); |
| 47 if (!gurl.is_valid()) | 50 if (!gurl.is_valid()) |
| 48 return PP_MakeUndefined(); | 51 return PP_MakeUndefined(); |
| 49 | 52 |
| 50 std::string proxy_host = instance->delegate()->ResolveProxy(gurl); | 53 std::string proxy_host = instance->delegate()->ResolveProxy(gurl); |
| 51 if (proxy_host.empty()) | 54 if (proxy_host.empty()) |
| 52 return PP_MakeUndefined(); // No proxy. | 55 return PP_MakeUndefined(); // No proxy. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 76 MessageLoop::current()->SetNestableTasksAllowed(true); | 79 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 77 MessageLoop::current()->Run(); | 80 MessageLoop::current()->Run(); |
| 78 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 81 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
| 79 } | 82 } |
| 80 | 83 |
| 81 void QuitMessageLoop(PP_Instance instance) { | 84 void QuitMessageLoop(PP_Instance instance) { |
| 82 MessageLoop::current()->QuitNow(); | 85 MessageLoop::current()->QuitNow(); |
| 83 } | 86 } |
| 84 | 87 |
| 85 double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { | 88 double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { |
| 86 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 89 PluginInstance* instance = |
| 90 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
| 87 if (!instance) | 91 if (!instance) |
| 88 return 0.0; | 92 return 0.0; |
| 89 | 93 |
| 90 // Evil hack. The time code handles exact "0" values as special, and produces | 94 // Evil hack. The time code handles exact "0" values as special, and produces |
| 91 // a "null" Time object. This will represent some date hundreds of years ago | 95 // a "null" Time object. This will represent some date hundreds of years ago |
| 92 // and will give us funny results at 1970 (there are some tests where this | 96 // and will give us funny results at 1970 (there are some tests where this |
| 93 // comes up, but it shouldn't happen in real life). To work around this | 97 // comes up, but it shouldn't happen in real life). To work around this |
| 94 // special handling, we just need to give it some nonzero value. | 98 // special handling, we just need to give it some nonzero value. |
| 95 if (t == 0.0) | 99 if (t == 0.0) |
| 96 t = 0.0000000001; | 100 t = 0.0000000001; |
| 97 | 101 |
| 98 // We can't do the conversion here because on Linux, the localtime calls | 102 // We can't do the conversion here because on Linux, the localtime calls |
| 99 // require filesystem access prohibited by the sandbox. | 103 // require filesystem access prohibited by the sandbox. |
| 100 return instance->delegate()->GetLocalTimeZoneOffset(PPTimeToTime(t)); | 104 return instance->delegate()->GetLocalTimeZoneOffset(PPTimeToTime(t)); |
| 101 } | 105 } |
| 102 | 106 |
| 103 PP_Var GetCommandLineArgs(PP_Module pp_module) { | 107 PP_Var GetCommandLineArgs(PP_Module pp_module) { |
| 104 PluginModule* module = ResourceTracker::Get()->GetModule(pp_module); | 108 PluginModule* module = |
| 109 HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module); |
| 105 if (!module) | 110 if (!module) |
| 106 return PP_MakeUndefined(); | 111 return PP_MakeUndefined(); |
| 107 | 112 |
| 108 PluginInstance* instance = module->GetSomeInstance(); | 113 PluginInstance* instance = module->GetSomeInstance(); |
| 109 if (!instance) | 114 if (!instance) |
| 110 return PP_MakeUndefined(); | 115 return PP_MakeUndefined(); |
| 111 | 116 |
| 112 std::string args = instance->delegate()->GetFlashCommandLineArgs(); | 117 std::string args = instance->delegate()->GetFlashCommandLineArgs(); |
| 113 return StringVar::StringToPPVar(pp_module, args); | 118 return StringVar::StringToPPVar(pp_module, args); |
| 114 } | 119 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 126 | 131 |
| 127 } // namespace | 132 } // namespace |
| 128 | 133 |
| 129 // static | 134 // static |
| 130 const PPB_Flash* PPB_Flash_Impl::GetInterface() { | 135 const PPB_Flash* PPB_Flash_Impl::GetInterface() { |
| 131 return &ppb_flash; | 136 return &ppb_flash; |
| 132 } | 137 } |
| 133 | 138 |
| 134 } // namespace ppapi | 139 } // namespace ppapi |
| 135 } // namespace webkit | 140 } // namespace webkit |
| OLD | NEW |