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