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 |
| 11 #include <utility> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" | 18 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" |
18 #include "chrome/browser/extensions/extension_tab_util.h" | 19 #include "chrome/browser/extensions/extension_tab_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 cookie.session = !canonical_cookie.IsPersistent(); | 97 cookie.session = !canonical_cookie.IsPersistent(); |
97 if (canonical_cookie.IsPersistent()) { | 98 if (canonical_cookie.IsPersistent()) { |
98 cookie.expiration_date.reset( | 99 cookie.expiration_date.reset( |
99 new double(canonical_cookie.ExpiryDate().ToDoubleT())); | 100 new double(canonical_cookie.ExpiryDate().ToDoubleT())); |
100 } | 101 } |
101 cookie.store_id = store_id; | 102 cookie.store_id = store_id; |
102 | 103 |
103 return cookie; | 104 return cookie; |
104 } | 105 } |
105 | 106 |
106 CookieStore CreateCookieStore(Profile* profile, base::ListValue* tab_ids) { | 107 CookieStore CreateCookieStore(Profile* profile, |
| 108 std::unique_ptr<base::ListValue> tab_ids) { |
107 DCHECK(profile); | 109 DCHECK(profile); |
108 DCHECK(tab_ids); | 110 DCHECK(tab_ids); |
109 base::DictionaryValue dict; | 111 base::DictionaryValue dict; |
110 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); | 112 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); |
111 dict.Set(keys::kTabIdsKey, tab_ids); | 113 dict.Set(keys::kTabIdsKey, std::move(tab_ids)); |
112 | 114 |
113 CookieStore cookie_store; | 115 CookieStore cookie_store; |
114 bool rv = CookieStore::Populate(dict, &cookie_store); | 116 bool rv = CookieStore::Populate(dict, &cookie_store); |
115 CHECK(rv); | 117 CHECK(rv); |
116 return cookie_store; | 118 return cookie_store; |
117 } | 119 } |
118 | 120 |
119 void GetCookieListFromStore( | 121 void GetCookieListFromStore( |
120 net::CookieStore* cookie_store, | 122 net::CookieStore* cookie_store, |
121 const GURL& url, | 123 const GURL& url, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (sub_domain == *details_->domain) | 214 if (sub_domain == *details_->domain) |
213 return true; | 215 return true; |
214 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 216 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
215 sub_domain.erase(0, next_dot); | 217 sub_domain.erase(0, next_dot); |
216 } | 218 } |
217 return false; | 219 return false; |
218 } | 220 } |
219 | 221 |
220 } // namespace cookies_helpers | 222 } // namespace cookies_helpers |
221 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |