| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 case net::ERR_CERT_REVOKED: | 41 case net::ERR_CERT_REVOKED: |
| 42 case net::ERR_CERT_INVALID: | 42 case net::ERR_CERT_INVALID: |
| 43 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: | 43 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: |
| 44 case net::ERR_CERT_WEAK_KEY: | 44 case net::ERR_CERT_WEAK_KEY: |
| 45 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: | 45 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: |
| 46 case net::ERR_INSECURE_RESPONSE: | 46 case net::ERR_INSECURE_RESPONSE: |
| 47 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: | 47 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: |
| 48 if (content::IsResourceTypeFrame(resource_type)) | 48 if (content::IsResourceTypeFrame(resource_type)) |
| 49 return CreateSecurityFilterPeerForFrame(std::move(peer), os_error); | 49 return CreateSecurityFilterPeerForFrame(std::move(peer), os_error); |
| 50 // Any other content is entirely filtered-out. | 50 // Any other content is entirely filtered-out. |
| 51 return base::WrapUnique(new ReplaceContentPeer( | 51 return base::MakeUnique<ReplaceContentPeer>(std::move(peer), |
| 52 std::move(peer), std::string(), std::string())); | 52 std::string(), std::string()); |
| 53 default: | 53 default: |
| 54 // For other errors, we use our normal error handling. | 54 // For other errors, we use our normal error handling. |
| 55 return peer; | 55 return peer; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 std::unique_ptr<content::RequestPeer> | 60 std::unique_ptr<content::RequestPeer> |
| 61 SecurityFilterPeer::CreateSecurityFilterPeerForFrame( | 61 SecurityFilterPeer::CreateSecurityFilterPeerForFrame( |
| 62 std::unique_ptr<content::RequestPeer> peer, | 62 std::unique_ptr<content::RequestPeer> peer, |
| 63 int os_error) { | 63 int os_error) { |
| 64 // TODO(jcampan): use a different message when getting a phishing/malware | 64 // TODO(jcampan): use a different message when getting a phishing/malware |
| 65 // error. | 65 // error. |
| 66 std::string html = base::StringPrintf( | 66 std::string html = base::StringPrintf( |
| 67 "<html><meta charset='UTF-8'>" | 67 "<html><meta charset='UTF-8'>" |
| 68 "<body style='background-color:#990000;color:white;'>" | 68 "<body style='background-color:#990000;color:white;'>" |
| 69 "%s</body></html>", | 69 "%s</body></html>", |
| 70 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str()); | 70 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str()); |
| 71 return base::WrapUnique( | 71 return base::MakeUnique<ReplaceContentPeer>(std::move(peer), "text/html", |
| 72 new ReplaceContentPeer(std::move(peer), "text/html", html)); | 72 html); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SecurityFilterPeer::OnUploadProgress(uint64_t position, uint64_t size) { | 75 void SecurityFilterPeer::OnUploadProgress(uint64_t position, uint64_t size) { |
| 76 original_peer_->OnUploadProgress(position, size); | 76 original_peer_->OnUploadProgress(position, size); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool SecurityFilterPeer::OnReceivedRedirect( | 79 bool SecurityFilterPeer::OnReceivedRedirect( |
| 80 const net::RedirectInfo& redirect_info, | 80 const net::RedirectInfo& redirect_info, |
| 81 const content::ResourceResponseInfo& info) { | 81 const content::ResourceResponseInfo& info) { |
| 82 NOTREACHED(); | 82 NOTREACHED(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Pretend we failed to load the resource. | 140 // Pretend we failed to load the resource. |
| 141 original_peer_->OnReceivedResponse(response_info_); | 141 original_peer_->OnReceivedResponse(response_info_); |
| 142 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, | 142 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, |
| 143 stale_copy_in_cache, completion_time, | 143 stale_copy_in_cache, completion_time, |
| 144 total_transfer_size); | 144 total_transfer_size); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 original_peer_->OnReceivedResponse(response_info_); | 148 original_peer_->OnReceivedResponse(response_info_); |
| 149 if (!data_.empty()) { | 149 if (!data_.empty()) { |
| 150 original_peer_->OnReceivedData(base::WrapUnique( | 150 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>( |
| 151 new content::FixedReceivedData(data_.data(), data_.size(), -1, 0))); | 151 data_.data(), data_.size(), -1, 0)); |
| 152 } | 152 } |
| 153 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, | 153 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, |
| 154 stale_copy_in_cache, completion_time, | 154 stale_copy_in_cache, completion_time, |
| 155 total_transfer_size); | 155 total_transfer_size); |
| 156 } | 156 } |
| 157 | 157 |
| 158 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 159 // ReplaceContentPeer | 159 // ReplaceContentPeer |
| 160 | 160 |
| 161 ReplaceContentPeer::ReplaceContentPeer( | 161 ReplaceContentPeer::ReplaceContentPeer( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 180 int error_code, | 180 int error_code, |
| 181 bool was_ignored_by_handler, | 181 bool was_ignored_by_handler, |
| 182 bool stale_copy_in_cache, | 182 bool stale_copy_in_cache, |
| 183 const base::TimeTicks& completion_time, | 183 const base::TimeTicks& completion_time, |
| 184 int64_t total_transfer_size) { | 184 int64_t total_transfer_size) { |
| 185 content::ResourceResponseInfo info; | 185 content::ResourceResponseInfo info; |
| 186 ProcessResponseInfo(info, &info, mime_type_); | 186 ProcessResponseInfo(info, &info, mime_type_); |
| 187 info.content_length = static_cast<int>(data_.size()); | 187 info.content_length = static_cast<int>(data_.size()); |
| 188 original_peer_->OnReceivedResponse(info); | 188 original_peer_->OnReceivedResponse(info); |
| 189 if (!data_.empty()) { | 189 if (!data_.empty()) { |
| 190 original_peer_->OnReceivedData(base::WrapUnique( | 190 original_peer_->OnReceivedData(base::MakeUnique<content::FixedReceivedData>( |
| 191 new content::FixedReceivedData(data_.data(), data_.size(), -1, 0))); | 191 data_.data(), data_.size(), -1, 0)); |
| 192 } | 192 } |
| 193 original_peer_->OnCompletedRequest(net::OK, false, stale_copy_in_cache, | 193 original_peer_->OnCompletedRequest(net::OK, false, stale_copy_in_cache, |
| 194 completion_time, total_transfer_size); | 194 completion_time, total_transfer_size); |
| 195 } | 195 } |
| OLD | NEW |