require_ct_delegate.cc 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) 2017 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "brightray/browser/net/require_ct_delegate.h"
  5. #include "content/public/browser/browser_thread.h"
  6. namespace brightray {
  7. RequireCTDelegate::RequireCTDelegate() {}
  8. RequireCTDelegate::~RequireCTDelegate() {}
  9. void RequireCTDelegate::AddCTExcludedHost(const std::string& host) {
  10. DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
  11. ct_excluded_hosts_.insert(host);
  12. }
  13. void RequireCTDelegate::ClearCTExcludedHostsList() {
  14. DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
  15. ct_excluded_hosts_.clear();
  16. }
  17. RequireCTDelegate::CTRequirementLevel RequireCTDelegate::IsCTRequiredForHost(
  18. const std::string& host) {
  19. DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
  20. if (!ct_excluded_hosts_.empty() &&
  21. (ct_excluded_hosts_.find(host) != ct_excluded_hosts_.end()))
  22. return CTRequirementLevel::NOT_REQUIRED;
  23. return CTRequirementLevel::DEFAULT;
  24. }
  25. } // namespace brightray