| 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 <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } else { | 127 } else { |
| 128 cookie_store->GetAllCookiesAsync(callback); | 128 cookie_store->GetAllCookiesAsync(callback); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) { | 132 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) { |
| 133 const std::string& domain_key = cookie.Domain(); | 133 const std::string& domain_key = cookie.Domain(); |
| 134 const std::string scheme = | 134 const std::string scheme = |
| 135 cookie.IsSecure() ? url::kHttpsScheme : url::kHttpScheme; | 135 cookie.IsSecure() ? url::kHttpsScheme : url::kHttpScheme; |
| 136 const std::string host = | 136 const std::string host = |
| 137 base::StartsWith(domain_key, ".", base::CompareCase::SENSITIVE) | 137 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); |
| 138 ? domain_key.substr(1) | |
| 139 : domain_key; | |
| 140 return GURL(scheme + url::kStandardSchemeSeparator + host + "/"); | 138 return GURL(scheme + url::kStandardSchemeSeparator + host + "/"); |
| 141 } | 139 } |
| 142 | 140 |
| 143 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, | 141 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, |
| 144 const GURL& url, | 142 const GURL& url, |
| 145 const GetAll::Params::Details* details, | 143 const GetAll::Params::Details* details, |
| 146 const Extension* extension, | 144 const Extension* extension, |
| 147 std::vector<Cookie>* match_vector) { | 145 std::vector<Cookie>* match_vector) { |
| 148 for (const net::CanonicalCookie& cookie : all_cookies) { | 146 for (const net::CanonicalCookie& cookie : all_cookies) { |
| 149 // Ignore any cookie whose domain doesn't match the extension's | 147 // Ignore any cookie whose domain doesn't match the extension's |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (sub_domain == *details_->domain) | 210 if (sub_domain == *details_->domain) |
| 213 return true; | 211 return true; |
| 214 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 212 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 215 sub_domain.erase(0, next_dot); | 213 sub_domain.erase(0, next_dot); |
| 216 } | 214 } |
| 217 return false; | 215 return false; |
| 218 } | 216 } |
| 219 | 217 |
| 220 } // namespace cookies_helpers | 218 } // namespace cookies_helpers |
| 221 } // namespace extensions | 219 } // namespace extensions |
| OLD | NEW |