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 26 matching lines...) Expand all Loading... | |
37 } | 37 } |
38 | 38 |
39 std::set<SSLManager*>& get() { return set_; } | 39 std::set<SSLManager*>& get() { return set_; } |
40 | 40 |
41 private: | 41 private: |
42 std::set<SSLManager*> set_; | 42 std::set<SSLManager*> set_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet); | 44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet); |
45 }; | 45 }; |
46 | 46 |
47 WebContents* GetWebContentsFromRFHID(int render_process_id, | |
nasko
2015/11/23 17:00:24
We have this method in two places. Can't we have i
clamy
2015/11/23 17:56:53
Done.
| |
48 int render_frame_id) { | |
49 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
50 RenderFrameHost* render_frame_host = | |
51 RenderFrameHost::FromID(render_process_id, render_frame_id); | |
52 if (!render_frame_host) | |
53 return nullptr; | |
54 | |
55 return WebContents::FromRenderFrameHost(render_frame_host); | |
56 } | |
57 | |
47 } // namespace | 58 } // namespace |
48 | 59 |
49 // static | 60 // static |
50 void SSLManager::OnSSLCertificateError( | 61 void SSLManager::OnSSLCertificateError( |
51 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | 62 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
52 const ResourceType resource_type, | 63 const ResourceType resource_type, |
53 const GURL& url, | 64 const GURL& url, |
54 int render_process_id, | 65 const base::Callback<WebContents*(void)>& web_contents_getter, |
55 int render_frame_id, | |
56 const net::SSLInfo& ssl_info, | 66 const net::SSLInfo& ssl_info, |
57 bool fatal) { | 67 bool fatal) { |
58 DCHECK(delegate.get()); | 68 DCHECK(delegate.get()); |
59 DVLOG(1) << "OnSSLCertificateError() cert_error: " | 69 DVLOG(1) << "OnSSLCertificateError() cert_error: " |
60 << net::MapCertStatusToNetError(ssl_info.cert_status) | 70 << net::MapCertStatusToNetError(ssl_info.cert_status) |
61 << " resource_type: " << resource_type | 71 << " resource_type: " << resource_type |
62 << " url: " << url.spec() | 72 << " 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; | 73 << " cert_status: " << std::hex << ssl_info.cert_status; |
66 | 74 |
67 // A certificate error occurred. Construct a SSLCertErrorHandler object and | 75 // A certificate error occurred. Construct a SSLCertErrorHandler object and |
68 // hand it over to the UI thread for processing. | 76 // hand it over to the UI thread for processing. |
69 BrowserThread::PostTask( | 77 BrowserThread::PostTask( |
70 BrowserThread::UI, FROM_HERE, | 78 BrowserThread::UI, FROM_HERE, |
71 base::Bind(&SSLCertErrorHandler::Dispatch, | 79 base::Bind(&SSLCertErrorHandler::Dispatch, |
72 new SSLCertErrorHandler(delegate, | 80 new SSLCertErrorHandler(delegate, resource_type, url, ssl_info, |
73 resource_type, | 81 fatal), |
74 url, | 82 web_contents_getter)); |
75 render_process_id, | |
76 render_frame_id, | |
77 ssl_info, | |
78 fatal))); | |
79 } | 83 } |
80 | 84 |
81 // static | 85 // static |
86 void SSLManager::OnSSLCertificateSubresourceError( | |
87 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | |
88 const GURL& url, | |
89 int render_process_id, | |
90 int render_frame_id, | |
91 const net::SSLInfo& ssl_info, | |
92 bool fatal) { | |
93 OnSSLCertificateError( | |
94 delegate, RESOURCE_TYPE_SUB_RESOURCE, url, | |
95 base::Bind(&GetWebContentsFromRFHID, render_process_id, render_frame_id), | |
96 ssl_info, fatal); | |
97 } | |
98 | |
99 // static | |
82 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { | 100 void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) { |
83 SSLManagerSet* managers = static_cast<SSLManagerSet*>( | 101 SSLManagerSet* managers = static_cast<SSLManagerSet*>( |
84 context->GetUserData(kSSLManagerKeyName)); | 102 context->GetUserData(kSSLManagerKeyName)); |
85 | 103 |
86 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 104 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
87 i != managers->get().end(); ++i) { | 105 i != managers->get().end(); ++i) { |
88 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); | 106 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry()); |
89 } | 107 } |
90 } | 108 } |
91 | 109 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 NotifyDidChangeVisibleSSLState(); | 211 NotifyDidChangeVisibleSSLState(); |
194 } | 212 } |
195 | 213 |
196 void SSLManager::NotifyDidChangeVisibleSSLState() { | 214 void SSLManager::NotifyDidChangeVisibleSSLState() { |
197 WebContentsImpl* contents = | 215 WebContentsImpl* contents = |
198 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 216 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
199 contents->DidChangeVisibleSSLState(); | 217 contents->DidChangeVisibleSSLState(); |
200 } | 218 } |
201 | 219 |
202 } // namespace content | 220 } // namespace content |
OLD | NEW |