| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 17 | 18 |
| 18 struct NPObject; | 19 struct NPObject; |
| 20 struct _NPP; |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 class JavaBridgeDispatcherHost; | 23 class JavaBridgeDispatcherHost; |
| 22 class RenderViewHost; | 24 class RenderViewHost; |
| 23 | 25 |
| 24 // This class handles injecting Java objects into all of the RenderViews | 26 // This class handles injecting Java objects into all of the RenderViews |
| 25 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost | 27 // associated with a WebContents. It manages a set of JavaBridgeDispatcherHost |
| 26 // objects, one per RenderViewHost. | 28 // objects, one per RenderViewHost. |
| 27 class JavaBridgeDispatcherHostManager | 29 class JavaBridgeDispatcherHostManager |
| 28 : public WebContentsObserver, | 30 : public WebContentsObserver, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 // WebContentsObserver overrides | 50 // WebContentsObserver overrides |
| 49 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 51 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 50 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; | 52 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
| 51 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | 53 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; |
| 52 virtual void DocumentAvailableInMainFrame() OVERRIDE; | 54 virtual void DocumentAvailableInMainFrame() OVERRIDE; |
| 53 | 55 |
| 54 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object); | 56 void JavaBoundObjectCreated(const base::android::JavaRef<jobject>& object); |
| 55 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object); | 57 void JavaBoundObjectDestroyed(const base::android::JavaRef<jobject>& object); |
| 56 | 58 |
| 59 // Returns the NPObject owner identifier to use when creating new |
| 60 // JavaBoundObject instances, to mark them as owned by this manager. |
| 61 struct _NPP* object_owner_id() { return object_owner_id_.get(); } |
| 62 |
| 57 private: | 63 private: |
| 58 typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> > | 64 typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> > |
| 59 InstanceMap; | 65 InstanceMap; |
| 60 InstanceMap instances_; | 66 InstanceMap instances_; |
| 61 typedef std::map<string16, NPObject*> ObjectMap; | 67 typedef std::map<string16, NPObject*> ObjectMap; |
| 62 ObjectMap objects_; | 68 ObjectMap objects_; |
| 63 JavaObjectWeakGlobalRef retained_object_set_; | 69 JavaObjectWeakGlobalRef retained_object_set_; |
| 64 | 70 |
| 71 // Dummy NPObject owner Id used to track JavaBoundObjects to this manager. |
| 72 scoped_ptr<struct _NPP> object_owner_id_; |
| 73 |
| 65 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); | 74 DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace content | 77 } // namespace content |
| 69 | 78 |
| 70 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ | 79 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_DISPATCHER_HOST_MANAGE
R_H_ |
| OLD | NEW |