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 "ios/web/net/request_tracker_impl.h" | 5 #include "ios/web/net/request_tracker_impl.h" |
6 | 6 |
7 #include <pthread.h> | 7 #include <pthread.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
15 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
20 #import "ios/net/clients/crn_forwarding_network_client.h" | 20 #import "ios/net/clients/crn_forwarding_network_client.h" |
21 #import "ios/net/clients/crn_forwarding_network_client_factory.h" | 21 #import "ios/net/clients/crn_forwarding_network_client_factory.h" |
22 #import "ios/web/crw_network_activity_indicator_manager.h" | 22 #import "ios/web/crw_network_activity_indicator_manager.h" |
23 #import "ios/web/history_state_util.h" | 23 #import "ios/web/history_state_util.h" |
24 #import "ios/web/net/crw_request_tracker_delegate.h" | 24 #import "ios/web/net/crw_request_tracker_delegate.h" |
25 #include "ios/web/public/browser_state.h" | 25 #include "ios/web/public/browser_state.h" |
26 #include "ios/web/public/cert_store.h" | |
27 #include "ios/web/public/certificate_policy_cache.h" | 26 #include "ios/web/public/certificate_policy_cache.h" |
28 #include "ios/web/public/ssl_status.h" | 27 #include "ios/web/public/ssl_status.h" |
29 #include "ios/web/public/url_util.h" | 28 #include "ios/web/public/url_util.h" |
30 #include "ios/web/public/web_thread.h" | 29 #include "ios/web/public/web_thread.h" |
31 #import "net/base/mac/url_conversions.h" | 30 #import "net/base/mac/url_conversions.h" |
32 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
33 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
34 #include "net/url_request/url_request.h" | 33 #include "net/url_request/url_request.h" |
35 | 34 |
36 #if !defined(__has_feature) || !__has_feature(objc_arc) | 35 #if !defined(__has_feature) || !__has_feature(objc_arc) |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, | 261 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, |
263 base::Bind(&web::RequestTrackerImpl::ErrorCallback, | 262 base::Bind(&web::RequestTrackerImpl::ErrorCallback, |
264 tracker_, scoped, flag)); | 263 tracker_, scoped, flag)); |
265 } | 264 } |
266 | 265 |
267 - (void)buildSSLStatus { | 266 - (void)buildSSLStatus { |
268 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 267 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
269 if (!sslInfo_.is_valid()) | 268 if (!sslInfo_.is_valid()) |
270 return; | 269 return; |
271 | 270 |
272 status_.cert_id = web::CertStore::GetInstance()->StoreCert( | 271 status_.certificate = sslInfo_.cert; |
273 sslInfo_.cert.get(), tracker_->identifier()); | |
274 | 272 |
275 status_.cert_status = sslInfo_.cert_status; | 273 status_.cert_status = sslInfo_.cert_status; |
276 if (status_.cert_status & net::CERT_STATUS_COMMON_NAME_INVALID) { | 274 if (status_.cert_status & net::CERT_STATUS_COMMON_NAME_INVALID) { |
277 // CAs issue certificates for intranet hosts to everyone. Therefore, we | 275 // CAs issue certificates for intranet hosts to everyone. Therefore, we |
278 // mark intranet hosts as being non-unique. | 276 // mark intranet hosts as being non-unique. |
279 if (IsIntranetHost(url_.host())) { | 277 if (IsIntranetHost(url_.host())) { |
280 status_.cert_status |= net::CERT_STATUS_NON_UNIQUE_NAME; | 278 status_.cert_status |= net::CERT_STATUS_NON_UNIQUE_NAME; |
281 } | 279 } |
282 } | 280 } |
283 | 281 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, | 404 web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, |
407 base::BindBlock(^{ | 405 base::BindBlock(^{ |
408 tracker->is_closing_ = true; | 406 tracker->is_closing_ = true; |
409 tracker->CancelRequests(); | 407 tracker->CancelRequests(); |
410 })); | 408 })); |
411 | 409 |
412 // Disable the delegate. | 410 // Disable the delegate. |
413 delegate_ = nil; | 411 delegate_ = nil; |
414 // The user_info is no longer needed. | 412 // The user_info is no longer needed. |
415 user_info_.reset(); | 413 user_info_.reset(); |
416 // Get rid of the stored certificates | |
417 web::CertStore::GetInstance()->RemoveCertsForGroup(identifier_); | |
418 } | 414 } |
419 | 415 |
420 // static | 416 // static |
421 void RequestTrackerImpl::RunAfterRequestsCancel(const base::Closure& callback) { | 417 void RequestTrackerImpl::RunAfterRequestsCancel(const base::Closure& callback) { |
422 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 418 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
423 // Post a no-op to the IO thread, and after that has executed, run |callback|. | 419 // Post a no-op to the IO thread, and after that has executed, run |callback|. |
424 // This ensures that |callback| runs after anything elese queued on the IO | 420 // This ensures that |callback| runs after anything elese queued on the IO |
425 // thread, in particular CancelRequest() calls made from closing trackers. | 421 // thread, in particular CancelRequest() calls made from closing trackers. |
426 web::WebThread::PostTaskAndReply(web::WebThread::IO, FROM_HERE, | 422 web::WebThread::PostTaskAndReply(web::WebThread::IO, FROM_HERE, |
427 base::Bind(&base::DoNothing), callback); | 423 base::Bind(&base::DoNothing), callback); |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 })); | 1305 })); |
1310 } | 1306 } |
1311 } | 1307 } |
1312 | 1308 |
1313 void RequestTrackerImpl::SetCertificatePolicyCacheForTest( | 1309 void RequestTrackerImpl::SetCertificatePolicyCacheForTest( |
1314 web::CertificatePolicyCache* cache) { | 1310 web::CertificatePolicyCache* cache) { |
1315 policy_cache_ = cache; | 1311 policy_cache_ = cache; |
1316 } | 1312 } |
1317 | 1313 |
1318 } // namespace web | 1314 } // namespace web |
OLD | NEW |