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

Unified Diff: chrome/browser/ssl/chrome_ssl_host_state_delegate.cc

Issue 2292443003: Support host-based deletion for SSLHostStateDelegate (Closed)
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/chrome_ssl_host_state_delegate.cc
diff --git a/chrome/browser/ssl/chrome_ssl_host_state_delegate.cc b/chrome/browser/ssl/chrome_ssl_host_state_delegate.cc
index af2c261d3819aebaab88bf25e072def6ecafd8d6..a9849a55646a926550ee72be0955bfa7c13a1a08 100644
--- a/chrome/browser/ssl/chrome_ssl_host_state_delegate.cc
+++ b/chrome/browser/ssl/chrome_ssl_host_state_delegate.cc
@@ -10,6 +10,7 @@
#include "base/base64.h"
#include "base/bind.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/guid.h"
#include "base/logging.h"
@@ -139,6 +140,17 @@ void MigrateOldSettings(HostContentSettingsMap* map) {
}
}
+bool HostFilterToPatternFilter(
+ const base::Callback<bool(const std::string&)>& host_filter,
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern) {
+ // We only store data for "https://<host>" primary patterns, so we can convert
+ // them directly to a URL. The secondary pattern is unused.
+ GURL url(primary_pattern.ToString());
+ DCHECK(url.is_valid());
estark 2016/08/30 01:52:16 Just checking that this DCHECK really is a DCHECK
msramek 2016/08/30 14:39:41 Oh, the shame! The DCHECK is wrong, thanks for cat
raymes 2016/08/30 23:32:00 Hmm, this file is dealing with CONTENT_SETTINGS_TY
msramek 2016/08/31 13:43:11 ...correct. I panicked and searched for the wrong
+ return host_filter.Run(url.host());
+}
+
} // namespace
// This helper function gets the dictionary of certificate fingerprints to
@@ -313,9 +325,22 @@ void ChromeSSLHostStateDelegate::AllowCert(const std::string& host,
std::string(), std::move(value));
}
-void ChromeSSLHostStateDelegate::Clear() {
+void ChromeSSLHostStateDelegate::Clear(
+ const base::Callback<bool(const std::string&)>& host_filter) {
+ // Convert host matching to content settings pattern matching. Content
+ // settings deletion is done synchronously on the UI thread, so we can use
+ // |host_filter| by reference.
+ base::Callback<bool(const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern)>
+ pattern_filter;
+ if (!host_filter.is_null()) {
+ pattern_filter =
+ base::Bind(&HostFilterToPatternFilter, base::ConstRef(host_filter));
+ }
+
HostContentSettingsMapFactory::GetForProfile(profile_)
- ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS);
+ ->ClearSettingsForOneTypeWithPredicate(
+ CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, pattern_filter);
}
content::SSLHostStateDelegate::CertJudgment

Powered by Google App Engine
This is Rietveld 408576698