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 "content/child/npapi/webplugin_delegate_impl.h" | 5 #include "content/child/npapi/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "content/child/npapi/plugin_instance.h" | 14 #include "content/child/npapi/plugin_instance.h" |
15 #include "content/child/npapi/plugin_lib.h" | 15 #include "content/child/npapi/plugin_lib.h" |
16 #include "content/child/npapi/plugin_stream_url.h" | 16 #include "content/child/npapi/plugin_stream_url.h" |
| 17 #include "content/child/npapi/plugin_url_fetcher.h" |
17 #include "third_party/WebKit/public/web/WebInputEvent.h" | 18 #include "third_party/WebKit/public/web/WebInputEvent.h" |
18 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
19 | 20 |
20 using WebKit::WebCursorInfo; | 21 using WebKit::WebCursorInfo; |
21 using WebKit::WebInputEvent; | 22 using WebKit::WebInputEvent; |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( | 26 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( |
| 27 WebPlugin* plugin, |
26 const base::FilePath& filename, | 28 const base::FilePath& filename, |
27 const std::string& mime_type) { | 29 const std::string& mime_type) { |
28 scoped_refptr<PluginLib> plugin_lib(PluginLib::CreatePluginLib(filename)); | 30 scoped_refptr<PluginLib> plugin_lib(PluginLib::CreatePluginLib(filename)); |
29 if (plugin_lib.get() == NULL) | 31 if (plugin_lib.get() == NULL) |
30 return NULL; | 32 return NULL; |
31 | 33 |
32 NPError err = plugin_lib->NP_Initialize(); | 34 NPError err = plugin_lib->NP_Initialize(); |
33 if (err != NPERR_NO_ERROR) | 35 if (err != NPERR_NO_ERROR) |
34 return NULL; | 36 return NULL; |
35 | 37 |
36 scoped_refptr<PluginInstance> instance(plugin_lib->CreateInstance(mime_type)); | 38 scoped_refptr<PluginInstance> instance(plugin_lib->CreateInstance(mime_type)); |
37 return new WebPluginDelegateImpl(instance.get()); | 39 return new WebPluginDelegateImpl(plugin, instance.get()); |
38 } | 40 } |
39 | 41 |
40 void WebPluginDelegateImpl::PluginDestroyed() { | 42 void WebPluginDelegateImpl::PluginDestroyed() { |
41 if (handle_event_depth_) { | 43 if (handle_event_depth_) { |
42 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 44 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
43 } else { | 45 } else { |
44 delete this; | 46 delete this; |
45 } | 47 } |
46 } | 48 } |
47 | 49 |
48 bool WebPluginDelegateImpl::Initialize( | 50 bool WebPluginDelegateImpl::Initialize( |
49 const GURL& url, | 51 const GURL& url, |
50 const std::vector<std::string>& arg_names, | 52 const std::vector<std::string>& arg_names, |
51 const std::vector<std::string>& arg_values, | 53 const std::vector<std::string>& arg_values, |
52 WebPlugin* plugin, | |
53 bool load_manually) { | 54 bool load_manually) { |
54 plugin_ = plugin; | |
55 | |
56 instance_->set_web_plugin(plugin_); | 55 instance_->set_web_plugin(plugin_); |
57 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { | 56 if (quirks_ & PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES) { |
58 PluginLib* plugin_lib = instance()->plugin_lib(); | 57 PluginLib* plugin_lib = instance()->plugin_lib(); |
59 if (plugin_lib->instance_count() > 1) { | 58 if (plugin_lib->instance_count() > 1) { |
60 return false; | 59 return false; |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
64 int argc = 0; | 63 int argc = 0; |
65 scoped_ptr<char*[]> argn(new char*[arg_names.size()]); | 64 scoped_ptr<char*[]> argn(new char*[arg_names.size()]); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 293 |
295 WebPluginResourceClient* WebPluginDelegateImpl::CreateSeekableResourceClient( | 294 WebPluginResourceClient* WebPluginDelegateImpl::CreateSeekableResourceClient( |
296 unsigned long resource_id, int range_request_id) { | 295 unsigned long resource_id, int range_request_id) { |
297 WebPluginResourceClient* resource_client = instance()->GetRangeRequest( | 296 WebPluginResourceClient* resource_client = instance()->GetRangeRequest( |
298 range_request_id); | 297 range_request_id); |
299 if (resource_client) | 298 if (resource_client) |
300 resource_client->AddRangeRequestResourceId(resource_id); | 299 resource_client->AddRangeRequestResourceId(resource_id); |
301 return resource_client; | 300 return resource_client; |
302 } | 301 } |
303 | 302 |
| 303 void WebPluginDelegateImpl::FetchURL(unsigned long resource_id, |
| 304 int notify_id, |
| 305 const GURL& url, |
| 306 const GURL& first_party_for_cookies, |
| 307 const std::string& method, |
| 308 const std::string& post_data, |
| 309 const GURL& referrer, |
| 310 bool notify_redirects, |
| 311 bool is_plugin_src_load, |
| 312 int origin_pid, |
| 313 int render_view_id) { |
| 314 // TODO(jam): once we switch over to resource loading always happening in this |
| 315 // code path, remove WebPluginResourceClient abstraction. |
| 316 PluginStreamUrl* plugin_stream = instance()->CreateStream( |
| 317 resource_id, url, std::string(), notify_id); |
| 318 |
| 319 plugin_stream->SetPluginURLFetcher(new PluginURLFetcher( |
| 320 plugin_stream, url, first_party_for_cookies, method, post_data, |
| 321 referrer, notify_redirects, is_plugin_src_load, origin_pid, |
| 322 render_view_id, resource_id)); |
| 323 } |
| 324 |
304 } // namespace content | 325 } // namespace content |
OLD | NEW |