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/plugin_stream_url.h" | 5 #include "webkit/plugins/npapi/plugin_stream_url.h" |
6 | 6 |
7 #include "net/http/http_response_headers.h" | 7 #include "net/http/http_response_headers.h" |
8 #include "webkit/glue/plugins/plugin_host.h" | 8 #include "webkit/plugins/npapi/plugin_host.h" |
9 #include "webkit/glue/plugins/plugin_instance.h" | 9 #include "webkit/plugins/npapi/plugin_instance.h" |
10 #include "webkit/glue/plugins/plugin_lib.h" | 10 #include "webkit/plugins/npapi/plugin_lib.h" |
11 #include "webkit/glue/plugins/webplugin.h" | 11 #include "webkit/plugins/npapi/webplugin.h" |
12 | 12 |
13 namespace NPAPI { | 13 namespace webkit { |
| 14 namespace npapi { |
14 | 15 |
15 PluginStreamUrl::PluginStreamUrl( | 16 PluginStreamUrl::PluginStreamUrl( |
16 unsigned long resource_id, | 17 unsigned long resource_id, |
17 const GURL &url, | 18 const GURL &url, |
18 PluginInstance *instance, | 19 PluginInstance *instance, |
19 bool notify_needed, | 20 bool notify_needed, |
20 void *notify_data) | 21 void *notify_data) |
21 : PluginStream(instance, url.spec().c_str(), notify_needed, notify_data), | 22 : PluginStream(instance, url.spec().c_str(), notify_needed, notify_data), |
22 url_(url), | 23 url_(url), |
23 id_(resource_id) { | 24 id_(resource_id) { |
24 } | 25 } |
25 | 26 |
26 PluginStreamUrl::~PluginStreamUrl() { | 27 PluginStreamUrl::~PluginStreamUrl() { |
27 if (instance() && instance()->webplugin()) { | 28 if (instance() && instance()->webplugin()) { |
28 instance()->webplugin()->ResourceClientDeleted(AsResourceClient()); | 29 instance()->webplugin()->ResourceClientDeleted(AsResourceClient()); |
29 } | 30 } |
30 } | 31 } |
31 | 32 |
32 bool PluginStreamUrl::Close(NPReason reason) { | 33 bool PluginStreamUrl::Close(NPReason reason) { |
33 // Protect the stream against it being destroyed or the whole plugin instance | 34 // Protect the stream against it being destroyed or the whole plugin instance |
34 // being destroyed within the destroy stream handler. | 35 // being destroyed within the destroy stream handler. |
35 scoped_refptr<PluginStream> protect(this); | 36 scoped_refptr<PluginStream> protect(this); |
36 CancelRequest(); | 37 CancelRequest(); |
37 bool result = PluginStream::Close(reason); | 38 bool result = PluginStream::Close(reason); |
38 instance()->RemoveStream(this); | 39 instance()->RemoveStream(this); |
39 return result; | 40 return result; |
40 } | 41 } |
41 | 42 |
42 webkit_glue::WebPluginResourceClient* PluginStreamUrl::AsResourceClient() { | 43 WebPluginResourceClient* PluginStreamUrl::AsResourceClient() { |
43 return static_cast<webkit_glue::WebPluginResourceClient*>(this); | 44 return static_cast<WebPluginResourceClient*>(this); |
44 } | 45 } |
45 | 46 |
46 void PluginStreamUrl::WillSendRequest(const GURL& url, int http_status_code) { | 47 void PluginStreamUrl::WillSendRequest(const GURL& url, int http_status_code) { |
47 if (notify_needed()) { | 48 if (notify_needed()) { |
48 // If the plugin participates in HTTP url redirect handling then notify it. | 49 // If the plugin participates in HTTP url redirect handling then notify it. |
49 if (net::HttpResponseHeaders::IsRedirectResponseCode(http_status_code) && | 50 if (net::HttpResponseHeaders::IsRedirectResponseCode(http_status_code) && |
50 instance()->handles_url_redirects()) { | 51 instance()->handles_url_redirects()) { |
51 pending_redirect_url_ = url.spec(); | 52 pending_redirect_url_ = url.spec(); |
52 instance()->NPP_URLRedirectNotify(url.spec().c_str(), http_status_code, | 53 instance()->NPP_URLRedirectNotify(url.spec().c_str(), http_status_code, |
53 notify_data()); | 54 notify_data()); |
(...skipping 66 matching lines...) Loading... |
120 | 121 |
121 void PluginStreamUrl::CancelRequest() { | 122 void PluginStreamUrl::CancelRequest() { |
122 if (id_ > 0) { | 123 if (id_ > 0) { |
123 if (instance()->webplugin()) { | 124 if (instance()->webplugin()) { |
124 instance()->webplugin()->CancelResource(id_); | 125 instance()->webplugin()->CancelResource(id_); |
125 } | 126 } |
126 id_ = 0; | 127 id_ = 0; |
127 } | 128 } |
128 } | 129 } |
129 | 130 |
130 } // namespace NPAPI | 131 } // namespace npapi |
| 132 } // namespace webkit |
OLD | NEW |