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.
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
#include "brightray/browser/net/require_ct_delegate.h"
|
2016-10-17 10:33:24 +00:00
|
|
|
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
namespace brightray {
|
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(
|
2016-10-17 10:33:24 +00:00
|
|
|
const std::string& host) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
} // namespace brightray
|