Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: content/browser/ssl/ssl_policy.cc

Issue 7976036: net: make HSTS hosts use the normal SSL interstitials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_policy.h" 5 #include "content/browser/ssl/ssl_policy.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // The judgment is either DENIED or UNKNOWN. 52 // The judgment is either DENIED or UNKNOWN.
53 // For now we handle the DENIED as the UNKNOWN, which means a blocking 53 // For now we handle the DENIED as the UNKNOWN, which means a blocking
54 // page is shown to the user every time he comes back to the page. 54 // page is shown to the user every time he comes back to the page.
55 55
56 switch (handler->cert_error()) { 56 switch (handler->cert_error()) {
57 case net::ERR_CERT_COMMON_NAME_INVALID: 57 case net::ERR_CERT_COMMON_NAME_INVALID:
58 case net::ERR_CERT_DATE_INVALID: 58 case net::ERR_CERT_DATE_INVALID:
59 case net::ERR_CERT_AUTHORITY_INVALID: 59 case net::ERR_CERT_AUTHORITY_INVALID:
60 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: 60 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
61 OnCertErrorInternal(handler, true); 61 OnCertErrorInternal(handler, true);
wtc 2011/09/23 00:04:51 We can pass !handler->must_be_fatal() instead of t
62 break; 62 break;
63 case net::ERR_CERT_NO_REVOCATION_MECHANISM: 63 case net::ERR_CERT_NO_REVOCATION_MECHANISM:
64 // Ignore this error. 64 // Ignore this error.
65 handler->ContinueRequest(); 65 handler->ContinueRequest();
66 break; 66 break;
67 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: 67 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
68 // We ignore this error but will show a warning status in the location 68 // We ignore this error but will show a warning status in the location
69 // bar. 69 // bar.
70 handler->ContinueRequest(); 70 handler->ContinueRequest();
71 break; 71 break;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 bool overridable) { 188 bool overridable) {
189 if (handler->resource_type() != ResourceType::MAIN_FRAME) { 189 if (handler->resource_type() != ResourceType::MAIN_FRAME) {
190 // A sub-resource has a certificate error. The user doesn't really 190 // A sub-resource has a certificate error. The user doesn't really
191 // have a context for making the right decision, so block the 191 // have a context for making the right decision, so block the
192 // request hard, without an info bar to allow showing the insecure 192 // request hard, without an info bar to allow showing the insecure
193 // content. 193 // content.
194 handler->DenyRequest(); 194 handler->DenyRequest();
195 return; 195 return;
196 } 196 }
197 197
198 // For HSTS hosts all certificate errors are fatal (the user cannot bypass).
199 // This is indicated by the |must_be_fatal()| flag.
200 if (handler->must_be_fatal())
201 overridable = false;
wtc 2011/09/23 00:04:51 I think it is better to move this code to the SSLP
202
198 Callback2<SSLCertErrorHandler*, bool>::Type* callback = 203 Callback2<SSLCertErrorHandler*, bool>::Type* callback =
199 NewCallback(this, &SSLPolicy::OnAllowCertificate); 204 NewCallback(this, &SSLPolicy::OnAllowCertificate);
200 content::GetContentClient()->browser()->AllowCertificateError( 205 content::GetContentClient()->browser()->AllowCertificateError(
201 handler, overridable, callback); 206 handler, overridable, callback);
202 } 207 }
203 208
204 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntry* entry) { 209 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntry* entry) {
205 if (entry->ssl().security_style() != SECURITY_STYLE_UNKNOWN) 210 if (entry->ssl().security_style() != SECURITY_STYLE_UNKNOWN)
206 return; 211 return;
207 212
208 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ? 213 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ?
209 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED); 214 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED);
210 } 215 }
211 216
212 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { 217 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) {
213 GURL parsed_origin(origin); 218 GURL parsed_origin(origin);
214 if (parsed_origin.SchemeIsSecure()) 219 if (parsed_origin.SchemeIsSecure())
215 backend_->HostRanInsecureContent(parsed_origin.host(), pid); 220 backend_->HostRanInsecureContent(parsed_origin.host(), pid);
216 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698