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