Index: content/browser/browser_plugin/browser_plugin_host_embedder_role.h |
diff --git a/content/browser/browser_plugin/browser_plugin_host_embedder_role.h b/content/browser/browser_plugin/browser_plugin_host_embedder_role.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..052dc192f3b7dd0e2db763c94d41518e14a63421 |
--- /dev/null |
+++ b/content/browser/browser_plugin/browser_plugin_host_embedder_role.h |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2012 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_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |
+#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "content/browser/browser_plugin/browser_plugin_host_embedder_delegate.h" |
+#include "content/browser/browser_plugin/browser_plugin_host_role.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
+#include "content/public/browser/render_view_host_observer.h" |
+#include "ipc/ipc_channel_handle.h" |
+#include "ipc/ipc_sync_message.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
+#include "ui/surface/transport_dib.h" |
+#include "webkit/glue/webcursor.h" |
+ |
+namespace gfx { |
+class Size; |
+} |
+ |
+struct BrowserPluginHostMsg_ResizeGuest_Params; |
+struct ViewHostMsg_UpdateRect_Params; |
+ |
+namespace content { |
+ |
+class RenderViewHost; |
+ |
+// Role for browser plugin embedder. |
+// A class having such a role means it is assuming the role of an embedder, i.e. |
+// it can embed zero to many guest browser plugins. A lot of messages coming |
+// from guests need to know the guest's RenderViewHost. |
+// BrowserPluginHostEmbedderRole handles BrowserPluginHostMsg messages and |
+// relays them with their associated RenderViewHosts to its delegate where they |
+// will be handled. |
+class BrowserPluginHostEmbedderRole : public BrowserPluginHostRole, |
+ public RenderViewHostObserver, |
+ public NotificationObserver { |
+ public: |
+ BrowserPluginHostEmbedderRole(WebContentsImpl* web_contents, |
+ RenderViewHost* render_view_host); |
+ virtual ~BrowserPluginHostEmbedderRole(); |
+ |
+ // Make it public for sync IPCs. |
+ virtual bool Send(IPC::Message* message) OVERRIDE; |
+ void NavigateGuest(int instance_id, int64 frame_id, const std::string& src, |
+ const gfx::Size& size); |
+ BrowserPluginHostEmbedderDelegate* GetDelegate() { |
+ return delegate_.get(); |
+ } |
+ |
+ private: |
+ // Message handlers. |
+ void OnNavigateGuest(int instance_id, int64 frame_id, const std::string& src, |
+ const gfx::Size& size); |
+ void OnResizeGuest(int instance_id, |
+ const BrowserPluginHostMsg_ResizeGuest_Params& params); |
+ void OnUpdateRectACK(int instance_id, int message_id, const gfx::Size& size); |
+ void OnHandleInputEvent(const IPC::SyncMessage& message, bool* handled); |
+ void OnSetFocus(int instance_id, bool focused); |
+ void OnPluginDestroyed(int instance_id); |
+ |
+ // RenderViewHostObserver implementation. |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ // NotificationObserver method override. |
+ virtual void Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) OVERRIDE; |
+ |
+ scoped_ptr<BrowserPluginHostEmbedderDelegate> delegate_; |
+ // A scoped container for notification registries. |
+ NotificationRegistrar registrar_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostEmbedderRole); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |