| 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 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 chrome/common/extensions/api/extension_api.json. | 6 // cookies, as specified in chrome/common/extensions/api/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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // non-NULL. | 87 // non-NULL. |
| 88 bool ParseStoreContext(const DictionaryValue* details, | 88 bool ParseStoreContext(const DictionaryValue* details, |
| 89 URLRequestContextGetter** context, | 89 URLRequestContextGetter** context, |
| 90 std::string* store_id); | 90 std::string* store_id); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 // Implements the cookies.get() extension function. | 93 // Implements the cookies.get() extension function. |
| 94 class GetCookieFunction : public CookiesFunction { | 94 class GetCookieFunction : public CookiesFunction { |
| 95 public: | 95 public: |
| 96 GetCookieFunction(); | 96 GetCookieFunction(); |
| 97 ~GetCookieFunction(); |
| 97 virtual bool RunImpl(); | 98 virtual bool RunImpl(); |
| 98 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") | 99 DECLARE_EXTENSION_FUNCTION_NAME("cookies.get") |
| 99 | 100 |
| 100 private: | 101 private: |
| 101 void GetCookieOnIOThread(); | 102 void GetCookieOnIOThread(); |
| 102 void RespondOnUIThread(); | 103 void RespondOnUIThread(); |
| 103 | 104 |
| 104 std::string name_; | 105 std::string name_; |
| 105 GURL url_; | 106 GURL url_; |
| 106 std::string store_id_; | 107 std::string store_id_; |
| 107 scoped_refptr<URLRequestContextGetter> store_context_; | 108 scoped_refptr<URLRequestContextGetter> store_context_; |
| 108 net::CookieMonster::CookieList cookie_list_; | 109 net::CookieMonster::CookieList cookie_list_; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 // Implements the cookies.getAll() extension function. | 112 // Implements the cookies.getAll() extension function. |
| 112 class GetAllCookiesFunction : public CookiesFunction { | 113 class GetAllCookiesFunction : public CookiesFunction { |
| 113 public: | 114 public: |
| 114 GetAllCookiesFunction(); | 115 GetAllCookiesFunction(); |
| 116 ~GetAllCookiesFunction(); |
| 115 virtual bool RunImpl(); | 117 virtual bool RunImpl(); |
| 116 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll") | 118 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAll") |
| 117 | 119 |
| 118 private: | 120 private: |
| 119 void GetAllCookiesOnIOThread(); | 121 void GetAllCookiesOnIOThread(); |
| 120 void RespondOnUIThread(); | 122 void RespondOnUIThread(); |
| 121 | 123 |
| 122 DictionaryValue* details_; | 124 DictionaryValue* details_; |
| 123 GURL url_; | 125 GURL url_; |
| 124 std::string store_id_; | 126 std::string store_id_; |
| 125 scoped_refptr<URLRequestContextGetter> store_context_; | 127 scoped_refptr<URLRequestContextGetter> store_context_; |
| 126 net::CookieMonster::CookieList cookie_list_; | 128 net::CookieMonster::CookieList cookie_list_; |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 // Implements the cookies.set() extension function. | 131 // Implements the cookies.set() extension function. |
| 130 class SetCookieFunction : public CookiesFunction { | 132 class SetCookieFunction : public CookiesFunction { |
| 131 public: | 133 public: |
| 132 SetCookieFunction(); | 134 SetCookieFunction(); |
| 135 ~SetCookieFunction(); |
| 133 virtual bool RunImpl(); | 136 virtual bool RunImpl(); |
| 134 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set") | 137 DECLARE_EXTENSION_FUNCTION_NAME("cookies.set") |
| 135 | 138 |
| 136 private: | 139 private: |
| 137 void SetCookieOnIOThread(); | 140 void SetCookieOnIOThread(); |
| 138 void RespondOnUIThread(); | 141 void RespondOnUIThread(); |
| 139 | 142 |
| 140 GURL url_; | 143 GURL url_; |
| 141 std::string name_; | 144 std::string name_; |
| 142 std::string value_; | 145 std::string value_; |
| 143 std::string domain_; | 146 std::string domain_; |
| 144 std::string path_; | 147 std::string path_; |
| 145 bool secure_; | 148 bool secure_; |
| 146 bool http_only_; | 149 bool http_only_; |
| 147 base::Time expiration_time_; | 150 base::Time expiration_time_; |
| 148 bool success_; | 151 bool success_; |
| 149 scoped_refptr<URLRequestContextGetter> store_context_; | 152 scoped_refptr<URLRequestContextGetter> store_context_; |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 // Implements the cookies.remove() extension function. | 155 // Implements the cookies.remove() extension function. |
| 153 class RemoveCookieFunction : public CookiesFunction { | 156 class RemoveCookieFunction : public CookiesFunction { |
| 154 public: | 157 public: |
| 155 virtual bool RunImpl(); | 158 virtual bool RunImpl(); |
| 156 // RemoveCookieFunction is sync. | 159 // RemoveCookieFunction is sync. |
| 157 virtual void Run() { | 160 virtual void Run(); |
| 158 SendResponse(RunImpl()); | |
| 159 } | |
| 160 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove") | 161 DECLARE_EXTENSION_FUNCTION_NAME("cookies.remove") |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 // Implements the cookies.getAllCookieStores() extension function. | 164 // Implements the cookies.getAllCookieStores() extension function. |
| 164 class GetAllCookieStoresFunction : public CookiesFunction { | 165 class GetAllCookieStoresFunction : public CookiesFunction { |
| 165 public: | 166 public: |
| 166 virtual bool RunImpl(); | 167 virtual bool RunImpl(); |
| 167 // GetAllCookieStoresFunction is sync. | 168 // GetAllCookieStoresFunction is sync. |
| 168 virtual void Run() { | 169 virtual void Run(); |
| 169 SendResponse(RunImpl()); | |
| 170 } | |
| 171 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") | 170 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") |
| 172 }; | 171 }; |
| 173 | 172 |
| 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ | 173 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ |
| OLD | NEW |