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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 2400673003: Remove SSLStatus::security_style member and content::SecurityStyle (Closed)
Patch Set: more curly braces Created 4 years, 2 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | content/common/BUILD.gn » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <openssl/ssl.h> 7 #include <openssl/ssl.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 16 matching lines...) Expand all
27 #include "content/child/ftp_directory_listing_response_delegate.h" 27 #include "content/child/ftp_directory_listing_response_delegate.h"
28 #include "content/child/request_extra_data.h" 28 #include "content/child/request_extra_data.h"
29 #include "content/child/resource_dispatcher.h" 29 #include "content/child/resource_dispatcher.h"
30 #include "content/child/shared_memory_data_consumer_handle.h" 30 #include "content/child/shared_memory_data_consumer_handle.h"
31 #include "content/child/sync_load_response.h" 31 #include "content/child/sync_load_response.h"
32 #include "content/child/web_url_request_util.h" 32 #include "content/child/web_url_request_util.h"
33 #include "content/child/weburlresponse_extradata_impl.h" 33 #include "content/child/weburlresponse_extradata_impl.h"
34 #include "content/common/resource_messages.h" 34 #include "content/common/resource_messages.h"
35 #include "content/common/resource_request.h" 35 #include "content/common/resource_request.h"
36 #include "content/common/resource_request_body_impl.h" 36 #include "content/common/resource_request_body_impl.h"
37 #include "content/common/security_style_util.h"
38 #include "content/common/service_worker/service_worker_types.h" 37 #include "content/common/service_worker/service_worker_types.h"
39 #include "content/common/url_loader.mojom.h" 38 #include "content/common/url_loader.mojom.h"
40 #include "content/public/child/fixed_received_data.h" 39 #include "content/public/child/fixed_received_data.h"
41 #include "content/public/child/request_peer.h" 40 #include "content/public/child/request_peer.h"
42 #include "content/public/common/browser_side_navigation_policy.h" 41 #include "content/public/common/browser_side_navigation_policy.h"
43 #include "net/base/data_url.h" 42 #include "net/base/data_url.h"
44 #include "net/base/filename_util.h" 43 #include "net/base/filename_util.h"
45 #include "net/base/net_errors.h" 44 #include "net/base/net_errors.h"
46 #include "net/cert/cert_status_flags.h" 45 #include "net/cert/cert_status_flags.h"
47 #include "net/cert/ct_sct_to_string.h" 46 #include "net/cert/ct_sct_to_string.h"
48 #include "net/cert/x509_util.h" 47 #include "net/cert/x509_util.h"
49 #include "net/http/http_response_headers.h" 48 #include "net/http/http_response_headers.h"
50 #include "net/http/http_util.h" 49 #include "net/http/http_util.h"
51 #include "net/ssl/ssl_cipher_suite_names.h" 50 #include "net/ssl/ssl_cipher_suite_names.h"
52 #include "net/ssl/ssl_connection_status_flags.h" 51 #include "net/ssl/ssl_connection_status_flags.h"
53 #include "net/url_request/url_request_data_job.h" 52 #include "net/url_request/url_request_data_job.h"
54 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" 53 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
55 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
55 #include "third_party/WebKit/public/platform/WebSecurityStyle.h"
56 #include "third_party/WebKit/public/platform/WebTaskRunner.h" 56 #include "third_party/WebKit/public/platform/WebTaskRunner.h"
57 #include "third_party/WebKit/public/platform/WebURL.h" 57 #include "third_party/WebKit/public/platform/WebURL.h"
58 #include "third_party/WebKit/public/platform/WebURLError.h" 58 #include "third_party/WebKit/public/platform/WebURLError.h"
59 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" 59 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
60 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 60 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
61 #include "third_party/WebKit/public/platform/WebURLRequest.h" 61 #include "third_party/WebKit/public/platform/WebURLRequest.h"
62 #include "third_party/WebKit/public/platform/WebURLResponse.h" 62 #include "third_party/WebKit/public/platform/WebURLResponse.h"
63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
64 64
65 using base::Time; 65 using base::Time;
(...skipping 14 matching lines...) Expand all
80 using blink::WebURLResponse; 80 using blink::WebURLResponse;
81 81
82 namespace content { 82 namespace content {
83 83
84 // Utilities ------------------------------------------------------------------ 84 // Utilities ------------------------------------------------------------------
85 85
86 namespace { 86 namespace {
87 87
88 using HeadersVector = ResourceDevToolsInfo::HeadersVector; 88 using HeadersVector = ResourceDevToolsInfo::HeadersVector;
89 89
90 // TODO(estark): Figure out a way for the embedder to provide the
91 // security style for a resource. Ideally, the logic for assigning
92 // per-resource security styles should live in the same place as the
93 // logic for assigning per-page security styles (which lives in the
94 // embedder). It would also be nice for the embedder to have the chance
95 // to control the per-resource security style beyond the simple logic
96 // here. (For example, the embedder might want to mark certain resources
97 // differently if they use SHA1 signatures.) https://crbug.com/648326
98 blink::WebSecurityStyle GetSecurityStyleForResource(
99 const GURL& url,
100 net::CertStatus cert_status) {
101 if (!url.SchemeIsCryptographic())
102 return blink::WebSecurityStyleUnauthenticated;
103
104 // Minor errors don't lower the security style to
105 // WebSecurityStyleAuthenticationBroken.
106 if (net::IsCertStatusError(cert_status) &&
107 !net::IsCertStatusMinorError(cert_status)) {
108 return blink::WebSecurityStyleAuthenticationBroken;
109 }
110
111 return blink::WebSecurityStyleAuthenticated;
112 }
113
90 // Converts timing data from |load_timing| to the format used by WebKit. 114 // Converts timing data from |load_timing| to the format used by WebKit.
91 void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing, 115 void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing,
92 WebURLLoadTiming* url_timing) { 116 WebURLLoadTiming* url_timing) {
93 DCHECK(!load_timing.request_start.is_null()); 117 DCHECK(!load_timing.request_start.is_null());
94 118
95 const TimeTicks kNullTicks; 119 const TimeTicks kNullTicks;
96 url_timing->initialize(); 120 url_timing->initialize();
97 url_timing->setRequestTime( 121 url_timing->setRequestTime(
98 (load_timing.request_start - kNullTicks).InSecondsF()); 122 (load_timing.request_start - kNullTicks).InSecondsF());
99 url_timing->setProxyStart( 123 url_timing->setProxyStart(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 WebString::fromUTF8( 245 WebString::fromUTF8(
222 base::HexEncode(sct_and_status.sct->signature.signature_data.c_str(), 246 base::HexEncode(sct_and_status.sct->signature.signature_data.c_str(),
223 sct_and_status.sct->signature.signature_data.length()))); 247 sct_and_status.sct->signature.signature_data.length())));
224 } 248 }
225 249
226 void SetSecurityStyleAndDetails(const GURL& url, 250 void SetSecurityStyleAndDetails(const GURL& url,
227 const ResourceResponseInfo& info, 251 const ResourceResponseInfo& info,
228 WebURLResponse* response, 252 WebURLResponse* response,
229 bool report_security_info) { 253 bool report_security_info) {
230 if (!report_security_info) { 254 if (!report_security_info) {
231 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 255 response->setSecurityStyle(blink::WebSecurityStyleUnknown);
232 return; 256 return;
233 } 257 }
234 if (!url.SchemeIsCryptographic()) { 258 if (!url.SchemeIsCryptographic()) {
235 response->setSecurityStyle(WebURLResponse::SecurityStyleUnauthenticated); 259 response->setSecurityStyle(blink::WebSecurityStyleUnauthenticated);
236 return; 260 return;
237 } 261 }
238 262
239 // There are cases where an HTTPS request can come in without security 263 // There are cases where an HTTPS request can come in without security
240 // info attached (such as a redirect response). 264 // info attached (such as a redirect response).
241 if (info.certificate.empty()) { 265 if (info.certificate.empty()) {
242 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 266 response->setSecurityStyle(blink::WebSecurityStyleUnknown);
243 return; 267 return;
244 } 268 }
245 269
246 int ssl_version = 270 int ssl_version =
247 net::SSLConnectionStatusToVersion(info.ssl_connection_status); 271 net::SSLConnectionStatusToVersion(info.ssl_connection_status);
248 const char* protocol; 272 const char* protocol;
249 net::SSLVersionToString(&protocol, ssl_version); 273 net::SSLVersionToString(&protocol, ssl_version);
250 274
251 const char* key_exchange; 275 const char* key_exchange;
252 const char* cipher; 276 const char* cipher;
(...skipping 11 matching lines...) Expand all
264 const char* key_exchange_group = ""; 288 const char* key_exchange_group = "";
265 if (info.ssl_key_exchange_group != 0) { 289 if (info.ssl_key_exchange_group != 0) {
266 // Historically the field was named 'curve' rather than 'group'. 290 // Historically the field was named 'curve' rather than 'group'.
267 key_exchange_group = SSL_get_curve_name(info.ssl_key_exchange_group); 291 key_exchange_group = SSL_get_curve_name(info.ssl_key_exchange_group);
268 if (!key_exchange_group) { 292 if (!key_exchange_group) {
269 NOTREACHED(); 293 NOTREACHED();
270 key_exchange_group = ""; 294 key_exchange_group = "";
271 } 295 }
272 } 296 }
273 297
274 SecurityStyle security_style = GetSecurityStyleForResource( 298 response->setSecurityStyle(
275 url, true, info.cert_status); 299 GetSecurityStyleForResource(url, info.cert_status));
276
277 blink::WebURLResponse::SecurityStyle security_style_blink =
278 WebURLResponse::SecurityStyleUnknown;
279 switch (security_style) {
280 case SECURITY_STYLE_UNKNOWN:
281 security_style_blink = WebURLResponse::SecurityStyleUnknown;
282 break;
283 case SECURITY_STYLE_UNAUTHENTICATED:
284 security_style_blink = WebURLResponse::SecurityStyleUnauthenticated;
285 break;
286 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
287 security_style_blink = WebURLResponse::SecurityStyleAuthenticationBroken;
288 break;
289 case SECURITY_STYLE_WARNING:
290 security_style_blink = WebURLResponse::SecurityStyleWarning;
291 break;
292 case SECURITY_STYLE_AUTHENTICATED:
293 security_style_blink = WebURLResponse::SecurityStyleAuthenticated;
294 break;
295 }
296
297 response->setSecurityStyle(security_style_blink);
298 300
299 blink::WebURLResponse::SignedCertificateTimestampList sct_list( 301 blink::WebURLResponse::SignedCertificateTimestampList sct_list(
300 info.signed_certificate_timestamps.size()); 302 info.signed_certificate_timestamps.size());
301 303
302 for (size_t i = 0; i < sct_list.size(); ++i) 304 for (size_t i = 0; i < sct_list.size(); ++i)
303 sct_list[i] = NetSCTToBlinkSCT(info.signed_certificate_timestamps[i]); 305 sct_list[i] = NetSCTToBlinkSCT(info.signed_certificate_timestamps[i]);
304 306
305 std::string subject, issuer; 307 std::string subject, issuer;
306 base::Time valid_start, valid_expiry; 308 base::Time valid_start, valid_expiry;
307 std::vector<std::string> san; 309 std::vector<std::string> san;
308 bool rv = net::x509_util::ParseCertificateSandboxed( 310 bool rv = net::x509_util::ParseCertificateSandboxed(
309 info.certificate[0], &subject, &issuer, &valid_start, &valid_expiry, &san, 311 info.certificate[0], &subject, &issuer, &valid_start, &valid_expiry, &san,
310 &san); 312 &san);
311 if (!rv) { 313 if (!rv) {
312 NOTREACHED(); 314 NOTREACHED();
313 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 315 response->setSecurityStyle(blink::WebSecurityStyleUnknown);
314 return; 316 return;
315 } 317 }
316 318
317 blink::WebVector<blink::WebString> web_san(san.size()); 319 blink::WebVector<blink::WebString> web_san(san.size());
318 std::transform( 320 std::transform(
319 san.begin(), 321 san.begin(),
320 san.end(), web_san.begin(), 322 san.end(), web_san.begin(),
321 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); 323 [](const std::string& h) { return blink::WebString::fromLatin1(h); });
322 324
323 blink::WebVector<blink::WebString> web_cert(info.certificate.size()); 325 blink::WebVector<blink::WebString> web_cert(info.certificate.size());
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 int intra_priority_value) { 1234 int intra_priority_value) {
1233 context_->DidChangePriority(new_priority, intra_priority_value); 1235 context_->DidChangePriority(new_priority, intra_priority_value);
1234 } 1236 }
1235 1237
1236 void WebURLLoaderImpl::setLoadingTaskRunner( 1238 void WebURLLoaderImpl::setLoadingTaskRunner(
1237 blink::WebTaskRunner* loading_task_runner) { 1239 blink::WebTaskRunner* loading_task_runner) {
1238 context_->SetTaskRunner(loading_task_runner->toSingleThreadTaskRunner()); 1240 context_->SetTaskRunner(loading_task_runner->toSingleThreadTaskRunner());
1239 } 1241 }
1240 1242
1241 } // namespace content 1243 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698