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 "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const std::string& domain_key = cookie_pair.first; | 87 const std::string& domain_key = cookie_pair.first; |
88 const net::CookieMonster::CanonicalCookie& cookie = cookie_pair.second; | 88 const net::CookieMonster::CanonicalCookie& cookie = cookie_pair.second; |
89 const std::string scheme = | 89 const std::string scheme = |
90 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; | 90 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; |
91 const std::string host = | 91 const std::string host = |
92 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); | 92 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); |
93 return GURL(scheme + chrome::kStandardSchemeSeparator + host + "/"); | 93 return GURL(scheme + chrome::kStandardSchemeSeparator + host + "/"); |
94 } | 94 } |
95 | 95 |
96 void AppendMatchingCookiesToList( | 96 void AppendMatchingCookiesToList( |
97 const net::CookieMonster::CookieList& all_cookies, | 97 net::CookieStore* cookie_store, const std::string& store_id, |
98 const std::string& store_id, | |
99 const GURL& url, const DictionaryValue* details, | 98 const GURL& url, const DictionaryValue* details, |
100 const Extension* extension, | 99 const Extension* extension, |
101 ListValue* match_list) { | 100 ListValue* match_list) { |
| 101 net::CookieMonster::CookieList all_cookies = GetCookieListFromStore( |
| 102 cookie_store, url); |
102 net::CookieMonster::CookieList::const_iterator it; | 103 net::CookieMonster::CookieList::const_iterator it; |
103 for (it = all_cookies.begin(); it != all_cookies.end(); ++it) { | 104 for (it = all_cookies.begin(); it != all_cookies.end(); ++it) { |
104 // Ignore any cookie whose domain doesn't match the extension's | 105 // Ignore any cookie whose domain doesn't match the extension's |
105 // host permissions. | 106 // host permissions. |
106 GURL cookie_domain_url = GetURLFromCookiePair(*it); | 107 GURL cookie_domain_url = GetURLFromCookiePair(*it); |
107 if (!extension->HasHostPermission(cookie_domain_url)) | 108 if (!extension->HasHostPermission(cookie_domain_url)) |
108 continue; | 109 continue; |
109 // Filter the cookie using the match filter. | 110 // Filter the cookie using the match filter. |
110 extension_cookies_helpers::MatchFilter filter(details); | 111 extension_cookies_helpers::MatchFilter filter(details); |
111 if (filter.MatchesCookie(*it)) | 112 if (filter.MatchesCookie(*it)) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 sub_domain.length() >= filter_value.length();) { | 177 sub_domain.length() >= filter_value.length();) { |
177 if (sub_domain == filter_value) | 178 if (sub_domain == filter_value) |
178 return true; | 179 return true; |
179 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 180 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
180 sub_domain.erase(0, next_dot); | 181 sub_domain.erase(0, next_dot); |
181 } | 182 } |
182 return false; | 183 return false; |
183 } | 184 } |
184 | 185 |
185 } // namespace extension_cookies_helpers | 186 } // namespace extension_cookies_helpers |
OLD | NEW |