OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "content/browser/browser_plugin/browser_plugin_host_embedder_delegate.h
" |
| 12 #include "content/browser/browser_plugin/browser_plugin_host_role.h" |
| 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/render_view_host_observer.h" |
| 16 #include "ipc/ipc_channel_handle.h" |
| 17 #include "ipc/ipc_sync_message.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 19 #include "ui/surface/transport_dib.h" |
| 20 #include "webkit/glue/webcursor.h" |
| 21 |
| 22 namespace gfx { |
| 23 class Size; |
| 24 } |
| 25 |
| 26 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 27 struct ViewHostMsg_UpdateRect_Params; |
| 28 |
| 29 namespace content { |
| 30 |
| 31 class RenderViewHost; |
| 32 |
| 33 // Role for browser plugin embedder. |
| 34 // A class having such a role means it is assuming the role of an embedder, i.e. |
| 35 // it can embed zero to many guest browser plugins. A lot of messages coming |
| 36 // from guests need to know the guest's RenderViewHost. |
| 37 // BrowserPluginHostEmbedderRole handles BrowserPluginHostMsg messages and |
| 38 // relays them with their associated RenderViewHosts to its delegate where they |
| 39 // will be handled. |
| 40 class BrowserPluginHostEmbedderRole : public BrowserPluginHostRole, |
| 41 public RenderViewHostObserver, |
| 42 public NotificationObserver { |
| 43 public: |
| 44 BrowserPluginHostEmbedderRole(WebContentsImpl* web_contents, |
| 45 RenderViewHost* render_view_host); |
| 46 virtual ~BrowserPluginHostEmbedderRole(); |
| 47 |
| 48 // Make it public for sync IPCs. |
| 49 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 50 void NavigateGuest(int instance_id, int64 frame_id, const std::string& src, |
| 51 const gfx::Size& size); |
| 52 BrowserPluginHostEmbedderDelegate* GetDelegate() { |
| 53 return delegate_.get(); |
| 54 } |
| 55 |
| 56 private: |
| 57 // Message handlers. |
| 58 void OnNavigateGuest(int instance_id, int64 frame_id, const std::string& src, |
| 59 const gfx::Size& size); |
| 60 void OnResizeGuest(int instance_id, |
| 61 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 62 void OnUpdateRectACK(int instance_id, int message_id, const gfx::Size& size); |
| 63 void OnHandleInputEvent(const IPC::SyncMessage& message, bool* handled); |
| 64 void OnSetFocus(int instance_id, bool focused); |
| 65 void OnPluginDestroyed(int instance_id); |
| 66 |
| 67 // RenderViewHostObserver implementation. |
| 68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 69 |
| 70 // NotificationObserver method override. |
| 71 virtual void Observe(int type, |
| 72 const NotificationSource& source, |
| 73 const NotificationDetails& details) OVERRIDE; |
| 74 |
| 75 scoped_ptr<BrowserPluginHostEmbedderDelegate> delegate_; |
| 76 // A scoped container for notification registries. |
| 77 NotificationRegistrar registrar_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostEmbedderRole); |
| 80 }; |
| 81 |
| 82 } // namespace content |
| 83 |
| 84 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_EMBEDDER_ROLE_H_ |
OLD | NEW |