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. | |
50 net::CookieMonster::CookieList GetCookieListFromStore( | 49 net::CookieMonster::CookieList GetCookieListFromStore( |
51 net::CookieStore* cookie_store, const GURL& url); | 50 net::CookieStore* cookie_store, const GURL& url); |
52 | 51 |
53 // Constructs a URL from a cookie's information for use in checking | 52 // Constructs a URL from a cookie's information for use in checking |
54 // a cookie against the extension's host permissions. The Secure | 53 // a cookie against the extension's host permissions. The Secure |
55 // property of the cookie defines the URL scheme, and the cookie's | 54 // property of the cookie defines the URL scheme, and the cookie's |
56 // domain becomes the URL host. | 55 // domain becomes the URL host. |
57 GURL GetURLFromCookiePair( | 56 GURL GetURLFromCookiePair( |
58 const net::CookieMonster::CookieListPair& cookie_pair); | 57 const net::CookieMonster::CookieListPair& cookie_pair); |
59 | 58 |
60 // Looks through all cookies in the given cookie store, and appends to the | 59 // Looks through all cookies in the given cookie store, and appends to the |
61 // match list all the cookies that both match the given URL and cookie details | 60 // match list all the cookies that both match the given URL and cookie details |
62 // and are allowed by extension host permissions. | 61 // and are allowed by extension host permissions. |
63 void AppendMatchingCookiesToList( | 62 void AppendMatchingCookiesToList( |
64 const net::CookieMonster::CookieList& all_cookies, | 63 net::CookieStore* cookie_store, const std::string& store_id, |
65 const std::string& store_id, | |
66 const GURL& url, const DictionaryValue* details, | 64 const GURL& url, const DictionaryValue* details, |
67 const Extension* extension, | 65 const Extension* extension, |
68 ListValue* match_list); | 66 ListValue* match_list); |
69 | 67 |
70 // Appends the IDs of all tabs belonging to the given browser to the | 68 // Appends the IDs of all tabs belonging to the given browser to the |
71 // given list. | 69 // given list. |
72 void AppendToTabIdList(Browser* browser, ListValue* tab_ids); | 70 void AppendToTabIdList(Browser* browser, ListValue* tab_ids); |
73 | 71 |
74 // A class representing the cookie filter parameters passed into | 72 // A class representing the cookie filter parameters passed into |
75 // cookies.getAll(). | 73 // cookies.getAll(). |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // as '.foo.bar.com', and both will match cookies with domain values of | 105 // as '.foo.bar.com', and both will match cookies with domain values of |
108 // 'foo.bar.com', '.foo.bar.com', and 'baz.foo.bar.com'. | 106 // 'foo.bar.com', '.foo.bar.com', and 'baz.foo.bar.com'. |
109 bool MatchesDomain(const std::string& domain); | 107 bool MatchesDomain(const std::string& domain); |
110 | 108 |
111 const DictionaryValue* details_; | 109 const DictionaryValue* details_; |
112 }; | 110 }; |
113 | 111 |
114 } // namespace extension_cookies_helpers | 112 } // namespace extension_cookies_helpers |
115 | 113 |
116 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_HELPERS_H_ |
OLD | NEW |