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

Unified Diff: content/browser/renderer_host/java_bridge_dispatcher_host_manager.h

Issue 8366034: Adds browser-side component of Java Bridge for a TabContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed another bugus assert Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/java_bridge_dispatcher_host_manager.h
diff --git a/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h b/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..00dc2ad6cb4cf63eedb6912fb34b5776916e3e63
--- /dev/null
+++ b/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_
+#define CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_
+#pragma once
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/string16.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
+
+#include <map>
jam 2011/10/21 16:18:21 nit: this goes first
+
+class JavaBridgeDispatcherHost;
+class RenderViewHost;
+struct NPObject;
+
+// This class handles injecting Java objects into all of the RenderViews
+// associated with a TabContents. It manages a set of JavaBridgeDispatcherHost
+// objects, one per RenderViewHost.
+class JavaBridgeDispatcherHostManager : public TabContentsObserver {
+ public:
+ JavaBridgeDispatcherHostManager(TabContents* tab_contents);
+
+ // These methods add or remove the object to each JavaBridgeDispatcherHost.
+ // Each one holds a reference to the NPObject while the object is bound to
+ // the corresponding RenderView. See JavaBridgeDispatcherHost for details.
+ void AddNamedObject(const string16& name, NPObject* object);
+ void RemoveNamedObject(const string16& name);
+
+ // TabContentsObserver overrides
+ virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
+ virtual void TabContentsDestroyed(TabContents* tab_contents) OVERRIDE;
+
+ private:
+ friend class scoped_ptr<JavaBridgeDispatcherHostManager>;
jam 2011/10/21 16:18:21 i haven't seen this pattern before with scoped_ptr
+ virtual ~JavaBridgeDispatcherHostManager();
+
+ typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> >
+ InstanceMap;
+ InstanceMap instances_;
+ typedef std::map<string16, NPObject*> ObjectMap;
+ ObjectMap objects_;
+
+ DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager);
+};
+
+#endif // CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698