Chromium Code Reviews| 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_GUEST_H_ | |
| 6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <map> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/id_map.h" | |
| 13 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | |
| 14 #include "content/public/browser/render_view_host_observer.h" | |
| 15 #include "content/public/browser/web_contents_delegate.h" | |
| 16 #include "content/public/browser/web_contents_observer.h" | |
| 17 #include "ipc/ipc_channel_handle.h" | |
| 18 #include "ipc/ipc_sync_message.h" | |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 20 #include "ui/surface/transport_dib.h" | |
| 21 #include "ui/gfx/rect.h" | |
| 22 #include "ui/gfx/size.h" | |
| 23 #include "webkit/glue/webcursor.h" | |
| 24 | |
| 25 namespace gfx { | |
| 26 class Size; | |
| 27 } | |
| 28 | |
| 29 struct BrowserPluginHostMsg_ResizeGuest_Params; | |
| 30 struct ViewHostMsg_UpdateRect_Params; | |
| 31 | |
| 32 namespace content { | |
| 33 | |
| 34 class BrowserPluginHostFactory; | |
| 35 class BrowserPluginEmbedder; | |
| 36 class RenderProcessHost; | |
| 37 | |
| 38 // A browser plugin guest provides functionality for WebContents to operate in | |
| 39 // the guest role and implements guest specific overrides for ViewHostMsg_* | |
| 40 // messages. | |
| 41 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsDelegate, | |
| 42 public WebContentsObserver { | |
|
awong
2012/09/06 00:23:27
indentation
lazyboy
2012/09/06 04:33:53
Done.
| |
| 43 public: | |
| 44 virtual ~BrowserPluginGuest(); | |
| 45 | |
| 46 static BrowserPluginGuest* Create(int instance_id, | |
| 47 WebContentsImpl* web_contents, | |
| 48 content::RenderViewHost* render_view_host); | |
| 49 | |
| 50 // Overrides factory for testing. Default (NULL) value indicates regular | |
| 51 // (non-test) environment. | |
| 52 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | |
| 53 content::BrowserPluginGuest::factory_ = factory; | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 friend class BrowserPluginEmbedder; | |
| 58 friend class BrowserPluginGuestHelper; | |
| 59 // For testing. | |
|
awong
2012/09/06 00:23:27
remove comment. Too obvious.
lazyboy
2012/09/06 04:33:53
Done.
| |
| 60 friend class TestBrowserPluginGuest; | |
| 61 | |
| 62 BrowserPluginGuest(int instance_id, | |
| 63 WebContentsImpl* web_contents, | |
| 64 RenderViewHost* render_view_host); | |
| 65 | |
| 66 void set_embedder_render_process_host( | |
| 67 RenderProcessHost* render_process_host) { | |
| 68 embedder_render_process_host_ = render_process_host; | |
| 69 } | |
| 70 RenderProcessHost* embedder_render_process_host() { | |
| 71 return embedder_render_process_host_; | |
| 72 } | |
| 73 // Returns the identifier that uniquely identifies a browser plugin guest | |
| 74 // within an embedder. | |
| 75 int instance_id() const { return instance_id_; } | |
| 76 | |
| 77 void SetDamageBuffer(TransportDIB* damage_buffer, | |
| 78 const gfx::Size& size, | |
| 79 float scale_factor); | |
| 80 TransportDIB* damage_buffer() const { return damage_buffer_; } | |
| 81 const gfx::Size& damage_buffer_size() const { return damage_buffer_size_; } | |
| 82 float damage_buffer_scale_factor() const { | |
| 83 return damage_buffer_scale_factor_; | |
| 84 } | |
| 85 | |
| 86 void UpdateRect(RenderViewHost* render_view_host, | |
| 87 const ViewHostMsg_UpdateRect_Params& params); | |
| 88 void UpdateRectACK(int message_id, const gfx::Size& size); | |
| 89 // Handles input event routed through the embedder (which is initiated in the | |
| 90 // browser plugin (renderer side of the embedder)). | |
| 91 void HandleInputEvent(RenderViewHost* render_view_host, | |
| 92 const gfx::Rect& guest_rect, | |
| 93 const WebKit::WebInputEvent& event, | |
| 94 IPC::Message* reply_message); | |
| 95 // Overrides default ShowWidget message so we show them on the correct | |
| 96 // coordinates. | |
| 97 void ShowWidget(RenderViewHost* render_view_host, | |
| 98 int route_id, | |
| 99 const gfx::Rect& initial_pos); | |
| 100 void SetFocus(bool focused); | |
| 101 void SetCursor(const WebCursor& cursor); | |
| 102 // Handles input event acks so they are sent to browser plugin host (via | |
| 103 // embedder) instead of default view/widget host. | |
| 104 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); | |
| 105 | |
| 106 void Destroy(); | |
| 107 | |
| 108 // WebContentsObserver implementation. | |
|
awong
2012/09/06 00:23:27
Keep the implementation functions public. It's st
lazyboy
2012/09/06 04:33:53
Done.
| |
| 109 virtual void DidCommitProvisionalLoadForFrame( | |
| 110 int64 frame_id, | |
| 111 bool is_main_frame, | |
| 112 const GURL& url, | |
| 113 PageTransition transition_type, | |
| 114 RenderViewHost* render_view_host) OVERRIDE; | |
| 115 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
| 116 | |
| 117 // WebContentsDelegate implementation. | |
| 118 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | |
| 119 | |
| 120 // Helper to send messages to embedder. Overriden in test implementation since | |
| 121 // we want to intercept certain messages for testing. | |
| 122 virtual void SendMessageToEmbedder(IPC::Message*); | |
| 123 | |
| 124 // Static factory instance (always NULL for non-test). | |
| 125 static content::BrowserPluginHostFactory* factory_; | |
| 126 | |
| 127 bool ViewTakeFocus(bool reverse); | |
| 128 | |
| 129 RenderProcessHost* embedder_render_process_host_; | |
| 130 // An identifier that uniquely identifies a browser plugin guest within an | |
| 131 // embedder. | |
| 132 int instance_id_; | |
| 133 TransportDIB* damage_buffer_; | |
| 134 gfx::Size damage_buffer_size_; | |
| 135 float damage_buffer_scale_factor_; | |
| 136 scoped_ptr<IPC::Message> pending_input_event_reply_; | |
| 137 gfx::Rect guest_rect_; | |
| 138 WebCursor cursor_; | |
| 139 IDMap<RenderViewHost> pending_updates_; | |
| 140 int pending_update_counter_; | |
| 141 | |
| 142 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | |
| 143 }; | |
| 144 | |
| 145 } // namespace content | |
| 146 | |
| 147 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | |
| OLD | NEW |