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_; } |
| 88 |
| 89 void set_swapped_out_embedder_routing_id(int routing_id) { |
| 90 swapped_out_embedder_routing_id_ = routing_id; |
| 91 } |
| 92 int swapped_out_embedder_routing_id() const { |
| 93 return swapped_out_embedder_routing_id_; |
| 94 } |
| 95 void set_swapped_out_guest_routing_id(int routing_id) { |
| 96 swapped_out_guest_routing_id_ = routing_id; |
| 97 } |
| 98 int swapped_out_guest_routing_id() const { |
| 99 return swapped_out_guest_routing_id_; |
| 100 } |
| 101 |
84 // WebContentsObserver implementation. | 102 // WebContentsObserver implementation. |
85 virtual void DidCommitProvisionalLoadForFrame( | 103 virtual void DidCommitProvisionalLoadForFrame( |
86 int64 frame_id, | 104 int64 frame_id, |
87 bool is_main_frame, | 105 bool is_main_frame, |
88 const GURL& url, | 106 const GURL& url, |
89 PageTransition transition_type, | 107 PageTransition transition_type, |
90 RenderViewHost* render_view_host) OVERRIDE; | 108 RenderViewHost* render_view_host) OVERRIDE; |
91 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 109 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
92 | 110 |
93 // WebContentsDelegate implementation. | 111 // WebContentsDelegate implementation. |
(...skipping 10 matching lines...) Expand all Loading... |
104 IPC::Message* reply_message); | 122 IPC::Message* reply_message); |
105 // Overrides default ShowWidget message so we show them on the correct | 123 // Overrides default ShowWidget message so we show them on the correct |
106 // coordinates. | 124 // coordinates. |
107 void ShowWidget(RenderViewHost* render_view_host, | 125 void ShowWidget(RenderViewHost* render_view_host, |
108 int route_id, | 126 int route_id, |
109 const gfx::Rect& initial_pos); | 127 const gfx::Rect& initial_pos); |
110 void SetCursor(const WebCursor& cursor); | 128 void SetCursor(const WebCursor& cursor); |
111 // Handles input event acks so they are sent to browser plugin host (via | 129 // Handles input event acks so they are sent to browser plugin host (via |
112 // embedder) instead of default view/widget host. | 130 // embedder) instead of default view/widget host. |
113 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); | 131 void HandleInputEventAck(RenderViewHost* render_view_host, bool handled); |
| 132 // Handles postMessages sent from the guest to the embedder. |
| 133 void RouteMessageEvent(const ViewMsg_PostMessage_Params& params); |
114 | 134 |
115 // The guest needs to notify the plugin in the embedder to start (or stop) | 135 // The guest needs to notify the plugin in the embedder to start (or stop) |
116 // accepting touch events. | 136 // accepting touch events. |
117 void SetIsAcceptingTouchEvents(bool accept); | 137 void SetIsAcceptingTouchEvents(bool accept); |
118 | 138 |
119 // Exposes the protected web_contents() from WebContentsObserver. | 139 // Exposes the protected web_contents() from WebContentsObserver. |
120 WebContents* GetWebContents(); | 140 WebContents* GetWebContents(); |
121 | 141 |
122 // Overridden in tests. | 142 // Overridden in tests. |
123 virtual bool ViewTakeFocus(bool reverse); | 143 virtual bool ViewTakeFocus(bool reverse); |
(...skipping 17 matching lines...) Expand all Loading... |
141 private: | 161 private: |
142 friend class TestBrowserPluginGuest; | 162 friend class TestBrowserPluginGuest; |
143 | 163 |
144 BrowserPluginGuest(int instance_id, | 164 BrowserPluginGuest(int instance_id, |
145 WebContentsImpl* web_contents, | 165 WebContentsImpl* web_contents, |
146 RenderViewHost* render_view_host); | 166 RenderViewHost* render_view_host); |
147 | 167 |
148 RenderProcessHost* embedder_render_process_host() { | 168 RenderProcessHost* embedder_render_process_host() { |
149 return embedder_render_process_host_; | 169 return embedder_render_process_host_; |
150 } | 170 } |
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(); } | 171 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } |
155 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 172 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
156 float damage_buffer_scale_factor() const { | 173 float damage_buffer_scale_factor() const { |
157 return damage_buffer_scale_factor_; | 174 return damage_buffer_scale_factor_; |
158 } | 175 } |
159 | 176 |
160 // Helper to send messages to embedder. Overridden in test implementation | 177 // Helper to send messages to embedder. Overridden in test implementation |
161 // since we want to intercept certain messages for testing. | 178 // since we want to intercept certain messages for testing. |
162 virtual void SendMessageToEmbedder(IPC::Message* msg); | 179 virtual void SendMessageToEmbedder(IPC::Message* msg); |
163 | 180 |
164 // Static factory instance (always NULL for non-test). | 181 // Static factory instance (always NULL for non-test). |
165 static content::BrowserPluginHostFactory* factory_; | 182 static content::BrowserPluginHostFactory* factory_; |
166 | 183 |
167 RenderProcessHost* embedder_render_process_host_; | 184 RenderProcessHost* embedder_render_process_host_; |
168 // An identifier that uniquely identifies a browser plugin guest within an | 185 // An identifier that uniquely identifies a browser plugin guest within an |
169 // embedder. | 186 // embedder. |
170 int instance_id_; | 187 int instance_id_; |
171 scoped_ptr<TransportDIB> damage_buffer_; | 188 scoped_ptr<TransportDIB> damage_buffer_; |
172 #if defined(OS_WIN) | 189 #if defined(OS_WIN) |
173 size_t damage_buffer_size_; | 190 size_t damage_buffer_size_; |
174 #endif | 191 #endif |
175 gfx::Size damage_view_size_; | 192 gfx::Size damage_view_size_; |
176 float damage_buffer_scale_factor_; | 193 float damage_buffer_scale_factor_; |
177 scoped_ptr<IPC::Message> pending_input_event_reply_; | 194 scoped_ptr<IPC::Message> pending_input_event_reply_; |
178 gfx::Rect guest_rect_; | 195 gfx::Rect guest_rect_; |
179 WebCursor cursor_; | 196 WebCursor cursor_; |
180 IDMap<RenderViewHost> pending_updates_; | 197 IDMap<RenderViewHost> pending_updates_; |
181 int pending_update_counter_; | 198 int pending_update_counter_; |
182 base::TimeDelta guest_hang_timeout_; | 199 base::TimeDelta guest_hang_timeout_; |
| 200 int swapped_out_embedder_routing_id_; |
| 201 int swapped_out_guest_routing_id_; |
183 | 202 |
184 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 203 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
185 }; | 204 }; |
186 | 205 |
187 } // namespace content | 206 } // namespace content |
188 | 207 |
189 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 208 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |