Implement a module system for the extension bindings JS.
BUG=104100
TEST=existing browser tests
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=125132
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=125801
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=126306
Review URL: http://codereview.chromium.org/9386001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127117 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/native_handler.h b/chrome/renderer/native_handler.h
index b4d3078e..f595a0d 100644
--- a/chrome/renderer/native_handler.h
+++ b/chrome/renderer/native_handler.h
@@ -16,6 +16,12 @@
// A NativeHandler is a factory for JS objects with functions on them that map
// to native C++ functions. Subclasses should call RouteFunction() in their
// constructor to define functions on the created JS objects.
+//
+// NativeHandlers are intended to be used with a ModuleSystem. The ModuleSystem
+// will assume ownership of the NativeHandler, and as a ModuleSystem is tied to
+// a single v8::Context, this implies that NativeHandlers will also be tied to
+// a single v8::context.
+// TODO(koz): Rename this to NativeJavaScriptModule.
class NativeHandler {
public:
explicit NativeHandler();
@@ -26,6 +32,7 @@
v8::Handle<v8::Object> NewInstance();
protected:
+ typedef v8::Handle<v8::Value> (*HandlerFunc)(const v8::Arguments&);
typedef base::Callback<v8::Handle<v8::Value>(const v8::Arguments&)>
HandlerFunction;
@@ -35,6 +42,9 @@
void RouteFunction(const std::string& name,
const HandlerFunction& handler_function);
+ void RouteStaticFunction(const std::string& name,
+ const HandlerFunc handler_func);
+
private:
static v8::Handle<v8::Value> Router(const v8::Arguments& args);