| 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 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ | 5 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ |
| 6 #define CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ | 6 #define CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/child/npapi/plugin_stream.h" | 11 #include "content/child/npapi/plugin_stream.h" |
| 11 #include "content/child/npapi/webplugin_resource_client.h" | 12 #include "content/child/npapi/webplugin_resource_client.h" |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | |
| 16 class PluginInstance; | 16 class PluginInstance; |
| 17 class PluginURLFetcher; |
| 17 | 18 |
| 18 // A NPAPI Stream based on a URL. | 19 // A NPAPI Stream based on a URL. |
| 19 class PluginStreamUrl : public PluginStream, | 20 class PluginStreamUrl : public PluginStream, |
| 20 public WebPluginResourceClient { | 21 public WebPluginResourceClient { |
| 21 public: | 22 public: |
| 22 // Create a new stream for sending to the plugin by fetching | 23 // Create a new stream for sending to the plugin by fetching |
| 23 // a URL. If notifyNeeded is set, then the plugin will be notified | 24 // a URL. If notifyNeeded is set, then the plugin will be notified |
| 24 // when the stream has been fully sent to the plugin. Initialize | 25 // when the stream has been fully sent to the plugin. Initialize |
| 25 // must be called before the object is used. | 26 // must be called before the object is used. |
| 26 PluginStreamUrl(unsigned long resource_id, | 27 PluginStreamUrl(unsigned long resource_id, |
| 27 const GURL &url, | 28 const GURL &url, |
| 28 PluginInstance *instance, | 29 PluginInstance *instance, |
| 29 bool notify_needed, | 30 bool notify_needed, |
| 30 void *notify_data); | 31 void *notify_data); |
| 31 | 32 |
| 33 void SetPluginURLFetcher(PluginURLFetcher* fetcher); |
| 34 |
| 35 void URLRedirectResponse(bool allow); |
| 36 |
| 32 // Stop sending the stream to the client. | 37 // Stop sending the stream to the client. |
| 33 // Overrides the base Close so we can cancel our fetching the URL if | 38 // Overrides the base Close so we can cancel our fetching the URL if |
| 34 // it is still loading. | 39 // it is still loading. |
| 35 virtual bool Close(NPReason reason) OVERRIDE; | 40 virtual bool Close(NPReason reason) OVERRIDE; |
| 36 virtual WebPluginResourceClient* AsResourceClient() OVERRIDE; | 41 virtual WebPluginResourceClient* AsResourceClient() OVERRIDE; |
| 37 virtual void CancelRequest() OVERRIDE; | 42 virtual void CancelRequest() OVERRIDE; |
| 38 | 43 |
| 39 // WebPluginResourceClient methods | 44 // WebPluginResourceClient methods |
| 40 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE; | 45 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE; |
| 41 virtual void DidReceiveResponse(const std::string& mime_type, | 46 virtual void DidReceiveResponse(const std::string& mime_type, |
| 42 const std::string& headers, | 47 const std::string& headers, |
| 43 uint32 expected_length, | 48 uint32 expected_length, |
| 44 uint32 last_modified, | 49 uint32 last_modified, |
| 45 bool request_is_seekable) OVERRIDE; | 50 bool request_is_seekable) OVERRIDE; |
| 46 virtual void DidReceiveData(const char* buffer, | 51 virtual void DidReceiveData(const char* buffer, |
| 47 int length, | 52 int length, |
| 48 int data_offset) OVERRIDE; | 53 int data_offset) OVERRIDE; |
| 49 virtual void DidFinishLoading(unsigned long resource_id) OVERRIDE; | 54 virtual void DidFinishLoading(unsigned long resource_id) OVERRIDE; |
| 50 virtual void DidFail(unsigned long resource_id) OVERRIDE; | 55 virtual void DidFail(unsigned long resource_id) OVERRIDE; |
| 51 virtual bool IsMultiByteResponseExpected() OVERRIDE; | 56 virtual bool IsMultiByteResponseExpected() OVERRIDE; |
| 52 virtual int ResourceId() OVERRIDE; | 57 virtual int ResourceId() OVERRIDE; |
| 53 virtual void AddRangeRequestResourceId(unsigned long resource_id) OVERRIDE; | 58 virtual void AddRangeRequestResourceId(unsigned long resource_id) OVERRIDE; |
| 54 | 59 |
| 55 protected: | 60 protected: |
| 56 virtual ~PluginStreamUrl(); | 61 virtual ~PluginStreamUrl(); |
| 57 | 62 |
| 58 private: | 63 private: |
| 59 void SetDeferLoading(bool value); | 64 void SetDeferLoading(bool value); |
| 60 | 65 |
| 66 // In case of a redirect, this can be called to update the url. But it must |
| 67 // be called before Open(). |
| 68 void UpdateUrl(const char* url); |
| 69 |
| 61 GURL url_; | 70 GURL url_; |
| 62 unsigned long id_; | 71 unsigned long id_; |
| 63 // Ids of additional resources requested via range requests issued on | 72 // Ids of additional resources requested via range requests issued on |
| 64 // seekable streams. | 73 // seekable streams. |
| 65 std::vector<unsigned long> range_requests_; | 74 std::vector<unsigned long> range_requests_; |
| 66 | 75 |
| 76 // If the plugin participates in HTTP URL redirect handling then this member |
| 77 // holds the url being redirected to while we wait for the plugin to make a |
| 78 // decision on whether to allow or deny the redirect. |
| 79 std::string pending_redirect_url_; |
| 80 |
| 81 scoped_ptr<PluginURLFetcher> plugin_url_fetcher_; |
| 82 |
| 67 DISALLOW_COPY_AND_ASSIGN(PluginStreamUrl); | 83 DISALLOW_COPY_AND_ASSIGN(PluginStreamUrl); |
| 68 }; | 84 }; |
| 69 | 85 |
| 70 } // namespace content | 86 } // namespace content |
| 71 | 87 |
| 72 #endif // CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ | 88 #endif // CONTENT_CHILD_NPAPI_PLUGIN_STREAM_URL_H_ |
| OLD | NEW |