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

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

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years 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/child/web_database_observer_impl.cc ('k') | content/child/web_url_request_util.cc » ('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 <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
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"
55 #include "third_party/WebKit/public/platform/StringVectorCopier.h"
54 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" 56 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
55 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 57 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
56 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" 58 #include "third_party/WebKit/public/platform/WebSecurityStyle.h"
57 #include "third_party/WebKit/public/platform/WebURL.h" 59 #include "third_party/WebKit/public/platform/WebURL.h"
58 #include "third_party/WebKit/public/platform/WebURLError.h" 60 #include "third_party/WebKit/public/platform/WebURLError.h"
59 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" 61 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
60 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 62 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
61 #include "third_party/WebKit/public/platform/WebURLRequest.h" 63 #include "third_party/WebKit/public/platform/WebURLRequest.h"
62 #include "third_party/WebKit/public/platform/WebURLResponse.h" 64 #include "third_party/WebKit/public/platform/WebURLResponse.h"
63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 65 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 std::vector<std::string> san; 318 std::vector<std::string> san;
317 bool rv = net::x509_util::ParseCertificateSandboxed( 319 bool rv = net::x509_util::ParseCertificateSandboxed(
318 info.certificate[0], &subject, &issuer, &valid_start, &valid_expiry, &san, 320 info.certificate[0], &subject, &issuer, &valid_start, &valid_expiry, &san,
319 &san); 321 &san);
320 if (!rv) { 322 if (!rv) {
321 NOTREACHED(); 323 NOTREACHED();
322 response->setSecurityStyle(blink::WebSecurityStyleUnknown); 324 response->setSecurityStyle(blink::WebSecurityStyleUnknown);
323 return; 325 return;
324 } 326 }
325 327
326 blink::WebVector<blink::WebString> web_san(san.size());
327 std::transform(
328 san.begin(),
329 san.end(), web_san.begin(),
330 [](const std::string& h) { return blink::WebString::fromLatin1(h); });
331
332 blink::WebVector<blink::WebString> web_cert(info.certificate.size());
333 std::transform(
334 info.certificate.begin(),
335 info.certificate.end(), web_cert.begin(),
336 [](const std::string& h) { return blink::WebString::fromLatin1(h); });
337
338 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( 328 blink::WebURLResponse::WebSecurityDetails webSecurityDetails(
339 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), 329 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange),
340 WebString::fromUTF8(key_exchange_group), 330 WebString::fromUTF8(key_exchange_group), WebString::fromUTF8(cipher),
341 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), 331 WebString::fromUTF8(mac), WebString::fromUTF8(subject),
342 WebString::fromUTF8(subject), 332 blink::CopyStringVectorFromLatin1(san), WebString::fromUTF8(issuer),
343 web_san, 333 valid_start.ToDoubleT(), valid_expiry.ToDoubleT(),
344 WebString::fromUTF8(issuer), 334 blink::CopyStringVectorFromLatin1(info.certificate), sct_list);
345 valid_start.ToDoubleT(),
346 valid_expiry.ToDoubleT(),
347 web_cert,
348 sct_list);
349 335
350 response->setSecurityDetails(webSecurityDetails); 336 response->setSecurityDetails(webSecurityDetails);
351 } 337 }
352 338
353 } // namespace 339 } // namespace
354 340
355 StreamOverrideParameters::StreamOverrideParameters() {} 341 StreamOverrideParameters::StreamOverrideParameters() {}
356 StreamOverrideParameters::~StreamOverrideParameters() {} 342 StreamOverrideParameters::~StreamOverrideParameters() {}
357 343
358 // This inner class exists since the WebURLLoader may be deleted while inside a 344 // This inner class exists since the WebURLLoader may be deleted while inside a
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 response->setHasMajorCertificateErrors(info.has_major_certificate_errors); 1023 response->setHasMajorCertificateErrors(info.has_major_certificate_errors);
1038 response->setAppCacheID(info.appcache_id); 1024 response->setAppCacheID(info.appcache_id);
1039 response->setAppCacheManifestURL(info.appcache_manifest_url); 1025 response->setAppCacheManifestURL(info.appcache_manifest_url);
1040 response->setWasCached(!info.load_timing.request_start_time.is_null() && 1026 response->setWasCached(!info.load_timing.request_start_time.is_null() &&
1041 info.response_time < info.load_timing.request_start_time); 1027 info.response_time < info.load_timing.request_start_time);
1042 response->setRemoteIPAddress( 1028 response->setRemoteIPAddress(
1043 WebString::fromUTF8(info.socket_address.HostForURL())); 1029 WebString::fromUTF8(info.socket_address.HostForURL()));
1044 response->setRemotePort(info.socket_address.port()); 1030 response->setRemotePort(info.socket_address.port());
1045 response->setConnectionID(info.load_timing.socket_log_id); 1031 response->setConnectionID(info.load_timing.socket_log_id);
1046 response->setConnectionReused(info.load_timing.socket_reused); 1032 response->setConnectionReused(info.load_timing.socket_reused);
1047 response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe()); 1033 response->setDownloadFilePath(
1034 blink::FilePathToWebString(info.download_file_path));
1048 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); 1035 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy);
1049 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker); 1036 response->setWasFetchedViaServiceWorker(info.was_fetched_via_service_worker);
1050 response->setWasFetchedViaForeignFetch(info.was_fetched_via_foreign_fetch); 1037 response->setWasFetchedViaForeignFetch(info.was_fetched_via_foreign_fetch);
1051 response->setWasFallbackRequiredByServiceWorker( 1038 response->setWasFallbackRequiredByServiceWorker(
1052 info.was_fallback_required_by_service_worker); 1039 info.was_fallback_required_by_service_worker);
1053 response->setServiceWorkerResponseType(info.response_type_via_service_worker); 1040 response->setServiceWorkerResponseType(info.response_type_via_service_worker);
1054 response->setOriginalURLViaServiceWorker( 1041 response->setOriginalURLViaServiceWorker(
1055 info.original_url_via_service_worker); 1042 info.original_url_via_service_worker);
1056 response->setCacheStorageCacheName( 1043 response->setCacheStorageCacheName(
1057 info.is_in_cache_storage 1044 info.is_in_cache_storage
1058 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) 1045 ? blink::WebString::fromUTF8(info.cache_storage_cache_name)
1059 : blink::WebString()); 1046 : blink::WebString());
1060 blink::WebVector<blink::WebString> cors_exposed_header_names( 1047 response->setCorsExposedHeaderNames(
1061 info.cors_exposed_header_names.size()); 1048 blink::CopyStringVectorFromLatin1(info.cors_exposed_header_names));
1062 std::transform(
1063 info.cors_exposed_header_names.begin(),
1064 info.cors_exposed_header_names.end(), cors_exposed_header_names.begin(),
1065 [](const std::string& h) { return blink::WebString::fromLatin1(h); });
1066 response->setCorsExposedHeaderNames(cors_exposed_header_names);
1067 response->setEncodedDataLength(info.encoded_data_length); 1049 response->setEncodedDataLength(info.encoded_data_length);
1068 1050
1069 SetSecurityStyleAndDetails(url, info, response, report_security_info); 1051 SetSecurityStyleAndDetails(url, info, response, report_security_info);
1070 1052
1071 WebURLResponseExtraDataImpl* extra_data = 1053 WebURLResponseExtraDataImpl* extra_data =
1072 new WebURLResponseExtraDataImpl(info.alpn_negotiated_protocol); 1054 new WebURLResponseExtraDataImpl(info.alpn_negotiated_protocol);
1073 response->setExtraData(extra_data); 1055 response->setExtraData(extra_data);
1074 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); 1056 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
1075 extra_data->set_was_alpn_negotiated(info.was_alpn_negotiated); 1057 extra_data->set_was_alpn_negotiated(info.was_alpn_negotiated);
1076 extra_data->set_was_alternate_protocol_available( 1058 extra_data->set_was_alternate_protocol_available(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 response->setHTTPVersion(version); 1120 response->setHTTPVersion(version);
1139 response->setHTTPStatusCode(headers->response_code()); 1121 response->setHTTPStatusCode(headers->response_code());
1140 response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText())); 1122 response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText()));
1141 1123
1142 // TODO(darin): We should leverage HttpResponseHeaders for this, and this 1124 // TODO(darin): We should leverage HttpResponseHeaders for this, and this
1143 // should be using the same code as ResourceDispatcherHost. 1125 // should be using the same code as ResourceDispatcherHost.
1144 // TODO(jungshik): Figure out the actual value of the referrer charset and 1126 // TODO(jungshik): Figure out the actual value of the referrer charset and
1145 // pass it to GetSuggestedFilename. 1127 // pass it to GetSuggestedFilename.
1146 std::string value; 1128 std::string value;
1147 headers->EnumerateHeader(NULL, "content-disposition", &value); 1129 headers->EnumerateHeader(NULL, "content-disposition", &value);
1148 response->setSuggestedFileName( 1130 response->setSuggestedFileName(blink::WebString::fromUTF16(
1149 net::GetSuggestedFilename(url, 1131 net::GetSuggestedFilename(url, value,
1150 value, 1132 std::string(), // referrer_charset
1151 std::string(), // referrer_charset 1133 std::string(), // suggested_name
1152 std::string(), // suggested_name 1134 std::string(), // mime_type
1153 std::string(), // mime_type 1135 std::string()))); // default_name
1154 std::string())); // default_name
1155 1136
1156 Time time_val; 1137 Time time_val;
1157 if (headers->GetLastModifiedValue(&time_val)) 1138 if (headers->GetLastModifiedValue(&time_val))
1158 response->setLastModifiedDate(time_val.ToDoubleT()); 1139 response->setLastModifiedDate(time_val.ToDoubleT());
1159 1140
1160 // Build up the header map. 1141 // Build up the header map.
1161 size_t iter = 0; 1142 size_t iter = 0;
1162 std::string name; 1143 std::string name;
1163 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { 1144 while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
1164 response->addHTTPHeaderField(WebString::fromLatin1(name), 1145 response->addHTTPHeaderField(WebString::fromLatin1(name),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 int intra_priority_value) { 1231 int intra_priority_value) {
1251 context_->DidChangePriority(new_priority, intra_priority_value); 1232 context_->DidChangePriority(new_priority, intra_priority_value);
1252 } 1233 }
1253 1234
1254 void WebURLLoaderImpl::setLoadingTaskRunner( 1235 void WebURLLoaderImpl::setLoadingTaskRunner(
1255 base::SingleThreadTaskRunner* loading_task_runner) { 1236 base::SingleThreadTaskRunner* loading_task_runner) {
1256 context_->SetTaskRunner(loading_task_runner); 1237 context_->SetTaskRunner(loading_task_runner);
1257 } 1238 }
1258 1239
1259 } // namespace content 1240 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_database_observer_impl.cc ('k') | content/child/web_url_request_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698