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/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/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; | 108 cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme; |
109 const std::string host = | 109 const std::string host = |
110 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); | 110 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); |
111 return GURL(scheme + content::kStandardSchemeSeparator + host + "/"); | 111 return GURL(scheme + content::kStandardSchemeSeparator + host + "/"); |
112 } | 112 } |
113 | 113 |
114 void AppendMatchingCookiesToList( | 114 void AppendMatchingCookiesToList( |
115 const net::CookieList& all_cookies, | 115 const net::CookieList& all_cookies, |
116 const std::string& store_id, | 116 const std::string& store_id, |
117 const GURL& url, const DictionaryValue* details, | 117 const GURL& url, const DictionaryValue* details, |
118 const Extension* extension, | 118 const extensions::Extension* extension, |
119 ListValue* match_list) { | 119 ListValue* match_list) { |
120 net::CookieList::const_iterator it; | 120 net::CookieList::const_iterator it; |
121 for (it = all_cookies.begin(); it != all_cookies.end(); ++it) { | 121 for (it = all_cookies.begin(); it != all_cookies.end(); ++it) { |
122 // Ignore any cookie whose domain doesn't match the extension's | 122 // Ignore any cookie whose domain doesn't match the extension's |
123 // host permissions. | 123 // host permissions. |
124 GURL cookie_domain_url = GetURLFromCanonicalCookie(*it); | 124 GURL cookie_domain_url = GetURLFromCanonicalCookie(*it); |
125 if (!extension->HasHostPermission(cookie_domain_url)) | 125 if (!extension->HasHostPermission(cookie_domain_url)) |
126 continue; | 126 continue; |
127 // Filter the cookie using the match filter. | 127 // Filter the cookie using the match filter. |
128 extension_cookies_helpers::MatchFilter filter(details); | 128 extension_cookies_helpers::MatchFilter filter(details); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 sub_domain.length() >= filter_value.length();) { | 193 sub_domain.length() >= filter_value.length();) { |
194 if (sub_domain == filter_value) | 194 if (sub_domain == filter_value) |
195 return true; | 195 return true; |
196 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 196 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
197 sub_domain.erase(0, next_dot); | 197 sub_domain.erase(0, next_dot); |
198 } | 198 } |
199 return false; | 199 return false; |
200 } | 200 } |
201 | 201 |
202 } // namespace extension_cookies_helpers | 202 } // namespace extension_cookies_helpers |
OLD | NEW |