Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: chrome/renderer/extensions/chrome_v8_extension.h

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/chrome_v8_extension.h
diff --git a/chrome/renderer/extensions/chrome_v8_extension.h b/chrome/renderer/extensions/chrome_v8_extension.h
index 511273fba3760c88da5b5fb51dc5fd455664e512..bf5ee33848cf7244a2b08a7e13eced86fb0e8db7 100644
--- a/chrome/renderer/extensions/chrome_v8_extension.h
+++ b/chrome/renderer/extensions/chrome_v8_extension.h
@@ -45,11 +45,9 @@ class ChromeV8Extension : public v8::Extension {
void ContextWillBeReleased(ChromeV8Context* context);
Aaron Boodman 2012/02/16 01:54:42 This might no longer be needed.
koz (OOO until 15th September) 2012/02/27 01:06:14 Removed.
- // Derived classes should call this at the end of their implementation in
- // order to expose common native functions, like GetChromeHidden, to the
- // v8 extension.
- virtual v8::Handle<v8::FunctionTemplate>
- GetNativeFunction(v8::Handle<v8::String> name) OVERRIDE;
+ // Derived classes should override this to set up named functions on
+ // |object|.
+ virtual void SetNativeFunctions(v8::Handle<v8::Object> object) {}
protected:
template<class T>
@@ -59,6 +57,8 @@ class ChromeV8Extension : public v8::Extension {
return result;
}
+ static v8::Handle<v8::Value> Router(const v8::Arguments& args);
Aaron Boodman 2012/02/16 01:54:42 This should not be exposed as interface. It can be
koz (OOO until 15th September) 2012/02/27 01:06:14 Done.
+
// Gets the render view for the current v8 context.
static content::RenderView* GetCurrentRenderView();
@@ -73,32 +73,24 @@ class ChromeV8Extension : public v8::Extension {
bool CheckCurrentContextAccessToExtensionAPI(
const std::string& function_name) const;
- // Create a handler for |context|. If a subclass of ChromeV8Extension wishes
- // to support handlers, it should override this.
- virtual ChromeV8ExtensionHandler* CreateHandler(ChromeV8Context* context);
+ // Handle a native function call from JavaScript.
+ virtual v8::Handle<v8::Value> HandleNativeFunction(
+ const std::string& function_name, const v8::Arguments& args);
+
+ // Causes the object to set a function named |name| on |object| that gets
+ // handled by HandleNativeFunction().
+ void RouteFunctionHere(const char* name, v8::Handle<v8::Object> object);
Aaron Boodman 2012/02/16 01:54:42 I think something like AddNativeFunction would be
- // Returns the chromeHidden object for the current context.
- static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args);
+ typedef v8::Handle<v8::Value> (*HandlerFunction)(const v8::Arguments& args);
+ // Causes the object to set |function| on |object| with name |name|.
+ void RouteFunctionToStatic(const char* name, HandlerFunction function,
+ v8::Handle<v8::Object> object);
ExtensionDispatcher* extension_dispatcher_;
private:
static base::StringPiece GetStringResource(int resource_id);
- // Helper to print from bindings javascript.
- static v8::Handle<v8::Value> Print(const v8::Arguments& args);
-
- // Handle a native function call from JavaScript.
- static v8::Handle<v8::Value> HandleNativeFunction(const v8::Arguments& args);
-
- // Get the handler instance for |context|, or NULL if no such context exists.
- ChromeV8ExtensionHandler* GetHandler(ChromeV8Context* context) const;
-
- // Map of all current handlers.
- typedef std::map<ChromeV8Context*,
- linked_ptr<ChromeV8ExtensionHandler> > HandlerMap;
- HandlerMap handlers_;
-
DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension);
};

Powered by Google App Engine
This is Rietveld 408576698