OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H
_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H
_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H
_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H
_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
| 11 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 | 15 |
16 class JavaBridgeDispatcherHost; | 16 class JavaBridgeDispatcherHost; |
17 struct NPObject; | 17 struct NPObject; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class RenderViewHost; | 20 class RenderViewHost; |
21 } | 21 } |
22 | 22 |
23 // This class handles injecting Java objects into all of the RenderViews | 23 // This class handles injecting Java objects into all of the RenderViews |
24 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost | 24 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost |
25 // objects, one per RenderViewHost. | 25 // objects, one per RenderViewHost. |
26 class JavaBridgeDispatcherHostManager : public content::WebContentsObserver { | 26 class JavaBridgeDispatcherHostManager : public content::WebContentsObserver { |
27 public: | 27 public: |
28 JavaBridgeDispatcherHostManager(content::WebContents* web_contents); | 28 explicit JavaBridgeDispatcherHostManager(content::WebContents* web_contents); |
29 virtual ~JavaBridgeDispatcherHostManager(); | 29 virtual ~JavaBridgeDispatcherHostManager(); |
30 | 30 |
31 // These methods add or remove the object to each JavaBridgeDispatcherHost. | 31 // These methods add or remove the object to each JavaBridgeDispatcherHost. |
32 // Each one holds a reference to the NPObject while the object is bound to | 32 // Each one holds a reference to the NPObject while the object is bound to |
33 // the corresponding RenderView. See JavaBridgeDispatcherHost for details. | 33 // the corresponding RenderView. See JavaBridgeDispatcherHost for details. |
34 void AddNamedObject(const string16& name, NPObject* object); | 34 void AddNamedObject(const string16& name, NPObject* object); |
35 void RemoveNamedObject(const string16& name); | 35 void RemoveNamedObject(const string16& name); |
36 | 36 |
37 // content::WebContentsObserver overrides | 37 // content::WebContentsObserver overrides |
38 virtual void RenderViewCreated( | 38 virtual void RenderViewCreated( |
39 content::RenderViewHost* render_view_host) OVERRIDE; | 39 content::RenderViewHost* render_view_host) OVERRIDE; |
40 virtual void RenderViewDeleted( | 40 virtual void RenderViewDeleted( |
41 content::RenderViewHost* render_view_host) OVERRIDE; | 41 content::RenderViewHost* render_view_host) OVERRIDE; |
42 virtual void WebContentsDestroyed( | 42 virtual void WebContentsDestroyed( |
43 content::WebContents* web_contents) OVERRIDE; | 43 content::WebContents* web_contents) OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 typedef std::map<content::RenderViewHost*, | 46 typedef std::map<content::RenderViewHost*, |
47 scoped_refptr<JavaBridgeDispatcherHost> > | 47 scoped_refptr<JavaBridgeDispatcherHost> > |
48 InstanceMap; | 48 InstanceMap; |
49 InstanceMap instances_; | 49 InstanceMap instances_; |
50 typedef std::map<string16, NPObject*> ObjectMap; | 50 typedef std::map<string16, NPObject*> ObjectMap; |
51 ObjectMap objects_; | 51 ObjectMap objects_; |
52 | 52 |
53 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); | 53 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); |
54 }; | 54 }; |
55 | 55 |
56 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ | 56 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ |
OLD | NEW |