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

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

Issue 11547033: Implement declarativeContent API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 11 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/module_system.h ('k') | chrome/renderer/resources/extensions/content_watcher.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/module_system.cc
diff --git a/chrome/renderer/extensions/module_system.cc b/chrome/renderer/extensions/module_system.cc
index 69b2c78fddf1b215350b554030c2f7bd7149c871..aa33bbc1a6e30e11c9b44a42cdfe289c7dc1699b 100644
--- a/chrome/renderer/extensions/module_system.cc
+++ b/chrome/renderer/extensions/module_system.cc
@@ -5,6 +5,7 @@
#include "chrome/renderer/extensions/module_system.h"
#include "base/bind.h"
+#include "base/stl_util.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSuppression.h"
namespace {
@@ -159,29 +160,39 @@ v8::Handle<v8::Value> ModuleSystem::RequireForJsInner(
void ModuleSystem::CallModuleMethod(const std::string& module_name,
const std::string& method_name) {
+ std::vector<v8::Handle<v8::Value> > args;
+ CallModuleMethod(module_name, method_name, &args);
+}
+
+v8::Local<v8::Value> ModuleSystem::CallModuleMethod(
+ const std::string& module_name,
+ const std::string& method_name,
+ std::vector<v8::Handle<v8::Value> >* args) {
v8::HandleScope handle_scope;
v8::Local<v8::Value> module =
v8::Local<v8::Value>::New(
RequireForJsInner(v8::String::New(module_name.c_str())));
if (module.IsEmpty() || !module->IsObject())
- return;
+ return v8::Local<v8::Value>();
v8::Local<v8::Value> value =
v8::Handle<v8::Object>::Cast(module)->Get(
v8::String::New(method_name.c_str()));
if (value.IsEmpty() || !value->IsFunction())
- return;
+ return v8::Local<v8::Value>();
v8::Handle<v8::Function> func =
v8::Handle<v8::Function>::Cast(value);
// TODO(jeremya/koz): refer to context_ here, not the current context.
v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global());
+ v8::Local<v8::Value> result;
{
WebKit::WebScopedMicrotaskSuppression suppression;
v8::TryCatch try_catch;
try_catch.SetCaptureMessage(true);
- func->Call(global, 0, NULL);
+ result = func->Call(global, args->size(), vector_as_array(args));
if (try_catch.HasCaught())
HandleException(try_catch);
}
+ return handle_scope.Close(result);
}
void ModuleSystem::RegisterNativeHandler(const std::string& name,
« no previous file with comments | « chrome/renderer/extensions/module_system.h ('k') | chrome/renderer/resources/extensions/content_watcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698