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 // Defines common functionality used by the implementation of the Chrome | 5 // Defines common functionality used by the implementation of the Chrome |
6 // Extensions Cookies API implemented in | 6 // Extensions Cookies API implemented in |
7 // chrome/browser/extensions/extension_cookies_api.cc. This separate interface | 7 // chrome/browser/extensions/extension_cookies_api.cc. This separate interface |
8 // exposes pieces of the API implementation mainly for unit testing purposes. | 8 // exposes pieces of the API implementation mainly for unit testing purposes. |
9 | 9 |
10 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ | 10 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ |
(...skipping 28 matching lines...) Expand all Loading... |
39 const std::string& store_id); | 39 const std::string& store_id); |
40 | 40 |
41 // Constructs a CookieStore object as defined by the cookies API. This function | 41 // Constructs a CookieStore object as defined by the cookies API. This function |
42 // allocates a new DictionaryValue object; the caller is responsible for | 42 // allocates a new DictionaryValue object; the caller is responsible for |
43 // freeing it. | 43 // freeing it. |
44 DictionaryValue* CreateCookieStoreValue(Profile* profile, | 44 DictionaryValue* CreateCookieStoreValue(Profile* profile, |
45 ListValue* tab_ids); | 45 ListValue* tab_ids); |
46 | 46 |
47 // Retrieves all cookies from the given cookie store corresponding to the given | 47 // Retrieves all cookies from the given cookie store corresponding to the given |
48 // URL. If the URL is empty, all cookies in the cookie store are retrieved. | 48 // URL. If the URL is empty, all cookies in the cookie store are retrieved. |
| 49 // This can only be called on the IO thread. |
49 net::CookieMonster::CookieList GetCookieListFromStore( | 50 net::CookieMonster::CookieList GetCookieListFromStore( |
50 net::CookieStore* cookie_store, const GURL& url); | 51 net::CookieStore* cookie_store, const GURL& url); |
51 | 52 |
52 // Constructs a URL from a cookie's information for use in checking | 53 // Constructs a URL from a cookie's information for use in checking |
53 // a cookie against the extension's host permissions. The Secure | 54 // a cookie against the extension's host permissions. The Secure |
54 // property of the cookie defines the URL scheme, and the cookie's | 55 // property of the cookie defines the URL scheme, and the cookie's |
55 // domain becomes the URL host. | 56 // domain becomes the URL host. |
56 GURL GetURLFromCookiePair( | 57 GURL GetURLFromCookiePair( |
57 const net::CookieMonster::CookieListPair& cookie_pair); | 58 const net::CookieMonster::CookieListPair& cookie_pair); |
58 | 59 |
59 // Looks through all cookies in the given cookie store, and appends to the | 60 // Looks through all cookies in the given cookie store, and appends to the |
60 // match list all the cookies that both match the given URL and cookie details | 61 // match list all the cookies that both match the given URL and cookie details |
61 // and are allowed by extension host permissions. | 62 // and are allowed by extension host permissions. |
62 void AppendMatchingCookiesToList( | 63 void AppendMatchingCookiesToList( |
63 net::CookieStore* cookie_store, const std::string& store_id, | 64 const net::CookieMonster::CookieList& all_cookies, |
| 65 const std::string& store_id, |
64 const GURL& url, const DictionaryValue* details, | 66 const GURL& url, const DictionaryValue* details, |
65 const Extension* extension, | 67 const Extension* extension, |
66 ListValue* match_list); | 68 ListValue* match_list); |
67 | 69 |
68 // Appends the IDs of all tabs belonging to the given browser to the | 70 // Appends the IDs of all tabs belonging to the given browser to the |
69 // given list. | 71 // given list. |
70 void AppendToTabIdList(Browser* browser, ListValue* tab_ids); | 72 void AppendToTabIdList(Browser* browser, ListValue* tab_ids); |
71 | 73 |
72 // A class representing the cookie filter parameters passed into | 74 // A class representing the cookie filter parameters passed into |
73 // cookies.getAll(). | 75 // cookies.getAll(). |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // as '.foo.bar.com', and both will match cookies with domain values of | 107 // as '.foo.bar.com', and both will match cookies with domain values of |
106 // 'foo.bar.com', '.foo.bar.com', and 'baz.foo.bar.com'. | 108 // 'foo.bar.com', '.foo.bar.com', and 'baz.foo.bar.com'. |
107 bool MatchesDomain(const std::string& domain); | 109 bool MatchesDomain(const std::string& domain); |
108 | 110 |
109 const DictionaryValue* details_; | 111 const DictionaryValue* details_; |
110 }; | 112 }; |
111 | 113 |
112 } // namespace extension_cookies_helpers | 114 } // namespace extension_cookies_helpers |
113 | 115 |
114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ | 116 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ |
OLD | NEW |