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

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

Issue 15841013: Make miscellaneous_bindings and event_bindings Required as needed. Previously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « chrome/renderer/extensions/miscellaneous_bindings.cc ('k') | chrome/renderer/extensions/module_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/module_system.h
diff --git a/chrome/renderer/extensions/module_system.h b/chrome/renderer/extensions/module_system.h
index a3c9606d7ef8874f6ed6dfa7e58be2877eb39855..a242a87cf3e6ac41388a14b8872ecad42c2818dd 100644
--- a/chrome/renderer/extensions/module_system.h
+++ b/chrome/renderer/extensions/module_system.h
@@ -16,8 +16,14 @@
#include <string>
#include <vector>
+namespace WebKit {
+class WebFrame;
+}
+
namespace extensions {
+class ChromeV8Context;
+
// A module system for JS similar to node.js' require() function.
// Each module has three variables in the global scope:
// - exports, an object returned to dependencies who require() this
@@ -46,7 +52,11 @@ class ModuleSystem : public ObjectBackedNativeHandler {
class ExceptionHandler {
public:
virtual ~ExceptionHandler() {}
- virtual void HandleUncaughtException() = 0;
+ virtual void HandleUncaughtException(const v8::TryCatch& try_catch) = 0;
+
+ protected:
+ // Formats |try_catch| as a nice string.
+ std::string CreateExceptionString(const v8::TryCatch& try_catch);
};
// Enables native bindings for the duration of its lifetime.
@@ -61,7 +71,7 @@ class ModuleSystem : public ObjectBackedNativeHandler {
};
// |source_map| is a weak pointer.
- ModuleSystem(v8::Handle<v8::Context> context, SourceMap* source_map);
+ ModuleSystem(ChromeV8Context* context, SourceMap* source_map);
virtual ~ModuleSystem();
// Require the specified module. This is the equivalent of calling
@@ -73,13 +83,15 @@ class ModuleSystem : public ObjectBackedNativeHandler {
// equivalent to calling require('module_name').method_name() from JS.
v8::Local<v8::Value> CallModuleMethod(const std::string& module_name,
const std::string& method_name);
-
- // Calls the specified method exported by the specified module. This is
- // equivalent to calling require('module_name').method_name(args) from JS.
v8::Local<v8::Value> CallModuleMethod(
const std::string& module_name,
const std::string& method_name,
std::vector<v8::Handle<v8::Value> >* args);
+ v8::Local<v8::Value> CallModuleMethod(
+ const std::string& module_name,
+ const std::string& method_name,
+ int argc,
+ v8::Handle<v8::Value> argv[]);
// Register |native_handler| as a potential target for requireNative(), so
// calls to requireNative(|name|) from JS will return a new object created by
@@ -177,6 +189,8 @@ class ModuleSystem : public ObjectBackedNativeHandler {
// Wraps |source| in a (function(require, requireNative, exports) {...}).
v8::Handle<v8::String> WrapSource(v8::Handle<v8::String> source);
+ ChromeV8Context* context_;
+
// A map from module names to the JS source for that module. GetSource()
// performs a lookup on this map.
SourceMap* source_map_;
@@ -188,8 +202,8 @@ class ModuleSystem : public ObjectBackedNativeHandler {
// pinned natives as enabled.
int natives_enabled_;
- // Called when an exception is thrown but not caught in JS.
- // Non-NULL in tests only.
+ // Called when an exception is thrown but not caught in JS. Overridable by
+ // tests.
scoped_ptr<ExceptionHandler> exception_handler_;
std::set<std::string> overridden_native_handlers_;
« no previous file with comments | « chrome/renderer/extensions/miscellaneous_bindings.cc ('k') | chrome/renderer/extensions/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698