OLD | NEW |
---|---|
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 "content/browser/ssl/ssl_manager.h" | 5 #include "content/browser/ssl/ssl_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
14 #include "content/browser/devtools/devtools_agent_host_impl.h" | |
15 #include "content/browser/devtools/protocol/security_handler.h" | |
14 #include "content/browser/frame_host/navigation_entry_impl.h" | 16 #include "content/browser/frame_host/navigation_entry_impl.h" |
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 17 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
16 #include "content/browser/loader/resource_request_info_impl.h" | 18 #include "content/browser/loader/resource_request_info_impl.h" |
17 #include "content/browser/ssl/ssl_error_handler.h" | 19 #include "content/browser/ssl/ssl_error_handler.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
19 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
20 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/certificate_request_result_type.h" | 23 #include "content/public/browser/certificate_request_result_type.h" |
22 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
25 #include "content/public/browser/devtools_agent_host.h" | |
23 #include "content/public/browser/navigation_details.h" | 26 #include "content/public/browser/navigation_details.h" |
24 #include "content/public/browser/ssl_host_state_delegate.h" | 27 #include "content/public/browser/ssl_host_state_delegate.h" |
25 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
26 | 29 |
27 namespace content { | 30 namespace content { |
28 | 31 |
29 namespace { | 32 namespace { |
30 | 33 |
31 const char kSSLManagerKeyName[] = "content_ssl_manager"; | 34 const char kSSLManagerKeyName[] = "content_ssl_manager"; |
32 | 35 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 bool overridable = (options_mask & OVERRIDABLE) != 0; | 352 bool overridable = (options_mask & OVERRIDABLE) != 0; |
350 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0; | 353 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0; |
351 bool expired_previous_decision = | 354 bool expired_previous_decision = |
352 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0; | 355 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0; |
353 | 356 |
354 WebContents* web_contents = handler->web_contents(); | 357 WebContents* web_contents = handler->web_contents(); |
355 int cert_error = handler->cert_error(); | 358 int cert_error = handler->cert_error(); |
356 const net::SSLInfo& ssl_info = handler->ssl_info(); | 359 const net::SSLInfo& ssl_info = handler->ssl_info(); |
357 const GURL& request_url = handler->request_url(); | 360 const GURL& request_url = handler->request_url(); |
358 ResourceType resource_type = handler->resource_type(); | 361 ResourceType resource_type = handler->resource_type(); |
359 GetContentClient()->browser()->AllowCertificateError( | 362 |
360 web_contents, cert_error, ssl_info, request_url, resource_type, | 363 base::Callback<void(content::CertificateRequestResultType)> callback = |
361 overridable, strict_enforcement, expired_previous_decision, | |
362 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), | 364 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), |
363 ssl_host_state_delegate_)); | 365 ssl_host_state_delegate_); |
366 | |
estark
2017/02/28 23:34:03
Note that this code won't fire for all cases of ce
irisu
2017/03/06 11:56:49
Done.
| |
367 DevToolsAgentHostImpl* agent_host = static_cast<DevToolsAgentHostImpl*>( | |
368 DevToolsAgentHost::GetOrCreateFor(web_contents).get()); | |
369 protocol::SecurityHandler* security_handler = | |
370 protocol::SecurityHandler::FromAgentHost(agent_host); | |
371 if (!security_handler || | |
372 !security_handler->NotifyCertificateError(cert_error, request_url, | |
estark
2017/02/28 23:34:04
As I mentioned elsewhere, I think it would be bett
irisu
2017/03/06 11:56:49
Done.
| |
373 callback)) { | |
374 GetContentClient()->browser()->AllowCertificateError( | |
375 web_contents, cert_error, ssl_info, request_url, resource_type, | |
376 overridable, strict_enforcement, expired_previous_decision, callback); | |
377 } | |
364 } | 378 } |
365 | 379 |
366 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, | 380 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, |
367 int add_content_status_flags, | 381 int add_content_status_flags, |
368 int remove_content_status_flags) { | 382 int remove_content_status_flags) { |
369 // We don't always have a navigation entry to update, for example in the | 383 // We don't always have a navigation entry to update, for example in the |
370 // case of the Web Inspector. | 384 // case of the Web Inspector. |
371 if (!entry) | 385 if (!entry) |
372 return; | 386 return; |
373 | 387 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 SSLManagerSet* managers = | 435 SSLManagerSet* managers = |
422 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); | 436 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); |
423 | 437 |
424 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 438 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
425 i != managers->get().end(); ++i) { | 439 i != managers->get().end(); ++i) { |
426 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0); | 440 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0); |
427 } | 441 } |
428 } | 442 } |
429 | 443 |
430 } // namespace content | 444 } // namespace content |
OLD | NEW |