OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_FRAME_PLUGIN_URL_REQUEST_H_ |
| 6 #define CHROME_FRAME_PLUGIN_URL_REQUEST_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/time.h" |
| 12 #include "ipc/ipc_message.h" |
| 13 #include "net/base/upload_data.h" |
| 14 #include "net/url_request/url_request_status.h" |
| 15 #include "base/ref_counted.h" |
| 16 |
| 17 class PluginUrlRequest; |
| 18 |
| 19 // Interface for a class that keeps a collection of outstanding |
| 20 // reqeusts and offers an outgoing channel. |
| 21 class PluginRequestHandler : public IPC::Message::Sender { |
| 22 public: |
| 23 virtual bool AddRequest(PluginUrlRequest* request) = 0; |
| 24 virtual void RemoveRequest(PluginUrlRequest* request) = 0; |
| 25 }; |
| 26 |
| 27 // A reference counting solution that's compatible with COM IUnknown |
| 28 class UrlRequestReference { |
| 29 public: |
| 30 virtual unsigned long API_CALL AddRef() = 0; |
| 31 virtual unsigned long API_CALL Release() = 0; |
| 32 }; |
| 33 |
| 34 class PluginUrlRequest : public UrlRequestReference { |
| 35 public: |
| 36 PluginUrlRequest(); |
| 37 ~PluginUrlRequest(); |
| 38 |
| 39 bool Initialize(PluginRequestHandler* handler, int tab, |
| 40 int remote_request_id, const std::string& url, |
| 41 const std::string& method, const std::string& referrer, |
| 42 const std::string& extra_headers, |
| 43 net::UploadData* upload_data, |
| 44 bool intercept_frame_options); |
| 45 |
| 46 // Called in response to automation IPCs |
| 47 virtual bool Start() = 0; |
| 48 virtual void Stop() = 0; |
| 49 virtual bool Read(int bytes_to_read) = 0; |
| 50 |
| 51 // Persistent cookies are read from the host browser and passed off to Chrome |
| 52 // These cookies are sent when we receive a response for every URL request |
| 53 // initiated by Chrome. Ideally we should only send cookies for the top level |
| 54 // URL and any subframes. However we don't receive information from Chrome |
| 55 // about the context for a URL, i.e. whether it is a subframe, etc. |
| 56 // Additionally cookies for a URL should be sent once for the page. This |
| 57 // is not done now as it is difficult to track URLs, specifically if they |
| 58 // are redirected, etc. |
| 59 void OnResponseStarted(const char* mime_type, const char* headers, int size, |
| 60 base::Time last_modified, const std::string& peristent_cookies, |
| 61 const std::string& redirect_url, int redirect_status); |
| 62 |
| 63 void OnReadComplete(const void* buffer, int len); |
| 64 void OnResponseEnd(const URLRequestStatus& status); |
| 65 |
| 66 PluginRequestHandler* request_handler() const { |
| 67 return request_handler_; |
| 68 } |
| 69 int id() const { |
| 70 return remote_request_id_; |
| 71 } |
| 72 const std::string& url() const { |
| 73 return url_; |
| 74 } |
| 75 const std::string& method() const { |
| 76 return method_; |
| 77 } |
| 78 const std::string& referrer() const { |
| 79 return referrer_; |
| 80 } |
| 81 const std::string& extra_headers() const { |
| 82 return extra_headers_; |
| 83 } |
| 84 scoped_refptr<net::UploadData> upload_data() { |
| 85 return upload_data_; |
| 86 } |
| 87 |
| 88 bool is_done() const { |
| 89 return (URLRequestStatus::IO_PENDING != status_); |
| 90 } |
| 91 |
| 92 void set_url(const std::string& url) { |
| 93 url_ = url; |
| 94 } |
| 95 |
| 96 protected: |
| 97 void SendData(); |
| 98 bool frame_busting_enabled_; |
| 99 |
| 100 private: |
| 101 PluginRequestHandler* request_handler_; |
| 102 int tab_; |
| 103 int remote_request_id_; |
| 104 std::string url_; |
| 105 std::string method_; |
| 106 std::string referrer_; |
| 107 std::string extra_headers_; |
| 108 scoped_refptr<net::UploadData> upload_data_; |
| 109 URLRequestStatus::Status status_; |
| 110 }; |
| 111 |
| 112 |
| 113 #endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_ |
| 114 |
OLD | NEW |