| 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 #include "chrome/renderer/security_filter_peer.h" | 5 #include "chrome/renderer/security_filter_peer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 11 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 12 #include "content/public/child/fixed_received_data.h" | 13 #include "content/public/child/fixed_received_data.h" |
| 13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 14 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 | 17 |
| 17 SecurityFilterPeer::SecurityFilterPeer(content::RequestPeer* peer) | 18 SecurityFilterPeer::SecurityFilterPeer(content::RequestPeer* peer) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 original_peer_->OnReceivedCompletedResponse( | 141 original_peer_->OnReceivedCompletedResponse( |
| 141 response_info_, nullptr, net::ERR_ABORTED, false, stale_copy_in_cache, | 142 response_info_, nullptr, net::ERR_ABORTED, false, stale_copy_in_cache, |
| 142 security_info, completion_time, total_transfer_size); | 143 security_info, completion_time, total_transfer_size); |
| 143 return; | 144 return; |
| 144 } | 145 } |
| 145 | 146 |
| 146 scoped_ptr<content::FixedReceivedData> data_to_pass( | 147 scoped_ptr<content::FixedReceivedData> data_to_pass( |
| 147 data_.empty() ? nullptr : new content::FixedReceivedData( | 148 data_.empty() ? nullptr : new content::FixedReceivedData( |
| 148 data_.data(), data_.size(), -1)); | 149 data_.data(), data_.size(), -1)); |
| 149 original_peer_->OnReceivedCompletedResponse( | 150 original_peer_->OnReceivedCompletedResponse( |
| 150 response_info_, data_to_pass.Pass(), error_code, was_ignored_by_handler, | 151 response_info_, std::move(data_to_pass), error_code, |
| 151 stale_copy_in_cache, security_info, completion_time, total_transfer_size); | 152 was_ignored_by_handler, stale_copy_in_cache, security_info, |
| 153 completion_time, total_transfer_size); |
| 152 } | 154 } |
| 153 | 155 |
| 154 void BufferedPeer::OnReceivedCompletedResponse( | 156 void BufferedPeer::OnReceivedCompletedResponse( |
| 155 const content::ResourceResponseInfo& info, | 157 const content::ResourceResponseInfo& info, |
| 156 scoped_ptr<ReceivedData> data, | 158 scoped_ptr<ReceivedData> data, |
| 157 int error_code, | 159 int error_code, |
| 158 bool was_ignored_by_handler, | 160 bool was_ignored_by_handler, |
| 159 bool stale_copy_in_cache, | 161 bool stale_copy_in_cache, |
| 160 const std::string& security_info, | 162 const std::string& security_info, |
| 161 const base::TimeTicks& completion_time, | 163 const base::TimeTicks& completion_time, |
| 162 int64_t total_transfer_size) { | 164 int64_t total_transfer_size) { |
| 163 // Make sure we delete ourselves at the end of this call. | 165 // Make sure we delete ourselves at the end of this call. |
| 164 scoped_ptr<BufferedPeer> this_deleter(this); | 166 scoped_ptr<BufferedPeer> this_deleter(this); |
| 165 original_peer_->OnReceivedCompletedResponse( | 167 original_peer_->OnReceivedCompletedResponse( |
| 166 info, data.Pass(), error_code, was_ignored_by_handler, | 168 info, std::move(data), error_code, was_ignored_by_handler, |
| 167 stale_copy_in_cache, security_info, completion_time, total_transfer_size); | 169 stale_copy_in_cache, security_info, completion_time, total_transfer_size); |
| 168 } | 170 } |
| 169 | 171 |
| 170 //////////////////////////////////////////////////////////////////////////////// | 172 //////////////////////////////////////////////////////////////////////////////// |
| 171 // ReplaceContentPeer | 173 // ReplaceContentPeer |
| 172 | 174 |
| 173 ReplaceContentPeer::ReplaceContentPeer(content::RequestPeer* peer, | 175 ReplaceContentPeer::ReplaceContentPeer(content::RequestPeer* peer, |
| 174 const std::string& mime_type, | 176 const std::string& mime_type, |
| 175 const std::string& data) | 177 const std::string& data) |
| 176 : SecurityFilterPeer(peer), | 178 : SecurityFilterPeer(peer), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 201 | 203 |
| 202 content::ResourceResponseInfo info; | 204 content::ResourceResponseInfo info; |
| 203 ProcessResponseInfo(info, &info, mime_type_); | 205 ProcessResponseInfo(info, &info, mime_type_); |
| 204 info.security_info = security_info; | 206 info.security_info = security_info; |
| 205 info.content_length = static_cast<int>(data_.size()); | 207 info.content_length = static_cast<int>(data_.size()); |
| 206 | 208 |
| 207 scoped_ptr<content::FixedReceivedData> data_to_pass( | 209 scoped_ptr<content::FixedReceivedData> data_to_pass( |
| 208 data_.empty() ? nullptr : new content::FixedReceivedData( | 210 data_.empty() ? nullptr : new content::FixedReceivedData( |
| 209 data_.data(), data_.size(), -1)); | 211 data_.data(), data_.size(), -1)); |
| 210 original_peer_->OnReceivedCompletedResponse( | 212 original_peer_->OnReceivedCompletedResponse( |
| 211 response_info_, data_to_pass.Pass(), net::OK, false, stale_copy_in_cache, | 213 response_info_, std::move(data_to_pass), net::OK, false, |
| 212 security_info, completion_time, total_transfer_size); | 214 stale_copy_in_cache, security_info, completion_time, total_transfer_size); |
| 213 } | 215 } |
| 214 | 216 |
| 215 void ReplaceContentPeer::OnReceivedCompletedResponse( | 217 void ReplaceContentPeer::OnReceivedCompletedResponse( |
| 216 const content::ResourceResponseInfo& info, | 218 const content::ResourceResponseInfo& info, |
| 217 scoped_ptr<ReceivedData> data, | 219 scoped_ptr<ReceivedData> data, |
| 218 int error_code, | 220 int error_code, |
| 219 bool was_ignored_by_handler, | 221 bool was_ignored_by_handler, |
| 220 bool stale_copy_in_cache, | 222 bool stale_copy_in_cache, |
| 221 const std::string& security_info, | 223 const std::string& security_info, |
| 222 const base::TimeTicks& completion_time, | 224 const base::TimeTicks& completion_time, |
| 223 int64_t total_transfer_size) { | 225 int64_t total_transfer_size) { |
| 224 // Make sure we delete ourselves at the end of this call. | 226 // Make sure we delete ourselves at the end of this call. |
| 225 scoped_ptr<ReplaceContentPeer> this_deleter(this); | 227 scoped_ptr<ReplaceContentPeer> this_deleter(this); |
| 226 | 228 |
| 227 original_peer_->OnReceivedCompletedResponse( | 229 original_peer_->OnReceivedCompletedResponse( |
| 228 info, data.Pass(), error_code, was_ignored_by_handler, | 230 info, std::move(data), error_code, was_ignored_by_handler, |
| 229 stale_copy_in_cache, security_info, completion_time, total_transfer_size); | 231 stale_copy_in_cache, security_info, completion_time, total_transfer_size); |
| 230 } | 232 } |
| OLD | NEW |