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_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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/metrics/histogram_macros.h" | |
11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "content/browser/frame_host/navigation_entry_impl.h" | 14 #include "content/browser/frame_host/navigation_entry_impl.h" |
14 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/site_instance_impl.h" | 17 #include "content/browser/site_instance_impl.h" |
17 #include "content/browser/ssl/ssl_cert_error_handler.h" | 18 #include "content/browser/ssl/ssl_cert_error_handler.h" |
18 #include "content/browser/ssl/ssl_request_info.h" | 19 #include "content/browser/ssl/ssl_request_info.h" |
19 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
21 #include "content/public/common/resource_type.h" | 22 #include "content/public/common/resource_type.h" |
22 #include "content/public/common/ssl_status.h" | 23 #include "content/public/common/ssl_status.h" |
23 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
24 #include "net/ssl/ssl_info.h" | 25 #include "net/ssl/ssl_info.h" |
25 | 26 |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
30 namespace { | |
31 | |
32 // Events for UMA. Do not reorder or change! | |
33 enum SSLGoodCertSeenEvent { | |
34 NO_PREVIOUS_EXCEPTION = 0, | |
35 HAD_PREVIOUS_EXCEPTION = 1, | |
36 END_OF_SSL_GOOD_CERT_SEEN_EVENT = 2 | |
37 }; | |
38 | |
39 } | |
40 | |
29 SSLPolicy::SSLPolicy(SSLPolicyBackend* backend) | 41 SSLPolicy::SSLPolicy(SSLPolicyBackend* backend) |
30 : backend_(backend) { | 42 : backend_(backend) { |
31 DCHECK(backend_); | 43 DCHECK(backend_); |
32 } | 44 } |
33 | 45 |
34 void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) { | 46 void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) { |
35 bool expired_previous_decision; | 47 bool expired_previous_decision; |
36 // First we check if we know the policy for this error. | 48 // First we check if we know the policy for this error. |
37 DCHECK(handler->ssl_info().is_valid()); | 49 DCHECK(handler->ssl_info().is_valid()); |
38 SSLHostStateDelegate::CertJudgment judgment = | 50 SSLHostStateDelegate::CertJudgment judgment = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 115 |
104 backend_->HostRanInsecureContent(GURL(security_origin).host(), | 116 backend_->HostRanInsecureContent(GURL(security_origin).host(), |
105 site_instance->GetProcess()->GetID()); | 117 site_instance->GetProcess()->GetID()); |
106 } | 118 } |
107 | 119 |
108 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { | 120 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { |
109 // TODO(abarth): This mechanism is wrong. What we should be doing is sending | 121 // TODO(abarth): This mechanism is wrong. What we should be doing is sending |
110 // this information back through WebKit and out some FrameLoaderClient | 122 // this information back through WebKit and out some FrameLoaderClient |
111 // methods. | 123 // methods. |
112 | 124 |
113 if (net::IsCertStatusError(info->ssl_cert_status())) | 125 if (net::IsCertStatusError(info->ssl_cert_status())) { |
114 backend_->HostRanInsecureContent(info->url().host(), info->child_id()); | 126 backend_->HostRanInsecureContent(info->url().host(), info->child_id()); |
127 } else { | |
128 SSLGoodCertSeenEvent event = NO_PREVIOUS_EXCEPTION; | |
129 if (backend_->HasAllowException(info->url().host())) | |
130 event = HAD_PREVIOUS_EXCEPTION; | |
131 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.good_cert_seen", event, | |
132 END_OF_SSL_GOOD_CERT_SEEN_EVENT); | |
133 | |
134 // If there's no certificate error, a good certificate has been seen, so | |
135 // clear out any exceptions that were made by the user for bad certificates. | |
136 backend_->RevokeUserAllowExceptions(info->url().host()); | |
felt
2015/04/17 19:58:03
is there a specific reason why this needs to be do
jww
2015/04/17 20:16:06
Nope. Moved into the if block.
| |
137 } | |
115 } | 138 } |
116 | 139 |
117 void SSLPolicy::UpdateEntry(NavigationEntryImpl* entry, | 140 void SSLPolicy::UpdateEntry(NavigationEntryImpl* entry, |
118 WebContentsImpl* web_contents) { | 141 WebContentsImpl* web_contents) { |
119 DCHECK(entry); | 142 DCHECK(entry); |
120 | 143 |
121 InitializeEntryIfNeeded(entry); | 144 InitializeEntryIfNeeded(entry); |
122 | 145 |
123 if (!entry->GetURL().SchemeIsSecure()) | 146 if (!entry->GetURL().SchemeIsSecure()) |
124 return; | 147 return; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED; | 255 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED; |
233 } | 256 } |
234 | 257 |
235 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { | 258 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { |
236 GURL parsed_origin(origin); | 259 GURL parsed_origin(origin); |
237 if (parsed_origin.SchemeIsSecure()) | 260 if (parsed_origin.SchemeIsSecure()) |
238 backend_->HostRanInsecureContent(parsed_origin.host(), pid); | 261 backend_->HostRanInsecureContent(parsed_origin.host(), pid); |
239 } | 262 } |
240 | 263 |
241 } // namespace content | 264 } // namespace content |
OLD | NEW |