Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1051)

Side by Side Diff: content/renderer/java/gin_java_bridge_dispatcher.h

Issue 259033002: [Android] Implement renderer side of Gin Java Bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_DISPATCHER_H_
6 #define CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_DISPATCHER_H_
7
8 #include <map>
9 #include <set>
10
11 #include "base/id_map.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/values.h"
15 #include "content/public/renderer/render_frame_observer.h"
16
17 namespace blink {
18 class WebFrame;
19 }
20
21 namespace content {
22
23 class GinJavaBridgeObject;
24
25 // This class handles injecting Java objects into the main frame of a
26 // RenderView. The 'add' and 'remove' messages received from the browser
27 // process modify the entries in a map of 'pending' objects. These objects are
28 // bound to the window object of the main frame when that window object is next
29 // cleared. These objects remain bound until the window object is cleared
30 // again.
31 class GinJavaBridgeDispatcher
32 : public base::SupportsWeakPtr<GinJavaBridgeDispatcher>,
33 public RenderFrameObserver {
34 public:
35 // GinJavaBridgeObjects are managed by gin. An object gets destroyed
36 // when it is no more referenced from JS. As GinJavaBridgeObject reports
37 // deletion of self to GinJavaBridgeDispatcher, we would not have stale
38 // pointers here.
39 typedef IDMap<GinJavaBridgeObject, IDMapExternalPointer> ObjectMap;
40 typedef ObjectMap::KeyType ObjectID;
41
42 GinJavaBridgeDispatcher(RenderFrame* render_frame);
jochen (gone - plz use gerrit) 2014/04/29 13:50:16 explicit
mnaganov (inactive) 2014/04/30 16:46:26 Done.
43 virtual ~GinJavaBridgeDispatcher();
44
45 // RenderFrameObserver override:
46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
47 virtual void DidClearWindowObject(int world_id) OVERRIDE;
48
49 void GetJavaMethods(ObjectID object_id, std::set<std::string>* methods);
50 bool HasJavaMethod(ObjectID object_id, const std::string& method_name);
51 scoped_ptr<base::Value> InvokeJavaMethod(ObjectID object_id,
52 const std::string& method_name,
53 const base::ListValue& arguments);
54 GinJavaBridgeObject* GetObject(ObjectID object_id);
55 void OnGinJavaBridgeObjectDeleted(ObjectID object_id);
56
57 private:
58 void OnAddNamedObject(const std::string& name,
59 ObjectID object_id);
60 void OnRemoveNamedObject(const std::string& name);
61 void OnSetAllowObjectContentsInspection(bool allow);
62
63 typedef std::map<std::string, ObjectID> NamedObjectMap;
64 NamedObjectMap named_objects_;
65 ObjectMap objects_;
66
67 DISALLOW_COPY_AND_ASSIGN(GinJavaBridgeDispatcher);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_RENDERER_JAVA_GIN_JAVA_BRIDGE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698