| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/java/gin_java_bridge_object.h" | 5 #include "content/renderer/java/gin_java_bridge_object.h" |
| 6 | 6 |
| 7 #include "content/renderer/java/gin_java_function_invocation_helper.h" | 7 #include "content/renderer/java/gin_java_function_invocation_helper.h" |
| 8 #include "gin/function_template.h" | 8 #include "gin/function_template.h" |
| 9 #include "third_party/WebKit/public/web/WebFrame.h" | 9 #include "third_party/WebKit/public/web/WebFrame.h" |
| 10 #include "third_party/WebKit/public/web/WebKit.h" | 10 #include "third_party/WebKit/public/web/WebKit.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 GinJavaBridgeObject* GinJavaBridgeObject::InjectNamed( | 15 GinJavaBridgeObject* GinJavaBridgeObject::InjectNamed( |
| 16 blink::WebFrame* frame, | 16 blink::WebFrame* frame, |
| 17 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, | 17 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
| 18 const std::string& object_name, | 18 const std::string& object_name, |
| 19 GinJavaBridgeDispatcher::ObjectID object_id) { | 19 GinJavaBridgeDispatcher::ObjectID object_id) { |
| 20 v8::Isolate* isolate = blink::mainThreadIsolate(); | 20 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 21 v8::HandleScope handle_scope(isolate); | 21 v8::HandleScope handle_scope(isolate); |
| 22 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 22 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 23 if (context.IsEmpty()) | 23 if (context.IsEmpty()) |
| 24 return NULL; | 24 return NULL; |
| 25 | 25 |
| 26 GinJavaBridgeObject* object = | 26 GinJavaBridgeObject* object = |
| 27 new GinJavaBridgeObject(isolate, dispatcher, object_id); | 27 new GinJavaBridgeObject(isolate, dispatcher, object_id); |
| 28 | 28 |
| 29 v8::Context::Scope context_scope(context); | 29 v8::Context::Scope context_scope(context); |
| 30 v8::Handle<v8::Object> global = context->Global(); | 30 v8::Local<v8::Object> global = context->Global(); |
| 31 gin::Handle<GinJavaBridgeObject> controller = | 31 gin::Handle<GinJavaBridgeObject> controller = |
| 32 gin::CreateHandle(isolate, object); | 32 gin::CreateHandle(isolate, object); |
| 33 // WrappableBase instance deletes itself in case of a wrapper | 33 // WrappableBase instance deletes itself in case of a wrapper |
| 34 // creation failure, thus there is no need to delete |object|. | 34 // creation failure, thus there is no need to delete |object|. |
| 35 if (controller.IsEmpty()) | 35 if (controller.IsEmpty()) |
| 36 return NULL; | 36 return NULL; |
| 37 | 37 |
| 38 global->Set(gin::StringToV8(isolate, object_name), controller.ToV8()); | 38 global->Set(gin::StringToV8(isolate, object_name), controller.ToV8()); |
| 39 return object; | 39 return object; |
| 40 } | 40 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 isolate, base::Bind(&GinJavaFunctionInvocationHelper::Invoke, | 103 isolate, base::Bind(&GinJavaFunctionInvocationHelper::Invoke, |
| 104 base::Owned(new GinJavaFunctionInvocationHelper( | 104 base::Owned(new GinJavaFunctionInvocationHelper( |
| 105 name, dispatcher_)))); | 105 name, dispatcher_)))); |
| 106 template_cache_.Set(name, function_template); | 106 template_cache_.Set(name, function_template); |
| 107 return function_template; | 107 return function_template; |
| 108 } | 108 } |
| 109 | 109 |
| 110 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; | 110 gin::WrapperInfo GinJavaBridgeObject::kWrapperInfo = {gin::kEmbedderNativeGin}; |
| 111 | 111 |
| 112 } // namespace content | 112 } // namespace content |
| OLD | NEW |