OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // The function has succeeded. | 88 // The function has succeeded. |
89 SUCCEEDED, | 89 SUCCEEDED, |
90 // The function has failed. | 90 // The function has failed. |
91 FAILED, | 91 FAILED, |
92 // The input message is malformed. | 92 // The input message is malformed. |
93 BAD_MESSAGE | 93 BAD_MESSAGE |
94 }; | 94 }; |
95 | 95 |
96 typedef base::Callback<void(ResponseType type, | 96 typedef base::Callback<void(ResponseType type, |
97 const base::ListValue& results, | 97 const base::ListValue& results, |
98 const std::string& error)> ResponseCallback; | 98 const std::string& error, |
| 99 bool retain_user_gesture)> ResponseCallback; |
99 | 100 |
100 ExtensionFunction(); | 101 ExtensionFunction(); |
101 | 102 |
102 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction(); | 103 virtual UIThreadExtensionFunction* AsUIThreadExtensionFunction(); |
103 virtual IOThreadExtensionFunction* AsIOThreadExtensionFunction(); | 104 virtual IOThreadExtensionFunction* AsIOThreadExtensionFunction(); |
104 | 105 |
105 // Returns true if the function has permission to run. | 106 // Returns true if the function has permission to run. |
106 // | 107 // |
107 // The default implementation is to check the Extension's permissions against | 108 // The default implementation is to check the Extension's permissions against |
108 // what this function requires to run, but some APIs may require finer | 109 // what this function requires to run, but some APIs may require finer |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 176 |
176 void set_has_callback(bool has_callback) { has_callback_ = has_callback; } | 177 void set_has_callback(bool has_callback) { has_callback_ = has_callback; } |
177 bool has_callback() { return has_callback_; } | 178 bool has_callback() { return has_callback_; } |
178 | 179 |
179 void set_include_incognito(bool include) { include_incognito_ = include; } | 180 void set_include_incognito(bool include) { include_incognito_ = include; } |
180 bool include_incognito() const { return include_incognito_; } | 181 bool include_incognito() const { return include_incognito_; } |
181 | 182 |
182 void set_user_gesture(bool user_gesture) { user_gesture_ = user_gesture; } | 183 void set_user_gesture(bool user_gesture) { user_gesture_ = user_gesture; } |
183 bool user_gesture() const { return user_gesture_; } | 184 bool user_gesture() const { return user_gesture_; } |
184 | 185 |
| 186 void set_retain_user_gesture(bool retain_user_gesture) { |
| 187 retain_user_gesture_ = retain_user_gesture; |
| 188 } |
| 189 bool retain_user_gesture() const { return retain_user_gesture_; } |
| 190 |
185 void set_histogram_value( | 191 void set_histogram_value( |
186 extensions::functions::HistogramValue histogram_value) { | 192 extensions::functions::HistogramValue histogram_value) { |
187 histogram_value_ = histogram_value; } | 193 histogram_value_ = histogram_value; } |
188 extensions::functions::HistogramValue histogram_value() const { | 194 extensions::functions::HistogramValue histogram_value() const { |
189 return histogram_value_; } | 195 return histogram_value_; } |
190 | 196 |
191 void set_response_callback(const ResponseCallback& callback) { | 197 void set_response_callback(const ResponseCallback& callback) { |
192 response_callback_ = callback; | 198 response_callback_ = callback; |
193 } | 199 } |
194 | 200 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 244 |
239 // True if this callback should include information from incognito contexts | 245 // True if this callback should include information from incognito contexts |
240 // even if our profile_ is non-incognito. Note that in the case of a "split" | 246 // even if our profile_ is non-incognito. Note that in the case of a "split" |
241 // mode extension, this will always be false, and we will limit access to | 247 // mode extension, this will always be false, and we will limit access to |
242 // data from within the same profile_ (either incognito or not). | 248 // data from within the same profile_ (either incognito or not). |
243 bool include_incognito_; | 249 bool include_incognito_; |
244 | 250 |
245 // True if the call was made in response of user gesture. | 251 // True if the call was made in response of user gesture. |
246 bool user_gesture_; | 252 bool user_gesture_; |
247 | 253 |
| 254 // True if the response callback should retain the |user_gesture_| bit when |
| 255 // sending the function response. |
| 256 bool retain_user_gesture_; |
| 257 |
248 // The arguments to the API. Only non-null if argument were specified. | 258 // The arguments to the API. Only non-null if argument were specified. |
249 scoped_ptr<base::ListValue> args_; | 259 scoped_ptr<base::ListValue> args_; |
250 | 260 |
251 // The results of the API. This should be populated by the derived class | 261 // The results of the API. This should be populated by the derived class |
252 // before SendResponse() is called. | 262 // before SendResponse() is called. |
253 scoped_ptr<base::ListValue> results_; | 263 scoped_ptr<base::ListValue> results_; |
254 | 264 |
255 // Any detailed error from the API. This should be populated by the derived | 265 // Any detailed error from the API. This should be populated by the derived |
256 // class before Run() returns. | 266 // class before Run() returns. |
257 std::string error_; | 267 std::string error_; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 public: | 456 public: |
447 SyncIOThreadExtensionFunction(); | 457 SyncIOThreadExtensionFunction(); |
448 | 458 |
449 virtual void Run() OVERRIDE; | 459 virtual void Run() OVERRIDE; |
450 | 460 |
451 protected: | 461 protected: |
452 virtual ~SyncIOThreadExtensionFunction(); | 462 virtual ~SyncIOThreadExtensionFunction(); |
453 }; | 463 }; |
454 | 464 |
455 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 465 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
OLD | NEW |