| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_cookies_helpers.h" | 7 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" | 11 #include "chrome/browser/extensions/extension_cookies_api_constants.h" |
| 12 #include "chrome/browser/extensions/extension_tabs_module.h" | 12 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/tab_contents_wrapper.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 | 20 |
| 20 namespace keys = extension_cookies_api_constants; | 21 namespace keys = extension_cookies_api_constants; |
| 21 | 22 |
| 22 namespace extension_cookies_helpers { | 23 namespace extension_cookies_helpers { |
| 23 | 24 |
| 24 static const char kOriginalProfileStoreId[] = "0"; | 25 static const char kOriginalProfileStoreId[] = "0"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 match_list->Append(CreateCookieValue(*it, store_id)); | 115 match_list->Append(CreateCookieValue(*it, store_id)); |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 void AppendToTabIdList(Browser* browser, ListValue* tab_ids) { | 119 void AppendToTabIdList(Browser* browser, ListValue* tab_ids) { |
| 119 DCHECK(browser); | 120 DCHECK(browser); |
| 120 DCHECK(tab_ids); | 121 DCHECK(tab_ids); |
| 121 TabStripModel* tab_strip = browser->tabstrip_model(); | 122 TabStripModel* tab_strip = browser->tabstrip_model(); |
| 122 for (int i = 0; i < tab_strip->count(); ++i) { | 123 for (int i = 0; i < tab_strip->count(); ++i) { |
| 123 tab_ids->Append(Value::CreateIntegerValue( | 124 tab_ids->Append(Value::CreateIntegerValue( |
| 124 ExtensionTabUtil::GetTabId(tab_strip->GetTabContentsAt(i)))); | 125 ExtensionTabUtil::GetTabId( |
| 126 tab_strip->GetTabContentsAt(i)->tab_contents()))); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 MatchFilter::MatchFilter(const DictionaryValue* details) | 130 MatchFilter::MatchFilter(const DictionaryValue* details) |
| 129 : details_(details) { | 131 : details_(details) { |
| 130 DCHECK(details_); | 132 DCHECK(details_); |
| 131 } | 133 } |
| 132 | 134 |
| 133 bool MatchFilter::MatchesCookie( | 135 bool MatchFilter::MatchesCookie( |
| 134 const net::CookieMonster::CanonicalCookie& cookie) { | 136 const net::CookieMonster::CanonicalCookie& cookie) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 sub_domain.length() >= filter_value.length();) { | 178 sub_domain.length() >= filter_value.length();) { |
| 177 if (sub_domain == filter_value) | 179 if (sub_domain == filter_value) |
| 178 return true; | 180 return true; |
| 179 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. | 181 const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot. |
| 180 sub_domain.erase(0, next_dot); | 182 sub_domain.erase(0, next_dot); |
| 181 } | 183 } |
| 182 return false; | 184 return false; |
| 183 } | 185 } |
| 184 | 186 |
| 185 } // namespace extension_cookies_helpers | 187 } // namespace extension_cookies_helpers |
| OLD | NEW |