Chromium Code Reviews| 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/cookies_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; | |
|
yzshen1
2017/06/20 18:33:17
We need to return true for each case?
| |
| 30 case content::mojom::CookiePriority::MEDIUM: | |
| 31 *output = net::CookiePriority::COOKIE_PRIORITY_MEDIUM; | |
| 32 case content::mojom::CookiePriority::HIGH: | |
| 33 *output = net::CookiePriority::COOKIE_PRIORITY_HIGH; | |
| 34 } | |
| 35 return false; | |
| 36 } | |
| 37 | |
| 38 content::mojom::CookieSameSite | |
| 39 EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::ToMojom( | |
| 40 net::CookieSameSite input) { | |
| 41 switch (input) { | |
| 42 case net::CookieSameSite::NO_RESTRICTION: | |
| 43 return content::mojom::CookieSameSite::NO_RESTRICTION; | |
| 44 case net::CookieSameSite::LAX_MODE: | |
| 45 return content::mojom::CookieSameSite::LAX_MODE; | |
| 46 case net::CookieSameSite::STRICT_MODE: | |
| 47 return content::mojom::CookieSameSite::STRICT_MODE; | |
| 48 } | |
| 49 NOTREACHED(); | |
| 50 return static_cast<content::mojom::CookieSameSite>(input); | |
| 51 } | |
| 52 | |
| 53 bool EnumTraits<content::mojom::CookieSameSite, net::CookieSameSite>::FromMojom( | |
| 54 content::mojom::CookieSameSite input, | |
| 55 net::CookieSameSite* output) { | |
| 56 switch (input) { | |
| 57 case content::mojom::CookieSameSite::NO_RESTRICTION: | |
| 58 *output = net::CookieSameSite::NO_RESTRICTION; | |
| 59 return true; | |
| 60 case content::mojom::CookieSameSite::LAX_MODE: | |
| 61 *output = net::CookieSameSite::LAX_MODE; | |
| 62 return true; | |
| 63 case content::mojom::CookieSameSite::STRICT_MODE: | |
| 64 *output = net::CookieSameSite::STRICT_MODE; | |
| 65 return true; | |
| 66 } | |
| 67 return false; | |
| 68 } | |
| 69 | |
| 70 content::mojom::CookieSameSiteFilter | |
| 71 EnumTraits<content::mojom::CookieSameSiteFilter, | |
| 72 net::CookieOptions::SameSiteCookieMode>:: | |
| 73 ToMojom(net::CookieOptions::SameSiteCookieMode input) { | |
| 74 switch (input) { | |
| 75 case net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX: | |
| 76 return content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX; | |
| 77 case net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX: | |
| 78 return content::mojom::CookieSameSiteFilter::INCLUDE_LAX; | |
| 79 case net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE: | |
| 80 return content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE; | |
| 81 } | |
| 82 NOTREACHED(); | |
| 83 return static_cast<content::mojom::CookieSameSiteFilter>(input); | |
| 84 } | |
| 85 | |
| 86 bool EnumTraits<content::mojom::CookieSameSiteFilter, | |
| 87 net::CookieOptions::SameSiteCookieMode>:: | |
| 88 FromMojom(content::mojom::CookieSameSiteFilter input, | |
| 89 net::CookieOptions::SameSiteCookieMode* output) { | |
| 90 switch (input) { | |
| 91 case content::mojom::CookieSameSiteFilter::INCLUDE_STRICT_AND_LAX: | |
| 92 *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX; | |
| 93 return true; | |
| 94 case content::mojom::CookieSameSiteFilter::INCLUDE_LAX: | |
| 95 *output = net::CookieOptions::SameSiteCookieMode::INCLUDE_LAX; | |
| 96 return true; | |
| 97 case content::mojom::CookieSameSiteFilter::DO_NOT_INCLUDE: | |
| 98 *output = net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE; | |
| 99 return true; | |
| 100 } | |
| 101 return false; | |
| 102 } | |
| 103 | |
| 104 content::mojom::CookieChangeCause | |
| 105 EnumTraits<content::mojom::CookieChangeCause, net::CookieStore::ChangeCause>:: | |
| 106 ToMojom(net::CookieStore::ChangeCause input) { | |
| 107 switch (input) { | |
| 108 case net::CookieStore::ChangeCause::INSERTED: | |
| 109 return content::mojom::CookieChangeCause::INSERTED; | |
| 110 case net::CookieStore::ChangeCause::EXPLICIT: | |
| 111 case net::CookieStore::ChangeCause::EXPLICIT_DELETE_BETWEEN: | |
| 112 case net::CookieStore::ChangeCause::EXPLICIT_DELETE_PREDICATE: | |
| 113 case net::CookieStore::ChangeCause::EXPLICIT_DELETE_SINGLE: | |
| 114 case net::CookieStore::ChangeCause::EXPLICIT_DELETE_CANONICAL: | |
| 115 return content::mojom::CookieChangeCause::EXPLICIT; | |
| 116 case net::CookieStore::ChangeCause::UNKNOWN_DELETION: | |
| 117 return content::mojom::CookieChangeCause::UNKNOWN_DELETION; | |
| 118 case net::CookieStore::ChangeCause::OVERWRITE: | |
| 119 return content::mojom::CookieChangeCause::OVERWRITE; | |
| 120 case net::CookieStore::ChangeCause::EXPIRED: | |
| 121 return content::mojom::CookieChangeCause::EXPIRED; | |
| 122 case net::CookieStore::ChangeCause::EVICTED: | |
| 123 return content::mojom::CookieChangeCause::EVICTED; | |
| 124 case net::CookieStore::ChangeCause::EXPIRED_OVERWRITE: | |
| 125 return content::mojom::CookieChangeCause::EXPIRED_OVERWRITE; | |
| 126 } | |
| 127 NOTREACHED(); | |
| 128 return static_cast<content::mojom::CookieChangeCause>(input); | |
| 129 } | |
| 130 | |
| 131 bool EnumTraits<content::mojom::CookieChangeCause, | |
| 132 net::CookieStore::ChangeCause>:: | |
| 133 FromMojom(content::mojom::CookieChangeCause input, | |
| 134 net::CookieStore::ChangeCause* output) { | |
| 135 switch (input) { | |
| 136 case content::mojom::CookieChangeCause::INSERTED: | |
| 137 *output = net::CookieStore::ChangeCause::INSERTED; | |
| 138 return true; | |
| 139 case content::mojom::CookieChangeCause::EXPLICIT: | |
| 140 *output = net::CookieStore::ChangeCause::EXPLICIT; | |
| 141 return true; | |
| 142 case content::mojom::CookieChangeCause::UNKNOWN_DELETION: | |
| 143 *output = net::CookieStore::ChangeCause::UNKNOWN_DELETION; | |
| 144 return true; | |
| 145 case content::mojom::CookieChangeCause::OVERWRITE: | |
| 146 *output = net::CookieStore::ChangeCause::OVERWRITE; | |
| 147 return true; | |
| 148 case content::mojom::CookieChangeCause::EXPIRED: | |
| 149 *output = net::CookieStore::ChangeCause::EXPIRED; | |
| 150 return true; | |
| 151 case content::mojom::CookieChangeCause::EVICTED: | |
| 152 *output = net::CookieStore::ChangeCause::EVICTED; | |
| 153 return true; | |
| 154 case content::mojom::CookieChangeCause::EXPIRED_OVERWRITE: | |
| 155 *output = net::CookieStore::ChangeCause::EXPIRED_OVERWRITE; | |
| 156 return true; | |
| 157 } | |
| 158 return false; | |
| 159 } | |
| 160 | |
| 161 } // namespace mojo | |
| OLD | NEW |