2017-11-15 13:09:22 +00:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
2016-10-17 10:33:24 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
#include "atom/browser/net/require_ct_delegate.h"
|
2016-10-17 10:33:24 +00:00
|
|
|
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
namespace atom {
|
2016-10-17 10:33:24 +00:00
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
RequireCTDelegate::RequireCTDelegate() {}
|
2016-10-17 10:33:24 +00:00
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
RequireCTDelegate::~RequireCTDelegate() {}
|
2016-10-17 10:33:24 +00:00
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
void RequireCTDelegate::AddCTExcludedHost(const std::string& host) {
|
2016-10-17 10:33:24 +00:00
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
|
|
|
ct_excluded_hosts_.insert(host);
|
|
|
|
}
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
void RequireCTDelegate::ClearCTExcludedHostsList() {
|
2016-10-17 10:33:24 +00:00
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
|
|
|
ct_excluded_hosts_.clear();
|
|
|
|
}
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
RequireCTDelegate::CTRequirementLevel RequireCTDelegate::IsCTRequiredForHost(
|
2018-07-20 21:09:52 +00:00
|
|
|
const std::string& host,
|
|
|
|
const net::X509Certificate* chain,
|
|
|
|
const net::HashValueVector& hashes) {
|
2016-10-17 10:33:24 +00:00
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
|
|
|
if (!ct_excluded_hosts_.empty() &&
|
|
|
|
(ct_excluded_hosts_.find(host) != ct_excluded_hosts_.end()))
|
|
|
|
return CTRequirementLevel::NOT_REQUIRED;
|
|
|
|
return CTRequirementLevel::DEFAULT;
|
|
|
|
}
|
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
} // namespace atom
|