summaryrefslogtreecommitdiffstats
path: root/chromium/net/http/url_security_manager.cc
blob: cbf9248f17aea95f2f4174b537b2bc03fc757909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2010 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/http/url_security_manager.h"

#include <utility>

#include "net/http/http_auth_filter.h"

namespace net {

URLSecurityManagerAllowlist::URLSecurityManagerAllowlist() = default;

URLSecurityManagerAllowlist::~URLSecurityManagerAllowlist() = default;

bool URLSecurityManagerAllowlist::CanUseDefaultCredentials(
    const url::SchemeHostPort& auth_scheme_host_port) const {
  if (allowlist_default_.get())
    return allowlist_default_->IsValid(auth_scheme_host_port,
                                       HttpAuth::AUTH_SERVER);
  return false;
}

bool URLSecurityManagerAllowlist::CanDelegate(
    const url::SchemeHostPort& auth_scheme_host_port) const {
  if (allowlist_delegate_.get())
    return allowlist_delegate_->IsValid(auth_scheme_host_port,
                                        HttpAuth::AUTH_SERVER);
  return false;
}

void URLSecurityManagerAllowlist::SetDefaultAllowlist(
    std::unique_ptr<HttpAuthFilter> allowlist_default) {
  allowlist_default_ = std::move(allowlist_default);
}

void URLSecurityManagerAllowlist::SetDelegateAllowlist(
    std::unique_ptr<HttpAuthFilter> allowlist_delegate) {
  allowlist_delegate_ = std::move(allowlist_delegate);
}

bool URLSecurityManagerAllowlist::HasDefaultAllowlist() const {
  return allowlist_default_.get() != nullptr;
}

}  //  namespace net