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

Unified Diff: extensions/renderer/script_context.cc

Issue 359413004: Add support for using AMD modules from extensions modules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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: extensions/renderer/script_context.cc
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index 60a558b6c37fd21e6d9576f1e6f9f57476195d0c..882837de7628cb18801e66b46f20f04a3c618a3d 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -16,6 +16,7 @@
#include "extensions/common/extension_api.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/features/base_feature_provider.h"
+#include "gin/per_context_data.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
@@ -42,6 +43,7 @@ ScriptContext::ScriptContext(const v8::Handle<v8::Context>& v8_context,
<< " extension id: " << GetExtensionID() << "\n"
<< " frame: " << web_frame_ << "\n"
<< " context type: " << GetContextTypeDescription();
+ gin::PerContextData::From(v8_context)->set_runner(this);
}
ScriptContext::~ScriptContext() {
@@ -221,4 +223,21 @@ void ScriptContext::OnResponseReceived(const std::string& name,
<< *v8::String::Utf8Value(retval);
}
+void ScriptContext::Run(const std::string& source,
+ const std::string& resource_name) {
+ module_system_->RunString(source, resource_name);
+}
+
+v8::Handle<v8::Value> ScriptContext::Call(v8::Handle<v8::Function> function,
+ v8::Handle<v8::Value> receiver,
+ int argc,
+ v8::Handle<v8::Value> argv[]) {
+ return CallFunction(function, argc, argv);
+}
+
+gin::ContextHolder* ScriptContext::GetContextHolder() {
+ v8::HandleScope handle_scope(isolate());
+ return gin::PerContextData::From(v8_context())->context_holder();
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698