OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cookies/cookie_constants.h" | 5 #include "net/cookies/cookie_constants.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 namespace { | 12 namespace { |
| 13 |
13 const char kPriorityLow[] = "low"; | 14 const char kPriorityLow[] = "low"; |
14 const char kPriorityMedium[] = "medium"; | 15 const char kPriorityMedium[] = "medium"; |
15 const char kPriorityHigh[] = "high"; | 16 const char kPriorityHigh[] = "high"; |
| 17 |
| 18 const char kSameSiteLax[] = "lax"; |
| 19 const char kSameSiteStrict[] = "strict"; |
| 20 |
16 } // namespace | 21 } // namespace |
17 | 22 |
18 NET_EXPORT const std::string CookiePriorityToString(CookiePriority priority) { | 23 std::string CookiePriorityToString(CookiePriority priority) { |
19 switch(priority) { | 24 switch(priority) { |
20 case COOKIE_PRIORITY_HIGH: | 25 case COOKIE_PRIORITY_HIGH: |
21 return kPriorityHigh; | 26 return kPriorityHigh; |
22 case COOKIE_PRIORITY_MEDIUM: | 27 case COOKIE_PRIORITY_MEDIUM: |
23 return kPriorityMedium; | 28 return kPriorityMedium; |
24 case COOKIE_PRIORITY_LOW: | 29 case COOKIE_PRIORITY_LOW: |
25 return kPriorityLow; | 30 return kPriorityLow; |
26 default: | 31 default: |
27 NOTREACHED(); | 32 NOTREACHED(); |
28 } | 33 } |
29 return std::string(); | 34 return std::string(); |
30 } | 35 } |
31 | 36 |
32 NET_EXPORT CookiePriority StringToCookiePriority(const std::string& priority) { | 37 CookiePriority StringToCookiePriority(const std::string& priority) { |
33 std::string priority_comp = base::ToLowerASCII(priority); | 38 std::string priority_comp = base::ToLowerASCII(priority); |
34 | 39 |
35 if (priority_comp == kPriorityHigh) | 40 if (priority_comp == kPriorityHigh) |
36 return COOKIE_PRIORITY_HIGH; | 41 return COOKIE_PRIORITY_HIGH; |
37 if (priority_comp == kPriorityMedium) | 42 if (priority_comp == kPriorityMedium) |
38 return COOKIE_PRIORITY_MEDIUM; | 43 return COOKIE_PRIORITY_MEDIUM; |
39 if (priority_comp == kPriorityLow) | 44 if (priority_comp == kPriorityLow) |
40 return COOKIE_PRIORITY_LOW; | 45 return COOKIE_PRIORITY_LOW; |
41 | 46 |
42 return COOKIE_PRIORITY_DEFAULT; | 47 return COOKIE_PRIORITY_DEFAULT; |
43 } | 48 } |
44 | 49 |
| 50 CookieSameSite StringToCookieSameSite(const std::string& same_site) { |
| 51 if (base::EqualsCaseInsensitiveASCII(same_site, kSameSiteLax)) |
| 52 return CookieSameSite::LAX_MODE; |
| 53 if (base::EqualsCaseInsensitiveASCII(same_site, kSameSiteStrict)) |
| 54 return CookieSameSite::STRICT_MODE; |
| 55 return CookieSameSite::DEFAULT_MODE; |
| 56 } |
| 57 |
45 } // namespace net | 58 } // namespace net |
OLD | NEW |