Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/renderer/security_filter_peer.cc

Issue 186193005: Move resource_loader_bridge to content/public/child/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/http/http_response_headers.h" 11 #include "net/http/http_response_headers.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 13
14 SecurityFilterPeer::SecurityFilterPeer( 14 SecurityFilterPeer::SecurityFilterPeer(
15 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 15 content::ResourceLoaderBridge* resource_loader_bridge,
16 webkit_glue::ResourceLoaderBridge::Peer* peer) 16 content::ResourceLoaderBridge::Peer* peer)
17 : original_peer_(peer), 17 : original_peer_(peer), resource_loader_bridge_(resource_loader_bridge) {}
18 resource_loader_bridge_(resource_loader_bridge) {
19 }
20 18
21 SecurityFilterPeer::~SecurityFilterPeer() { 19 SecurityFilterPeer::~SecurityFilterPeer() {
22 } 20 }
23 21
24 // static 22 // static
25 SecurityFilterPeer* 23 SecurityFilterPeer*
26 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( 24 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest(
27 ResourceType::Type resource_type, 25 ResourceType::Type resource_type,
28 webkit_glue::ResourceLoaderBridge::Peer* peer, 26 content::ResourceLoaderBridge::Peer* peer,
29 int os_error) { 27 int os_error) {
30 // Create a filter for SSL and CERT errors. 28 // Create a filter for SSL and CERT errors.
31 switch (os_error) { 29 switch (os_error) {
32 case net::ERR_SSL_PROTOCOL_ERROR: 30 case net::ERR_SSL_PROTOCOL_ERROR:
33 case net::ERR_CERT_COMMON_NAME_INVALID: 31 case net::ERR_CERT_COMMON_NAME_INVALID:
34 case net::ERR_CERT_DATE_INVALID: 32 case net::ERR_CERT_DATE_INVALID:
35 case net::ERR_CERT_AUTHORITY_INVALID: 33 case net::ERR_CERT_AUTHORITY_INVALID:
36 case net::ERR_CERT_CONTAINS_ERRORS: 34 case net::ERR_CERT_CONTAINS_ERRORS:
37 case net::ERR_CERT_NO_REVOCATION_MECHANISM: 35 case net::ERR_CERT_NO_REVOCATION_MECHANISM:
38 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: 36 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
39 case net::ERR_CERT_REVOKED: 37 case net::ERR_CERT_REVOKED:
40 case net::ERR_CERT_INVALID: 38 case net::ERR_CERT_INVALID:
41 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: 39 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
42 case net::ERR_CERT_WEAK_KEY: 40 case net::ERR_CERT_WEAK_KEY:
43 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: 41 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
44 case net::ERR_INSECURE_RESPONSE: 42 case net::ERR_INSECURE_RESPONSE:
45 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: 43 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN:
46 if (ResourceType::IsFrame(resource_type)) 44 if (ResourceType::IsFrame(resource_type))
47 return CreateSecurityFilterPeerForFrame(peer, os_error); 45 return CreateSecurityFilterPeerForFrame(peer, os_error);
48 // Any other content is entirely filtered-out. 46 // Any other content is entirely filtered-out.
49 return new ReplaceContentPeer(NULL, peer, std::string(), std::string()); 47 return new ReplaceContentPeer(NULL, peer, std::string(), std::string());
50 default: 48 default:
51 // For other errors, we use our normal error handling. 49 // For other errors, we use our normal error handling.
52 return NULL; 50 return NULL;
53 } 51 }
54 } 52 }
55 53
56 // static 54 // static
57 SecurityFilterPeer* SecurityFilterPeer::CreateSecurityFilterPeerForFrame( 55 SecurityFilterPeer* SecurityFilterPeer::CreateSecurityFilterPeerForFrame(
58 webkit_glue::ResourceLoaderBridge::Peer* peer, int os_error) { 56 content::ResourceLoaderBridge::Peer* peer,
57 int os_error) {
59 // TODO(jcampan): use a different message when getting a phishing/malware 58 // TODO(jcampan): use a different message when getting a phishing/malware
60 // error. 59 // error.
61 std::string html = base::StringPrintf( 60 std::string html = base::StringPrintf(
62 "<html><meta charset='UTF-8'>" 61 "<html><meta charset='UTF-8'>"
63 "<body style='background-color:#990000;color:white;'>" 62 "<body style='background-color:#990000;color:white;'>"
64 "%s</body></html>", 63 "%s</body></html>",
65 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str()); 64 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str());
66 return new ReplaceContentPeer(NULL, peer, "text/html", html); 65 return new ReplaceContentPeer(NULL, peer, "text/html", html);
67 } 66 }
68 67
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 raw_headers.push_back('\0'); 125 raw_headers.push_back('\0');
127 net::HttpResponseHeaders* new_headers = 126 net::HttpResponseHeaders* new_headers =
128 new net::HttpResponseHeaders(raw_headers); 127 new net::HttpResponseHeaders(raw_headers);
129 info_out->headers = new_headers; 128 info_out->headers = new_headers;
130 } 129 }
131 130
132 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
133 // BufferedPeer 132 // BufferedPeer
134 133
135 BufferedPeer::BufferedPeer( 134 BufferedPeer::BufferedPeer(
136 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 135 content::ResourceLoaderBridge* resource_loader_bridge,
137 webkit_glue::ResourceLoaderBridge::Peer* peer, 136 content::ResourceLoaderBridge::Peer* peer,
138 const std::string& mime_type) 137 const std::string& mime_type)
139 : SecurityFilterPeer(resource_loader_bridge, peer), 138 : SecurityFilterPeer(resource_loader_bridge, peer), mime_type_(mime_type) {}
140 mime_type_(mime_type) {
141 }
142 139
143 BufferedPeer::~BufferedPeer() { 140 BufferedPeer::~BufferedPeer() {
144 } 141 }
145 142
146 void BufferedPeer::OnReceivedResponse( 143 void BufferedPeer::OnReceivedResponse(
147 const webkit_glue::ResourceResponseInfo& info) { 144 const webkit_glue::ResourceResponseInfo& info) {
148 ProcessResponseInfo(info, &response_info_, mime_type_); 145 ProcessResponseInfo(info, &response_info_, mime_type_);
149 } 146 }
150 147
151 void BufferedPeer::OnReceivedData(const char* data, 148 void BufferedPeer::OnReceivedData(const char* data,
(...skipping 29 matching lines...) Expand all
181 -1); 178 -1);
182 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 179 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
183 stale_copy_in_cache, security_info, 180 stale_copy_in_cache, security_info,
184 completion_time, total_transfer_size); 181 completion_time, total_transfer_size);
185 } 182 }
186 183
187 //////////////////////////////////////////////////////////////////////////////// 184 ////////////////////////////////////////////////////////////////////////////////
188 // ReplaceContentPeer 185 // ReplaceContentPeer
189 186
190 ReplaceContentPeer::ReplaceContentPeer( 187 ReplaceContentPeer::ReplaceContentPeer(
191 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 188 content::ResourceLoaderBridge* resource_loader_bridge,
192 webkit_glue::ResourceLoaderBridge::Peer* peer, 189 content::ResourceLoaderBridge::Peer* peer,
193 const std::string& mime_type, 190 const std::string& mime_type,
194 const std::string& data) 191 const std::string& data)
195 : SecurityFilterPeer(resource_loader_bridge, peer), 192 : SecurityFilterPeer(resource_loader_bridge, peer),
196 mime_type_(mime_type), 193 mime_type_(mime_type),
197 data_(data) { 194 data_(data) {}
198 }
199 195
200 ReplaceContentPeer::~ReplaceContentPeer() { 196 ReplaceContentPeer::~ReplaceContentPeer() {
201 } 197 }
202 198
203 void ReplaceContentPeer::OnReceivedResponse( 199 void ReplaceContentPeer::OnReceivedResponse(
204 const webkit_glue::ResourceResponseInfo& info) { 200 const webkit_glue::ResourceResponseInfo& info) {
205 // Ignore this, we'll serve some alternate content in OnCompletedRequest. 201 // Ignore this, we'll serve some alternate content in OnCompletedRequest.
206 } 202 }
207 203
208 void ReplaceContentPeer::OnReceivedData(const char* data, 204 void ReplaceContentPeer::OnReceivedData(const char* data,
(...skipping 21 matching lines...) Expand all
230 original_peer_->OnCompletedRequest(net::OK, 226 original_peer_->OnCompletedRequest(net::OK,
231 false, 227 false,
232 stale_copy_in_cache, 228 stale_copy_in_cache,
233 security_info, 229 security_info,
234 completion_time, 230 completion_time,
235 total_transfer_size); 231 total_transfer_size);
236 232
237 // The request processing is complete, we must delete ourselves. 233 // The request processing is complete, we must delete ourselves.
238 delete this; 234 delete this;
239 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698