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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Gets the store identified by |store_id| and returns it in |context|. | 81 // Gets the store identified by |store_id| and returns it in |context|. |
82 // If |store_id| contains an empty string, retrieves the current execution | 82 // If |store_id| contains an empty string, retrieves the current execution |
83 // context's store. In this case, |store_id| is populated with the found | 83 // context's store. In this case, |store_id| is populated with the found |
84 // store, and |context| can be NULL if the caller only wants |store_id|. | 84 // store, and |context| can be NULL if the caller only wants |store_id|. |
85 bool ParseStoreContext(std::string* store_id, | 85 bool ParseStoreContext(std::string* store_id, |
86 net::URLRequestContextGetter** context); | 86 net::URLRequestContextGetter** context); |
87 }; | 87 }; |
88 | 88 |
89 // Implements the cookies.get() extension function. | 89 // Implements the cookies.get() extension function. |
90 class GetCookieFunction : public CookiesFunction { | 90 class CookiesGetFunction : public CookiesFunction { |
91 public: | 91 public: |
92 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") | 92 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") |
93 | 93 |
94 GetCookieFunction(); | 94 CookiesGetFunction(); |
95 | 95 |
96 protected: | 96 protected: |
97 virtual ~GetCookieFunction(); | 97 virtual ~CookiesGetFunction(); |
98 | 98 |
99 // ExtensionFunction: | 99 // ExtensionFunction: |
100 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
101 | 101 |
102 private: | 102 private: |
103 void GetCookieOnIOThread(); | 103 void GetCookieOnIOThread(); |
104 void RespondOnUIThread(); | 104 void RespondOnUIThread(); |
105 void GetCookieCallback(const net::CookieList& cookie_list); | 105 void GetCookieCallback(const net::CookieList& cookie_list); |
106 | 106 |
107 GURL url_; | 107 GURL url_; |
108 scoped_refptr<net::URLRequestContextGetter> store_context_; | 108 scoped_refptr<net::URLRequestContextGetter> store_context_; |
109 scoped_ptr<extensions::api::cookies::Get::Params> parsed_args_; | 109 scoped_ptr<extensions::api::cookies::Get::Params> parsed_args_; |
110 }; | 110 }; |
111 | 111 |
112 // Implements the cookies.getAll() extension function. | 112 // Implements the cookies.getAll() extension function. |
113 class GetAllCookiesFunction : public CookiesFunction { | 113 class CookiesGetAllFunction : public CookiesFunction { |
114 public: | 114 public: |
115 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll") | 115 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll") |
116 | 116 |
117 GetAllCookiesFunction(); | 117 CookiesGetAllFunction(); |
118 | 118 |
119 protected: | 119 protected: |
120 virtual ~GetAllCookiesFunction(); | 120 virtual ~CookiesGetAllFunction(); |
121 | 121 |
122 // ExtensionFunction: | 122 // ExtensionFunction: |
123 virtual bool RunImpl() OVERRIDE; | 123 virtual bool RunImpl() OVERRIDE; |
124 | 124 |
125 private: | 125 private: |
126 void GetAllCookiesOnIOThread(); | 126 void GetAllCookiesOnIOThread(); |
127 void RespondOnUIThread(); | 127 void RespondOnUIThread(); |
128 void GetAllCookiesCallback(const net::CookieList& cookie_list); | 128 void GetAllCookiesCallback(const net::CookieList& cookie_list); |
129 | 129 |
130 GURL url_; | 130 GURL url_; |
131 scoped_refptr<net::URLRequestContextGetter> store_context_; | 131 scoped_refptr<net::URLRequestContextGetter> store_context_; |
132 scoped_ptr<extensions::api::cookies::GetAll::Params> parsed_args_; | 132 scoped_ptr<extensions::api::cookies::GetAll::Params> parsed_args_; |
133 }; | 133 }; |
134 | 134 |
135 // Implements the cookies.set() extension function. | 135 // Implements the cookies.set() extension function. |
136 class SetCookieFunction : public CookiesFunction { | 136 class CookiesSetFunction : public CookiesFunction { |
137 public: | 137 public: |
138 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set") | 138 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set") |
139 | 139 |
140 SetCookieFunction(); | 140 CookiesSetFunction(); |
141 | 141 |
142 protected: | 142 protected: |
143 virtual ~SetCookieFunction(); | 143 virtual ~CookiesSetFunction(); |
144 virtual bool RunImpl() OVERRIDE; | 144 virtual bool RunImpl() OVERRIDE; |
145 | 145 |
146 private: | 146 private: |
147 void SetCookieOnIOThread(); | 147 void SetCookieOnIOThread(); |
148 void RespondOnUIThread(); | 148 void RespondOnUIThread(); |
149 void PullCookie(bool set_cookie_); | 149 void PullCookie(bool set_cookie_); |
150 void PullCookieCallback(const net::CookieList& cookie_list); | 150 void PullCookieCallback(const net::CookieList& cookie_list); |
151 | 151 |
152 GURL url_; | 152 GURL url_; |
153 bool success_; | 153 bool success_; |
154 scoped_refptr<net::URLRequestContextGetter> store_context_; | 154 scoped_refptr<net::URLRequestContextGetter> store_context_; |
155 scoped_ptr<extensions::api::cookies::Set::Params> parsed_args_; | 155 scoped_ptr<extensions::api::cookies::Set::Params> parsed_args_; |
156 }; | 156 }; |
157 | 157 |
158 // Implements the cookies.remove() extension function. | 158 // Implements the cookies.remove() extension function. |
159 class RemoveCookieFunction : public CookiesFunction { | 159 class CookiesRemoveFunction : public CookiesFunction { |
160 public: | 160 public: |
161 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove") | 161 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove") |
162 | 162 |
163 RemoveCookieFunction(); | 163 CookiesRemoveFunction(); |
164 | 164 |
165 protected: | 165 protected: |
166 virtual ~RemoveCookieFunction(); | 166 virtual ~CookiesRemoveFunction(); |
167 | 167 |
168 // ExtensionFunction: | 168 // ExtensionFunction: |
169 virtual bool RunImpl() OVERRIDE; | 169 virtual bool RunImpl() OVERRIDE; |
170 | 170 |
171 private: | 171 private: |
172 void RemoveCookieOnIOThread(); | 172 void RemoveCookieOnIOThread(); |
173 void RespondOnUIThread(); | 173 void RespondOnUIThread(); |
174 void RemoveCookieCallback(); | 174 void RemoveCookieCallback(); |
175 | 175 |
176 GURL url_; | 176 GURL url_; |
177 scoped_refptr<net::URLRequestContextGetter> store_context_; | 177 scoped_refptr<net::URLRequestContextGetter> store_context_; |
178 scoped_ptr<extensions::api::cookies::Remove::Params> parsed_args_; | 178 scoped_ptr<extensions::api::cookies::Remove::Params> parsed_args_; |
179 }; | 179 }; |
180 | 180 |
181 // Implements the cookies.getAllCookieStores() extension function. | 181 // Implements the cookies.getAllCookieStores() extension function. |
182 class GetAllCookieStoresFunction : public CookiesFunction { | 182 class CookiesGetAllCookieStoresFunction : public CookiesFunction { |
183 public: | 183 public: |
184 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") | 184 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") |
185 | 185 |
186 protected: | 186 protected: |
187 virtual ~GetAllCookieStoresFunction() {} | 187 virtual ~CookiesGetAllCookieStoresFunction() {} |
188 | 188 |
189 // ExtensionFunction: | 189 // ExtensionFunction: |
190 // GetAllCookieStoresFunction is sync. | 190 // CookiesGetAllCookieStoresFunction is sync. |
191 virtual void Run() OVERRIDE; | 191 virtual void Run() OVERRIDE; |
192 virtual bool RunImpl() OVERRIDE; | 192 virtual bool RunImpl() OVERRIDE; |
193 }; | 193 }; |
194 | 194 |
195 class CookiesAPI : public ProfileKeyedAPI, | 195 class CookiesAPI : public ProfileKeyedAPI, |
196 public extensions::EventRouter::Observer { | 196 public extensions::EventRouter::Observer { |
197 public: | 197 public: |
198 explicit CookiesAPI(Profile* profile); | 198 explicit CookiesAPI(Profile* profile); |
199 virtual ~CookiesAPI(); | 199 virtual ~CookiesAPI(); |
200 | 200 |
(...skipping 20 matching lines...) Expand all Loading... |
221 | 221 |
222 // Created lazily upon OnListenerAdded. | 222 // Created lazily upon OnListenerAdded. |
223 scoped_ptr<CookiesEventRouter> cookies_event_router_; | 223 scoped_ptr<CookiesEventRouter> cookies_event_router_; |
224 | 224 |
225 DISALLOW_COPY_AND_ASSIGN(CookiesAPI); | 225 DISALLOW_COPY_AND_ASSIGN(CookiesAPI); |
226 }; | 226 }; |
227 | 227 |
228 } // namespace extensions | 228 } // namespace extensions |
229 | 229 |
230 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 230 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
OLD | NEW |