OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_cookies_helpers.h" | 7 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return monster->GetAllCookiesForURL(url); | 87 return monster->GetAllCookiesForURL(url); |
88 } | 88 } |
89 return monster->GetAllCookies(); | 89 return monster->GetAllCookies(); |
90 } | 90 } |
91 | 91 |
92 GURL GetURLFromCanonicalCookie( | 92 GURL GetURLFromCanonicalCookie( |
93 const net::CookieMonster::CanonicalCookie& cookie) { | 93 const net::CookieMonster::CanonicalCookie& cookie) { |
94 const std::string& domain_key = cookie.Domain(); | 94 const std::string& domain_key = cookie.Domain(); |
95 const std::string scheme = | 95 const std::string scheme = |
96 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; | 96 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; |
| 97 // TODO(sqs): secure cookies must be able to be reconstructed, but this is a |
| 98 // problem with httpsv |
97 const std::string host = | 99 const std::string host = |
98 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); | 100 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); |
99 return GURL(scheme + chrome::kStandardSchemeSeparator + host + "/"); | 101 return GURL(scheme + chrome::kStandardSchemeSeparator + host + "/"); |
100 } | 102 } |
101 | 103 |
102 void AppendMatchingCookiesToList( | 104 void AppendMatchingCookiesToList( |
103 const net::CookieList& all_cookies, | 105 const net::CookieList& all_cookies, |
104 const std::string& store_id, | 106 const std::string& store_id, |
105 const GURL& url, const DictionaryValue* details, | 107 const GURL& url, const DictionaryValue* details, |
106 const Extension* extension, | 108 const Extension* extension, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 sub_domain.length() >= filter_value.length();) { | 183 sub_domain.length() >= filter_value.length();) { |
182 if (sub_domain == filter_value) | 184 if (sub_domain == filter_value) |
183 return true; | 185 return true; |
184 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 186 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
185 sub_domain.erase(0, next_dot); | 187 sub_domain.erase(0, next_dot); |
186 } | 188 } |
187 return false; | 189 return false; |
188 } | 190 } |
189 | 191 |
190 } // namespace extension_cookies_helpers | 192 } // namespace extension_cookies_helpers |
OLD | NEW |