OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/webplugin_delegate_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
16 #include "webkit/glue/plugins/plugin_constants_win.h" | |
17 #include "webkit/glue/plugins/plugin_instance.h" | |
18 #include "webkit/glue/plugins/plugin_lib.h" | |
19 #include "webkit/glue/plugins/plugin_list.h" | |
20 #include "webkit/glue/plugins/plugin_stream_url.h" | |
21 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 17 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 18 #include "webkit/plugins/npapi/plugin_instance.h" |
| 19 #include "webkit/plugins/npapi/plugin_lib.h" |
| 20 #include "webkit/plugins/npapi/plugin_list.h" |
| 21 #include "webkit/plugins/npapi/plugin_stream_url.h" |
22 | 22 |
23 using webkit_glue::WebPlugin; | |
24 using webkit_glue::WebPluginDelegate; | |
25 using webkit_glue::WebPluginResourceClient; | |
26 using WebKit::WebCursorInfo; | 23 using WebKit::WebCursorInfo; |
27 using WebKit::WebKeyboardEvent; | 24 using WebKit::WebKeyboardEvent; |
28 using WebKit::WebInputEvent; | 25 using WebKit::WebInputEvent; |
29 using WebKit::WebMouseEvent; | 26 using WebKit::WebMouseEvent; |
30 | 27 |
| 28 namespace webkit { |
| 29 namespace npapi { |
| 30 |
31 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( | 31 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( |
32 const FilePath& filename, | 32 const FilePath& filename, |
33 const std::string& mime_type, | 33 const std::string& mime_type, |
34 gfx::PluginWindowHandle containing_view) { | 34 gfx::PluginWindowHandle containing_view) { |
35 scoped_refptr<NPAPI::PluginLib> plugin_lib( | 35 scoped_refptr<PluginLib> plugin_lib( |
36 NPAPI::PluginLib::CreatePluginLib(filename)); | 36 PluginLib::CreatePluginLib(filename)); |
37 if (plugin_lib.get() == NULL) | 37 if (plugin_lib.get() == NULL) |
38 return NULL; | 38 return NULL; |
39 | 39 |
40 NPError err = plugin_lib->NP_Initialize(); | 40 NPError err = plugin_lib->NP_Initialize(); |
41 if (err != NPERR_NO_ERROR) | 41 if (err != NPERR_NO_ERROR) |
42 return NULL; | 42 return NULL; |
43 | 43 |
44 scoped_refptr<NPAPI::PluginInstance> instance( | 44 scoped_refptr<PluginInstance> instance( |
45 plugin_lib->CreateInstance(mime_type)); | 45 plugin_lib->CreateInstance(mime_type)); |
46 return new WebPluginDelegateImpl(containing_view, instance.get()); | 46 return new WebPluginDelegateImpl(containing_view, instance.get()); |
47 } | 47 } |
48 | 48 |
49 void WebPluginDelegateImpl::PluginDestroyed() { | 49 void WebPluginDelegateImpl::PluginDestroyed() { |
50 if (handle_event_depth_) { | 50 if (handle_event_depth_) { |
51 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 51 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
52 } else { | 52 } else { |
53 delete this; | 53 delete this; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 bool WebPluginDelegateImpl::Initialize( | 57 bool WebPluginDelegateImpl::Initialize( |
58 const GURL& url, | 58 const GURL& url, |
59 const std::vector<std::string>& arg_names, | 59 const std::vector<std::string>& arg_names, |
60 const std::vector<std::string>& arg_values, | 60 const std::vector<std::string>& arg_values, |
61 WebPlugin* plugin, | 61 WebPlugin* plugin, |
62 bool load_manually) { | 62 bool load_manually) { |
63 plugin_ = plugin; | 63 plugin_ = plugin; |
64 | 64 |
65 instance_->set_web_plugin(plugin_); | 65 instance_->set_web_plugin(plugin_); |
66 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { | 66 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { |
67 NPAPI::PluginLib* plugin_lib = instance()->plugin_lib(); | 67 PluginLib* plugin_lib = instance()->plugin_lib(); |
68 if (plugin_lib->instance_count() > 1) { | 68 if (plugin_lib->instance_count() > 1) { |
69 return false; | 69 return false; |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 if (quirks_ & PLUGIN_QUIRK_DIE_AFTER_UNLOAD) | 73 if (quirks_ & PLUGIN_QUIRK_DIE_AFTER_UNLOAD) |
74 webkit_glue::SetForcefullyTerminatePluginProcess(true); | 74 webkit_glue::SetForcefullyTerminatePluginProcess(true); |
75 | 75 |
76 int argc = 0; | 76 int argc = 0; |
77 scoped_array<char*> argn(new char*[arg_names.size()]); | 77 scoped_array<char*> argn(new char*[arg_names.size()]); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( | 295 WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( |
296 unsigned long resource_id, const GURL& url, int notify_id) { | 296 unsigned long resource_id, const GURL& url, int notify_id) { |
297 return instance()->CreateStream( | 297 return instance()->CreateStream( |
298 resource_id, url, std::string(), notify_id); | 298 resource_id, url, std::string(), notify_id); |
299 } | 299 } |
300 | 300 |
301 WebPluginResourceClient* WebPluginDelegateImpl::CreateSeekableResourceClient( | 301 WebPluginResourceClient* WebPluginDelegateImpl::CreateSeekableResourceClient( |
302 unsigned long resource_id, int range_request_id) { | 302 unsigned long resource_id, int range_request_id) { |
303 return instance()->GetRangeRequest(range_request_id); | 303 return instance()->GetRangeRequest(range_request_id); |
304 } | 304 } |
| 305 |
| 306 } // namespace npapi |
| 307 } // namespace webkit |
OLD | NEW |