OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 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 "content/common/cookie_traits.h" |
| 6 |
| 7 namespace mojo { |
| 8 |
| 9 content::mojom::CookiePriority |
| 10 EnumTraits<content::mojom::CookiePriority, net::CookiePriority>::ToMojom( |
| 11 net::CookiePriority input) { |
| 12 switch (input) { |
| 13 case net::COOKIE_PRIORITY_LOW: |
| 14 return content::mojom::CookiePriority::LOW; |
| 15 case net::COOKIE_PRIORITY_MEDIUM: |
| 16 return content::mojom::CookiePriority::MEDIUM; |
| 17 case net::COOKIE_PRIORITY_HIGH: |
| 18 return content::mojom::CookiePriority::HIGH; |
| 19 } |
| 20 NOTREACHED(); |
| 21 return static_cast<content::mojom::CookiePriority>(input); |
| 22 } |
| 23 |
| 24 bool EnumTraits<content::mojom::CookiePriority, net::CookiePriority>::FromMojom( |
| 25 content::mojom::CookiePriority input, |
| 26 net::CookiePriority* output) { |
| 27 switch (input) { |
| 28 case content::mojom::CookiePriority::LOW: |
| 29 *output = net::CookiePriority::COOKIE_PRIORITY_LOW; |
| 30 return true; |
| 31 case content::mojom::CookiePriority::MEDIUM: |
| 32 *output = net::CookiePriority::COOKIE_PRIORITY_MEDIUM; |
| 33 return true; |
| 34 case content::mojom::CookiePriority::HIGH: |
| 35 *output = net::CookiePriority::COOKIE_PRIORITY_HIGH; |
| 36 return true; |
| 37 } |
| 38 return false; |
| 39 } |
| 40 |
| 41 content::mojom::CookieSameSite |
| 42 EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::ToMojom( |
| 43 net::CookieSameSite input) { |
| 44 switch (input) { |
| 45 case net::CookieSameSite::NO_RESTRICTION: |
| 46 return content::mojom::CookieSameSite::NO_RESTRICTION; |
| 47 case net::CookieSameSite::LAX_MODE: |
| 48 return content::mojom::CookieSameSite::LAX_MODE; |
| 49 case net::CookieSameSite::STRICT_MODE: |
| 50 return content::mojom::CookieSameSite::STRICT_MODE; |
| 51 } |
| 52 NOTREACHED(); |
| 53 return static_cast<content::mojom::CookieSameSite>(input); |
| 54 } |
| 55 |
| 56 bool EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::FromMojom( |
| 57 content::mojom::CookieSameSite input, |
| 58 net::CookieSameSite* output) { |
| 59 switch (input) { |
| 60 case content::mojom::CookieSameSite::NO_RESTRICTION: |
| 61 *output = net::CookieSameSite::NO_RESTRICTION; |
| 62 return true; |
| 63 case content::mojom::CookieSameSite::LAX_MODE: |
| 64 *output = net::CookieSameSite::LAX_MODE; |
| 65 return true; |
| 66 case content::mojom::CookieSameSite::STRICT_MODE: |
| 67 *output = net::CookieSameSite::STRICT_MODE; |
| 68 return true; |
| 69 } |
| 70 return false; |
| 71 } |
| 72 |
| 73 content::mojom::CookieSameSiteFilter |
| 74 EnumTraits<content::mojom::CookieSameSiteFilter, |
| 75 net::CookieOptions::SameSiteCookieMode>:: |
| 76 ToMojom(net::CookieOptions::SameSiteCookieMode input) { |
| 77 switch (input) { |
| 78 case net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX: |
| 79 return content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX; |
| 80 case net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX: |
| 81 return content::mojom::CookieSameSiteFilter::INCLUDE_LAX; |
| 82 case net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE: |
| 83 return content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE; |
| 84 } |
| 85 NOTREACHED(); |
| 86 return static_cast<content::mojom::CookieSameSiteFilter>(input); |
| 87 } |
| 88 |
| 89 bool EnumTraits<content::mojom::CookieSameSiteFilter, |
| 90 net::CookieOptions::SameSiteCookieMode>:: |
| 91 FromMojom(content::mojom::CookieSameSiteFilter input, |
| 92 net::CookieOptions::SameSiteCookieMode* output) { |
| 93 switch (input) { |
| 94 case content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX: |
| 95 *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX; |
| 96 return true; |
| 97 case content::mojom::CookieSameSiteFilter::INCLUDE_LAX: |
| 98 *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX; |
| 99 return true; |
| 100 case content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE: |
| 101 *output = net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE; |
| 102 return true; |
| 103 } |
| 104 return false; |
| 105 } |
| 106 |
| 107 } // namespace mojo |
OLD | NEW |