OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
| 6 #define CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "content/public/renderer/v8_value_converter.h" |
| 12 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
| 13 #include "gin/handle.h" |
| 14 #include "gin/interceptor.h" |
| 15 #include "gin/object_template_builder.h" |
| 16 #include "gin/wrappable.h" |
| 17 |
| 18 namespace blink { |
| 19 class WebFrame; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class GinJavaBridgeObject : public gin::Wrappable<GinJavaBridgeObject>, |
| 25 public gin::NamedPropertyInterceptor, |
| 26 public content::V8ValueConverter::Strategy { |
| 27 public: |
| 28 // gin::Wrappable. |
| 29 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 30 v8::Isolate* isolate) OVERRIDE; |
| 31 |
| 32 // gin::NamedPropertyInterceptor |
| 33 virtual v8::Local<v8::Value> GetNamedProperty( |
| 34 v8::Isolate* isolate, const std::string& property) OVERRIDE; |
| 35 virtual std::vector<std::string> EnumerateNamedProperties( |
| 36 v8::Isolate* isolate) OVERRIDE; |
| 37 |
| 38 // content::V8ValueConverter::Strategy |
| 39 virtual bool FromV8Object(v8::Handle<v8::Object> value, |
| 40 base::Value** out, |
| 41 v8::Isolate* isolate, |
| 42 const FromV8ValueCallback& callback) const OVERRIDE; |
| 43 virtual bool FromV8ArrayBuffer(v8::Handle<v8::Object> value, |
| 44 base::Value** out) const OVERRIDE; |
| 45 virtual bool FromV8Number(v8::Handle<v8::Number> value, |
| 46 base::Value** out) const OVERRIDE; |
| 47 virtual bool FromV8Undefined(base::Value** out) const OVERRIDE; |
| 48 |
| 49 static GinJavaBridgeObject* Inject( |
| 50 blink::WebFrame* frame, |
| 51 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
| 52 const std::string& object_name, |
| 53 GinJavaBridgeDispatcher::ObjectID object_id); |
| 54 static GinJavaBridgeObject* InjectAnonymous( |
| 55 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
| 56 GinJavaBridgeDispatcher::ObjectID object_id); |
| 57 static bool InjectExisting(blink::WebFrame* frame, |
| 58 GinJavaBridgeObject* object, |
| 59 const std::string& object_name); |
| 60 |
| 61 static gin::WrapperInfo kWrapperInfo; |
| 62 |
| 63 private: |
| 64 GinJavaBridgeObject(v8::Isolate* isolate, |
| 65 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
| 66 GinJavaBridgeDispatcher::ObjectID object_id); |
| 67 virtual ~GinJavaBridgeObject(); |
| 68 |
| 69 v8::Handle<v8::Value> InvokeMethod(const std::string& name, |
| 70 gin::Arguments* args); |
| 71 |
| 72 base::WeakPtr<GinJavaBridgeDispatcher> dispatcher_; |
| 73 GinJavaBridgeDispatcher::ObjectID object_id_; |
| 74 scoped_ptr<V8ValueConverter> converter_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeObject); |
| 77 }; |
| 78 |
| 79 } // namespace content |
| 80 |
| 81 #endif // CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
OLD | NEW |