summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/automation_extension_function.h
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:58:33 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 22:58:33 +0000
commitb83e4600fc1c2f1c42598f8d89dbd36d9415309d (patch)
tree4b2ee497813a59a91105f91f6a5329224da18eac /chrome/browser/automation/automation_extension_function.h
parenta9a2668386addfa40ff262005d396468f54b99e2 (diff)
downloadchromium_src-b83e4600fc1c2f1c42598f8d89dbd36d9415309d.zip
chromium_src-b83e4600fc1c2f1c42598f8d89dbd36d9415309d.tar.gz
chromium_src-b83e4600fc1c2f1c42598f8d89dbd36d9415309d.tar.bz2
First step to enable end-to-end testing of extensions through the
automation interface. This adds a method to turn on automation of extension API functions, plumbing that redirects API requests through the automation interface when appropriate, and a couple of UITests that exercise the functionality. See http://codereview.chromium.org/113277 for the original review. Review URL: http://codereview.chromium.org/115427 Patch from Joi Sigurdsson <joi.sigurdsson@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_extension_function.h')
-rw-r--r--chrome/browser/automation/automation_extension_function.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_extension_function.h b/chrome/browser/automation/automation_extension_function.h
new file mode 100644
index 0000000..a399cd7
--- /dev/null
+++ b/chrome/browser/automation/automation_extension_function.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Defines AutomationExtensionFunction.
+
+#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_
+#define CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_
+
+#include <string>
+
+#include "base/singleton.h"
+#include "chrome/browser/extensions/extension_function.h"
+
+class RenderViewHost;
+
+// An extension function that pipes the extension API call through the
+// automation interface, so that extensions can be tested using UITests.
+class AutomationExtensionFunction : public ExtensionFunction {
+ public:
+ AutomationExtensionFunction() { }
+
+ // ExtensionFunction implementation.
+ virtual void SetName(const std::string& name);
+ virtual void SetArgs(const std::string& args);
+ virtual const std::string GetResult();
+ virtual const std::string GetError();
+ virtual void Run();
+
+ static ExtensionFunction* Factory();
+
+ // If enabled, we set an instance of this function as the functor
+ // for all function names in ExtensionFunctionFactoryRegistry.
+ // If disabled, we restore the initial functions.
+ static void SetEnabled(bool enabled);
+
+ // Intercepts messages sent from the external host to check if they
+ // are actually responses to extension API calls. If they are, redirects
+ // the message to view_host->SendExtensionResponse and returns true,
+ // otherwise returns false to indicate the message was not intercepted.
+ static bool InterceptMessageFromExternalHost(RenderViewHost* view_host,
+ const std::string& message,
+ const std::string& origin,
+ const std::string& target);
+
+ private:
+ static bool enabled_;
+ std::string name_;
+ std::string args_;
+ DISALLOW_COPY_AND_ASSIGN(AutomationExtensionFunction);
+};
+
+#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EXTENSION_FUNCTION_H_