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

Side by Side Diff: android_webview/browser/aw_ssl_host_state_delegate.cc

Issue 2292443003: Support host-based deletion for SSLHostStateDelegate (Closed)
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "android_webview/browser/aw_ssl_host_state_delegate.h" 5 #include "android_webview/browser/aw_ssl_host_state_delegate.h"
6 6
7 #include "base/callback.h"
7 #include "net/base/hash_value.h" 8 #include "net/base/hash_value.h"
8 9
9 using content::SSLHostStateDelegate; 10 using content::SSLHostStateDelegate;
10 11
11 namespace android_webview { 12 namespace android_webview {
12 13
13 namespace internal { 14 namespace internal {
14 net::SHA256HashValue getChainFingerprint256(const net::X509Certificate& cert) { 15 net::SHA256HashValue getChainFingerprint256(const net::X509Certificate& cert) {
15 net::SHA256HashValue fingerprint = 16 net::SHA256HashValue fingerprint =
16 net::X509Certificate::CalculateChainFingerprint256( 17 net::X509Certificate::CalculateChainFingerprint256(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Intentional no-op for Android WebView. 70 // Intentional no-op for Android WebView.
70 return false; 71 return false;
71 } 72 }
72 73
73 void AwSSLHostStateDelegate::AllowCert(const std::string& host, 74 void AwSSLHostStateDelegate::AllowCert(const std::string& host,
74 const net::X509Certificate& cert, 75 const net::X509Certificate& cert,
75 net::CertStatus error) { 76 net::CertStatus error) {
76 cert_policy_for_host_[host].Allow(cert, error); 77 cert_policy_for_host_[host].Allow(cert, error);
77 } 78 }
78 79
79 void AwSSLHostStateDelegate::Clear() { 80 void AwSSLHostStateDelegate::Clear(
80 cert_policy_for_host_.clear(); 81 const base::Callback<bool(const std::string&)>& host_filter) {
82 if (host_filter.IsNull()) {
83 cert_policy_for_host_.clear();
84 return;
85 }
86
87 for (auto it = cert_policy_for_host_.begin(); it != cert_policy_map_.end();) {
estark 2016/08/30 01:52:15 |cert_policy_map_| doesn't appear to be a thing; g
msramek 2016/08/30 14:39:41 Done. Of course I didn't get a compilation error s
88 auto next_it = std::next(it);
89
90 if (host_filter.Run(it->first))
91 cert_policy_for_host_.erase(it);
92
93 it = next_it;
94 }
81 } 95 }
82 96
83 SSLHostStateDelegate::CertJudgment AwSSLHostStateDelegate::QueryPolicy( 97 SSLHostStateDelegate::CertJudgment AwSSLHostStateDelegate::QueryPolicy(
84 const std::string& host, 98 const std::string& host,
85 const net::X509Certificate& cert, 99 const net::X509Certificate& cert,
86 net::CertStatus error, 100 net::CertStatus error,
87 bool* expired_previous_decision) { 101 bool* expired_previous_decision) {
88 return cert_policy_for_host_[host].Check(cert, error) 102 return cert_policy_for_host_[host].Check(cert, error)
89 ? SSLHostStateDelegate::ALLOWED 103 ? SSLHostStateDelegate::ALLOWED
90 : SSLHostStateDelegate::DENIED; 104 : SSLHostStateDelegate::DENIED;
91 } 105 }
92 106
93 void AwSSLHostStateDelegate::RevokeUserAllowExceptions( 107 void AwSSLHostStateDelegate::RevokeUserAllowExceptions(
94 const std::string& host) { 108 const std::string& host) {
95 cert_policy_for_host_.erase(host); 109 cert_policy_for_host_.erase(host);
96 } 110 }
97 111
98 bool AwSSLHostStateDelegate::HasAllowException(const std::string& host) const { 112 bool AwSSLHostStateDelegate::HasAllowException(const std::string& host) const {
99 auto policy_iterator = cert_policy_for_host_.find(host); 113 auto policy_iterator = cert_policy_for_host_.find(host);
100 return policy_iterator != cert_policy_for_host_.end() && 114 return policy_iterator != cert_policy_for_host_.end() &&
101 policy_iterator->second.HasAllowException(); 115 policy_iterator->second.HasAllowException();
102 } 116 }
103 117
104 } // namespace android_webview 118 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698