OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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/memory/ref_counted.h" | |
12 #include "base/time/time.h" | |
13 #include "base/win/scoped_comptr.h" | |
14 #include "chrome_frame/chrome_frame_delegate.h" | |
15 #include "chrome_frame/urlmon_upload_data_stream.h" | |
16 #include "ipc/ipc_message.h" | |
17 #include "net/base/host_port_pair.h" | |
18 #include "net/base/upload_data.h" | |
19 #include "net/url_request/url_request_status.h" | |
20 #include "webkit/common/resource_type.h" | |
21 | |
22 class PluginUrlRequest; | |
23 class PluginUrlRequestDelegate; | |
24 class PluginUrlRequestManager; | |
25 | |
26 class DECLSPEC_NOVTABLE PluginUrlRequestDelegate { // NOLINT | |
27 public: | |
28 virtual void AddPrivacyDataForUrl(const std::string& url, | |
29 const std::string& policy_ref, | |
30 int32 flags) {} | |
31 protected: | |
32 PluginUrlRequestDelegate() {} | |
33 ~PluginUrlRequestDelegate() {} | |
34 }; | |
35 | |
36 class DECLSPEC_NOVTABLE PluginUrlRequestManager { // NOLINT | |
37 public: | |
38 PluginUrlRequestManager() : delegate_(NULL), enable_frame_busting_(true) {} | |
39 virtual ~PluginUrlRequestManager() {} | |
40 | |
41 void set_frame_busting(bool enable) { | |
42 enable_frame_busting_ = enable; | |
43 } | |
44 | |
45 virtual void set_delegate(PluginUrlRequestDelegate* delegate) { | |
46 delegate_ = delegate; | |
47 } | |
48 | |
49 enum ThreadSafeFlags { | |
50 NOT_THREADSAFE = 0x00, | |
51 START_REQUEST_THREADSAFE = 0x01, | |
52 STOP_REQUEST_THREADSAFE = 0x02, | |
53 READ_REQUEST_THREADSAFE = 0x04, | |
54 DOWNLOAD_REQUEST_THREADSAFE = 0x08, | |
55 COOKIE_REQUEST_THREADSAFE = 0x10 | |
56 }; | |
57 virtual ThreadSafeFlags GetThreadSafeFlags() = 0; | |
58 | |
59 protected: | |
60 PluginUrlRequestDelegate* delegate_; | |
61 bool enable_frame_busting_; | |
62 }; | |
63 | |
64 // Used as base class. Holds Url request properties (url, method, referrer..) | |
65 class PluginUrlRequest { | |
66 public: | |
67 PluginUrlRequest(); | |
68 ~PluginUrlRequest(); | |
69 | |
70 bool Initialize(PluginUrlRequestDelegate* delegate, | |
71 int remote_request_id, const std::string& url, const std::string& method, | |
72 const std::string& referrer, const std::string& extra_headers, | |
73 net::UploadData* upload_data, ResourceType::Type resource_type, | |
74 bool enable_frame_busting_, int load_flags); | |
75 | |
76 // Accessors. | |
77 int id() const { | |
78 return remote_request_id_; | |
79 } | |
80 | |
81 const std::string& url() const { | |
82 return url_; | |
83 } | |
84 | |
85 const std::string& method() const { | |
86 return method_; | |
87 } | |
88 | |
89 const std::string& referrer() const { | |
90 return referrer_; | |
91 } | |
92 | |
93 const std::string& extra_headers() const { | |
94 return extra_headers_; | |
95 } | |
96 | |
97 uint64 post_data_len() const { | |
98 return post_data_len_; | |
99 } | |
100 | |
101 bool is_chunked_upload() const { | |
102 return is_chunked_upload_; | |
103 } | |
104 | |
105 protected: | |
106 HRESULT get_upload_data(IStream** ret) { | |
107 DCHECK(ret); | |
108 if (!upload_data_.get()) | |
109 return S_FALSE; | |
110 *ret = upload_data_.get(); | |
111 (*ret)->AddRef(); | |
112 return S_OK; | |
113 } | |
114 | |
115 void set_url(const std::string& url) { | |
116 url_ = url; | |
117 } | |
118 | |
119 void SendData(); | |
120 bool enable_frame_busting_; | |
121 | |
122 PluginUrlRequestDelegate* delegate_; | |
123 int remote_request_id_; | |
124 uint64 post_data_len_; | |
125 std::string url_; | |
126 std::string method_; | |
127 std::string referrer_; | |
128 std::string extra_headers_; | |
129 ResourceType::Type resource_type_; | |
130 int load_flags_; | |
131 base::win::ScopedComPtr<IStream> upload_data_; | |
132 bool is_chunked_upload_; | |
133 // Contains the ip address and port of the destination host. | |
134 net::HostPortPair socket_address_; | |
135 }; | |
136 | |
137 #endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_ | |
OLD | NEW |