Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer | 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer |
| 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of | 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of |
| 7 // browser <--> guest renderer communication. The 'guest' renderer is a | 7 // browser <--> guest renderer communication. The 'guest' renderer is a |
| 8 // <browser> tag. | 8 // <browser> tag. |
| 9 // | 9 // |
| 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a | 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "base/compiler_specific.h" | 34 #include "base/compiler_specific.h" |
| 35 #include "base/id_map.h" | 35 #include "base/id_map.h" |
| 36 #include "base/time.h" | 36 #include "base/time.h" |
| 37 #include "content/public/browser/web_contents_delegate.h" | 37 #include "content/public/browser/web_contents_delegate.h" |
| 38 #include "content/public/browser/web_contents_observer.h" | 38 #include "content/public/browser/web_contents_observer.h" |
| 39 #include "ui/gfx/rect.h" | 39 #include "ui/gfx/rect.h" |
| 40 #include "webkit/glue/webcursor.h" | 40 #include "webkit/glue/webcursor.h" |
| 41 | 41 |
| 42 class TransportDIB; | 42 class TransportDIB; |
| 43 struct ViewHostMsg_UpdateRect_Params; | 43 struct ViewHostMsg_UpdateRect_Params; |
| 44 struct ViewMsg_PostMessage_Params; | |
| 44 | 45 |
| 45 namespace WebKit { | 46 namespace WebKit { |
| 46 class WebInputEvent; | 47 class WebInputEvent; |
| 47 } | 48 } |
| 48 | 49 |
| 49 namespace content { | 50 namespace content { |
| 50 | 51 |
| 51 class BrowserPluginHostFactory; | 52 class BrowserPluginHostFactory; |
| 52 class BrowserPluginEmbedder; | 53 class BrowserPluginEmbedder; |
| 53 class RenderProcessHost; | 54 class RenderProcessHost; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 74 | 75 |
| 75 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { | 76 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { |
| 76 guest_hang_timeout_ = timeout; | 77 guest_hang_timeout_ = timeout; |
| 77 } | 78 } |
| 78 | 79 |
| 79 void set_embedder_render_process_host( | 80 void set_embedder_render_process_host( |
| 80 RenderProcessHost* render_process_host) { | 81 RenderProcessHost* render_process_host) { |
| 81 embedder_render_process_host_ = render_process_host; | 82 embedder_render_process_host_ = render_process_host; |
| 82 } | 83 } |
| 83 | 84 |
| 85 // Returns the identifier that uniquely identifies a browser plugin guest | |
| 86 // within an embedder. | |
| 87 int instance_id() const { return instance_id_; } | |
|
nasko
2012/10/02 17:52:31
nit: I'll add an empty line after this, since it i
Fady Samuel
2012/10/02 22:04:08
Done.
| |
| 88 void set_swapped_out_embedder_routing_id(int routing_id) { | |
| 89 swapped_out_embedder_routing_id_ = routing_id; | |
| 90 } | |
| 91 int swapped_out_embedder_routing_id() const { | |
| 92 return swapped_out_embedder_routing_id_; | |
| 93 } | |
| 94 void set_swapped_out_guest_routing_id(int routing_id) { | |
| 95 swapped_out_guest_routing_id_ = routing_id; | |
| 96 } | |
| 97 int swapped_out_guest_routing_id() const { | |
| 98 return swapped_out_guest_routing_id_; | |
| 99 } | |
| 100 | |
| 84 // WebContentsObserver implementation. | 101 // WebContentsObserver implementation. |
| 85 virtual void DidCommitProvisionalLoadForFrame( | 102 virtual void DidCommitProvisionalLoadForFrame( |
| 86 int64 frame_id, | 103 int64 frame_id, |
| 87 bool is_main_frame, | 104 bool is_main_frame, |
| 88 const GURL& url, | 105 const GURL& url, |
| 89 PageTransition transition_type, | 106 PageTransition transition_type, |
| 90 RenderViewHost* render_view_host) OVERRIDE; | 107 RenderViewHost* render_view_host) OVERRIDE; |
| 91 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 108 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 92 | 109 |
| 93 // WebContentsDelegate implementation. | 110 // WebContentsDelegate implementation. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 104 IPC::Message* reply_message); | 121 IPC::Message* reply_message); |
| 105 // Overrides default ShowWidget message so we show them on the correct | 122 // Overrides default ShowWidget message so we show them on the correct |
| 106 // coordinates. | 123 // coordinates. |
| 107 void ShowWidget(RenderViewHost* render_view_host, | 124 void ShowWidget(RenderViewHost* render_view_host, |
| 108 int route_id, | 125 int route_id, |
| 109 const gfx::Rect& initial_pos); | 126 const gfx::Rect& initial_pos); |
| 110 void SetCursor(const WebCursor& cursor); | 127 void SetCursor(const WebCursor& cursor); |
| 111 // Handles input event acks so they are sent to browser plugin host (via | 128 // Handles input event acks so they are sent to browser plugin host (via |
| 112 // embedder) instead of default view/widget host. | 129 // embedder) instead of default view/widget host. |
| 113 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); | 130 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); |
| 131 // Handles postMessages sent from the guest to the embedder. | |
| 132 void RouteMessageEvent(const ViewMsg_PostMessage_Params& params); | |
| 114 | 133 |
| 115 // The guest needs to notify the plugin in the embedder to start (or stop) | 134 // The guest needs to notify the plugin in the embedder to start (or stop) |
| 116 // accepting touch events. | 135 // accepting touch events. |
| 117 void SetIsAcceptingTouchEvents(bool accept); | 136 void SetIsAcceptingTouchEvents(bool accept); |
| 118 | 137 |
| 119 // Exposes the protected web_contents() from WebContentsObserver. | 138 // Exposes the protected web_contents() from WebContentsObserver. |
| 120 WebContents* GetWebContents(); | 139 WebContents* GetWebContents(); |
| 121 | 140 |
| 122 // Overridden in tests. | 141 // Overridden in tests. |
| 123 virtual bool ViewTakeFocus(bool reverse); | 142 virtual bool ViewTakeFocus(bool reverse); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 141 private: | 160 private: |
| 142 friend class TestBrowserPluginGuest; | 161 friend class TestBrowserPluginGuest; |
| 143 | 162 |
| 144 BrowserPluginGuest(int instance_id, | 163 BrowserPluginGuest(int instance_id, |
| 145 WebContentsImpl* web_contents, | 164 WebContentsImpl* web_contents, |
| 146 RenderViewHost* render_view_host); | 165 RenderViewHost* render_view_host); |
| 147 | 166 |
| 148 RenderProcessHost* embedder_render_process_host() { | 167 RenderProcessHost* embedder_render_process_host() { |
| 149 return embedder_render_process_host_; | 168 return embedder_render_process_host_; |
| 150 } | 169 } |
| 151 // Returns the identifier that uniquely identifies a browser plugin guest | |
| 152 // within an embedder. | |
| 153 int instance_id() const { return instance_id_; } | |
| 154 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } | 170 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } |
| 155 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 171 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
| 156 float damage_buffer_scale_factor() const { | 172 float damage_buffer_scale_factor() const { |
| 157 return damage_buffer_scale_factor_; | 173 return damage_buffer_scale_factor_; |
| 158 } | 174 } |
| 159 | 175 |
| 160 // Helper to send messages to embedder. Overridden in test implementation | 176 // Helper to send messages to embedder. Overridden in test implementation |
| 161 // since we want to intercept certain messages for testing. | 177 // since we want to intercept certain messages for testing. |
| 162 virtual void SendMessageToEmbedder(IPC::Message* msg); | 178 virtual void SendMessageToEmbedder(IPC::Message* msg); |
| 163 | 179 |
| 164 // Static factory instance (always NULL for non-test). | 180 // Static factory instance (always NULL for non-test). |
| 165 static content::BrowserPluginHostFactory* factory_; | 181 static content::BrowserPluginHostFactory* factory_; |
| 166 | 182 |
| 167 RenderProcessHost* embedder_render_process_host_; | 183 RenderProcessHost* embedder_render_process_host_; |
| 168 // An identifier that uniquely identifies a browser plugin guest within an | 184 // An identifier that uniquely identifies a browser plugin guest within an |
| 169 // embedder. | 185 // embedder. |
| 170 int instance_id_; | 186 int instance_id_; |
| 171 scoped_ptr<TransportDIB> damage_buffer_; | 187 scoped_ptr<TransportDIB> damage_buffer_; |
| 172 #if defined(OS_WIN) | 188 #if defined(OS_WIN) |
| 173 size_t damage_buffer_size_; | 189 size_t damage_buffer_size_; |
| 174 #endif | 190 #endif |
| 175 gfx::Size damage_view_size_; | 191 gfx::Size damage_view_size_; |
| 176 float damage_buffer_scale_factor_; | 192 float damage_buffer_scale_factor_; |
| 177 scoped_ptr<IPC::Message> pending_input_event_reply_; | 193 scoped_ptr<IPC::Message> pending_input_event_reply_; |
| 178 gfx::Rect guest_rect_; | 194 gfx::Rect guest_rect_; |
| 179 WebCursor cursor_; | 195 WebCursor cursor_; |
| 180 IDMap<RenderViewHost> pending_updates_; | 196 IDMap<RenderViewHost> pending_updates_; |
| 181 int pending_update_counter_; | 197 int pending_update_counter_; |
| 182 base::TimeDelta guest_hang_timeout_; | 198 base::TimeDelta guest_hang_timeout_; |
| 199 int swapped_out_embedder_routing_id_; | |
| 200 int swapped_out_guest_routing_id_; | |
| 183 | 201 |
| 184 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 202 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 185 }; | 203 }; |
| 186 | 204 |
| 187 } // namespace content | 205 } // namespace content |
| 188 | 206 |
| 189 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 207 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |