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 #ifndef CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ | 5 #ifndef CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
6 #define CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ | 6 #define CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/renderer/java/gin_java_bridge_dispatcher.h" | 12 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
13 #include "gin/handle.h" | 13 #include "gin/handle.h" |
14 #include "gin/interceptor.h" | 14 #include "gin/interceptor.h" |
15 #include "gin/object_template_builder.h" | 15 #include "gin/object_template_builder.h" |
16 #include "gin/wrappable.h" | 16 #include "gin/wrappable.h" |
17 #include "v8/include/v8-util.h" | 17 #include "v8/include/v8-util.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 class WebFrame; | 20 class WebLocalFrame; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class GinJavaBridgeObject : public gin::Wrappable<GinJavaBridgeObject>, | 25 class GinJavaBridgeObject : public gin::Wrappable<GinJavaBridgeObject>, |
26 public gin::NamedPropertyInterceptor { | 26 public gin::NamedPropertyInterceptor { |
27 public: | 27 public: |
28 static gin::WrapperInfo kWrapperInfo; | 28 static gin::WrapperInfo kWrapperInfo; |
29 | 29 |
30 GinJavaBridgeDispatcher::ObjectID object_id() const { return object_id_; } | 30 GinJavaBridgeDispatcher::ObjectID object_id() const { return object_id_; } |
31 | 31 |
32 // gin::Wrappable. | 32 // gin::Wrappable. |
33 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 33 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
34 v8::Isolate* isolate) override; | 34 v8::Isolate* isolate) override; |
35 | 35 |
36 // gin::NamedPropertyInterceptor | 36 // gin::NamedPropertyInterceptor |
37 v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate, | 37 v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate, |
38 const std::string& property) override; | 38 const std::string& property) override; |
39 std::vector<std::string> EnumerateNamedProperties( | 39 std::vector<std::string> EnumerateNamedProperties( |
40 v8::Isolate* isolate) override; | 40 v8::Isolate* isolate) override; |
41 | 41 |
42 static GinJavaBridgeObject* InjectNamed( | 42 static GinJavaBridgeObject* InjectNamed( |
43 blink::WebFrame* frame, | 43 blink::WebLocalFrame* frame, |
44 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, | 44 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
45 const std::string& object_name, | 45 const std::string& object_name, |
46 GinJavaBridgeDispatcher::ObjectID object_id); | 46 GinJavaBridgeDispatcher::ObjectID object_id); |
47 static GinJavaBridgeObject* InjectAnonymous( | 47 static GinJavaBridgeObject* InjectAnonymous( |
48 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, | 48 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
49 GinJavaBridgeDispatcher::ObjectID object_id); | 49 GinJavaBridgeDispatcher::ObjectID object_id); |
50 | 50 |
51 private: | 51 private: |
52 GinJavaBridgeObject(v8::Isolate* isolate, | 52 GinJavaBridgeObject(v8::Isolate* isolate, |
53 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, | 53 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher, |
54 GinJavaBridgeDispatcher::ObjectID object_id); | 54 GinJavaBridgeDispatcher::ObjectID object_id); |
55 ~GinJavaBridgeObject() override; | 55 ~GinJavaBridgeObject() override; |
56 | 56 |
57 v8::Local<v8::FunctionTemplate> GetFunctionTemplate(v8::Isolate* isolate, | 57 v8::Local<v8::FunctionTemplate> GetFunctionTemplate(v8::Isolate* isolate, |
58 const std::string& name); | 58 const std::string& name); |
59 | 59 |
60 base::WeakPtr<GinJavaBridgeDispatcher> dispatcher_; | 60 base::WeakPtr<GinJavaBridgeDispatcher> dispatcher_; |
61 GinJavaBridgeDispatcher::ObjectID object_id_; | 61 GinJavaBridgeDispatcher::ObjectID object_id_; |
62 int frame_routing_id_; | 62 int frame_routing_id_; |
63 std::map<std::string, bool> known_methods_; | 63 std::map<std::string, bool> known_methods_; |
64 v8::StdGlobalValueMap<std::string, v8::FunctionTemplate> template_cache_; | 64 v8::StdGlobalValueMap<std::string, v8::FunctionTemplate> template_cache_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeObject); | 66 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeObject); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace content | 69 } // namespace content |
70 | 70 |
71 #endif // CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ | 71 #endif // CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_ |
OLD | NEW |