| 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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (canonical_cookie.IsPersistent()) { | 83 if (canonical_cookie.IsPersistent()) { |
| 84 cookie->expiration_date.reset( | 84 cookie->expiration_date.reset( |
| 85 new double(canonical_cookie.ExpiryDate().ToDoubleT())); | 85 new double(canonical_cookie.ExpiryDate().ToDoubleT())); |
| 86 } | 86 } |
| 87 cookie->store_id = store_id; | 87 cookie->store_id = store_id; |
| 88 | 88 |
| 89 return cookie.Pass(); | 89 return cookie.Pass(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 scoped_ptr<CookieStore> CreateCookieStore(Profile* profile, | 92 scoped_ptr<CookieStore> CreateCookieStore(Profile* profile, |
| 93 ListValue* tab_ids) { | 93 base::ListValue* tab_ids) { |
| 94 DCHECK(profile); | 94 DCHECK(profile); |
| 95 DCHECK(tab_ids); | 95 DCHECK(tab_ids); |
| 96 DictionaryValue dict; | 96 base::DictionaryValue dict; |
| 97 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); | 97 dict.SetString(keys::kIdKey, GetStoreIdFromProfile(profile)); |
| 98 dict.Set(keys::kTabIdsKey, tab_ids); | 98 dict.Set(keys::kTabIdsKey, tab_ids); |
| 99 | 99 |
| 100 CookieStore* cookie_store = new CookieStore(); | 100 CookieStore* cookie_store = new CookieStore(); |
| 101 bool rv = CookieStore::Populate(dict, cookie_store); | 101 bool rv = CookieStore::Populate(dict, cookie_store); |
| 102 CHECK(rv); | 102 CHECK(rv); |
| 103 return scoped_ptr<CookieStore>(cookie_store); | 103 return scoped_ptr<CookieStore>(cookie_store); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void GetCookieListFromStore( | 106 void GetCookieListFromStore( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 continue; | 139 continue; |
| 140 // Filter the cookie using the match filter. | 140 // Filter the cookie using the match filter. |
| 141 cookies_helpers::MatchFilter filter(details); | 141 cookies_helpers::MatchFilter filter(details); |
| 142 if (filter.MatchesCookie(*it)) { | 142 if (filter.MatchesCookie(*it)) { |
| 143 match_vector->push_back(make_linked_ptr( | 143 match_vector->push_back(make_linked_ptr( |
| 144 CreateCookie(*it, *details->store_id).release())); | 144 CreateCookie(*it, *details->store_id).release())); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 void AppendToTabIdList(Browser* browser, ListValue* tab_ids) { | 149 void AppendToTabIdList(Browser* browser, base::ListValue* tab_ids) { |
| 150 DCHECK(browser); | 150 DCHECK(browser); |
| 151 DCHECK(tab_ids); | 151 DCHECK(tab_ids); |
| 152 TabStripModel* tab_strip = browser->tab_strip_model(); | 152 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 153 for (int i = 0; i < tab_strip->count(); ++i) { | 153 for (int i = 0; i < tab_strip->count(); ++i) { |
| 154 tab_ids->Append(Value::CreateIntegerValue( | 154 tab_ids->Append(Value::CreateIntegerValue( |
| 155 ExtensionTabUtil::GetTabId(tab_strip->GetWebContentsAt(i)))); | 155 ExtensionTabUtil::GetTabId(tab_strip->GetWebContentsAt(i)))); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 MatchFilter::MatchFilter(const GetAll::Params::Details* details) | 159 MatchFilter::MatchFilter(const GetAll::Params::Details* details) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (sub_domain == *details_->domain) | 200 if (sub_domain == *details_->domain) |
| 201 return true; | 201 return true; |
| 202 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 202 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 203 sub_domain.erase(0, next_dot); | 203 sub_domain.erase(0, next_dot); |
| 204 } | 204 } |
| 205 return false; | 205 return false; |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace cookies_helpers | 208 } // namespace cookies_helpers |
| 209 } // namespace extension | 209 } // namespace extension |
| OLD | NEW |