Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/extensions/extension_cookies_api.h

Issue 10071035: RefCounted types should not have public destructors, chrome/browser/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_EXTENSION_COOKIES_API_H_ 8 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_
9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_
10 #pragma once 10 #pragma once
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 // Serves as a base class for all cookies API functions, and defines some 66 // Serves as a base class for all cookies API functions, and defines some
67 // common functionality for parsing cookies API function arguments. 67 // common functionality for parsing cookies API function arguments.
68 // Note that all of the functions in this file derive from 68 // Note that all of the functions in this file derive from
69 // AsyncExtensionFunction, and are not threadsafe, so they should not be 69 // AsyncExtensionFunction, and are not threadsafe, so they should not be
70 // concurrently accessed from multiple threads. They modify |result_| and other 70 // concurrently accessed from multiple threads. They modify |result_| and other
71 // member variables directly. 71 // member variables directly.
72 // See chrome/browser/extensions/extension_function.h for more information. 72 // See chrome/browser/extensions/extension_function.h for more information.
73 class CookiesFunction : public AsyncExtensionFunction { 73 class CookiesFunction : public AsyncExtensionFunction {
74 protected: 74 protected:
75 virtual ~CookiesFunction() {}
76
75 // Looks for a 'url' value in the given details dictionary and constructs a 77 // Looks for a 'url' value in the given details dictionary and constructs a
76 // GURL from it. Returns false and assigns the internal error_ value if the 78 // GURL from it. Returns false and assigns the internal error_ value if the
77 // URL is invalid or isn't found in the dictionary. If check_host_permissions 79 // URL is invalid or isn't found in the dictionary. If check_host_permissions
78 // is true, the URL is also checked against the extension's host permissions, 80 // is true, the URL is also checked against the extension's host permissions,
79 // and if there is no permission for the URL, this function returns false. 81 // and if there is no permission for the URL, this function returns false.
80 bool ParseUrl(const base::DictionaryValue* details, GURL* url, 82 bool ParseUrl(const base::DictionaryValue* details, GURL* url,
81 bool check_host_permissions); 83 bool check_host_permissions);
82 84
83 // Checks the given details dictionary for a 'storeId' value, and retrieves 85 // Checks the given details dictionary for a 'storeId' value, and retrieves
84 // the cookie store context and the store ID associated with it. If the 86 // the cookie store context and the store ID associated with it. If the
85 // 'storeId' value isn't found in the dictionary, the current execution 87 // 'storeId' value isn't found in the dictionary, the current execution
86 // context's cookie store context is retrieved. Returns false on error and 88 // context's cookie store context is retrieved. Returns false on error and
87 // assigns the internal error_ value if that occurs. 89 // assigns the internal error_ value if that occurs.
88 // At least one of the output parameters store and store_id should be 90 // At least one of the output parameters store and store_id should be
89 // non-NULL. 91 // non-NULL.
90 bool ParseStoreContext(const base::DictionaryValue* details, 92 bool ParseStoreContext(const base::DictionaryValue* details,
91 net::URLRequestContextGetter** context, 93 net::URLRequestContextGetter** context,
92 std::string* store_id); 94 std::string* store_id);
93 }; 95 };
94 96
95 // Implements the cookies.get() extension function. 97 // Implements the cookies.get() extension function.
96 class GetCookieFunction : public CookiesFunction { 98 class GetCookieFunction : public CookiesFunction {
97 public: 99 public:
100 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get")
101
98 GetCookieFunction(); 102 GetCookieFunction();
103
104 protected:
99 virtual ~GetCookieFunction(); 105 virtual ~GetCookieFunction();
106
107 // ExtensionFunction:
100 virtual bool RunImpl() OVERRIDE; 108 virtual bool RunImpl() OVERRIDE;
101 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get")
102 109
103 private: 110 private:
104 void GetCookieOnIOThread(); 111 void GetCookieOnIOThread();
105 void RespondOnUIThread(); 112 void RespondOnUIThread();
106 void GetCookieCallback(const net::CookieList& cookie_list); 113 void GetCookieCallback(const net::CookieList& cookie_list);
107 114
108 std::string name_; 115 std::string name_;
109 GURL url_; 116 GURL url_;
110 std::string store_id_; 117 std::string store_id_;
111 scoped_refptr<net::URLRequestContextGetter> store_context_; 118 scoped_refptr<net::URLRequestContextGetter> store_context_;
112 }; 119 };
113 120
114 // Implements the cookies.getAll() extension function. 121 // Implements the cookies.getAll() extension function.
115 class GetAllCookiesFunction : public CookiesFunction { 122 class GetAllCookiesFunction : public CookiesFunction {
116 public: 123 public:
124 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll")
125
117 GetAllCookiesFunction(); 126 GetAllCookiesFunction();
127
128 protected:
118 virtual ~GetAllCookiesFunction(); 129 virtual ~GetAllCookiesFunction();
130
131 // ExtensionFunction:
119 virtual bool RunImpl() OVERRIDE; 132 virtual bool RunImpl() OVERRIDE;
120 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll")
121 133
122 private: 134 private:
123 void GetAllCookiesOnIOThread(); 135 void GetAllCookiesOnIOThread();
124 void RespondOnUIThread(); 136 void RespondOnUIThread();
125 void GetAllCookiesCallback(const net::CookieList& cookie_list); 137 void GetAllCookiesCallback(const net::CookieList& cookie_list);
126 138
127 base::DictionaryValue* details_; 139 base::DictionaryValue* details_;
128 GURL url_; 140 GURL url_;
129 std::string store_id_; 141 std::string store_id_;
130 scoped_refptr<net::URLRequestContextGetter> store_context_; 142 scoped_refptr<net::URLRequestContextGetter> store_context_;
131 }; 143 };
132 144
133 // Implements the cookies.set() extension function. 145 // Implements the cookies.set() extension function.
134 class SetCookieFunction : public CookiesFunction { 146 class SetCookieFunction : public CookiesFunction {
135 public: 147 public:
148 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set")
149
136 SetCookieFunction(); 150 SetCookieFunction();
151
152 protected:
137 virtual ~SetCookieFunction(); 153 virtual ~SetCookieFunction();
138 virtual bool RunImpl() OVERRIDE; 154 virtual bool RunImpl() OVERRIDE;
139 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set")
140 155
141 private: 156 private:
142 void SetCookieOnIOThread(); 157 void SetCookieOnIOThread();
143 void RespondOnUIThread(); 158 void RespondOnUIThread();
144 void PullCookie(bool set_cookie_); 159 void PullCookie(bool set_cookie_);
145 void PullCookieCallback(const net::CookieList& cookie_list); 160 void PullCookieCallback(const net::CookieList& cookie_list);
146 161
147 GURL url_; 162 GURL url_;
148 std::string name_; 163 std::string name_;
149 std::string value_; 164 std::string value_;
150 std::string domain_; 165 std::string domain_;
151 std::string path_; 166 std::string path_;
152 bool secure_; 167 bool secure_;
153 bool http_only_; 168 bool http_only_;
154 base::Time expiration_time_; 169 base::Time expiration_time_;
155 bool success_; 170 bool success_;
156 std::string store_id_; 171 std::string store_id_;
157 scoped_refptr<net::URLRequestContextGetter> store_context_; 172 scoped_refptr<net::URLRequestContextGetter> store_context_;
158 }; 173 };
159 174
160 // Implements the cookies.remove() extension function. 175 // Implements the cookies.remove() extension function.
161 class RemoveCookieFunction : public CookiesFunction { 176 class RemoveCookieFunction : public CookiesFunction {
162 public: 177 public:
178 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove")
179
163 RemoveCookieFunction(); 180 RemoveCookieFunction();
181
182 protected:
164 virtual ~RemoveCookieFunction(); 183 virtual ~RemoveCookieFunction();
184
185 // ExtensionFunction:
165 virtual bool RunImpl() OVERRIDE; 186 virtual bool RunImpl() OVERRIDE;
166 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove")
167 187
168 private: 188 private:
169 void RemoveCookieOnIOThread(); 189 void RemoveCookieOnIOThread();
170 void RespondOnUIThread(); 190 void RespondOnUIThread();
171 void RemoveCookieCallback(); 191 void RemoveCookieCallback();
172 192
173 GURL url_; 193 GURL url_;
174 std::string name_; 194 std::string name_;
175 bool success_; 195 bool success_;
176 std::string store_id_; 196 std::string store_id_;
177 scoped_refptr<net::URLRequestContextGetter> store_context_; 197 scoped_refptr<net::URLRequestContextGetter> store_context_;
178 }; 198 };
179 199
180 // Implements the cookies.getAllCookieStores() extension function. 200 // Implements the cookies.getAllCookieStores() extension function.
181 class GetAllCookieStoresFunction : public CookiesFunction { 201 class GetAllCookieStoresFunction : public CookiesFunction {
182 public: 202 public:
183 virtual bool RunImpl() OVERRIDE; 203 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores")
204
205 protected:
206 virtual ~GetAllCookieStoresFunction() {}
207
208 // ExtensionFunction:
184 // GetAllCookieStoresFunction is sync. 209 // GetAllCookieStoresFunction is sync.
185 virtual void Run() OVERRIDE; 210 virtual void Run() OVERRIDE;
186 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") 211 virtual bool RunImpl() OVERRIDE;
187 }; 212 };
188 213
189 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ 214 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_context_menu_model.cc ('k') | chrome/browser/extensions/extension_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698