Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/cookies/cookie_constants.h" |
| 6 | |
| 7 | #include "base/logging.h" |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 8 | #include "base/strings/string_util.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 9 | |
| 10 | namespace net { |
| 11 | |
| 12 | namespace { |
| 13 | const char kPriorityLow[] = "low"; |
| 14 | const char kPriorityMedium[] = "medium"; |
| 15 | const char kPriorityHigh[] = "high"; |
| 16 | } // namespace |
| 17 | |
| 18 | NET_EXPORT const std::string CookiePriorityToString(CookiePriority priority) { |
| 19 | switch(priority) { |
| 20 | case COOKIE_PRIORITY_HIGH: |
| 21 | return kPriorityHigh; |
| 22 | case COOKIE_PRIORITY_MEDIUM: |
| 23 | return kPriorityMedium; |
| 24 | case COOKIE_PRIORITY_LOW: |
| 25 | return kPriorityLow; |
| 26 | default: |
| 27 | NOTREACHED(); |
| 28 | } |
| 29 | return std::string(); |
| 30 | } |
| 31 | |
| 32 | NET_EXPORT CookiePriority StringToCookiePriority(const std::string& priority) { |
| 33 | std::string priority_comp(priority); |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame] | 34 | base::StringToLowerASCII(&priority_comp); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 35 | |
| 36 | if (priority_comp == kPriorityHigh) |
| 37 | return COOKIE_PRIORITY_HIGH; |
| 38 | if (priority_comp == kPriorityMedium) |
| 39 | return COOKIE_PRIORITY_MEDIUM; |
| 40 | if (priority_comp == kPriorityLow) |
| 41 | return COOKIE_PRIORITY_LOW; |
| 42 | |
| 43 | return COOKIE_PRIORITY_DEFAULT; |
| 44 | } |
| 45 | |
| 46 | } // namespace net |