| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_COOKIES_PARSED_COOKIE_H_ | 5 #ifndef NET_COOKIES_PARSED_COOKIE_H_ |
| 6 #define NET_COOKIES_PARSED_COOKIE_H_ | 6 #define NET_COOKIES_PARSED_COOKIE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 bool HasPath() const { return path_index_ != 0; } | 41 bool HasPath() const { return path_index_ != 0; } |
| 42 const std::string& Path() const { return pairs_[path_index_].second; } | 42 const std::string& Path() const { return pairs_[path_index_].second; } |
| 43 bool HasDomain() const { return domain_index_ != 0; } | 43 bool HasDomain() const { return domain_index_ != 0; } |
| 44 const std::string& Domain() const { return pairs_[domain_index_].second; } | 44 const std::string& Domain() const { return pairs_[domain_index_].second; } |
| 45 bool HasExpires() const { return expires_index_ != 0; } | 45 bool HasExpires() const { return expires_index_ != 0; } |
| 46 const std::string& Expires() const { return pairs_[expires_index_].second; } | 46 const std::string& Expires() const { return pairs_[expires_index_].second; } |
| 47 bool HasMaxAge() const { return maxage_index_ != 0; } | 47 bool HasMaxAge() const { return maxage_index_ != 0; } |
| 48 const std::string& MaxAge() const { return pairs_[maxage_index_].second; } | 48 const std::string& MaxAge() const { return pairs_[maxage_index_].second; } |
| 49 bool IsSecure() const { return secure_index_ != 0; } | 49 bool IsSecure() const { return secure_index_ != 0; } |
| 50 bool IsHttpOnly() const { return httponly_index_ != 0; } | 50 bool IsHttpOnly() const { return httponly_index_ != 0; } |
| 51 bool IsFirstPartyOnly() const { return firstpartyonly_index_ != 0; } |
| 51 CookiePriority Priority() const; | 52 CookiePriority Priority() const; |
| 52 | 53 |
| 53 // Returns the number of attributes, for example, returning 2 for: | 54 // Returns the number of attributes, for example, returning 2 for: |
| 54 // "BLAH=hah; path=/; domain=.google.com" | 55 // "BLAH=hah; path=/; domain=.google.com" |
| 55 size_t NumberOfAttributes() const { return pairs_.size() - 1; } | 56 size_t NumberOfAttributes() const { return pairs_.size() - 1; } |
| 56 | 57 |
| 57 // These functions set the respective properties of the cookie. If the | 58 // These functions set the respective properties of the cookie. If the |
| 58 // parameters are empty, the respective properties are cleared. | 59 // parameters are empty, the respective properties are cleared. |
| 59 // The functions return false in case an error occurred. | 60 // The functions return false in case an error occurred. |
| 60 // The cookie needs to be assigned a name/value before setting the other | 61 // The cookie needs to be assigned a name/value before setting the other |
| 61 // attributes. | 62 // attributes. |
| 62 bool SetName(const std::string& name); | 63 bool SetName(const std::string& name); |
| 63 bool SetValue(const std::string& value); | 64 bool SetValue(const std::string& value); |
| 64 bool SetPath(const std::string& path); | 65 bool SetPath(const std::string& path); |
| 65 bool SetDomain(const std::string& domain); | 66 bool SetDomain(const std::string& domain); |
| 66 bool SetExpires(const std::string& expires); | 67 bool SetExpires(const std::string& expires); |
| 67 bool SetMaxAge(const std::string& maxage); | 68 bool SetMaxAge(const std::string& maxage); |
| 68 bool SetIsSecure(bool is_secure); | 69 bool SetIsSecure(bool is_secure); |
| 69 bool SetIsHttpOnly(bool is_http_only); | 70 bool SetIsHttpOnly(bool is_http_only); |
| 71 bool SetIsFirstPartyOnly(bool is_first_party_only); |
| 70 bool SetPriority(const std::string& priority); | 72 bool SetPriority(const std::string& priority); |
| 71 | 73 |
| 72 // Returns the cookie description as it appears in a HTML response header. | 74 // Returns the cookie description as it appears in a HTML response header. |
| 73 std::string ToCookieLine() const; | 75 std::string ToCookieLine() const; |
| 74 | 76 |
| 75 // Returns an iterator pointing to the first terminator character found in | 77 // Returns an iterator pointing to the first terminator character found in |
| 76 // the given string. | 78 // the given string. |
| 77 static std::string::const_iterator FindFirstTerminator(const std::string& s); | 79 static std::string::const_iterator FindFirstTerminator(const std::string& s); |
| 78 | 80 |
| 79 // Given iterators pointing to the beginning and end of a string segment, | 81 // Given iterators pointing to the beginning and end of a string segment, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // These will default to 0, but that should never be valid since the | 131 // These will default to 0, but that should never be valid since the |
| 130 // 0th index is the user supplied token/value, not an attribute. | 132 // 0th index is the user supplied token/value, not an attribute. |
| 131 // We're really never going to have more than like 8 attributes, so we | 133 // We're really never going to have more than like 8 attributes, so we |
| 132 // could fit these into 3 bits each if we're worried about size... | 134 // could fit these into 3 bits each if we're worried about size... |
| 133 size_t path_index_; | 135 size_t path_index_; |
| 134 size_t domain_index_; | 136 size_t domain_index_; |
| 135 size_t expires_index_; | 137 size_t expires_index_; |
| 136 size_t maxage_index_; | 138 size_t maxage_index_; |
| 137 size_t secure_index_; | 139 size_t secure_index_; |
| 138 size_t httponly_index_; | 140 size_t httponly_index_; |
| 141 size_t firstpartyonly_index_; |
| 139 size_t priority_index_; | 142 size_t priority_index_; |
| 140 | 143 |
| 141 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); | 144 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); |
| 142 }; | 145 }; |
| 143 | 146 |
| 144 } // namespace net | 147 } // namespace net |
| 145 | 148 |
| 146 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 149 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
| OLD | NEW |