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