| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet); | 44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 void SSLManager::OnSSLCertificateError( | 50 void SSLManager::OnSSLCertificateError( |
| 51 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | 51 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
| 52 const ResourceType resource_type, | 52 const ResourceType resource_type, |
| 53 const GURL& url, | 53 const GURL& url, |
| 54 int render_process_id, | 54 const base::Callback<WebContents*(void)>& web_contents_getter, |
| 55 int render_frame_id, | |
| 56 const net::SSLInfo& ssl_info, | 55 const net::SSLInfo& ssl_info, |
| 57 bool fatal) { | 56 bool fatal) { |
| 58 DCHECK(delegate.get()); | 57 DCHECK(delegate.get()); |
| 59 DVLOG(1) << "OnSSLCertificateError() cert_error: " | 58 DVLOG(1) << "OnSSLCertificateError() cert_error: " |
| 60 << net::MapCertStatusToNetError(ssl_info.cert_status) | 59 << net::MapCertStatusToNetError(ssl_info.cert_status) |
| 61 << " resource_type: " << resource_type | 60 << " resource_type: " << resource_type |
| 62 << " url: " << url.spec() | 61 << " url: " << url.spec() |
| 63 << " render_process_id: " << render_process_id | |
| 64 << " render_frame_id: " << render_frame_id | |
| 65 << " cert_status: " << std::hex << ssl_info.cert_status; | 62 << " cert_status: " << std::hex << ssl_info.cert_status; |
| 66 | 63 |
| 67 // A certificate error occurred. Construct a SSLCertErrorHandler object and | 64 // A certificate error occurred. Construct a SSLCertErrorHandler object and |
| 68 // hand it over to the UI thread for processing. | 65 // hand it over to the UI thread for processing. |
| 69 BrowserThread::PostTask( | 66 BrowserThread::PostTask( |
| 70 BrowserThread::UI, FROM_HERE, | 67 BrowserThread::UI, FROM_HERE, |
| 71 base::Bind(&SSLCertErrorHandler::Dispatch, | 68 base::Bind(&SSLCertErrorHandler::Dispatch, |
| 72 new SSLCertErrorHandler(delegate, | 69 new SSLCertErrorHandler(delegate, resource_type, url, ssl_info, |
| 73 resource_type, | 70 fatal), |
| 74 url, | 71 web_contents_getter)); |
| 75 render_process_id, | |
| 76 render_frame_id, | |
| 77 ssl_info, | |
| 78 fatal))); | |
| 79 } | 72 } |
| 80 | 73 |
| 81 // static | 74 // static |
| 75 void SSLManager::OnSSLCertificateSubresourceError( |
| 76 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
| 77 const GURL& url, |
| 78 int render_process_id, |
| 79 int render_frame_id, |
| 80 const net::SSLInfo& ssl_info, |
| 81 bool fatal) { |
| 82 OnSSLCertificateError(delegate, RESOURCE_TYPE_SUB_RESOURCE, url, |
| 83 base::Bind(&WebContentsImpl::FromRPHAndRFHIDs, |
| 84 render_process_id, render_frame_id), |
| 85 ssl_info, fatal); |
| 86 } |
| 87 |
| 88 // static |
| 82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 89 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
| 83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 90 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
| 84 context->GetUserData(kSSLManagerKeyName)); | 91 context->GetUserData(kSSLManagerKeyName)); |
| 85 | 92 |
| 86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 93 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 87 i != managers->get().end(); ++i) { | 94 i != managers->get().end(); ++i) { |
| 88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); | 95 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); |
| 89 } | 96 } |
| 90 } | 97 } |
| 91 | 98 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 NotifyDidChangeVisibleSSLState(); | 200 NotifyDidChangeVisibleSSLState(); |
| 194 } | 201 } |
| 195 | 202 |
| 196 void SSLManager::NotifyDidChangeVisibleSSLState() { | 203 void SSLManager::NotifyDidChangeVisibleSSLState() { |
| 197 WebContentsImpl* contents = | 204 WebContentsImpl* contents = |
| 198 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 205 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 199 contents->DidChangeVisibleSSLState(); | 206 contents->DidChangeVisibleSSLState(); |
| 200 } | 207 } |
| 201 | 208 |
| 202 } // namespace content | 209 } // namespace content |
| OLD | NEW |