| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_policy.h" | 5 #include "chrome/browser/ssl/ssl_policy.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/browser/cert_store.h" | 12 #include "chrome/browser/cert_store.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host.h" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
| 14 #include "chrome/browser/ssl/ssl_cert_error_handler.h" |
| 14 #include "chrome/browser/ssl/ssl_error_info.h" | 15 #include "chrome/browser/ssl/ssl_error_info.h" |
| 16 #include "chrome/browser/ssl/ssl_mixed_content_handler.h" |
| 17 #include "chrome/browser/ssl/ssl_request_info.h" |
| 15 #include "chrome/browser/tab_contents/navigation_entry.h" | 18 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/jstemplate_builder.h" | 20 #include "chrome/common/jstemplate_builder.h" |
| 18 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
| 19 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/pref_service.h" | 23 #include "chrome/common/pref_service.h" |
| 21 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/time_format.h" | 25 #include "chrome/common/time_format.h" |
| 23 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 24 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 | 48 |
| 46 static void AllowMixedContentForOrigin(SSLManager* manager, | 49 static void AllowMixedContentForOrigin(SSLManager* manager, |
| 47 const std::string& origin) { | 50 const std::string& origin) { |
| 48 GURL parsed_origin(origin); | 51 GURL parsed_origin(origin); |
| 49 if (!parsed_origin.SchemeIsSecure()) | 52 if (!parsed_origin.SchemeIsSecure()) |
| 50 return; | 53 return; |
| 51 | 54 |
| 52 manager->AllowMixedContentForHost(parsed_origin.host()); | 55 manager->AllowMixedContentForHost(parsed_origin.host()); |
| 53 } | 56 } |
| 54 | 57 |
| 55 static void UpdateStateForMixedContent(SSLManager::RequestInfo* info) { | 58 static void UpdateStateForMixedContent(SSLRequestInfo* info) { |
| 56 if (info->resource_type() != ResourceType::MAIN_FRAME || | 59 if (info->resource_type() != ResourceType::MAIN_FRAME || |
| 57 info->resource_type() != ResourceType::SUB_FRAME) { | 60 info->resource_type() != ResourceType::SUB_FRAME) { |
| 58 // The frame's origin now contains mixed content and therefore is broken. | 61 // The frame's origin now contains mixed content and therefore is broken. |
| 59 MarkOriginAsBroken(info->manager(), info->frame_origin(), info->pid()); | 62 MarkOriginAsBroken(info->manager(), info->frame_origin(), info->pid()); |
| 60 } | 63 } |
| 61 | 64 |
| 62 if (info->resource_type() != ResourceType::MAIN_FRAME) { | 65 if (info->resource_type() != ResourceType::MAIN_FRAME) { |
| 63 // The main frame now contains a frame with mixed content. Therefore, we | 66 // The main frame now contains a frame with mixed content. Therefore, we |
| 64 // mark the main frame's origin as broken too. | 67 // mark the main frame's origin as broken too. |
| 65 MarkOriginAsBroken(info->manager(), info->main_frame_origin(), info->pid()); | 68 MarkOriginAsBroken(info->manager(), info->main_frame_origin(), info->pid()); |
| 66 } | 69 } |
| 67 } | 70 } |
| 68 | 71 |
| 69 static void UpdateStateForUnsafeContent(SSLManager::RequestInfo* info) { | 72 static void UpdateStateForUnsafeContent(SSLRequestInfo* info) { |
| 70 // This request as a broken cert, which means its host is broken. | 73 // This request as a broken cert, which means its host is broken. |
| 71 info->manager()->MarkHostAsBroken(info->url().host(), info->pid()); | 74 info->manager()->MarkHostAsBroken(info->url().host(), info->pid()); |
| 72 | 75 |
| 73 UpdateStateForMixedContent(info); | 76 UpdateStateForMixedContent(info); |
| 74 } | 77 } |
| 75 | 78 |
| 76 class ShowMixedContentTask : public Task { | 79 class ShowMixedContentTask : public Task { |
| 77 public: | 80 public: |
| 78 ShowMixedContentTask(SSLManager::MixedContentHandler* handler); | 81 ShowMixedContentTask(SSLMixedContentHandler* handler); |
| 79 virtual ~ShowMixedContentTask(); | 82 virtual ~ShowMixedContentTask(); |
| 80 | 83 |
| 81 virtual void Run(); | 84 virtual void Run(); |
| 82 | 85 |
| 83 private: | 86 private: |
| 84 scoped_refptr<SSLManager::MixedContentHandler> handler_; | 87 scoped_refptr<SSLMixedContentHandler> handler_; |
| 85 | 88 |
| 86 DISALLOW_COPY_AND_ASSIGN(ShowMixedContentTask); | 89 DISALLOW_COPY_AND_ASSIGN(ShowMixedContentTask); |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 ShowMixedContentTask::ShowMixedContentTask( | 92 ShowMixedContentTask::ShowMixedContentTask(SSLMixedContentHandler* handler) |
| 90 SSLManager::MixedContentHandler* handler) | |
| 91 : handler_(handler) { | 93 : handler_(handler) { |
| 92 } | 94 } |
| 93 | 95 |
| 94 ShowMixedContentTask::~ShowMixedContentTask() { | 96 ShowMixedContentTask::~ShowMixedContentTask() { |
| 95 } | 97 } |
| 96 | 98 |
| 97 void ShowMixedContentTask::Run() { | 99 void ShowMixedContentTask::Run() { |
| 98 AllowMixedContentForOrigin(handler_->manager(), handler_->frame_origin()); | 100 AllowMixedContentForOrigin(handler_->manager(), handler_->frame_origin()); |
| 99 AllowMixedContentForOrigin(handler_->manager(), | 101 AllowMixedContentForOrigin(handler_->manager(), |
| 100 handler_->main_frame_origin()); | 102 handler_->main_frame_origin()); |
| 101 handler_->manager()->controller()->Reload(true); | 103 handler_->manager()->controller()->Reload(true); |
| 102 } | 104 } |
| 103 | 105 |
| 104 static void ShowErrorPage(SSLPolicy* policy, SSLManager::CertError* error) { | 106 static void ShowErrorPage(SSLPolicy* policy, SSLCertErrorHandler* handler) { |
| 105 SSLErrorInfo error_info = policy->GetSSLErrorInfo(error); | 107 SSLErrorInfo error_info = policy->GetSSLErrorInfo(handler); |
| 106 | 108 |
| 107 // Let's build the html error page. | 109 // Let's build the html error page. |
| 108 DictionaryValue strings; | 110 DictionaryValue strings; |
| 109 strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE)); | 111 strings.SetString(L"title", l10n_util::GetString(IDS_SSL_ERROR_PAGE_TITLE)); |
| 110 strings.SetString(L"headLine", error_info.title()); | 112 strings.SetString(L"headLine", error_info.title()); |
| 111 strings.SetString(L"description", error_info.details()); | 113 strings.SetString(L"description", error_info.details()); |
| 112 strings.SetString(L"moreInfoTitle", | 114 strings.SetString(L"moreInfoTitle", |
| 113 l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); | 115 l10n_util::GetString(IDS_CERT_ERROR_EXTRA_INFO_TITLE)); |
| 114 SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information()); | 116 SSLBlockingPage::SetExtraInfo(&strings, error_info.extra_information()); |
| 115 | 117 |
| 116 strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)); | 118 strings.SetString(L"back", l10n_util::GetString(IDS_SSL_ERROR_PAGE_BACK)); |
| 117 | 119 |
| 118 strings.SetString(L"textdirection", | 120 strings.SetString(L"textdirection", |
| 119 (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? | 121 (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? |
| 120 L"rtl" : L"ltr"); | 122 L"rtl" : L"ltr"); |
| 121 | 123 |
| 122 static const StringPiece html( | 124 static const StringPiece html( |
| 123 ResourceBundle::GetSharedInstance().GetRawDataResource( | 125 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 124 IDR_SSL_ERROR_HTML)); | 126 IDR_SSL_ERROR_HTML)); |
| 125 | 127 |
| 126 std::string html_text(jstemplate_builder::GetTemplateHtml(html, &strings, | 128 std::string html_text(jstemplate_builder::GetTemplateHtml(html, &strings, |
| 127 "template_root")); | 129 "template_root")); |
| 128 | 130 |
| 129 TabContents* tab = error->GetTabContents(); | 131 TabContents* tab = handler->GetTabContents(); |
| 130 int cert_id = CertStore::GetSharedInstance()->StoreCert( | 132 int cert_id = CertStore::GetSharedInstance()->StoreCert( |
| 131 error->ssl_info().cert, tab->render_view_host()->process()->pid()); | 133 handler->ssl_info().cert, tab->render_view_host()->process()->pid()); |
| 132 std::string security_info = | 134 std::string security_info = |
| 133 SSLManager::SerializeSecurityInfo(cert_id, | 135 SSLManager::SerializeSecurityInfo(cert_id, |
| 134 error->ssl_info().cert_status, | 136 handler->ssl_info().cert_status, |
| 135 error->ssl_info().security_bits); | 137 handler->ssl_info().security_bits); |
| 136 tab->render_view_host()->LoadAlternateHTMLString(html_text, | 138 tab->render_view_host()->LoadAlternateHTMLString(html_text, |
| 137 true, | 139 true, |
| 138 error->request_url(), | 140 handler->request_url(), |
| 139 security_info); | 141 security_info); |
| 140 tab->controller().GetActiveEntry()->set_page_type( | 142 tab->controller().GetActiveEntry()->set_page_type( |
| 141 NavigationEntry::ERROR_PAGE); | 143 NavigationEntry::ERROR_PAGE); |
| 142 } | 144 } |
| 143 | 145 |
| 144 static void ShowBlockingPage(SSLPolicy* policy, SSLManager::CertError* error) { | 146 static void ShowBlockingPage(SSLPolicy* policy, SSLCertErrorHandler* handler) { |
| 145 SSLBlockingPage* blocking_page = new SSLBlockingPage(error, policy); | 147 SSLBlockingPage* blocking_page = new SSLBlockingPage(handler, policy); |
| 146 blocking_page->Show(); | 148 blocking_page->Show(); |
| 147 } | 149 } |
| 148 | 150 |
| 149 static void InitializeEntryIfNeeded(NavigationEntry* entry) { | 151 static void InitializeEntryIfNeeded(NavigationEntry* entry) { |
| 150 if (entry->ssl().security_style() != SECURITY_STYLE_UNKNOWN) | 152 if (entry->ssl().security_style() != SECURITY_STYLE_UNKNOWN) |
| 151 return; | 153 return; |
| 152 | 154 |
| 153 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ? | 155 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ? |
| 154 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED); | 156 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED); |
| 155 } | 157 } |
| 156 | 158 |
| 157 static void AddMixedContentWarningToConsole( | 159 static void AddMixedContentWarningToConsole(SSLMixedContentHandler* handler) { |
| 158 SSLManager::MixedContentHandler* handler) { | |
| 159 const std::wstring& text = l10n_util::GetStringF( | 160 const std::wstring& text = l10n_util::GetStringF( |
| 160 IDS_MIXED_CONTENT_LOG_MESSAGE, | 161 IDS_MIXED_CONTENT_LOG_MESSAGE, |
| 161 UTF8ToWide(handler->frame_origin()), | 162 UTF8ToWide(handler->frame_origin()), |
| 162 UTF8ToWide(handler->request_url().spec())); | 163 UTF8ToWide(handler->request_url().spec())); |
| 163 handler->manager()->AddMessageToConsole( | 164 handler->manager()->AddMessageToConsole( |
| 164 WideToUTF16Hack(text), WebConsoleMessage::LevelWarning); | 165 WideToUTF16Hack(text), WebConsoleMessage::LevelWarning); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace | 168 } // namespace |
| 168 | 169 |
| 169 SSLPolicy::SSLPolicy() { | 170 SSLPolicy::SSLPolicy() { |
| 170 } | 171 } |
| 171 | 172 |
| 172 SSLPolicy* SSLPolicy::GetDefaultPolicy() { | 173 SSLPolicy* SSLPolicy::GetDefaultPolicy() { |
| 173 return Singleton<SSLPolicy>::get(); | 174 return Singleton<SSLPolicy>::get(); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void SSLPolicy::OnCertError(SSLManager::CertError* error) { | 177 void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) { |
| 177 // First we check if we know the policy for this error. | 178 // First we check if we know the policy for this error. |
| 178 net::X509Certificate::Policy::Judgment judgment = | 179 net::X509Certificate::Policy::Judgment judgment = |
| 179 error->manager()->QueryPolicy(error->ssl_info().cert, | 180 handler->manager()->QueryPolicy(handler->ssl_info().cert, |
| 180 error->request_url().host()); | 181 handler->request_url().host()); |
| 181 | 182 |
| 182 if (judgment == net::X509Certificate::Policy::ALLOWED) { | 183 if (judgment == net::X509Certificate::Policy::ALLOWED) { |
| 183 error->ContinueRequest(); | 184 handler->ContinueRequest(); |
| 184 return; | 185 return; |
| 185 } | 186 } |
| 186 | 187 |
| 187 // The judgment is either DENIED or UNKNOWN. | 188 // The judgment is either DENIED or UNKNOWN. |
| 188 // For now we handle the DENIED as the UNKNOWN, which means a blocking | 189 // For now we handle the DENIED as the UNKNOWN, which means a blocking |
| 189 // page is shown to the user every time he comes back to the page. | 190 // page is shown to the user every time he comes back to the page. |
| 190 | 191 |
| 191 switch(error->cert_error()) { | 192 switch(handler->cert_error()) { |
| 192 case net::ERR_CERT_COMMON_NAME_INVALID: | 193 case net::ERR_CERT_COMMON_NAME_INVALID: |
| 193 case net::ERR_CERT_DATE_INVALID: | 194 case net::ERR_CERT_DATE_INVALID: |
| 194 case net::ERR_CERT_AUTHORITY_INVALID: | 195 case net::ERR_CERT_AUTHORITY_INVALID: |
| 195 OnOverridableCertError(error); | 196 OnOverridableCertError(handler); |
| 196 break; | 197 break; |
| 197 case net::ERR_CERT_NO_REVOCATION_MECHANISM: | 198 case net::ERR_CERT_NO_REVOCATION_MECHANISM: |
| 198 // Ignore this error. | 199 // Ignore this error. |
| 199 error->ContinueRequest(); | 200 handler->ContinueRequest(); |
| 200 break; | 201 break; |
| 201 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: | 202 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: |
| 202 // We ignore this error and display an infobar. | 203 // We ignore this error and display an infobar. |
| 203 error->ContinueRequest(); | 204 handler->ContinueRequest(); |
| 204 error->manager()->ShowMessage(l10n_util::GetString( | 205 handler->manager()->ShowMessage(l10n_util::GetString( |
| 205 IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_INFO_BAR)); | 206 IDS_CERT_ERROR_UNABLE_TO_CHECK_REVOCATION_INFO_BAR)); |
| 206 break; | 207 break; |
| 207 case net::ERR_CERT_CONTAINS_ERRORS: | 208 case net::ERR_CERT_CONTAINS_ERRORS: |
| 208 case net::ERR_CERT_REVOKED: | 209 case net::ERR_CERT_REVOKED: |
| 209 case net::ERR_CERT_INVALID: | 210 case net::ERR_CERT_INVALID: |
| 210 OnFatalCertError(error); | 211 OnFatalCertError(handler); |
| 211 break; | 212 break; |
| 212 default: | 213 default: |
| 213 NOTREACHED(); | 214 NOTREACHED(); |
| 214 error->CancelRequest(); | 215 handler->CancelRequest(); |
| 215 break; | 216 break; |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 219 void SSLPolicy::OnMixedContent(SSLManager::MixedContentHandler* handler) { | 220 void SSLPolicy::OnMixedContent(SSLMixedContentHandler* handler) { |
| 220 // Get the user's mixed content preference. | 221 // Get the user's mixed content preference. |
| 221 PrefService* prefs = handler->GetTabContents()->profile()->GetPrefs(); | 222 PrefService* prefs = handler->GetTabContents()->profile()->GetPrefs(); |
| 222 FilterPolicy::Type filter_policy = | 223 FilterPolicy::Type filter_policy = |
| 223 FilterPolicy::FromInt(prefs->GetInteger(prefs::kMixedContentFiltering)); | 224 FilterPolicy::FromInt(prefs->GetInteger(prefs::kMixedContentFiltering)); |
| 224 | 225 |
| 225 // If the user has added an exception, doctor the |filter_policy|. | 226 // If the user has added an exception, doctor the |filter_policy|. |
| 226 std::string host = GURL(handler->main_frame_origin()).host(); | 227 std::string host = GURL(handler->main_frame_origin()).host(); |
| 227 if (handler->manager()->DidAllowMixedContentForHost(host) || | 228 if (handler->manager()->DidAllowMixedContentForHost(host) || |
| 228 handler->manager()->DidMarkHostAsBroken(host, handler->pid())) | 229 handler->manager()->DidMarkHostAsBroken(host, handler->pid())) |
| 229 filter_policy = FilterPolicy::DONT_FILTER; | 230 filter_policy = FilterPolicy::DONT_FILTER; |
| 230 | 231 |
| 231 if (filter_policy != FilterPolicy::DONT_FILTER) { | 232 if (filter_policy != FilterPolicy::DONT_FILTER) { |
| 232 handler->manager()->ShowMessageWithLink( | 233 handler->manager()->ShowMessageWithLink( |
| 233 l10n_util::GetString(IDS_SSL_INFO_BAR_FILTERED_CONTENT), | 234 l10n_util::GetString(IDS_SSL_INFO_BAR_FILTERED_CONTENT), |
| 234 l10n_util::GetString(IDS_SSL_INFO_BAR_SHOW_CONTENT), | 235 l10n_util::GetString(IDS_SSL_INFO_BAR_SHOW_CONTENT), |
| 235 new ShowMixedContentTask(handler)); | 236 new ShowMixedContentTask(handler)); |
| 236 } | 237 } |
| 237 | 238 |
| 238 handler->StartRequest(filter_policy); | 239 handler->StartRequest(filter_policy); |
| 239 AddMixedContentWarningToConsole(handler); | 240 AddMixedContentWarningToConsole(handler); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void SSLPolicy::OnRequestStarted(SSLManager::RequestInfo* info) { | 243 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { |
| 243 if (net::IsCertStatusError(info->ssl_cert_status())) | 244 if (net::IsCertStatusError(info->ssl_cert_status())) |
| 244 UpdateStateForUnsafeContent(info); | 245 UpdateStateForUnsafeContent(info); |
| 245 | 246 |
| 246 if (IsMixedContent(info->url(), | 247 if (IsMixedContent(info->url(), |
| 247 info->resource_type(), | 248 info->resource_type(), |
| 248 info->filter_policy(), | 249 info->filter_policy(), |
| 249 info->frame_origin())) | 250 info->frame_origin())) |
| 250 UpdateStateForMixedContent(info); | 251 UpdateStateForMixedContent(info); |
| 251 } | 252 } |
| 252 | 253 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // We aren't worried about mixed content if we're loading an HTTPS URL. | 303 // We aren't worried about mixed content if we're loading an HTTPS URL. |
| 303 if (url.SchemeIsSecure()) | 304 if (url.SchemeIsSecure()) |
| 304 return false; | 305 return false; |
| 305 | 306 |
| 306 return true; | 307 return true; |
| 307 } | 308 } |
| 308 | 309 |
| 309 //////////////////////////////////////////////////////////////////////////////// | 310 //////////////////////////////////////////////////////////////////////////////// |
| 310 // SSLBlockingPage::Delegate methods | 311 // SSLBlockingPage::Delegate methods |
| 311 | 312 |
| 312 SSLErrorInfo SSLPolicy::GetSSLErrorInfo(SSLManager::CertError* error) { | 313 SSLErrorInfo SSLPolicy::GetSSLErrorInfo(SSLCertErrorHandler* handler) { |
| 313 return SSLErrorInfo::CreateError( | 314 return SSLErrorInfo::CreateError( |
| 314 SSLErrorInfo::NetErrorToErrorType(error->cert_error()), | 315 SSLErrorInfo::NetErrorToErrorType(handler->cert_error()), |
| 315 error->ssl_info().cert, error->request_url()); | 316 handler->ssl_info().cert, handler->request_url()); |
| 316 } | 317 } |
| 317 | 318 |
| 318 void SSLPolicy::OnDenyCertificate(SSLManager::CertError* error) { | 319 void SSLPolicy::OnDenyCertificate(SSLCertErrorHandler* handler) { |
| 319 // Default behavior for rejecting a certificate. | 320 // Default behavior for rejecting a certificate. |
| 320 // | 321 // |
| 321 // While DenyCertForHost() executes synchronously on this thread, | 322 // While DenyCertForHost() executes synchronously on this thread, |
| 322 // CancelRequest() gets posted to a different thread. Calling | 323 // CancelRequest() gets posted to a different thread. Calling |
| 323 // DenyCertForHost() first ensures deterministic ordering. | 324 // DenyCertForHost() first ensures deterministic ordering. |
| 324 error->manager()->DenyCertForHost(error->ssl_info().cert, | 325 handler->manager()->DenyCertForHost(handler->ssl_info().cert, |
| 325 error->request_url().host()); | 326 handler->request_url().host()); |
| 326 error->CancelRequest(); | 327 handler->CancelRequest(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void SSLPolicy::OnAllowCertificate(SSLManager::CertError* error) { | 330 void SSLPolicy::OnAllowCertificate(SSLCertErrorHandler* handler) { |
| 330 // Default behavior for accepting a certificate. | 331 // Default behavior for accepting a certificate. |
| 331 // Note that we should not call SetMaxSecurityStyle here, because the active | 332 // Note that we should not call SetMaxSecurityStyle here, because the active |
| 332 // NavigationEntry has just been deleted (in HideInterstitialPage) and the | 333 // NavigationEntry has just been deleted (in HideInterstitialPage) and the |
| 333 // new NavigationEntry will not be set until DidNavigate. This is ok, | 334 // new NavigationEntry will not be set until DidNavigate. This is ok, |
| 334 // because the new NavigationEntry will have its max security style set | 335 // because the new NavigationEntry will have its max security style set |
| 335 // within DidNavigate. | 336 // within DidNavigate. |
| 336 // | 337 // |
| 337 // While AllowCertForHost() executes synchronously on this thread, | 338 // While AllowCertForHost() executes synchronously on this thread, |
| 338 // ContinueRequest() gets posted to a different thread. Calling | 339 // ContinueRequest() gets posted to a different thread. Calling |
| 339 // AllowCertForHost() first ensures deterministic ordering. | 340 // AllowCertForHost() first ensures deterministic ordering. |
| 340 error->manager()->AllowCertForHost(error->ssl_info().cert, | 341 handler->manager()->AllowCertForHost(handler->ssl_info().cert, |
| 341 error->request_url().host()); | 342 handler->request_url().host()); |
| 342 error->ContinueRequest(); | 343 handler->ContinueRequest(); |
| 343 } | 344 } |
| 344 | 345 |
| 345 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
| 346 // Certificate Error Routines | 347 // Certificate Error Routines |
| 347 | 348 |
| 348 void SSLPolicy::OnOverridableCertError(SSLManager::CertError* error) { | 349 void SSLPolicy::OnOverridableCertError(SSLCertErrorHandler* handler) { |
| 349 if (error->resource_type() != ResourceType::MAIN_FRAME) { | 350 if (handler->resource_type() != ResourceType::MAIN_FRAME) { |
| 350 // A sub-resource has a certificate error. The user doesn't really | 351 // A sub-resource has a certificate error. The user doesn't really |
| 351 // have a context for making the right decision, so block the | 352 // have a context for making the right decision, so block the |
| 352 // request hard, without an info bar to allow showing the insecure | 353 // request hard, without an info bar to allow showing the insecure |
| 353 // content. | 354 // content. |
| 354 error->DenyRequest(); | 355 handler->DenyRequest(); |
| 355 return; | 356 return; |
| 356 } | 357 } |
| 357 // We need to ask the user to approve this certificate. | 358 // We need to ask the user to approve this certificate. |
| 358 ShowBlockingPage(this, error); | 359 ShowBlockingPage(this, handler); |
| 359 } | 360 } |
| 360 | 361 |
| 361 void SSLPolicy::OnFatalCertError(SSLManager::CertError* error) { | 362 void SSLPolicy::OnFatalCertError(SSLCertErrorHandler* handler) { |
| 362 if (error->resource_type() != ResourceType::MAIN_FRAME) { | 363 if (handler->resource_type() != ResourceType::MAIN_FRAME) { |
| 363 error->DenyRequest(); | 364 handler->DenyRequest(); |
| 364 return; | 365 return; |
| 365 } | 366 } |
| 366 error->CancelRequest(); | 367 handler->CancelRequest(); |
| 367 ShowErrorPage(this, error); | 368 ShowErrorPage(this, handler); |
| 368 // No need to degrade our security indicators because we didn't continue. | 369 // No need to degrade our security indicators because we didn't continue. |
| 369 } | 370 } |
| OLD | NEW |