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_GUEST_DELEGATE_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_GUEST_DELEGATE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <map> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/id_map.h" |
| 13 #include "content/public/browser/render_view_host_observer.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "content/public/browser/web_contents_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 "ui/gfx/rect.h" |
| 21 #include "ui/gfx/size.h" |
| 22 #include "webkit/glue/webcursor.h" |
| 23 |
| 24 namespace gfx { |
| 25 class Size; |
| 26 } |
| 27 |
| 28 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 29 struct ViewHostMsg_UpdateRect_Params; |
| 30 |
| 31 namespace content { |
| 32 |
| 33 class BrowserPluginHostEmbedderDelegate; |
| 34 class RenderProcessHost; |
| 35 |
| 36 // Delegate for browser plugin guest. Provides functionality for WebContents to |
| 37 // operate in the guest role, implements guest specific overrides for |
| 38 // ViewHostMsg_* messages. |
| 39 class BrowserPluginHostGuestDelegate : public WebContentsDelegate, |
| 40 public WebContentsObserver { |
| 41 public: |
| 42 BrowserPluginHostGuestDelegate(int instance_id, |
| 43 WebContentsImpl* web_contents); |
| 44 virtual ~BrowserPluginHostGuestDelegate(); |
| 45 |
| 46 private: |
| 47 friend class BrowserPluginHostEmbedderDelegate; |
| 48 friend class BrowserPluginHostGuestRole; |
| 49 |
| 50 void set_embedder_render_process_host( |
| 51 RenderProcessHost* render_process_host) { |
| 52 embedder_render_process_host_ = render_process_host; |
| 53 } |
| 54 RenderProcessHost* embedder_render_process_host() { |
| 55 return embedder_render_process_host_; |
| 56 } |
| 57 int instance_id() const { return instance_id_; } |
| 58 |
| 59 void SetDamageBuffer(TransportDIB* damage_buffer, |
| 60 const gfx::Size& size, |
| 61 float scale_factor); |
| 62 TransportDIB* damage_buffer() const { return damage_buffer_; } |
| 63 const gfx::Size& damage_buffer_size() const { return damage_buffer_size_; } |
| 64 float damage_buffer_scale_factor() const { |
| 65 return damage_buffer_scale_factor_; |
| 66 } |
| 67 |
| 68 void UpdateRect(RenderViewHost* render_view_host, |
| 69 const ViewHostMsg_UpdateRect_Params& params); |
| 70 void UpdateRectACK(int message_id, const gfx::Size& size); |
| 71 // Handles input event routed through the embedder (which is initiated in the |
| 72 // browser plugin {renderer side of the embedder}). |
| 73 void HandleInputEvent(RenderViewHost* render_view_host, |
| 74 const gfx::Rect& guest_rect, |
| 75 const WebKit::WebInputEvent& event, |
| 76 IPC::Message* reply_message); |
| 77 // Overrides default ShowWidget message so we show them on the correct |
| 78 // coordinates. |
| 79 void ShowWidget(RenderViewHost* render_view_host, |
| 80 int route_id, |
| 81 const gfx::Rect& initial_pos); |
| 82 void SetFocus(bool focused); |
| 83 void SetCursor(const WebCursor& cursor); |
| 84 // Handles input event ack so it's sent to browser plugin host (via embedder) |
| 85 // instead of default view/widget host. |
| 86 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); |
| 87 |
| 88 void Destroy(); |
| 89 |
| 90 // WebContentsObserver implementation. |
| 91 // Used to monitor frame navigation to cleanup itself up. |
| 92 virtual void DidCommitProvisionalLoadForFrame( |
| 93 int64 frame_id, |
| 94 bool is_main_frame, |
| 95 const GURL& url, |
| 96 PageTransition transition_type, |
| 97 RenderViewHost* render_view_host) OVERRIDE; |
| 98 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 99 |
| 100 // WebContentsDelegate implementation. |
| 101 virtual bool TakeFocus(bool reverse) OVERRIDE; |
| 102 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
| 103 |
| 104 RenderProcessHost* embedder_render_process_host_; |
| 105 // An identifier that uniquely identifies a browser plugin container |
| 106 // within an embedder. |
| 107 int instance_id_; |
| 108 TransportDIB* damage_buffer_; |
| 109 gfx::Size damage_buffer_size_; |
| 110 float damage_buffer_scale_factor_; |
| 111 scoped_ptr<IPC::Message> pending_input_event_reply_; |
| 112 gfx::Rect guest_rect_; |
| 113 WebCursor cursor_; |
| 114 IDMap<RenderViewHost> pending_updates_; |
| 115 int pending_update_counter_; |
| 116 |
| 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostGuestDelegate); |
| 119 }; |
| 120 |
| 121 } // namespace content |
| 122 |
| 123 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_GUEST_DELEGATE_H_ |
OLD | NEW |