| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/string16.h" | |
| 11 | |
| 12 class JavaBridgeChannelHost; | |
| 13 class RenderViewHost; | |
| 14 struct NPObject; | |
| 15 | |
| 16 // This class handles injecting Java objects into a single RenderView. The Java | |
| 17 // object itself lives on the browser's WEBKIT thread, while a proxy object is | |
| 18 // created in the renderer. An instance of this class exists for each | |
| 19 // RenderViewHost. | |
| 20 class JavaBridgeDispatcherHost : | |
| 21 public base::RefCountedThreadSafe<JavaBridgeDispatcherHost> { | |
| 22 public: | |
| 23 // We hold a weak pointer to the RenderViewhost. It must outlive this object. | |
| 24 JavaBridgeDispatcherHost(RenderViewHost* render_view_host); | |
| 25 | |
| 26 // Injects |object| into the main frame of the corresponding RenderView. A | |
| 27 // proxy object is created in the renderer and when the main frame's window | |
| 28 // object is next cleared, this proxy object is bound to the window object | |
| 29 // using |name|. The proxy object remains bound until the next time the | |
| 30 // window object is cleared after a call to RemoveNamedObject() or | |
| 31 // AddNamedObject() with the same name. The proxy object proxies calls back | |
| 32 // to |object|, which is manipulated on the WEBKIT thread. This class holds a | |
| 33 // reference to |object| for the time that the proxy object is bound to the | |
| 34 // window object. | |
| 35 void AddNamedObject(const string16& name, NPObject* object); | |
| 36 void RemoveNamedObject(const string16& name); | |
| 37 | |
| 38 private: | |
| 39 friend class base::RefCountedThreadSafe<JavaBridgeDispatcherHost>; | |
| 40 ~JavaBridgeDispatcherHost(); | |
| 41 | |
| 42 void DoAddNamedObject(const string16& name, NPObject* object); | |
| 43 void EnsureChannelIsSetUp(); | |
| 44 | |
| 45 RenderViewHost* render_view_host_; | |
| 46 scoped_refptr<JavaBridgeChannelHost> channel_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHost); | |
| 49 }; | |
| 50 | |
| 51 #endif // CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_H_ | |
| OLD | NEW |