OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/glue/plugins/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/stats_counters.h" | 13 #include "base/stats_counters.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "webkit/api/public/WebInputEvent.h" | 15 #include "webkit/api/public/WebInputEvent.h" |
16 #include "webkit/glue/glue_util.h" | 16 #include "webkit/glue/glue_util.h" |
17 #include "webkit/glue/plugins/plugin_constants_win.h" | 17 #include "webkit/glue/plugins/plugin_constants_win.h" |
18 #include "webkit/glue/plugins/plugin_instance.h" | 18 #include "webkit/glue/plugins/plugin_instance.h" |
19 #include "webkit/glue/plugins/plugin_lib.h" | 19 #include "webkit/glue/plugins/plugin_lib.h" |
20 #include "webkit/glue/plugins/plugin_list.h" | 20 #include "webkit/glue/plugins/plugin_list.h" |
21 #include "webkit/glue/plugins/plugin_stream_url.h" | 21 #include "webkit/glue/plugins/plugin_stream_url.h" |
22 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
23 | 23 |
| 24 using webkit_glue::WebPlugin; |
| 25 using webkit_glue::WebPluginDelegate; |
| 26 using webkit_glue::WebPluginResourceClient; |
24 using WebKit::WebCursorInfo; | 27 using WebKit::WebCursorInfo; |
25 using WebKit::WebKeyboardEvent; | 28 using WebKit::WebKeyboardEvent; |
26 using WebKit::WebInputEvent; | 29 using WebKit::WebInputEvent; |
27 using WebKit::WebMouseEvent; | 30 using WebKit::WebMouseEvent; |
28 | 31 |
29 WebPluginDelegate* WebPluginDelegate::Create( | 32 WebPluginDelegate* WebPluginDelegate::Create( |
30 const FilePath& filename, | 33 const FilePath& filename, |
31 const std::string& mime_type, | 34 const std::string& mime_type, |
32 gfx::PluginWindowHandle containing_view) { | 35 gfx::PluginWindowHandle containing_view) { |
33 scoped_refptr<NPAPI::PluginLib> plugin = | 36 scoped_refptr<NPAPI::PluginLib> plugin_lib = |
34 NPAPI::PluginLib::CreatePluginLib(filename); | 37 NPAPI::PluginLib::CreatePluginLib(filename); |
35 if (plugin.get() == NULL) | 38 if (plugin_lib.get() == NULL) |
36 return NULL; | 39 return NULL; |
37 | 40 |
38 NPError err = plugin->NP_Initialize(); | 41 NPError err = plugin_lib->NP_Initialize(); |
39 if (err != NPERR_NO_ERROR) | 42 if (err != NPERR_NO_ERROR) |
40 return NULL; | 43 return NULL; |
41 | 44 |
42 scoped_refptr<NPAPI::PluginInstance> instance = | 45 scoped_refptr<NPAPI::PluginInstance> instance = |
43 plugin->CreateInstance(mime_type); | 46 plugin_lib->CreateInstance(mime_type); |
44 return new WebPluginDelegateImpl(containing_view, instance.get()); | 47 return new WebPluginDelegateImpl(containing_view, instance.get()); |
45 } | 48 } |
46 | 49 |
47 bool WebPluginDelegateImpl::Initialize(const GURL& url, | 50 bool WebPluginDelegateImpl::Initialize(const GURL& url, |
48 char** argn, | 51 char** argn, |
49 char** argv, | 52 char** argv, |
50 int argc, | 53 int argc, |
51 WebPlugin* plugin, | 54 WebPlugin* plugin, |
52 bool load_manually) { | 55 bool load_manually) { |
53 plugin_ = plugin; | 56 plugin_ = plugin; |
54 | 57 |
55 instance_->set_web_plugin(plugin); | 58 instance_->set_web_plugin(plugin_); |
56 NPAPI::PluginInstance* old_instance = | 59 NPAPI::PluginInstance* old_instance = |
57 NPAPI::PluginInstance::SetInitializingInstance(instance_); | 60 NPAPI::PluginInstance::SetInitializingInstance(instance_); |
58 | 61 |
59 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { | 62 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { |
60 NPAPI::PluginLib* plugin_lib = instance()->plugin_lib(); | 63 NPAPI::PluginLib* plugin_lib = instance()->plugin_lib(); |
61 if (plugin_lib->instance_count() > 1) { | 64 if (plugin_lib->instance_count() > 1) { |
62 return false; | 65 return false; |
63 } | 66 } |
64 } | 67 } |
65 | 68 |
(...skipping 13 matching lines...) Expand all Loading... |
79 return false; | 82 return false; |
80 } else { | 83 } else { |
81 // For windowless plugins we should set the containing window handle | 84 // For windowless plugins we should set the containing window handle |
82 // as the instance window handle. This is what Safari does. Not having | 85 // as the instance window handle. This is what Safari does. Not having |
83 // a valid window handle causes subtle bugs with plugins which retreive | 86 // a valid window handle causes subtle bugs with plugins which retreive |
84 // the window handle and validate the same. The window handle can be | 87 // the window handle and validate the same. The window handle can be |
85 // retreived via NPN_GetValue of NPNVnetscapeWindow. | 88 // retreived via NPN_GetValue of NPNVnetscapeWindow. |
86 instance_->set_window_handle(parent_); | 89 instance_->set_window_handle(parent_); |
87 } | 90 } |
88 | 91 |
89 PlatformInitialize(plugin); | 92 PlatformInitialize(); |
90 | 93 |
91 plugin_url_ = url.spec(); | 94 plugin_url_ = url.spec(); |
92 | 95 |
93 return true; | 96 return true; |
94 } | 97 } |
95 | 98 |
96 void WebPluginDelegateImpl::DestroyInstance() { | 99 void WebPluginDelegateImpl::DestroyInstance() { |
97 if (instance_ && (instance_->npp()->ndata != NULL)) { | 100 if (instance_ && (instance_->npp()->ndata != NULL)) { |
98 // Shutdown all streams before destroying so that | 101 // Shutdown all streams before destroying so that |
99 // no streams are left "in progress". Need to do | 102 // no streams are left "in progress". Need to do |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 205 |
203 return plugin_stream->AsResourceClient(); | 206 return plugin_stream->AsResourceClient(); |
204 } | 207 } |
205 | 208 |
206 std::string mime_type; | 209 std::string mime_type; |
207 NPAPI::PluginStreamUrl *stream = instance()->CreateStream( | 210 NPAPI::PluginStreamUrl *stream = instance()->CreateStream( |
208 resource_id, url, mime_type, notify_needed, | 211 resource_id, url, mime_type, notify_needed, |
209 reinterpret_cast<void*>(notify_data)); | 212 reinterpret_cast<void*>(notify_data)); |
210 return stream; | 213 return stream; |
211 } | 214 } |
OLD | NEW |