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 // Implements common functionality for the Chrome Extensions Cookies API. | 5 // Implements common functionality for the Chrome Extensions Cookies API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" | 7 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 scoped_ptr<Cookie> cookie(new Cookie()); | 67 scoped_ptr<Cookie> cookie(new Cookie()); |
68 | 68 |
69 // A cookie is a raw byte sequence. By explicitly parsing it as UTF-8, we | 69 // A cookie is a raw byte sequence. By explicitly parsing it as UTF-8, we |
70 // apply error correction, so the string can be safely passed to the renderer. | 70 // apply error correction, so the string can be safely passed to the renderer. |
71 cookie->name = UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Name())); | 71 cookie->name = UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Name())); |
72 cookie->value = UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Value())); | 72 cookie->value = UTF16ToUTF8(UTF8ToUTF16(canonical_cookie.Value())); |
73 cookie->domain = canonical_cookie.Domain(); | 73 cookie->domain = canonical_cookie.Domain(); |
74 cookie->host_only = net::cookie_util::DomainIsHostOnly( | 74 cookie->host_only = net::cookie_util::DomainIsHostOnly( |
75 canonical_cookie.Domain()); | 75 canonical_cookie.Domain()); |
76 // A non-UTF8 path is invalid, so we just replace it with an empty string. | 76 // A non-UTF8 path is invalid, so we just replace it with an empty string. |
77 cookie->path = IsStringUTF8(canonical_cookie.Path()) ? | 77 cookie->path = IsStringUTF8(canonical_cookie.Path()) ? canonical_cookie.Path() |
78 canonical_cookie.Path() : ""; | 78 : std::string(); |
79 cookie->secure = canonical_cookie.IsSecure(); | 79 cookie->secure = canonical_cookie.IsSecure(); |
80 cookie->http_only = canonical_cookie.IsHttpOnly(); | 80 cookie->http_only = canonical_cookie.IsHttpOnly(); |
81 cookie->session = !canonical_cookie.IsPersistent(); | 81 cookie->session = !canonical_cookie.IsPersistent(); |
82 if (canonical_cookie.IsPersistent()) { | 82 if (canonical_cookie.IsPersistent()) { |
83 cookie->expiration_date.reset( | 83 cookie->expiration_date.reset( |
84 new double(canonical_cookie.ExpiryDate().ToDoubleT())); | 84 new double(canonical_cookie.ExpiryDate().ToDoubleT())); |
85 } | 85 } |
86 cookie->store_id = store_id; | 86 cookie->store_id = store_id; |
87 | 87 |
88 return cookie.Pass(); | 88 return cookie.Pass(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (sub_domain == *details_->domain) | 199 if (sub_domain == *details_->domain) |
200 return true; | 200 return true; |
201 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 201 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
202 sub_domain.erase(0, next_dot); | 202 sub_domain.erase(0, next_dot); |
203 } | 203 } |
204 return false; | 204 return false; |
205 } | 205 } |
206 | 206 |
207 } // namespace cookies_helpers | 207 } // namespace cookies_helpers |
208 } // namespace extension | 208 } // namespace extension |
OLD | NEW |