OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/renderer/security_filter_peer.h" | 5 #include "chrome/renderer/security_filter_peer.h" |
6 | 6 |
7 #include "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 GURL* new_first_party_for_cookies) { | 72 GURL* new_first_party_for_cookies) { |
73 NOTREACHED(); | 73 NOTREACHED(); |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 void SecurityFilterPeer::OnReceivedResponse( | 77 void SecurityFilterPeer::OnReceivedResponse( |
78 const webkit_glue::ResourceResponseInfo& info) { | 78 const webkit_glue::ResourceResponseInfo& info) { |
79 NOTREACHED(); | 79 NOTREACHED(); |
80 } | 80 } |
81 | 81 |
82 void SecurityFilterPeer::OnReceivedData(const char* data, int len) { | 82 void SecurityFilterPeer::OnReceivedData(const char* data, int data_length, |
pfeldman
2011/04/01 08:48:06
ditto
vsevik
2011/04/01 09:50:59
Done.
| |
83 int length_received) { | |
83 NOTREACHED(); | 84 NOTREACHED(); |
84 } | 85 } |
85 | 86 |
86 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status, | 87 void SecurityFilterPeer::OnCompletedRequest(const net::URLRequestStatus& status, |
87 const std::string& security_info, | 88 const std::string& security_info, |
88 const base::Time& completion_time) { | 89 const base::Time& completion_time) { |
89 NOTREACHED(); | 90 NOTREACHED(); |
90 } | 91 } |
91 | 92 |
92 // static | 93 // static |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 } | 131 } |
131 | 132 |
132 BufferedPeer::~BufferedPeer() { | 133 BufferedPeer::~BufferedPeer() { |
133 } | 134 } |
134 | 135 |
135 void BufferedPeer::OnReceivedResponse( | 136 void BufferedPeer::OnReceivedResponse( |
136 const webkit_glue::ResourceResponseInfo& info) { | 137 const webkit_glue::ResourceResponseInfo& info) { |
137 ProcessResponseInfo(info, &response_info_, mime_type_); | 138 ProcessResponseInfo(info, &response_info_, mime_type_); |
138 } | 139 } |
139 | 140 |
140 void BufferedPeer::OnReceivedData(const char* data, int len) { | 141 void BufferedPeer::OnReceivedData(const char* data, int data_length, |
pfeldman
2011/04/01 08:48:06
diffo
vsevik
2011/04/01 09:50:59
Done.
| |
141 data_.append(data, len); | 142 int length_received) { |
143 data_.append(data, data_length); | |
142 } | 144 } |
143 | 145 |
144 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, | 146 void BufferedPeer::OnCompletedRequest(const net::URLRequestStatus& status, |
145 const std::string& security_info, | 147 const std::string& security_info, |
146 const base::Time& completion_time) { | 148 const base::Time& completion_time) { |
147 // Make sure we delete ourselves at the end of this call. | 149 // Make sure we delete ourselves at the end of this call. |
148 scoped_ptr<BufferedPeer> this_deleter(this); | 150 scoped_ptr<BufferedPeer> this_deleter(this); |
149 | 151 |
150 // Give sub-classes a chance at altering the data. | 152 // Give sub-classes a chance at altering the data. |
151 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { | 153 if (status.status() != net::URLRequestStatus::SUCCESS || !DataReady()) { |
152 // Pretend we failed to load the resource. | 154 // Pretend we failed to load the resource. |
153 original_peer_->OnReceivedResponse(response_info_); | 155 original_peer_->OnReceivedResponse(response_info_); |
154 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, | 156 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, |
155 net::ERR_ABORTED); | 157 net::ERR_ABORTED); |
156 original_peer_->OnCompletedRequest(status, security_info, completion_time); | 158 original_peer_->OnCompletedRequest(status, security_info, completion_time); |
157 return; | 159 return; |
158 } | 160 } |
159 | 161 |
160 original_peer_->OnReceivedResponse(response_info_); | 162 original_peer_->OnReceivedResponse(response_info_); |
161 if (!data_.empty()) | 163 if (!data_.empty()) |
162 original_peer_->OnReceivedData(data_.data(), | 164 original_peer_->OnReceivedData(data_.data(), |
163 static_cast<int>(data_.size())); | 165 static_cast<int>(data_.size()), -1); |
164 original_peer_->OnCompletedRequest(status, security_info, completion_time); | 166 original_peer_->OnCompletedRequest(status, security_info, completion_time); |
165 } | 167 } |
166 | 168 |
167 //////////////////////////////////////////////////////////////////////////////// | 169 //////////////////////////////////////////////////////////////////////////////// |
168 // ReplaceContentPeer | 170 // ReplaceContentPeer |
169 | 171 |
170 ReplaceContentPeer::ReplaceContentPeer( | 172 ReplaceContentPeer::ReplaceContentPeer( |
171 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, | 173 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, |
172 webkit_glue::ResourceLoaderBridge::Peer* peer, | 174 webkit_glue::ResourceLoaderBridge::Peer* peer, |
173 const std::string& mime_type, | 175 const std::string& mime_type, |
174 const std::string& data) | 176 const std::string& data) |
175 : SecurityFilterPeer(resource_loader_bridge, peer), | 177 : SecurityFilterPeer(resource_loader_bridge, peer), |
176 mime_type_(mime_type), | 178 mime_type_(mime_type), |
177 data_(data) { | 179 data_(data) { |
178 } | 180 } |
179 | 181 |
180 ReplaceContentPeer::~ReplaceContentPeer() { | 182 ReplaceContentPeer::~ReplaceContentPeer() { |
181 } | 183 } |
182 | 184 |
183 void ReplaceContentPeer::OnReceivedResponse( | 185 void ReplaceContentPeer::OnReceivedResponse( |
184 const webkit_glue::ResourceResponseInfo& info) { | 186 const webkit_glue::ResourceResponseInfo& info) { |
185 // Ignore this, we'll serve some alternate content in OnCompletedRequest. | 187 // Ignore this, we'll serve some alternate content in OnCompletedRequest. |
186 } | 188 } |
187 | 189 |
188 void ReplaceContentPeer::OnReceivedData(const char* data, int len) { | 190 void ReplaceContentPeer::OnReceivedData(const char* data, int data_length, |
pfeldman
2011/04/01 08:48:06
ditto
vsevik
2011/04/01 09:50:59
Done.
| |
191 int length_received) { | |
189 // Ignore this, we'll serve some alternate content in OnCompletedRequest. | 192 // Ignore this, we'll serve some alternate content in OnCompletedRequest. |
190 } | 193 } |
191 | 194 |
192 void ReplaceContentPeer::OnCompletedRequest( | 195 void ReplaceContentPeer::OnCompletedRequest( |
193 const net::URLRequestStatus& status, | 196 const net::URLRequestStatus& status, |
194 const std::string& security_info, | 197 const std::string& security_info, |
195 const base::Time& completion_time) { | 198 const base::Time& completion_time) { |
196 webkit_glue::ResourceResponseInfo info; | 199 webkit_glue::ResourceResponseInfo info; |
197 ProcessResponseInfo(info, &info, mime_type_); | 200 ProcessResponseInfo(info, &info, mime_type_); |
198 info.security_info = security_info; | 201 info.security_info = security_info; |
199 info.content_length = static_cast<int>(data_.size()); | 202 info.content_length = static_cast<int>(data_.size()); |
200 original_peer_->OnReceivedResponse(info); | 203 original_peer_->OnReceivedResponse(info); |
201 if (!data_.empty()) | 204 if (!data_.empty()) |
202 original_peer_->OnReceivedData(data_.data(), | 205 original_peer_->OnReceivedData(data_.data(), |
203 static_cast<int>(data_.size())); | 206 static_cast<int>(data_.size()), -1); |
pfeldman
2011/04/01 08:48:06
ditto
vsevik
2011/04/01 09:50:59
Done.
| |
204 original_peer_->OnCompletedRequest(net::URLRequestStatus(), | 207 original_peer_->OnCompletedRequest(net::URLRequestStatus(), |
205 security_info, | 208 security_info, |
206 completion_time); | 209 completion_time); |
207 | 210 |
208 // The request processing is complete, we must delete ourselves. | 211 // The request processing is complete, we must delete ourselves. |
209 delete this; | 212 delete this; |
210 } | 213 } |
OLD | NEW |