summaryrefslogtreecommitdiff
path: root/chromium/net/cookies/cookie_change_dispatcher.cc
blob: 755a4128d190e0f18191cf137d5a792263c9493f (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
48
49
50
51
52
53
54
55
56
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/cookies/cookie_change_dispatcher.h"

namespace net {

const char* CookieChangeCauseToString(CookieChangeCause cause) {
  const char* cause_string = "INVALID";
  switch (cause) {
    case CookieChangeCause::INSERTED:
      cause_string = "inserted";
      break;
    case CookieChangeCause::EXPLICIT:
      cause_string = "explicit";
      break;
    case CookieChangeCause::UNKNOWN_DELETION:
      cause_string = "unknown";
      break;
    case CookieChangeCause::OVERWRITE:
      cause_string = "overwrite";
      break;
    case CookieChangeCause::EXPIRED:
      cause_string = "expired";
      break;
    case CookieChangeCause::EVICTED:
      cause_string = "evicted";
      break;
    case CookieChangeCause::EXPIRED_OVERWRITE:
      cause_string = "expired_overwrite";
      break;
  }
  return cause_string;
}

CookieChangeInfo::CookieChangeInfo() = default;

CookieChangeInfo::CookieChangeInfo(const CanonicalCookie& cookie,
                                   CookieAccessResult access_result,
                                   CookieChangeCause cause)
    : cookie(cookie), access_result(access_result), cause(cause) {
  DCHECK(access_result.status.IsInclude());
  if (CookieChangeCauseIsDeletion(cause)) {
    DCHECK_EQ(access_result.effective_same_site,
              CookieEffectiveSameSite::UNDEFINED);
  }
}

CookieChangeInfo::~CookieChangeInfo() = default;

bool CookieChangeCauseIsDeletion(CookieChangeCause cause) {
  return cause != CookieChangeCause::INSERTED;
}

}  // namespace net