Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / java / gin_java_bridge_object.h
blob2f6c6e4306aa389fe46f8f94a1fe27a861a9c23f
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/scoped_ptr.h"
11 #include "base/memory/weak_ptr.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"
18 namespace blink {
19 class WebFrame;
22 namespace content {
24 class GinJavaBridgeValueConverter;
26 class GinJavaBridgeObject : public gin::Wrappable<GinJavaBridgeObject>,
27 public gin::NamedPropertyInterceptor {
28 public:
29 static gin::WrapperInfo kWrapperInfo;
31 GinJavaBridgeDispatcher::ObjectID object_id() const { return object_id_; }
33 // gin::Wrappable.
34 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
35 v8::Isolate* isolate) OVERRIDE;
37 // gin::NamedPropertyInterceptor
38 virtual v8::Local<v8::Value> GetNamedProperty(
39 v8::Isolate* isolate, const std::string& property) OVERRIDE;
40 virtual std::vector<std::string> EnumerateNamedProperties(
41 v8::Isolate* isolate) OVERRIDE;
43 static GinJavaBridgeObject* InjectNamed(
44 blink::WebFrame* frame,
45 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher,
46 const std::string& object_name,
47 GinJavaBridgeDispatcher::ObjectID object_id);
48 static GinJavaBridgeObject* InjectAnonymous(
49 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher,
50 GinJavaBridgeDispatcher::ObjectID object_id);
52 private:
53 GinJavaBridgeObject(v8::Isolate* isolate,
54 const base::WeakPtr<GinJavaBridgeDispatcher>& dispatcher,
55 GinJavaBridgeDispatcher::ObjectID object_id);
56 virtual ~GinJavaBridgeObject();
58 v8::Handle<v8::Value> InvokeMethod(const std::string& name,
59 gin::Arguments* args);
61 base::WeakPtr<GinJavaBridgeDispatcher> dispatcher_;
62 GinJavaBridgeDispatcher::ObjectID object_id_;
63 scoped_ptr<GinJavaBridgeValueConverter> converter_;
64 std::map<std::string, bool> known_methods_;
66 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeObject);
69 } // namespace content
71 #endif // CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_OBJECT_H_