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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compilation Created 7 years, 9 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/send_request_natives.h ('k') | chrome/renderer/extensions/set_icon_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/send_request_natives.cc
diff --git a/chrome/renderer/extensions/send_request_natives.cc b/chrome/renderer/extensions/send_request_natives.cc
index b788a8af7a99439ad60b58b3e1726b5c9440a8c7..be87840dcd105ed2d0ff2f1446f027dbdfe68883 100644
--- a/chrome/renderer/extensions/send_request_natives.cc
+++ b/chrome/renderer/extensions/send_request_natives.cc
@@ -13,14 +13,20 @@ using content::V8ValueConverter;
namespace extensions {
SendRequestNatives::SendRequestNatives(Dispatcher* dispatcher,
- RequestSender* request_sender)
- : ChromeV8Extension(dispatcher), request_sender_(request_sender) {
+ RequestSender* request_sender,
+ ChromeV8Context* context)
+ : ChromeV8Extension(dispatcher, context->v8_context()),
+ request_sender_(request_sender),
+ context_(context) {
RouteFunction("GetNextRequestId",
base::Bind(&SendRequestNatives::GetNextRequestId,
base::Unretained(this)));
RouteFunction("StartRequest",
base::Bind(&SendRequestNatives::StartRequest,
base::Unretained(this)));
+ RouteFunction("GetGlobal",
+ base::Bind(&SendRequestNatives::GetGlobal,
+ base::Unretained(this)));
}
v8::Handle<v8::Value> SendRequestNatives::GetNextRequestId(
@@ -42,22 +48,28 @@ v8::Handle<v8::Value> SendRequestNatives::StartRequest(
scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
// See http://crbug.com/149880. The context menus APIs relies on this, but
- // we shouln't really be doing it (e.g. for the sake of the storage API).
+ // we shouldn't really be doing it (e.g. for the sake of the storage API).
converter->SetFunctionAllowed(true);
if (!preserve_null_in_objects)
converter->SetStripNullFromObjects(true);
- scoped_ptr<Value> value_args(
- converter->FromV8Value(args[1], v8::Context::GetCurrent()));
+ scoped_ptr<Value> value_args(converter->FromV8Value(args[1], v8_context()));
if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) {
NOTREACHED() << "Unable to convert args passed to StartRequest";
return v8::Undefined();
}
- request_sender_->StartRequest(name, request_id, has_callback, for_io_thread,
- static_cast<ListValue*>(value_args.get()));
+ request_sender_->StartRequest(
+ context_, name, request_id, has_callback, for_io_thread,
+ static_cast<ListValue*>(value_args.get()));
return v8::Undefined();
}
+v8::Handle<v8::Value> SendRequestNatives::GetGlobal(const v8::Arguments& args) {
+ CHECK_EQ(1, args.Length());
+ CHECK(args[0]->IsObject());
+ return v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global();
+}
+
} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/send_request_natives.h ('k') | chrome/renderer/extensions/set_icon_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698