OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "content/browser/load_from_memory_cache_details.h" | 9 #include "content/browser/load_from_memory_cache_details.h" |
10 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
11 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 11 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
12 #include "content/browser/renderer_host/resource_request_details.h" | 12 #include "content/browser/renderer_host/resource_request_details.h" |
13 #include "content/browser/ssl/ssl_cert_error_handler.h" | 13 #include "content/browser/ssl/ssl_cert_error_handler.h" |
14 #include "content/browser/ssl/ssl_policy.h" | 14 #include "content/browser/ssl/ssl_policy.h" |
15 #include "content/browser/ssl/ssl_request_info.h" | 15 #include "content/browser/ssl/ssl_request_info.h" |
16 #include "content/browser/tab_contents/navigation_details.h" | 16 #include "content/browser/tab_contents/navigation_details.h" |
17 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
18 #include "content/browser/tab_contents/provisional_load_details.h" | 18 #include "content/browser/tab_contents/provisional_load_details.h" |
19 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
20 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
21 #include "content/common/notification_source.h" | |
22 #include "net/base/cert_status_flags.h" | 21 #include "net/base/cert_status_flags.h" |
23 | 22 |
24 // static | 23 // static |
25 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, | 24 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, |
26 net::URLRequest* request, | 25 net::URLRequest* request, |
27 int cert_error, | 26 int cert_error, |
28 net::X509Certificate* cert) { | 27 net::X509Certificate* cert) { |
29 DVLOG(1) << "OnSSLCertificateError() cert_error: " << cert_error | 28 DVLOG(1) << "OnSSLCertificateError() cert_error: " << cert_error |
30 << " url: " << request->url().spec(); | 29 << " url: " << request->url().spec(); |
31 | 30 |
32 ResourceDispatcherHostRequestInfo* info = | 31 ResourceDispatcherHostRequestInfo* info = |
33 ResourceDispatcherHost::InfoForRequest(request); | 32 ResourceDispatcherHost::InfoForRequest(request); |
34 | 33 |
35 // A certificate error occurred. Construct a SSLCertErrorHandler object and | 34 // A certificate error occurred. Construct a SSLCertErrorHandler object and |
36 // hand it over to the UI thread for processing. | 35 // hand it over to the UI thread for processing. |
37 BrowserThread::PostTask( | 36 BrowserThread::PostTask( |
38 BrowserThread::UI, FROM_HERE, | 37 BrowserThread::UI, FROM_HERE, |
39 NewRunnableMethod(new SSLCertErrorHandler(rdh, | 38 NewRunnableMethod(new SSLCertErrorHandler(rdh, |
40 request, | 39 request, |
41 info->resource_type(), | 40 info->resource_type(), |
42 cert_error, | 41 cert_error, |
43 cert), | 42 cert), |
44 &SSLCertErrorHandler::Dispatch)); | 43 &SSLCertErrorHandler::Dispatch)); |
45 } | 44 } |
46 | 45 |
47 // static | 46 // static |
48 void SSLManager::NotifySSLInternalStateChanged( | 47 void SSLManager::NotifySSLInternalStateChanged() { |
49 NavigationController* controller) { | |
50 NotificationService::current()->Notify( | 48 NotificationService::current()->Notify( |
51 content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, | 49 content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, |
52 Source<content::BrowserContext>(controller->browser_context()), | 50 NotificationService::AllSources(), |
53 NotificationService::NoDetails()); | 51 NotificationService::NoDetails()); |
54 } | 52 } |
55 | 53 |
56 // static | 54 // static |
57 std::string SSLManager::SerializeSecurityInfo(int cert_id, | 55 std::string SSLManager::SerializeSecurityInfo(int cert_id, |
58 int cert_status, | 56 int cert_status, |
59 int security_bits, | 57 int security_bits, |
60 int ssl_connection_status) { | 58 int ssl_connection_status) { |
61 Pickle pickle; | 59 Pickle pickle; |
62 pickle.WriteInt(cert_id); | 60 pickle.WriteInt(cert_id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Subscribe to various notifications. | 98 // Subscribe to various notifications. |
101 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 99 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
102 Source<NavigationController>(controller_)); | 100 Source<NavigationController>(controller_)); |
103 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, | 101 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, |
104 Source<RenderViewHostDelegate>(controller_->tab_contents())); | 102 Source<RenderViewHostDelegate>(controller_->tab_contents())); |
105 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 103 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
106 Source<RenderViewHostDelegate>(controller_->tab_contents())); | 104 Source<RenderViewHostDelegate>(controller_->tab_contents())); |
107 registrar_.Add(this, content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 105 registrar_.Add(this, content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
108 Source<NavigationController>(controller_)); | 106 Source<NavigationController>(controller_)); |
109 registrar_.Add(this, content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, | 107 registrar_.Add(this, content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED, |
110 Source<content::BrowserContext>( | 108 NotificationService::AllSources()); |
111 controller_->browser_context())); | |
112 } | 109 } |
113 | 110 |
114 SSLManager::~SSLManager() { | 111 SSLManager::~SSLManager() { |
115 } | 112 } |
116 | 113 |
117 void SSLManager::DidCommitProvisionalLoad( | 114 void SSLManager::DidCommitProvisionalLoad( |
118 const NotificationDetails& in_details) { | 115 const NotificationDetails& in_details) { |
119 content::LoadCommittedDetails* details = | 116 content::LoadCommittedDetails* details = |
120 Details<content::LoadCommittedDetails>(in_details).ptr(); | 117 Details<content::LoadCommittedDetails>(in_details).ptr(); |
121 | 118 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 237 |
241 policy()->UpdateEntry(entry, controller_->tab_contents()); | 238 policy()->UpdateEntry(entry, controller_->tab_contents()); |
242 | 239 |
243 if (!entry->ssl().Equals(original_ssl_status)) { | 240 if (!entry->ssl().Equals(original_ssl_status)) { |
244 NotificationService::current()->Notify( | 241 NotificationService::current()->Notify( |
245 content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, | 242 content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, |
246 Source<NavigationController>(controller_), | 243 Source<NavigationController>(controller_), |
247 NotificationService::NoDetails()); | 244 NotificationService::NoDetails()); |
248 } | 245 } |
249 } | 246 } |
OLD | NEW |