Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "net/base/filename_util.h" | 44 #include "net/base/filename_util.h" |
| 45 #include "net/base/net_errors.h" | 45 #include "net/base/net_errors.h" |
| 46 #include "net/cert/cert_status_flags.h" | 46 #include "net/cert/cert_status_flags.h" |
| 47 #include "net/cert/ct_sct_to_string.h" | 47 #include "net/cert/ct_sct_to_string.h" |
| 48 #include "net/cert/x509_util.h" | 48 #include "net/cert/x509_util.h" |
| 49 #include "net/http/http_response_headers.h" | 49 #include "net/http/http_response_headers.h" |
| 50 #include "net/http/http_util.h" | 50 #include "net/http/http_util.h" |
| 51 #include "net/ssl/ssl_cipher_suite_names.h" | 51 #include "net/ssl/ssl_cipher_suite_names.h" |
| 52 #include "net/ssl/ssl_connection_status_flags.h" | 52 #include "net/ssl/ssl_connection_status_flags.h" |
| 53 #include "net/url_request/url_request_data_job.h" | 53 #include "net/url_request/url_request_data_job.h" |
| 54 #include "third_party/WebKit/public/platform/FilePathConversion.h" | |
| 54 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" | 55 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" |
| 55 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 56 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 56 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" | 57 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" |
| 57 #include "third_party/WebKit/public/platform/WebURL.h" | 58 #include "third_party/WebKit/public/platform/WebURL.h" |
| 58 #include "third_party/WebKit/public/platform/WebURLError.h" | 59 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 59 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" | 60 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" |
| 60 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 61 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
| 61 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 62 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 62 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 63 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 64 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 info->encoded_body_length = 0; | 227 info->encoded_body_length = 0; |
| 227 | 228 |
| 228 return net::OK; | 229 return net::OK; |
| 229 } | 230 } |
| 230 | 231 |
| 231 // Convert a net::SignedCertificateTimestampAndStatus object to a | 232 // Convert a net::SignedCertificateTimestampAndStatus object to a |
| 232 // blink::WebURLResponse::SignedCertificateTimestamp object. | 233 // blink::WebURLResponse::SignedCertificateTimestamp object. |
| 233 blink::WebURLResponse::SignedCertificateTimestamp NetSCTToBlinkSCT( | 234 blink::WebURLResponse::SignedCertificateTimestamp NetSCTToBlinkSCT( |
| 234 const net::SignedCertificateTimestampAndStatus& sct_and_status) { | 235 const net::SignedCertificateTimestampAndStatus& sct_and_status) { |
| 235 return blink::WebURLResponse::SignedCertificateTimestamp( | 236 return blink::WebURLResponse::SignedCertificateTimestamp( |
| 236 WebString::fromUTF8(net::ct::StatusToString(sct_and_status.status)), | 237 WebString::fromASCII(net::ct::StatusToString(sct_and_status.status)), |
| 237 WebString::fromUTF8(net::ct::OriginToString(sct_and_status.sct->origin)), | 238 WebString::fromASCII(net::ct::OriginToString(sct_and_status.sct->origin)), |
| 238 WebString::fromUTF8(sct_and_status.sct->log_description), | 239 WebString::fromUTF8(sct_and_status.sct->log_description), |
| 239 WebString::fromUTF8(base::HexEncode(sct_and_status.sct->log_id.c_str(), | 240 WebString::fromASCII( |
| 240 sct_and_status.sct->log_id.length())), | 241 base::HexEncode(sct_and_status.sct->log_id.c_str(), |
| 242 sct_and_status.sct->log_id.length())), | |
| 241 sct_and_status.sct->timestamp.ToJavaTime(), | 243 sct_and_status.sct->timestamp.ToJavaTime(), |
| 242 WebString::fromUTF8(net::ct::HashAlgorithmToString( | 244 WebString::fromASCII(net::ct::HashAlgorithmToString( |
| 243 sct_and_status.sct->signature.hash_algorithm)), | 245 sct_and_status.sct->signature.hash_algorithm)), |
| 244 WebString::fromUTF8(net::ct::SignatureAlgorithmToString( | 246 WebString::fromASCII(net::ct::SignatureAlgorithmToString( |
| 245 sct_and_status.sct->signature.signature_algorithm)), | 247 sct_and_status.sct->signature.signature_algorithm)), |
| 246 WebString::fromUTF8( | 248 WebString::fromASCII(base::HexEncode( |
| 247 base::HexEncode(sct_and_status.sct->signature.signature_data.c_str(), | 249 sct_and_status.sct->signature.signature_data.c_str(), |
| 248 sct_and_status.sct->signature.signature_data.length()))); | 250 sct_and_status.sct->signature.signature_data.length()))); |
| 249 } | 251 } |
| 250 | 252 |
| 251 void SetSecurityStyleAndDetails(const GURL& url, | 253 void SetSecurityStyleAndDetails(const GURL& url, |
| 252 const ResourceResponseInfo& info, | 254 const ResourceResponseInfo& info, |
| 253 WebURLResponse* response, | 255 WebURLResponse* response, |
| 254 bool report_security_info) { | 256 bool report_security_info) { |
| 255 if (!report_security_info) { | 257 if (!report_security_info) { |
| 256 response->setSecurityStyle(blink::WebSecurityStyleUnknown); | 258 response->setSecurityStyle(blink::WebSecurityStyleUnknown); |
| 257 return; | 259 return; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 san.end(), web_san.begin(), | 331 san.end(), web_san.begin(), |
| 330 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); | 332 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); |
| 331 | 333 |
| 332 blink::WebVector<blink::WebString> web_cert(info.certificate.size()); | 334 blink::WebVector<blink::WebString> web_cert(info.certificate.size()); |
| 333 std::transform( | 335 std::transform( |
| 334 info.certificate.begin(), | 336 info.certificate.begin(), |
| 335 info.certificate.end(), web_cert.begin(), | 337 info.certificate.end(), web_cert.begin(), |
| 336 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); | 338 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); |
| 337 | 339 |
| 338 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( | 340 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( |
| 339 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), | 341 WebString::fromASCII(protocol), WebString::fromASCII(key_exchange), |
| 340 WebString::fromUTF8(key_exchange_group), | 342 WebString::fromASCII(key_exchange_group), WebString::fromASCII(cipher), |
| 341 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), | 343 WebString::fromASCII(mac), WebString::fromUTF8(subject), web_san, |
| 342 WebString::fromUTF8(subject), | 344 WebString::fromUTF8(issuer), valid_start.ToDoubleT(), |
| 343 web_san, | 345 valid_expiry.ToDoubleT(), web_cert, sct_list); |
| 344 WebString::fromUTF8(issuer), | |
| 345 valid_start.ToDoubleT(), | |
| 346 valid_expiry.ToDoubleT(), | |
| 347 web_cert, | |
| 348 sct_list); | |
| 349 | 346 |
| 350 response->setSecurityDetails(webSecurityDetails); | 347 response->setSecurityDetails(webSecurityDetails); |
| 351 } | 348 } |
| 352 | 349 |
| 353 } // namespace | 350 } // namespace |
| 354 | 351 |
| 355 StreamOverrideParameters::StreamOverrideParameters() {} | 352 StreamOverrideParameters::StreamOverrideParameters() {} |
| 356 StreamOverrideParameters::~StreamOverrideParameters() {} | 353 StreamOverrideParameters::~StreamOverrideParameters() {} |
| 357 | 354 |
| 358 // This inner class exists since the WebURLLoader may be deleted while inside a | 355 // This inner class exists since the WebURLLoader may be deleted while inside a |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 | 535 |
| 539 | 536 |
| 540 // PlzNavigate: outside of tests, the only navigation requests going through | 537 // PlzNavigate: outside of tests, the only navigation requests going through |
| 541 // the WebURLLoader are the ones created by CommitNavigation. Several browser | 538 // the WebURLLoader are the ones created by CommitNavigation. Several browser |
| 542 // tests load HTML directly through a data url which will be handled by the | 539 // tests load HTML directly through a data url which will be handled by the |
| 543 // block above. | 540 // block above. |
| 544 DCHECK(!IsBrowserSideNavigationEnabled() || stream_override_.get() || | 541 DCHECK(!IsBrowserSideNavigationEnabled() || stream_override_.get() || |
| 545 request.getFrameType() == WebURLRequest::FrameTypeNone); | 542 request.getFrameType() == WebURLRequest::FrameTypeNone); |
| 546 | 543 |
| 547 GURL referrer_url( | 544 GURL referrer_url( |
| 548 request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()); | 545 request.httpHeaderField(WebString::fromASCII("Referer")).latin1()); |
|
yhirano
2016/12/26 03:36:22
WebString::fromASCII(c_str).latin1() looks identic
kinuko
2016/12/26 07:28:05
This gets the latin1 of request.httpHeaderField(),
yhirano
2016/12/26 07:38:59
Ah, I see. Thanks.
| |
| 549 const std::string& method = request.httpMethod().latin1(); | 546 const std::string& method = request.httpMethod().latin1(); |
| 550 | 547 |
| 551 // TODO(brettw) this should take parameter encoding into account when | 548 // TODO(brettw) this should take parameter encoding into account when |
| 552 // creating the GURLs. | 549 // creating the GURLs. |
| 553 | 550 |
| 554 // TODO(horo): Check credentials flag is unset when credentials mode is omit. | 551 // TODO(horo): Check credentials flag is unset when credentials mode is omit. |
| 555 // Check credentials flag is set when credentials mode is include. | 552 // Check credentials flag is set when credentials mode is include. |
| 556 | 553 |
| 557 std::unique_ptr<ResourceRequest> resource_request(new ResourceRequest); | 554 std::unique_ptr<ResourceRequest> resource_request(new ResourceRequest); |
| 558 | 555 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 response->setHasMajorCertificateErrors(info.has_major_certificate_errors); | 1044 response->setHasMajorCertificateErrors(info.has_major_certificate_errors); |
| 1048 response->setAppCacheID(info.appcache_id); | 1045 response->setAppCacheID(info.appcache_id); |
| 1049 response->setAppCacheManifestURL(info.appcache_manifest_url); | 1046 response->setAppCacheManifestURL(info.appcache_manifest_url); |
| 1050 response->setWasCached(!info.load_timing.request_start_time.is_null() && | 1047 response->setWasCached(!info.load_timing.request_start_time.is_null() && |
| 1051 info.response_time < info.load_timing.request_start_time); | 1048 info.response_time < info.load_timing.request_start_time); |
| 1052 response->setRemoteIPAddress( | 1049 response->setRemoteIPAddress( |
| 1053 WebString::fromUTF8(info.socket_address.HostForURL())); | 1050 WebString::fromUTF8(info.socket_address.HostForURL())); |
| 1054 response->setRemotePort(info.socket_address.port()); | 1051 response->setRemotePort(info.socket_address.port()); |
| 1055 response->setConnectionID(info.load_timing.socket_log_id); | 1052 response->setConnectionID(info.load_timing.socket_log_id); |
| 1056 response->setConnectionReused(info.load_timing.socket_reused); | 1053 response->setConnectionReused(info.load_timing.socket_reused); |
| 1057 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe()); | 1054 response->setDownloadFilePath( |
| 1055 blink::FilePathToWebString(info.download_file_path)); | |
| 1058 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); | 1056 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); |
| 1059 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker); | 1057 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker); |
| 1060 response->setWasFetchedViaForeignFetch(info.was_fetched_via_foreign_fetch); | 1058 response->setWasFetchedViaForeignFetch(info.was_fetched_via_foreign_fetch); |
| 1061 response->setWasFallbackRequiredByServiceWorker( | 1059 response->setWasFallbackRequiredByServiceWorker( |
| 1062 info.was_fallback_required_by_service_worker); | 1060 info.was_fallback_required_by_service_worker); |
| 1063 response->setServiceWorkerResponseType(info.response_type_via_service_worker); | 1061 response->setServiceWorkerResponseType(info.response_type_via_service_worker); |
| 1064 response->setURLListViaServiceWorker(info.url_list_via_service_worker); | 1062 response->setURLListViaServiceWorker(info.url_list_via_service_worker); |
| 1065 response->setCacheStorageCacheName( | 1063 response->setCacheStorageCacheName( |
| 1066 info.is_in_cache_storage | 1064 info.is_in_cache_storage |
| 1067 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) | 1065 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 response->setHTTPVersion(version); | 1145 response->setHTTPVersion(version); |
| 1148 response->setHTTPStatusCode(headers->response_code()); | 1146 response->setHTTPStatusCode(headers->response_code()); |
| 1149 response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText())); | 1147 response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText())); |
| 1150 | 1148 |
| 1151 // TODO(darin): We should leverage HttpResponseHeaders for this, and this | 1149 // TODO(darin): We should leverage HttpResponseHeaders for this, and this |
| 1152 // should be using the same code as ResourceDispatcherHost. | 1150 // should be using the same code as ResourceDispatcherHost. |
| 1153 // TODO(jungshik): Figure out the actual value of the referrer charset and | 1151 // TODO(jungshik): Figure out the actual value of the referrer charset and |
| 1154 // pass it to GetSuggestedFilename. | 1152 // pass it to GetSuggestedFilename. |
| 1155 std::string value; | 1153 std::string value; |
| 1156 headers->EnumerateHeader(NULL, "content-disposition", &value); | 1154 headers->EnumerateHeader(NULL, "content-disposition", &value); |
| 1157 response->setSuggestedFileName( | 1155 response->setSuggestedFileName(blink::WebString::fromUTF16( |
| 1158 net::GetSuggestedFilename(url, | 1156 net::GetSuggestedFilename(url, value, |
| 1159 value, | 1157 std::string(), // referrer_charset |
| 1160 std::string(), // referrer_charset | 1158 std::string(), // suggested_name |
| 1161 std::string(), // suggested_name | 1159 std::string(), // mime_type |
| 1162 std::string(), // mime_type | 1160 std::string()))); // default_name |
| 1163 std::string())); // default_name | |
| 1164 | 1161 |
| 1165 Time time_val; | 1162 Time time_val; |
| 1166 if (headers->GetLastModifiedValue(&time_val)) | 1163 if (headers->GetLastModifiedValue(&time_val)) |
| 1167 response->setLastModifiedDate(time_val.ToDoubleT()); | 1164 response->setLastModifiedDate(time_val.ToDoubleT()); |
| 1168 | 1165 |
| 1169 // Build up the header map. | 1166 // Build up the header map. |
| 1170 size_t iter = 0; | 1167 size_t iter = 0; |
| 1171 std::string name; | 1168 std::string name; |
| 1172 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 1169 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
| 1173 response->addHTTPHeaderField(WebString::fromLatin1(name), | 1170 response->addHTTPHeaderField(WebString::fromLatin1(name), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1215 SyncLoadResponse sync_load_response; | 1212 SyncLoadResponse sync_load_response; |
| 1216 context_->Start(request, &sync_load_response); | 1213 context_->Start(request, &sync_load_response); |
| 1217 | 1214 |
| 1218 const GURL& final_url = sync_load_response.url; | 1215 const GURL& final_url = sync_load_response.url; |
| 1219 | 1216 |
| 1220 // TODO(tc): For file loads, we may want to include a more descriptive | 1217 // TODO(tc): For file loads, we may want to include a more descriptive |
| 1221 // status code or status text. | 1218 // status code or status text. |
| 1222 int error_code = sync_load_response.error_code; | 1219 int error_code = sync_load_response.error_code; |
| 1223 if (error_code != net::OK) { | 1220 if (error_code != net::OK) { |
| 1224 response.setURL(final_url); | 1221 response.setURL(final_url); |
| 1225 error.domain = WebString::fromUTF8(net::kErrorDomain); | 1222 error.domain = WebString::fromASCII(net::kErrorDomain); |
| 1226 error.reason = error_code; | 1223 error.reason = error_code; |
| 1227 error.unreachableURL = final_url; | 1224 error.unreachableURL = final_url; |
| 1228 return; | 1225 return; |
| 1229 } | 1226 } |
| 1230 | 1227 |
| 1231 PopulateURLResponse(final_url, sync_load_response, &response, | 1228 PopulateURLResponse(final_url, sync_load_response, &response, |
| 1232 request.reportRawHeaders()); | 1229 request.reportRawHeaders()); |
| 1233 response.addToDecodedBodyLength(sync_load_response.data.size()); | 1230 response.addToDecodedBodyLength(sync_load_response.data.size()); |
| 1234 encoded_data_length = sync_load_response.encoded_data_length; | 1231 encoded_data_length = sync_load_response.encoded_data_length; |
| 1235 encoded_body_length = sync_load_response.encoded_body_length; | 1232 encoded_body_length = sync_load_response.encoded_body_length; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1259 int intra_priority_value) { | 1256 int intra_priority_value) { |
| 1260 context_->DidChangePriority(new_priority, intra_priority_value); | 1257 context_->DidChangePriority(new_priority, intra_priority_value); |
| 1261 } | 1258 } |
| 1262 | 1259 |
| 1263 void WebURLLoaderImpl::setLoadingTaskRunner( | 1260 void WebURLLoaderImpl::setLoadingTaskRunner( |
| 1264 base::SingleThreadTaskRunner* loading_task_runner) { | 1261 base::SingleThreadTaskRunner* loading_task_runner) { |
| 1265 context_->SetTaskRunner(loading_task_runner); | 1262 context_->SetTaskRunner(loading_task_runner); |
| 1266 } | 1263 } |
| 1267 | 1264 |
| 1268 } // namespace content | 1265 } // namespace content |
| OLD | NEW |