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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_api.h

Issue 10702088: Refactor chrome.cookies API to use JSON schema compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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
OLDNEW
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 #pragma once 10 #pragma once
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // common functionality for parsing cookies API function arguments. 69 // common functionality for parsing cookies API function arguments.
70 // Note that all of the functions in this file derive from 70 // Note that all of the functions in this file derive from
71 // AsyncExtensionFunction, and are not threadsafe, so they should not be 71 // AsyncExtensionFunction, and are not threadsafe, so they should not be
72 // concurrently accessed from multiple threads. They modify |result_| and other 72 // concurrently accessed from multiple threads. They modify |result_| and other
73 // member variables directly. 73 // member variables directly.
74 // See chrome/browser/extensions/extension_function.h for more information. 74 // See chrome/browser/extensions/extension_function.h for more information.
75 class CookiesFunction : public AsyncExtensionFunction { 75 class CookiesFunction : public AsyncExtensionFunction {
76 protected: 76 protected:
77 virtual ~CookiesFunction() {} 77 virtual ~CookiesFunction() {}
78 78
79 // Looks for a 'url' value in the given details dictionary and constructs a 79 // Constructs a GURL from the given url string. Returns false and assigns the
80 // GURL from it. Returns false and assigns the internal error_ value if the 80 // internal error_ value if the URL is invalid. If check_host_permissions is
81 // URL is invalid or isn't found in the dictionary. If check_host_permissions 81 // true, the URL is also checked against the extension's host permissions, and
82 // is true, the URL is also checked against the extension's host permissions, 82 // if there is no permission for the URL, this function returns false.
83 // and if there is no permission for the URL, this function returns false. 83 bool ParseUrl(std::string url_string, GURL* url, bool check_host_permissions);
Aaron Boodman 2012/07/04 00:04:31 Input params that are non-primitive should almost
mitchellwrosen 2012/07/04 02:04:40 Done.
84 bool ParseUrl(const base::DictionaryValue* details, GURL* url,
85 bool check_host_permissions);
86 84
87 // Checks the given details dictionary for a 'storeId' value, and retrieves 85 // If |store_id| is non-NULL, retrieves the specified store. Otherwise,
88 // the cookie store context and the store ID associated with it. If the 86 // retrieves the current execution context's store. Returns false on error
89 // 'storeId' value isn't found in the dictionary, the current execution 87 // and assigns the internal error_ value if that occurs. At least one of the
90 // context's cookie store context is retrieved. Returns false on error and 88 // output parameters context and out_store_id should be non-NULL.
91 // assigns the internal error_ value if that occurs. 89 bool ParseStoreContext(std::string* in_store_id,
Aaron Boodman 2012/07/04 00:04:31 Can you just have a single std::string* store_id a
mitchellwrosen 2012/07/04 02:04:40 Can you elaborate on this? How can you assign to s
Aaron Boodman 2012/07/04 06:35:40 Right you are. You could use empty string for the
92 // At least one of the output parameters store and store_id should be
93 // non-NULL.
94 bool ParseStoreContext(const base::DictionaryValue* details,
95 net::URLRequestContextGetter** context, 90 net::URLRequestContextGetter** context,
96 std::string* store_id); 91 std::string* out_store_id);
97 }; 92 };
98 93
99 // Implements the cookies.get() extension function. 94 // Implements the cookies.get() extension function.
100 class GetCookieFunction : public CookiesFunction { 95 class GetCookieFunction : public CookiesFunction {
101 public: 96 public:
102 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") 97 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get")
103 98
104 GetCookieFunction(); 99 GetCookieFunction();
105 100
106 protected: 101 protected:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 204
210 // ExtensionFunction: 205 // ExtensionFunction:
211 // GetAllCookieStoresFunction is sync. 206 // GetAllCookieStoresFunction is sync.
212 virtual void Run() OVERRIDE; 207 virtual void Run() OVERRIDE;
213 virtual bool RunImpl() OVERRIDE; 208 virtual bool RunImpl() OVERRIDE;
214 }; 209 };
215 210
216 } // namespace extensions 211 } // namespace extensions
217 212
218 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ 213 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698