| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 // Helper class for tests to force all ExtensionFunction::user_gesture() | 162 // Helper class for tests to force all ExtensionFunction::user_gesture() |
| 163 // calls to return true as long as at least one instance of this class | 163 // calls to return true as long as at least one instance of this class |
| 164 // exists. | 164 // exists. |
| 165 class ScopedUserGestureForTests { | 165 class ScopedUserGestureForTests { |
| 166 public: | 166 public: |
| 167 ScopedUserGestureForTests(); | 167 ScopedUserGestureForTests(); |
| 168 ~ScopedUserGestureForTests(); | 168 ~ScopedUserGestureForTests(); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 // A string used in the case of an unknown error being detected. |
| 172 // DON'T USE THIS. It's only here during conversion to flag cases where errors |
| 173 // aren't already set. |
| 174 // TODO(devlin): Remove this if/when all functions are updated to return real |
| 175 // errors. |
| 176 static const char* kUnknownErrorDoNotUse; |
| 177 |
| 171 // Called before Run() in order to perform a common verification check so that | 178 // Called before Run() in order to perform a common verification check so that |
| 172 // APIs subclassing this don't have to roll their own RunSafe() variants. | 179 // APIs subclassing this don't have to roll their own RunSafe() variants. |
| 173 // If this returns false, then Run() is never called, and the function | 180 // If this returns false, then Run() is never called, and the function |
| 174 // responds immediately with an error (note that error must be non-empty in | 181 // responds immediately with an error (note that error must be non-empty in |
| 175 // this case). If this returns true, execution continues on to Run(). | 182 // this case). If this returns true, execution continues on to Run(). |
| 176 virtual bool PreRunValidation(std::string* error); | 183 virtual bool PreRunValidation(std::string* error); |
| 177 | 184 |
| 178 // Runs the extension function if PreRunValidation() succeeds. | 185 // Runs the extension function if PreRunValidation() succeeds. |
| 179 ResponseAction RunWithValidation(); | 186 ResponseAction RunWithValidation(); |
| 180 | 187 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 private: | 662 private: |
| 656 // If you're hitting a compile error here due to "final" - great! You're | 663 // If you're hitting a compile error here due to "final" - great! You're |
| 657 // doing the right thing, you just need to extend UIThreadExtensionFunction | 664 // doing the right thing, you just need to extend UIThreadExtensionFunction |
| 658 // instead of AsyncExtensionFunction. | 665 // instead of AsyncExtensionFunction. |
| 659 ResponseAction Run() final; | 666 ResponseAction Run() final; |
| 660 | 667 |
| 661 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); | 668 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); |
| 662 }; | 669 }; |
| 663 | 670 |
| 664 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ | 671 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ |
| OLD | NEW |