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

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

Issue 218973002: Extract Peer interface out of ResourceLoaderBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASED Created 6 years, 8 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
« no previous file with comments | « chrome/renderer/security_filter_peer.h ('k') | content/child/npapi/plugin_url_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
16 webkit_glue::ResourceLoaderBridge::Peer* peer) 16 content::RequestPeer* peer)
17 : original_peer_(peer), 17 : original_peer_(peer),
18 resource_loader_bridge_(resource_loader_bridge) { 18 resource_loader_bridge_(resource_loader_bridge) {
19 } 19 }
20 20
21 SecurityFilterPeer::~SecurityFilterPeer() { 21 SecurityFilterPeer::~SecurityFilterPeer() {
22 } 22 }
23 23
24 // static 24 // static
25 SecurityFilterPeer* 25 SecurityFilterPeer*
26 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest( 26 SecurityFilterPeer::CreateSecurityFilterPeerForDeniedRequest(
27 ResourceType::Type resource_type, 27 ResourceType::Type resource_type,
28 webkit_glue::ResourceLoaderBridge::Peer* peer, 28 content::RequestPeer* peer,
29 int os_error) { 29 int os_error) {
30 // Create a filter for SSL and CERT errors. 30 // Create a filter for SSL and CERT errors.
31 switch (os_error) { 31 switch (os_error) {
32 case net::ERR_SSL_PROTOCOL_ERROR: 32 case net::ERR_SSL_PROTOCOL_ERROR:
33 case net::ERR_CERT_COMMON_NAME_INVALID: 33 case net::ERR_CERT_COMMON_NAME_INVALID:
34 case net::ERR_CERT_DATE_INVALID: 34 case net::ERR_CERT_DATE_INVALID:
35 case net::ERR_CERT_AUTHORITY_INVALID: 35 case net::ERR_CERT_AUTHORITY_INVALID:
36 case net::ERR_CERT_CONTAINS_ERRORS: 36 case net::ERR_CERT_CONTAINS_ERRORS:
37 case net::ERR_CERT_NO_REVOCATION_MECHANISM: 37 case net::ERR_CERT_NO_REVOCATION_MECHANISM:
38 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: 38 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
39 case net::ERR_CERT_REVOKED: 39 case net::ERR_CERT_REVOKED:
40 case net::ERR_CERT_INVALID: 40 case net::ERR_CERT_INVALID:
41 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: 41 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
42 case net::ERR_CERT_WEAK_KEY: 42 case net::ERR_CERT_WEAK_KEY:
43 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: 43 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
44 case net::ERR_INSECURE_RESPONSE: 44 case net::ERR_INSECURE_RESPONSE:
45 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: 45 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN:
46 if (ResourceType::IsFrame(resource_type)) 46 if (ResourceType::IsFrame(resource_type))
47 return CreateSecurityFilterPeerForFrame(peer, os_error); 47 return CreateSecurityFilterPeerForFrame(peer, os_error);
48 // Any other content is entirely filtered-out. 48 // Any other content is entirely filtered-out.
49 return new ReplaceContentPeer(NULL, peer, std::string(), std::string()); 49 return new ReplaceContentPeer(NULL, peer, std::string(), std::string());
50 default: 50 default:
51 // For other errors, we use our normal error handling. 51 // For other errors, we use our normal error handling.
52 return NULL; 52 return NULL;
53 } 53 }
54 } 54 }
55 55
56 // static 56 // static
57 SecurityFilterPeer* SecurityFilterPeer::CreateSecurityFilterPeerForFrame( 57 SecurityFilterPeer* SecurityFilterPeer::CreateSecurityFilterPeerForFrame(
58 webkit_glue::ResourceLoaderBridge::Peer* peer, int os_error) { 58 content::RequestPeer* peer,
59 int os_error) {
59 // TODO(jcampan): use a different message when getting a phishing/malware 60 // TODO(jcampan): use a different message when getting a phishing/malware
60 // error. 61 // error.
61 std::string html = base::StringPrintf( 62 std::string html = base::StringPrintf(
62 "<html><meta charset='UTF-8'>" 63 "<html><meta charset='UTF-8'>"
63 "<body style='background-color:#990000;color:white;'>" 64 "<body style='background-color:#990000;color:white;'>"
64 "%s</body></html>", 65 "%s</body></html>",
65 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str()); 66 l10n_util::GetStringUTF8(IDS_UNSAFE_FRAME_MESSAGE).c_str());
66 return new ReplaceContentPeer(NULL, peer, "text/html", html); 67 return new ReplaceContentPeer(NULL, peer, "text/html", html);
67 } 68 }
68 69
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 net::HttpResponseHeaders* new_headers = 128 net::HttpResponseHeaders* new_headers =
128 new net::HttpResponseHeaders(raw_headers); 129 new net::HttpResponseHeaders(raw_headers);
129 info_out->headers = new_headers; 130 info_out->headers = new_headers;
130 } 131 }
131 132
132 //////////////////////////////////////////////////////////////////////////////// 133 ////////////////////////////////////////////////////////////////////////////////
133 // BufferedPeer 134 // BufferedPeer
134 135
135 BufferedPeer::BufferedPeer( 136 BufferedPeer::BufferedPeer(
136 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 137 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
137 webkit_glue::ResourceLoaderBridge::Peer* peer, 138 content::RequestPeer* peer,
138 const std::string& mime_type) 139 const std::string& mime_type)
139 : SecurityFilterPeer(resource_loader_bridge, peer), 140 : SecurityFilterPeer(resource_loader_bridge, peer),
140 mime_type_(mime_type) { 141 mime_type_(mime_type) {
141 } 142 }
142 143
143 BufferedPeer::~BufferedPeer() { 144 BufferedPeer::~BufferedPeer() {
144 } 145 }
145 146
146 void BufferedPeer::OnReceivedResponse( 147 void BufferedPeer::OnReceivedResponse(
147 const webkit_glue::ResourceResponseInfo& info) { 148 const webkit_glue::ResourceResponseInfo& info) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 183 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
183 stale_copy_in_cache, security_info, 184 stale_copy_in_cache, security_info,
184 completion_time, total_transfer_size); 185 completion_time, total_transfer_size);
185 } 186 }
186 187
187 //////////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////////////
188 // ReplaceContentPeer 189 // ReplaceContentPeer
189 190
190 ReplaceContentPeer::ReplaceContentPeer( 191 ReplaceContentPeer::ReplaceContentPeer(
191 webkit_glue::ResourceLoaderBridge* resource_loader_bridge, 192 webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
192 webkit_glue::ResourceLoaderBridge::Peer* peer, 193 content::RequestPeer* peer,
193 const std::string& mime_type, 194 const std::string& mime_type,
194 const std::string& data) 195 const std::string& data)
195 : SecurityFilterPeer(resource_loader_bridge, peer), 196 : SecurityFilterPeer(resource_loader_bridge, peer),
196 mime_type_(mime_type), 197 mime_type_(mime_type),
197 data_(data) { 198 data_(data) {
198 } 199 }
199 200
200 ReplaceContentPeer::~ReplaceContentPeer() { 201 ReplaceContentPeer::~ReplaceContentPeer() {
201 } 202 }
202 203
(...skipping 27 matching lines...) Expand all
230 original_peer_->OnCompletedRequest(net::OK, 231 original_peer_->OnCompletedRequest(net::OK,
231 false, 232 false,
232 stale_copy_in_cache, 233 stale_copy_in_cache,
233 security_info, 234 security_info,
234 completion_time, 235 completion_time,
235 total_transfer_size); 236 total_transfer_size);
236 237
237 // The request processing is complete, we must delete ourselves. 238 // The request processing is complete, we must delete ourselves.
238 delete this; 239 delete this;
239 } 240 }
OLDNEW
« no previous file with comments | « chrome/renderer/security_filter_peer.h ('k') | content/child/npapi/plugin_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698