| 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 // Defines the Chrome Extensions Cookies API functions for accessing internet | 5 // Defines the Chrome Extensions Cookies API functions for accessing internet |
| 6 // cookies, as specified in the extension API JSON. | 6 // cookies, as specified in the extension API JSON. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| 9 #define CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 class CookiesGetFunction : public ChromeAsyncExtensionFunction { | 64 class CookiesGetFunction : public ChromeAsyncExtensionFunction { |
| 65 public: | 65 public: |
| 66 DECLARE_EXTENSION_FUNCTION("cookies.get", COOKIES_GET) | 66 DECLARE_EXTENSION_FUNCTION("cookies.get", COOKIES_GET) |
| 67 | 67 |
| 68 CookiesGetFunction(); | 68 CookiesGetFunction(); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 virtual ~CookiesGetFunction(); | 71 virtual ~CookiesGetFunction(); |
| 72 | 72 |
| 73 // ExtensionFunction: | 73 // ExtensionFunction: |
| 74 virtual bool RunImpl() OVERRIDE; | 74 virtual bool RunAsync() OVERRIDE; |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 void GetCookieOnIOThread(); | 77 void GetCookieOnIOThread(); |
| 78 void RespondOnUIThread(); | 78 void RespondOnUIThread(); |
| 79 void GetCookieCallback(const net::CookieList& cookie_list); | 79 void GetCookieCallback(const net::CookieList& cookie_list); |
| 80 | 80 |
| 81 GURL url_; | 81 GURL url_; |
| 82 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; | 82 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; |
| 83 scoped_ptr<extensions::api::cookies::Get::Params> parsed_args_; | 83 scoped_ptr<extensions::api::cookies::Get::Params> parsed_args_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // Implements the cookies.getAll() extension function. | 86 // Implements the cookies.getAll() extension function. |
| 87 class CookiesGetAllFunction : public ChromeAsyncExtensionFunction { | 87 class CookiesGetAllFunction : public ChromeAsyncExtensionFunction { |
| 88 public: | 88 public: |
| 89 DECLARE_EXTENSION_FUNCTION("cookies.getAll", COOKIES_GETALL) | 89 DECLARE_EXTENSION_FUNCTION("cookies.getAll", COOKIES_GETALL) |
| 90 | 90 |
| 91 CookiesGetAllFunction(); | 91 CookiesGetAllFunction(); |
| 92 | 92 |
| 93 protected: | 93 protected: |
| 94 virtual ~CookiesGetAllFunction(); | 94 virtual ~CookiesGetAllFunction(); |
| 95 | 95 |
| 96 // ExtensionFunction: | 96 // ExtensionFunction: |
| 97 virtual bool RunImpl() OVERRIDE; | 97 virtual bool RunAsync() OVERRIDE; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 void GetAllCookiesOnIOThread(); | 100 void GetAllCookiesOnIOThread(); |
| 101 void RespondOnUIThread(); | 101 void RespondOnUIThread(); |
| 102 void GetAllCookiesCallback(const net::CookieList& cookie_list); | 102 void GetAllCookiesCallback(const net::CookieList& cookie_list); |
| 103 | 103 |
| 104 GURL url_; | 104 GURL url_; |
| 105 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; | 105 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; |
| 106 scoped_ptr<extensions::api::cookies::GetAll::Params> parsed_args_; | 106 scoped_ptr<extensions::api::cookies::GetAll::Params> parsed_args_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 // Implements the cookies.set() extension function. | 109 // Implements the cookies.set() extension function. |
| 110 class CookiesSetFunction : public ChromeAsyncExtensionFunction { | 110 class CookiesSetFunction : public ChromeAsyncExtensionFunction { |
| 111 public: | 111 public: |
| 112 DECLARE_EXTENSION_FUNCTION("cookies.set", COOKIES_SET) | 112 DECLARE_EXTENSION_FUNCTION("cookies.set", COOKIES_SET) |
| 113 | 113 |
| 114 CookiesSetFunction(); | 114 CookiesSetFunction(); |
| 115 | 115 |
| 116 protected: | 116 protected: |
| 117 virtual ~CookiesSetFunction(); | 117 virtual ~CookiesSetFunction(); |
| 118 virtual bool RunImpl() OVERRIDE; | 118 virtual bool RunAsync() OVERRIDE; |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 void SetCookieOnIOThread(); | 121 void SetCookieOnIOThread(); |
| 122 void RespondOnUIThread(); | 122 void RespondOnUIThread(); |
| 123 void PullCookie(bool set_cookie_); | 123 void PullCookie(bool set_cookie_); |
| 124 void PullCookieCallback(const net::CookieList& cookie_list); | 124 void PullCookieCallback(const net::CookieList& cookie_list); |
| 125 | 125 |
| 126 GURL url_; | 126 GURL url_; |
| 127 bool success_; | 127 bool success_; |
| 128 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; | 128 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; |
| 129 scoped_ptr<extensions::api::cookies::Set::Params> parsed_args_; | 129 scoped_ptr<extensions::api::cookies::Set::Params> parsed_args_; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 // Implements the cookies.remove() extension function. | 132 // Implements the cookies.remove() extension function. |
| 133 class CookiesRemoveFunction : public ChromeAsyncExtensionFunction { | 133 class CookiesRemoveFunction : public ChromeAsyncExtensionFunction { |
| 134 public: | 134 public: |
| 135 DECLARE_EXTENSION_FUNCTION("cookies.remove", COOKIES_REMOVE) | 135 DECLARE_EXTENSION_FUNCTION("cookies.remove", COOKIES_REMOVE) |
| 136 | 136 |
| 137 CookiesRemoveFunction(); | 137 CookiesRemoveFunction(); |
| 138 | 138 |
| 139 protected: | 139 protected: |
| 140 virtual ~CookiesRemoveFunction(); | 140 virtual ~CookiesRemoveFunction(); |
| 141 | 141 |
| 142 // ExtensionFunction: | 142 // ExtensionFunction: |
| 143 virtual bool RunImpl() OVERRIDE; | 143 virtual bool RunAsync() OVERRIDE; |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 void RemoveCookieOnIOThread(); | 146 void RemoveCookieOnIOThread(); |
| 147 void RespondOnUIThread(); | 147 void RespondOnUIThread(); |
| 148 void RemoveCookieCallback(); | 148 void RemoveCookieCallback(); |
| 149 | 149 |
| 150 GURL url_; | 150 GURL url_; |
| 151 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; | 151 scoped_refptr<net::URLRequestContextGetter> store_browser_context_; |
| 152 scoped_ptr<extensions::api::cookies::Remove::Params> parsed_args_; | 152 scoped_ptr<extensions::api::cookies::Remove::Params> parsed_args_; |
| 153 }; | 153 }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 // Created lazily upon OnListenerAdded. | 195 // Created lazily upon OnListenerAdded. |
| 196 scoped_ptr<CookiesEventRouter> cookies_event_router_; | 196 scoped_ptr<CookiesEventRouter> cookies_event_router_; |
| 197 | 197 |
| 198 DISALLOW_COPY_AND_ASSIGN(CookiesAPI); | 198 DISALLOW_COPY_AND_ASSIGN(CookiesAPI); |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 } // namespace extensions | 201 } // namespace extensions |
| 202 | 202 |
| 203 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 203 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| OLD | NEW |