• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/cookies/cookie_change_dispatcher.h"
6 
7 namespace net {
8 
CookieChangeCauseToString(CookieChangeCause cause)9 const char* CookieChangeCauseToString(CookieChangeCause cause) {
10   const char* cause_string = "INVALID";
11   switch (cause) {
12     case CookieChangeCause::INSERTED:
13       cause_string = "inserted";
14       break;
15     case CookieChangeCause::EXPLICIT:
16       cause_string = "explicit";
17       break;
18     case CookieChangeCause::UNKNOWN_DELETION:
19       cause_string = "unknown";
20       break;
21     case CookieChangeCause::OVERWRITE:
22       cause_string = "overwrite";
23       break;
24     case CookieChangeCause::EXPIRED:
25       cause_string = "expired";
26       break;
27     case CookieChangeCause::EVICTED:
28       cause_string = "evicted";
29       break;
30     case CookieChangeCause::EXPIRED_OVERWRITE:
31       cause_string = "expired_overwrite";
32       break;
33   }
34   return cause_string;
35 }
36 
37 CookieChangeInfo::CookieChangeInfo() = default;
38 
CookieChangeInfo(const CanonicalCookie & cookie,CookieAccessResult access_result,CookieChangeCause cause)39 CookieChangeInfo::CookieChangeInfo(const CanonicalCookie& cookie,
40                                    CookieAccessResult access_result,
41                                    CookieChangeCause cause)
42     : cookie(cookie), access_result(access_result), cause(cause) {
43   DCHECK(access_result.status.IsInclude());
44   if (CookieChangeCauseIsDeletion(cause)) {
45     DCHECK_EQ(access_result.effective_same_site,
46               CookieEffectiveSameSite::UNDEFINED);
47   }
48 }
49 
50 CookieChangeInfo::~CookieChangeInfo() = default;
51 
CookieChangeCauseIsDeletion(CookieChangeCause cause)52 bool CookieChangeCauseIsDeletion(CookieChangeCause cause) {
53   return cause != CookieChangeCause::INSERTED;
54 }
55 
56 }  // namespace net
57