summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_function.h
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 23:09:10 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 23:09:10 +0000
commit73404a373b7c8ca68793d58a0750d086dc49fdda (patch)
treeeb9a0569b42fd3235913754df7a2baf79abb9e4f /chrome/browser/extensions/extension_function.h
parentbc5987b6febaa0562c1f21e91197937a53116a30 (diff)
downloadchromium_src-73404a373b7c8ca68793d58a0750d086dc49fdda.zip
chromium_src-73404a373b7c8ca68793d58a0750d086dc49fdda.tar.gz
chromium_src-73404a373b7c8ca68793d58a0750d086dc49fdda.tar.bz2
A subset of the bookmarks API- missing events- missing unit tests- missing ability to change URL
Review URL: http://codereview.chromium.org/77003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_function.h')
-rw-r--r--chrome/browser/extensions/extension_function.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h
index 421df81..ed8fe9e 100644
--- a/chrome/browser/extensions/extension_function.h
+++ b/chrome/browser/extensions/extension_function.h
@@ -11,12 +11,21 @@
#include "base/scoped_ptr.h"
class ExtensionFunctionDispatcher;
+class Profile;
+
+#define EXTENSION_FUNCTION_VALIDATE(test) do { \
+ if (!test) { \
+ bad_message_ = true; \
+ return false; \
+ } \
+ } while (0)
// Base class for an extension function.
// TODO(aa): This will have to become reference counted when we introduce APIs
// that live beyond a single stack frame.
class ExtensionFunction {
public:
+ ExtensionFunction() : bad_message_(false) {}
virtual ~ExtensionFunction() {}
void set_dispatcher(ExtensionFunctionDispatcher* dispatcher) {
@@ -43,6 +52,8 @@ class ExtensionFunction {
protected:
void SendResponse(bool success);
+ Profile* profile();
+
// The arguments to the API. Only non-null if argument were specfied.
Value* args_;
@@ -54,9 +65,15 @@ class ExtensionFunction {
// class before Run() returns.
std::string error_;
+ // Any class that gets a malformed message should set this to true before
+ // returning. The calling renderer process will be killed.
+ bool bad_message_;
+
private:
ExtensionFunctionDispatcher* dispatcher_;
int callback_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionFunction);
};
@@ -69,6 +86,8 @@ class ExtensionFunction {
// need to interact with things on the browser UI thread.
class SyncExtensionFunction : public ExtensionFunction {
public:
+ SyncExtensionFunction() {}
+
// Derived classes should implement this method to do their work and return
// success/failure.
virtual bool RunImpl() = 0;
@@ -76,6 +95,9 @@ class SyncExtensionFunction : public ExtensionFunction {
virtual void Run() {
SendResponse(RunImpl());
}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction);
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_