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

Unified Diff: extensions/renderer/app_runtime_custom_bindings.cc

Issue 1174343003: blink:bindings: Passes the global context instead of |this| in JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « extensions/renderer/app_runtime_custom_bindings.h ('k') | extensions/renderer/blob_native_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/app_runtime_custom_bindings.cc
diff --git a/extensions/renderer/app_runtime_custom_bindings.cc b/extensions/renderer/app_runtime_custom_bindings.cc
index 4302590d0a2cffc770bcab352000bee5da98cb7f..f279c846b3d092614281a4ea277a538b8600ebcc 100644
--- a/extensions/renderer/app_runtime_custom_bindings.cc
+++ b/extensions/renderer/app_runtime_custom_bindings.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/strings/string_number_conversions.h"
+#include "extensions/renderer/script_context.h"
#include "third_party/WebKit/public/platform/WebCString.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/web/WebBlob.h"
@@ -38,7 +39,20 @@ void SerializeToString(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::String::NewFromUtf8(args.GetIsolate(), v.c_str()));
}
-void CreateBlob(const v8::FunctionCallbackInfo<v8::Value>& args) {
+} // namespace
+
+namespace extensions {
+
+AppRuntimeCustomBindings::AppRuntimeCustomBindings(ScriptContext* context)
+ : ObjectBackedNativeHandler(context) {
+ RouteFunction("DeserializeString", base::Bind(&DeserializeString));
+ RouteFunction("SerializeToString", base::Bind(&SerializeToString));
+ RouteFunction("CreateBlob", base::Bind(&AppRuntimeCustomBindings::CreateBlob,
+ base::Unretained(this)));
+}
+
+void AppRuntimeCustomBindings::CreateBlob(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
DCHECK(args.Length() == 2);
DCHECK(args[0]->IsString());
DCHECK(args[1]->IsNumber());
@@ -50,18 +64,7 @@ void CreateBlob(const v8::FunctionCallbackInfo<v8::Value>& args) {
blink::WebBlob web_blob =
WebBlob::createFromFile(WebString::fromUTF8(blob_file_path), blob_length);
args.GetReturnValue().Set(
- web_blob.toV8Value(args.Holder(), args.GetIsolate()));
-}
-
-} // namespace
-
-namespace extensions {
-
-AppRuntimeCustomBindings::AppRuntimeCustomBindings(ScriptContext* context)
- : ObjectBackedNativeHandler(context) {
- RouteFunction("DeserializeString", base::Bind(&DeserializeString));
- RouteFunction("SerializeToString", base::Bind(&SerializeToString));
- RouteFunction("CreateBlob", base::Bind(&CreateBlob));
+ web_blob.toV8Value(context()->v8_context()->Global(), args.GetIsolate()));
}
} // namespace extensions
« no previous file with comments | « extensions/renderer/app_runtime_custom_bindings.h ('k') | extensions/renderer/blob_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698