| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 AutomationExtensionFunction. | 5 // Defines AutomationExtensionFunction. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ | 7 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ |
| 8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ | 8 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "chrome/browser/extensions/extension_function.h" | 12 #include "chrome/browser/extensions/extension_function.h" |
| 13 | 13 |
| 14 class RenderViewHost; | 14 class RenderViewHost; |
| 15 | 15 |
| 16 // An extension function that pipes the extension API call through the | 16 // An extension function that pipes the extension API call through the |
| 17 // automation interface, so that extensions can be tested using UITests. | 17 // automation interface, so that extensions can be tested using UITests. |
| 18 class AutomationExtensionFunction : public ExtensionFunction { | 18 class AutomationExtensionFunction : public ExtensionFunction { |
| 19 public: | 19 public: |
| 20 AutomationExtensionFunction() { } | 20 AutomationExtensionFunction() { } |
| 21 | 21 |
| 22 // ExtensionFunction implementation. | 22 // ExtensionFunction implementation. |
| 23 virtual void SetArgs(const std::string& args); | 23 virtual void SetArgs(const Value* args); |
| 24 virtual const std::string GetResult(); | 24 virtual const std::string GetResult(); |
| 25 virtual const std::string GetError(); | 25 virtual const std::string GetError(); |
| 26 virtual void Run(); | 26 virtual void Run(); |
| 27 | 27 |
| 28 static ExtensionFunction* Factory(); | 28 static ExtensionFunction* Factory(); |
| 29 | 29 |
| 30 // If enabled, we set an instance of this function as the functor | 30 // If enabled, we set an instance of this function as the functor |
| 31 // for all function names in ExtensionFunctionFactoryRegistry. | 31 // for all function names in ExtensionFunctionFactoryRegistry. |
| 32 // If disabled, we restore the initial functions. | 32 // If disabled, we restore the initial functions. |
| 33 static void SetEnabled(bool enabled); | 33 static void SetEnabled(bool enabled); |
| 34 | 34 |
| 35 // Intercepts messages sent from the external host to check if they | 35 // Intercepts messages sent from the external host to check if they |
| 36 // are actually responses to extension API calls. If they are, redirects | 36 // are actually responses to extension API calls. If they are, redirects |
| 37 // the message to view_host->SendExtensionResponse and returns true, | 37 // the message to view_host->SendExtensionResponse and returns true, |
| 38 // otherwise returns false to indicate the message was not intercepted. | 38 // otherwise returns false to indicate the message was not intercepted. |
| 39 static bool InterceptMessageFromExternalHost(RenderViewHost* view_host, | 39 static bool InterceptMessageFromExternalHost(RenderViewHost* view_host, |
| 40 const std::string& message, | 40 const std::string& message, |
| 41 const std::string& origin, | 41 const std::string& origin, |
| 42 const std::string& target); | 42 const std::string& target); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 static bool enabled_; | 45 static bool enabled_; |
| 46 std::string args_; | 46 std::string args_; |
| 47 DISALLOW_COPY_AND_ASSIGN(AutomationExtensionFunction); | 47 DISALLOW_COPY_AND_ASSIGN(AutomationExtensionFunction); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ | 50 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_ |
| OLD | NEW |