| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" | 17 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" |
| 18 #include "chrome/browser/extensions/extension_tab_util.h" | 18 #include "chrome/browser/extensions/extension_tab_util.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/extensions/api/cookies.h" | 22 #include "chrome/common/extensions/api/cookies.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/permissions/permissions_data.h" | 26 #include "extensions/common/permissions/permissions_data.h" |
| 27 #include "net/base/url_constants.h" |
| 27 #include "net/cookies/canonical_cookie.h" | 28 #include "net/cookies/canonical_cookie.h" |
| 28 #include "net/cookies/cookie_util.h" | 29 #include "net/cookies/cookie_util.h" |
| 29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 30 | 31 |
| 31 using extensions::api::cookies::Cookie; | 32 using extensions::api::cookies::Cookie; |
| 32 using extensions::api::cookies::CookieStore; | 33 using extensions::api::cookies::CookieStore; |
| 33 | 34 |
| 34 namespace GetAll = extensions::api::cookies::GetAll; | 35 namespace GetAll = extensions::api::cookies::GetAll; |
| 35 | 36 |
| 36 namespace extensions { | 37 namespace extensions { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 DCHECK(url.is_valid()); | 114 DCHECK(url.is_valid()); |
| 114 monster->GetAllCookiesForURLAsync(url, callback); | 115 monster->GetAllCookiesForURLAsync(url, callback); |
| 115 } else { | 116 } else { |
| 116 monster->GetAllCookiesAsync(callback); | 117 monster->GetAllCookiesAsync(callback); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 | 120 |
| 120 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) { | 121 GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) { |
| 121 const std::string& domain_key = cookie.Domain(); | 122 const std::string& domain_key = cookie.Domain(); |
| 122 const std::string scheme = | 123 const std::string scheme = |
| 123 cookie.IsSecure() ? content::kHttpsScheme : content::kHttpScheme; | 124 cookie.IsSecure() ? net::kHttpsScheme : net::kHttpScheme; |
| 124 const std::string host = | 125 const std::string host = |
| 125 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); | 126 domain_key.find('.') != 0 ? domain_key : domain_key.substr(1); |
| 126 return GURL(scheme + content::kStandardSchemeSeparator + host + "/"); | 127 return GURL(scheme + content::kStandardSchemeSeparator + host + "/"); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, | 130 void AppendMatchingCookiesToVector(const net::CookieList& all_cookies, |
| 130 const GURL& url, | 131 const GURL& url, |
| 131 const GetAll::Params::Details* details, | 132 const GetAll::Params::Details* details, |
| 132 const Extension* extension, | 133 const Extension* extension, |
| 133 LinkedCookieVec* match_vector) { | 134 LinkedCookieVec* match_vector) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (sub_domain == *details_->domain) | 202 if (sub_domain == *details_->domain) |
| 202 return true; | 203 return true; |
| 203 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 204 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 204 sub_domain.erase(0, next_dot); | 205 sub_domain.erase(0, next_dot); |
| 205 } | 206 } |
| 206 return false; | 207 return false; |
| 207 } | 208 } |
| 208 | 209 |
| 209 } // namespace cookies_helpers | 210 } // namespace cookies_helpers |
| 210 } // namespace extensions | 211 } // namespace extensions |
| OLD | NEW |