| 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/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/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/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 27 #include "net/cookies/canonical_cookie.h" | 27 #include "net/cookies/canonical_cookie.h" |
| 28 #include "net/cookies/cookie_constants.h" |
| 28 #include "net/cookies/cookie_util.h" | 29 #include "net/cookies/cookie_util.h" |
| 29 | 30 |
| 30 using extensions::api::cookies::Cookie; | 31 using extensions::api::cookies::Cookie; |
| 31 using extensions::api::cookies::CookieStore; | 32 using extensions::api::cookies::CookieStore; |
| 32 | 33 |
| 33 namespace GetAll = extensions::api::cookies::GetAll; | 34 namespace GetAll = extensions::api::cookies::GetAll; |
| 34 | 35 |
| 35 namespace extensions { | 36 namespace extensions { |
| 36 | 37 |
| 37 namespace keys = cookies_api_constants; | 38 namespace keys = cookies_api_constants; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 cookie->path = IsStringUTF8(canonical_cookie.Path()) ? canonical_cookie.Path() | 78 cookie->path = IsStringUTF8(canonical_cookie.Path()) ? canonical_cookie.Path() |
| 78 : std::string(); | 79 : std::string(); |
| 79 cookie->secure = canonical_cookie.IsSecure(); | 80 cookie->secure = canonical_cookie.IsSecure(); |
| 80 cookie->http_only = canonical_cookie.IsHttpOnly(); | 81 cookie->http_only = canonical_cookie.IsHttpOnly(); |
| 81 cookie->session = !canonical_cookie.IsPersistent(); | 82 cookie->session = !canonical_cookie.IsPersistent(); |
| 82 if (canonical_cookie.IsPersistent()) { | 83 if (canonical_cookie.IsPersistent()) { |
| 83 cookie->expiration_date.reset( | 84 cookie->expiration_date.reset( |
| 84 new double(canonical_cookie.ExpiryDate().ToDoubleT())); | 85 new double(canonical_cookie.ExpiryDate().ToDoubleT())); |
| 85 } | 86 } |
| 86 cookie->store_id = store_id; | 87 cookie->store_id = store_id; |
| 88 cookie->priority = net::CookiePriorityToString(canonical_cookie.Priority()); |
| 87 | 89 |
| 88 return cookie.Pass(); | 90 return cookie.Pass(); |
| 89 } | 91 } |
| 90 | 92 |
| 91 scoped_ptr<CookieStore> CreateCookieStore(Profile* profile, | 93 scoped_ptr<CookieStore> CreateCookieStore(Profile* profile, |
| 92 ListValue* tab_ids) { | 94 ListValue* tab_ids) { |
| 93 DCHECK(profile); | 95 DCHECK(profile); |
| 94 DCHECK(tab_ids); | 96 DCHECK(tab_ids); |
| 95 DictionaryValue dict; | 97 DictionaryValue dict; |
| 96 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); | 98 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (sub_domain == *details_->domain) | 201 if (sub_domain == *details_->domain) |
| 200 return true; | 202 return true; |
| 201 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 203 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 202 sub_domain.erase(0, next_dot); | 204 sub_domain.erase(0, next_dot); |
| 203 } | 205 } |
| 204 return false; | 206 return false; |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // namespace cookies_helpers | 209 } // namespace cookies_helpers |
| 208 } // namespace extension | 210 } // namespace extension |
| OLD | NEW |