OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_JAVA_BRIDGE_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ |
7 | 7 |
8 #include "content/public/common/webkit_param_traits.h" | 8 #include "content/public/common/webkit_param_traits.h" |
9 #include "content/public/renderer/render_view_observer.h" | 9 #include "content/public/renderer/render_view_observer.h" |
10 #include "ipc/ipc_channel_handle.h" | 10 #include "ipc/ipc_channel_handle.h" |
11 | 11 |
12 class JavaBridgeChannel; | 12 class JavaBridgeChannel; |
13 | 13 |
14 // This class handles injecting Java objects into the main frame of a | 14 // This class handles injecting Java objects into the main frame of a |
15 // RenderView. The 'add' and 'remove' messages received from the browser | 15 // RenderView. The 'add' and 'remove' messages received from the browser |
16 // process modify the entries in a map of 'pending' objects. These objects are | 16 // process modify the entries in a map of 'pending' objects. These objects are |
17 // bound to the window object of the main frame when that window object is next | 17 // bound to the window object of the main frame when that window object is next |
18 // cleared. These objects remain bound until the window object is cleared | 18 // cleared. These objects remain bound until the window object is cleared |
19 // again. | 19 // again. |
20 class JavaBridgeDispatcher : public content::RenderViewObserver { | 20 class JavaBridgeDispatcher : public content::RenderViewObserver { |
21 public: | 21 public: |
22 JavaBridgeDispatcher(content::RenderView* render_view, | 22 JavaBridgeDispatcher(content::RenderView* render_view); |
23 const IPC::ChannelHandle& channel_handle); | |
24 virtual ~JavaBridgeDispatcher(); | 23 virtual ~JavaBridgeDispatcher(); |
25 | 24 |
26 private: | 25 private: |
27 // RenderViewObserver override: | 26 // RenderViewObserver override: |
28 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 27 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
29 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 28 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
30 | 29 |
31 // Message handlers | 30 // Message handlers |
32 void OnAddNamedObject(const string16& name, | 31 void OnAddNamedObject(const string16& name, |
33 const NPVariant_Param& variant_param); | 32 const NPVariant_Param& variant_param); |
34 void OnRemoveNamedObject(const string16& name); | 33 void OnRemoveNamedObject(const string16& name); |
35 | 34 |
| 35 void EnsureChannelIsSetUp(); |
| 36 |
36 // Objects that will be bound to the window when the window object is next | 37 // Objects that will be bound to the window when the window object is next |
37 // cleared. We hold a ref to these. | 38 // cleared. We hold a ref to these. |
38 typedef std::map<string16, NPVariant> ObjectMap; | 39 typedef std::map<string16, NPVariant> ObjectMap; |
39 ObjectMap objects_; | 40 ObjectMap objects_; |
40 scoped_ptr<JavaBridgeChannel> channel_; | 41 scoped_ptr<JavaBridgeChannel> channel_; |
41 }; | 42 }; |
42 | 43 |
43 #endif // CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ | 44 #endif // CONTENT_RENDERER_JAVA_JAVA_BRIDGE_DISPATCHER_H_ |
OLD | NEW |