| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/ssl/ssl_manager.h" | 5 #include "chrome/browser/ssl/ssl_manager.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/browser/load_from_memory_cache_details.h" | 10 #include "chrome/browser/load_from_memory_cache_details.h" |
| 11 #include "chrome/browser/net/url_request_tracking.h" | 11 #include "chrome/browser/net/url_request_tracking.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/renderer_host/resource_request_details.h" | 13 #include "chrome/browser/renderer_host/resource_request_details.h" |
| 14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 15 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 14 #include "chrome/browser/ssl/ssl_cert_error_handler.h" | 16 #include "chrome/browser/ssl/ssl_cert_error_handler.h" |
| 15 #include "chrome/browser/ssl/ssl_policy.h" | 17 #include "chrome/browser/ssl/ssl_policy.h" |
| 16 #include "chrome/browser/ssl/ssl_request_info.h" | 18 #include "chrome/browser/ssl/ssl_request_info.h" |
| 17 #include "chrome/browser/tab_contents/navigation_controller.h" | 19 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 18 #include "chrome/browser/tab_contents/navigation_entry.h" | 20 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 19 #include "chrome/browser/tab_contents/provisional_load_details.h" | 21 #include "chrome/browser/tab_contents/provisional_load_details.h" |
| 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 21 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 22 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 23 #include "net/base/cert_status_flags.h" | 26 #include "net/base/cert_status_flags.h" |
| 24 | 27 |
| 25 // static | 28 // static |
| 26 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, | 29 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, |
| 27 net::URLRequest* request, | 30 net::URLRequest* request, |
| 28 int cert_error, | 31 int cert_error, |
| 29 net::X509Certificate* cert) { | 32 net::X509Certificate* cert) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 SSLManager::SSLManager(NavigationController* controller) | 114 SSLManager::SSLManager(NavigationController* controller) |
| 112 : backend_(controller), | 115 : backend_(controller), |
| 113 policy_(new SSLPolicy(&backend_)), | 116 policy_(new SSLPolicy(&backend_)), |
| 114 controller_(controller) { | 117 controller_(controller) { |
| 115 DCHECK(controller_); | 118 DCHECK(controller_); |
| 116 | 119 |
| 117 // Subscribe to various notifications. | 120 // Subscribe to various notifications. |
| 118 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 121 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
| 119 Source<NavigationController>(controller_)); | 122 Source<NavigationController>(controller_)); |
| 120 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, | 123 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, |
| 121 Source<NavigationController>(controller_)); | 124 Source<RenderViewHostDelegate>(controller_->tab_contents())); |
| 122 registrar_.Add(this, NotificationType::RESOURCE_RECEIVED_REDIRECT, | 125 registrar_.Add(this, NotificationType::RESOURCE_RECEIVED_REDIRECT, |
| 123 Source<NavigationController>(controller_)); | 126 Source<RenderViewHostDelegate>(controller_->tab_contents())); |
| 124 registrar_.Add(this, NotificationType::LOAD_FROM_MEMORY_CACHE, | 127 registrar_.Add(this, NotificationType::LOAD_FROM_MEMORY_CACHE, |
| 125 Source<NavigationController>(controller_)); | 128 Source<NavigationController>(controller_)); |
| 126 registrar_.Add(this, NotificationType::SSL_INTERNAL_STATE_CHANGED, | 129 registrar_.Add(this, NotificationType::SSL_INTERNAL_STATE_CHANGED, |
| 127 NotificationService::AllSources()); | 130 NotificationService::AllSources()); |
| 128 } | 131 } |
| 129 | 132 |
| 130 SSLManager::~SSLManager() { | 133 SSLManager::~SSLManager() { |
| 131 } | 134 } |
| 132 | 135 |
| 133 void SSLManager::DidCommitProvisionalLoad( | 136 void SSLManager::DidCommitProvisionalLoad( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 break; | 200 break; |
| 198 case NotificationType::SSL_INTERNAL_STATE_CHANGED: | 201 case NotificationType::SSL_INTERNAL_STATE_CHANGED: |
| 199 DidChangeSSLInternalState(); | 202 DidChangeSSLInternalState(); |
| 200 break; | 203 break; |
| 201 default: | 204 default: |
| 202 NOTREACHED() << "The SSLManager received an unexpected notification."; | 205 NOTREACHED() << "The SSLManager received an unexpected notification."; |
| 203 } | 206 } |
| 204 } | 207 } |
| 205 | 208 |
| 206 void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) { | 209 void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) { |
| 207 DCHECK(details); | |
| 208 | |
| 209 // Simulate loading this resource through the usual path. | 210 // Simulate loading this resource through the usual path. |
| 210 // Note that we specify SUB_RESOURCE as the resource type as WebCore only | 211 // Note that we specify SUB_RESOURCE as the resource type as WebCore only |
| 211 // caches sub-resources. | 212 // caches sub-resources. |
| 212 // This resource must have been loaded with no filtering because filtered | 213 // This resource must have been loaded with no filtering because filtered |
| 213 // resouces aren't cachable. | 214 // resouces aren't cachable. |
| 214 scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo( | 215 scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo( |
| 215 details->url(), | 216 details->url(), |
| 216 ResourceType::SUB_RESOURCE, | 217 ResourceType::SUB_RESOURCE, |
| 217 details->frame_origin(), | 218 details->frame_origin(), |
| 218 details->main_frame_origin(), | 219 details->main_frame_origin(), |
| 219 details->pid(), | 220 details->pid(), |
| 220 details->ssl_cert_id(), | 221 details->ssl_cert_id(), |
| 221 details->ssl_cert_status())); | 222 details->ssl_cert_status())); |
| 222 | 223 |
| 223 // Simulate loading this resource through the usual path. | 224 // Simulate loading this resource through the usual path. |
| 224 policy()->OnRequestStarted(info.get()); | 225 policy()->OnRequestStarted(info.get()); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) { | 228 void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) { |
| 228 DCHECK(details); | |
| 229 | |
| 230 scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo( | 229 scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo( |
| 231 details->url(), | 230 details->url(), |
| 232 details->resource_type(), | 231 details->resource_type(), |
| 233 details->frame_origin(), | 232 details->frame_origin(), |
| 234 details->main_frame_origin(), | 233 details->main_frame_origin(), |
| 235 details->origin_child_id(), | 234 details->origin_child_id(), |
| 236 details->ssl_cert_id(), | 235 details->ssl_cert_id(), |
| 237 details->ssl_cert_status())); | 236 details->ssl_cert_status())); |
| 238 | 237 |
| 239 // Notify our policy that we started a resource request. Ideally, the | 238 // Notify our policy that we started a resource request. Ideally, the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 264 | 263 |
| 265 policy()->UpdateEntry(entry, controller_->tab_contents()); | 264 policy()->UpdateEntry(entry, controller_->tab_contents()); |
| 266 | 265 |
| 267 if (!entry->ssl().Equals(original_ssl_status)) { | 266 if (!entry->ssl().Equals(original_ssl_status)) { |
| 268 NotificationService::current()->Notify( | 267 NotificationService::current()->Notify( |
| 269 NotificationType::SSL_VISIBLE_STATE_CHANGED, | 268 NotificationType::SSL_VISIBLE_STATE_CHANGED, |
| 270 Source<NavigationController>(controller_), | 269 Source<NavigationController>(controller_), |
| 271 NotificationService::NoDetails()); | 270 NotificationService::NoDetails()); |
| 272 } | 271 } |
| 273 } | 272 } |
| OLD | NEW |