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 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/pickle.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
12 #include "content/browser/browser_thread_impl.h" | 13 #include "content/browser/browser_thread_impl.h" |
13 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
14 #include "content/browser/frame_host/render_frame_host_impl.h" | 15 #include "content/browser/frame_host/render_frame_host_impl.h" |
15 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 16 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
16 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 17 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
17 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
18 #include "content/browser/renderer_host/render_widget_host_impl.h" | 19 #include "content/browser/renderer_host/render_widget_host_impl.h" |
19 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
20 #include "content/browser/web_contents/web_contents_impl.h" | 21 #include "content/browser/web_contents/web_contents_impl.h" |
21 #include "content/browser/web_contents/web_contents_view_guest.h" | 22 #include "content/browser/web_contents/web_contents_view_guest.h" |
| 23 #include "content/common/browser_plugin/browser_plugin_constants.h" |
22 #include "content/common/browser_plugin/browser_plugin_messages.h" | 24 #include "content/common/browser_plugin/browser_plugin_messages.h" |
23 #include "content/common/content_constants_internal.h" | 25 #include "content/common/content_constants_internal.h" |
24 #include "content/common/drag_messages.h" | 26 #include "content/common/drag_messages.h" |
25 #include "content/common/input_messages.h" | 27 #include "content/common/input_messages.h" |
26 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
27 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
28 #include "content/public/browser/browser_plugin_guest_manager.h" | 30 #include "content/public/browser/browser_plugin_guest_manager.h" |
29 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
30 #include "content/public/browser/render_widget_host_view.h" | 32 #include "content/public/browser/render_widget_host_view.h" |
31 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
(...skipping 26 matching lines...) Expand all Loading... |
58 virtual void WasHidden() OVERRIDE { | 60 virtual void WasHidden() OVERRIDE { |
59 browser_plugin_guest_->EmbedderVisibilityChanged(false); | 61 browser_plugin_guest_->EmbedderVisibilityChanged(false); |
60 } | 62 } |
61 | 63 |
62 private: | 64 private: |
63 BrowserPluginGuest* browser_plugin_guest_; | 65 BrowserPluginGuest* browser_plugin_guest_; |
64 | 66 |
65 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver); | 67 DISALLOW_COPY_AND_ASSIGN(EmbedderWebContentsObserver); |
66 }; | 68 }; |
67 | 69 |
68 BrowserPluginGuest::BrowserPluginGuest( | 70 BrowserPluginGuest::BrowserPluginGuest(bool has_render_view, |
69 int instance_id, | 71 WebContentsImpl* web_contents, |
70 bool has_render_view, | 72 BrowserPluginGuestDelegate* delegate) |
71 WebContentsImpl* web_contents, | |
72 BrowserPluginGuestDelegate* delegate) | |
73 : WebContentsObserver(web_contents), | 73 : WebContentsObserver(web_contents), |
74 embedder_web_contents_(NULL), | 74 embedder_web_contents_(NULL), |
75 instance_id_(instance_id), | 75 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), |
76 guest_device_scale_factor_(1.0f), | 76 guest_device_scale_factor_(1.0f), |
77 focused_(false), | 77 focused_(false), |
78 mouse_locked_(false), | 78 mouse_locked_(false), |
79 pending_lock_request_(false), | 79 pending_lock_request_(false), |
80 guest_visible_(false), | 80 guest_visible_(false), |
81 guest_opaque_(true), | 81 guest_opaque_(true), |
82 embedder_visible_(true), | 82 embedder_visible_(true), |
83 copy_request_id_(0), | 83 copy_request_id_(0), |
84 has_render_view_(has_render_view), | 84 has_render_view_(has_render_view), |
85 is_in_destruction_(false), | 85 is_in_destruction_(false), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 OnSetContentsOpaque) | 156 OnSetContentsOpaque) |
157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) | 157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) |
158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) | 158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) |
159 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) | 159 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) |
160 IPC_MESSAGE_UNHANDLED(handled = false) | 160 IPC_MESSAGE_UNHANDLED(handled = false) |
161 IPC_END_MESSAGE_MAP() | 161 IPC_END_MESSAGE_MAP() |
162 return handled; | 162 return handled; |
163 } | 163 } |
164 | 164 |
165 void BrowserPluginGuest::Initialize( | 165 void BrowserPluginGuest::Initialize( |
| 166 int browser_plugin_instance_id, |
166 const BrowserPluginHostMsg_Attach_Params& params, | 167 const BrowserPluginHostMsg_Attach_Params& params, |
167 WebContentsImpl* embedder_web_contents, | 168 WebContentsImpl* embedder_web_contents) { |
168 const base::DictionaryValue& extra_params) { | 169 browser_plugin_instance_id_ = browser_plugin_instance_id; |
169 focused_ = params.focused; | 170 focused_ = params.focused; |
170 guest_visible_ = params.visible; | 171 guest_visible_ = params.visible; |
171 guest_opaque_ = params.opaque; | 172 guest_opaque_ = params.opaque; |
172 guest_window_rect_ = gfx::Rect(params.origin, | 173 guest_window_rect_ = gfx::Rect(params.origin, |
173 params.resize_guest_params.view_size); | 174 params.resize_guest_params.view_size); |
174 | 175 |
175 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 176 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
176 // be attached. | 177 // be attached. |
177 embedder_web_contents_ = embedder_web_contents; | 178 embedder_web_contents_ = embedder_web_contents; |
178 | 179 |
(...skipping 18 matching lines...) Expand all Loading... |
197 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. | 198 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. |
198 renderer_prefs->report_frame_name_changes = true; | 199 renderer_prefs->report_frame_name_changes = true; |
199 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated | 200 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated |
200 // navigations still continue to function inside the app. | 201 // navigations still continue to function inside the app. |
201 renderer_prefs->browser_handles_all_top_level_requests = false; | 202 renderer_prefs->browser_handles_all_top_level_requests = false; |
202 // Disable "client blocked" error page for browser plugin. | 203 // Disable "client blocked" error page for browser plugin. |
203 renderer_prefs->disable_client_blocked_error_page = true; | 204 renderer_prefs->disable_client_blocked_error_page = true; |
204 | 205 |
205 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); | 206 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); |
206 | 207 |
207 OnResizeGuest(instance_id_, params.resize_guest_params); | 208 OnResizeGuest(browser_plugin_instance_id_, params.resize_guest_params); |
208 | 209 |
209 // Create a swapped out RenderView for the guest in the embedder render | 210 // Create a swapped out RenderView for the guest in the embedder render |
210 // process, so that the embedder can access the guest's window object. | 211 // process, so that the embedder can access the guest's window object. |
211 int guest_routing_id = | 212 int guest_routing_id = |
212 GetWebContents()->CreateSwappedOutRenderView( | 213 GetWebContents()->CreateSwappedOutRenderView( |
213 embedder_web_contents_->GetSiteInstance()); | 214 embedder_web_contents_->GetSiteInstance()); |
214 SendMessageToEmbedder( | |
215 new BrowserPluginMsg_GuestContentWindowReady(instance_id_, | |
216 guest_routing_id)); | |
217 | 215 |
218 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will | 216 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will |
219 // be reset again the next time preferences are updated. | 217 // be reset again the next time preferences are updated. |
220 WebPreferences prefs = | 218 WebPreferences prefs = |
221 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); | 219 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); |
222 prefs.navigate_on_drag_drop = false; | 220 prefs.navigate_on_drag_drop = false; |
223 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | 221 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); |
224 | 222 |
225 // Enable input method for guest if it's enabled for the embedder. | 223 // Enable input method for guest if it's enabled for the embedder. |
226 if (static_cast<RenderViewHostImpl*>( | 224 if (static_cast<RenderViewHostImpl*>( |
227 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { | 225 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { |
228 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 226 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
229 GetWebContents()->GetRenderViewHost()); | 227 GetWebContents()->GetRenderViewHost()); |
230 guest_rvh->SetInputMethodActive(true); | 228 guest_rvh->SetInputMethodActive(true); |
231 } | 229 } |
232 | 230 |
233 // Inform the embedder of the guest's attachment. | 231 // Inform the embedder of the guest's attachment. |
234 SendMessageToEmbedder(new BrowserPluginMsg_Attach_ACK(instance_id_)); | 232 SendMessageToEmbedder( |
| 233 new BrowserPluginMsg_Attach_ACK(browser_plugin_instance_id_)); |
| 234 |
| 235 SendMessageToEmbedder(new BrowserPluginMsg_GuestContentWindowReady( |
| 236 browser_plugin_instance_id_, guest_routing_id)); |
235 } | 237 } |
236 | 238 |
237 BrowserPluginGuest::~BrowserPluginGuest() { | 239 BrowserPluginGuest::~BrowserPluginGuest() { |
238 } | 240 } |
239 | 241 |
240 // static | 242 // static |
241 BrowserPluginGuest* BrowserPluginGuest::Create( | 243 BrowserPluginGuest* BrowserPluginGuest::Create( |
242 int instance_id, | |
243 WebContentsImpl* web_contents, | 244 WebContentsImpl* web_contents, |
244 BrowserPluginGuestDelegate* delegate) { | 245 BrowserPluginGuestDelegate* delegate) { |
245 return new BrowserPluginGuest( | 246 return new BrowserPluginGuest( |
246 instance_id, web_contents->opener() != NULL, web_contents, delegate); | 247 web_contents->opener() != NULL, web_contents, delegate); |
247 } | 248 } |
248 | 249 |
249 // static | 250 // static |
250 bool BrowserPluginGuest::IsGuest(WebContentsImpl* web_contents) { | 251 bool BrowserPluginGuest::IsGuest(WebContentsImpl* web_contents) { |
251 return web_contents && web_contents->GetBrowserPluginGuest(); | 252 return web_contents && web_contents->GetBrowserPluginGuest(); |
252 } | 253 } |
253 | 254 |
254 // static | 255 // static |
255 bool BrowserPluginGuest::IsGuest(RenderViewHostImpl* render_view_host) { | 256 bool BrowserPluginGuest::IsGuest(RenderViewHostImpl* render_view_host) { |
256 return render_view_host && IsGuest( | 257 return render_view_host && IsGuest( |
257 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( | 258 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( |
258 render_view_host))); | 259 render_view_host))); |
259 } | 260 } |
260 | 261 |
261 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() { | 262 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() { |
262 if (!attached()) | 263 if (!attached()) |
263 return NULL; | 264 return NULL; |
264 return embedder_web_contents_->GetRenderWidgetHostView(); | 265 return embedder_web_contents_->GetRenderWidgetHostView(); |
265 } | 266 } |
266 | 267 |
267 void BrowserPluginGuest::UpdateVisibility() { | 268 void BrowserPluginGuest::UpdateVisibility() { |
268 OnSetVisibility(instance_id_, visible()); | 269 OnSetVisibility(browser_plugin_instance_id(), visible()); |
269 } | 270 } |
270 | 271 |
271 void BrowserPluginGuest::CopyFromCompositingSurface( | 272 void BrowserPluginGuest::CopyFromCompositingSurface( |
272 gfx::Rect src_subrect, | 273 gfx::Rect src_subrect, |
273 gfx::Size dst_size, | 274 gfx::Size dst_size, |
274 const base::Callback<void(bool, const SkBitmap&)>& callback) { | 275 const base::Callback<void(bool, const SkBitmap&)>& callback) { |
275 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback)); | 276 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback)); |
276 SendMessageToEmbedder( | 277 SendMessageToEmbedder( |
277 new BrowserPluginMsg_CopyFromCompositingSurface(instance_id(), | 278 new BrowserPluginMsg_CopyFromCompositingSurface( |
278 copy_request_id_, src_subrect, dst_size)); | 279 browser_plugin_instance_id(), |
| 280 copy_request_id_, |
| 281 src_subrect, |
| 282 dst_size)); |
279 } | 283 } |
280 | 284 |
281 BrowserPluginGuestManager* | 285 BrowserPluginGuestManager* |
282 BrowserPluginGuest::GetBrowserPluginGuestManager() const { | 286 BrowserPluginGuest::GetBrowserPluginGuestManager() const { |
283 return GetWebContents()->GetBrowserContext()->GetGuestManager(); | 287 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
284 } | 288 } |
285 | 289 |
286 // screen. | 290 // screen. |
287 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { | 291 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { |
288 gfx::Rect guest_rect(bounds); | 292 gfx::Rect guest_rect(bounds); |
289 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); | 293 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); |
290 if (embedder_web_contents()->GetBrowserPluginGuest()) { | 294 if (embedder_web_contents()->GetBrowserPluginGuest()) { |
291 BrowserPluginGuest* embedder_guest = | 295 BrowserPluginGuest* embedder_guest = |
292 embedder_web_contents()->GetBrowserPluginGuest(); | 296 embedder_web_contents()->GetBrowserPluginGuest(); |
293 guest_rect.Offset(embedder_guest->guest_window_rect_.OffsetFromOrigin()); | 297 guest_rect.Offset(embedder_guest->guest_window_rect_.OffsetFromOrigin()); |
294 } | 298 } |
295 return guest_rect; | 299 return guest_rect; |
296 } | 300 } |
297 | 301 |
298 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { | 302 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { |
299 embedder_visible_ = visible; | 303 embedder_visible_ = visible; |
300 UpdateVisibility(); | 304 UpdateVisibility(); |
301 } | 305 } |
302 | 306 |
303 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { | 307 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { |
304 SendMessageToEmbedder( | 308 SendMessageToEmbedder( |
305 new BrowserPluginMsg_SetMouseLock(instance_id(), allow)); | 309 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), allow)); |
306 } | 310 } |
307 | 311 |
308 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { | 312 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { |
309 return static_cast<WebContentsImpl*>(web_contents()); | 313 return static_cast<WebContentsImpl*>(web_contents()); |
310 } | 314 } |
311 | 315 |
312 gfx::Point BrowserPluginGuest::GetScreenCoordinates( | 316 gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
313 const gfx::Point& relative_position) const { | 317 const gfx::Point& relative_position) const { |
314 if (!attached()) | 318 if (!attached()) |
315 return relative_position; | 319 return relative_position; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); | 372 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); |
369 } | 373 } |
370 | 374 |
371 void BrowserPluginGuest::RenderViewReady() { | 375 void BrowserPluginGuest::RenderViewReady() { |
372 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); | 376 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); |
373 // TODO(fsamuel): Investigate whether it's possible to update state earlier | 377 // TODO(fsamuel): Investigate whether it's possible to update state earlier |
374 // here (see http://crbug.com/158151). | 378 // here (see http://crbug.com/158151). |
375 Send(new InputMsg_SetFocus(routing_id(), focused_)); | 379 Send(new InputMsg_SetFocus(routing_id(), focused_)); |
376 UpdateVisibility(); | 380 UpdateVisibility(); |
377 | 381 |
378 OnSetContentsOpaque(instance_id_, guest_opaque_); | 382 OnSetContentsOpaque(browser_plugin_instance_id(), guest_opaque_); |
379 | 383 |
380 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( | 384 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( |
381 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); | 385 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); |
382 } | 386 } |
383 | 387 |
384 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { | 388 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { |
385 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(instance_id())); | 389 SendMessageToEmbedder( |
| 390 new BrowserPluginMsg_GuestGone(browser_plugin_instance_id())); |
386 switch (status) { | 391 switch (status) { |
387 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 392 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
388 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed")); | 393 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed")); |
389 break; | 394 break; |
390 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 395 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
391 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Crashed")); | 396 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Crashed")); |
392 break; | 397 break; |
393 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 398 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
394 RecordAction( | 399 RecordAction( |
395 base::UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); | 400 base::UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 456 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
452 OnTextInputStateChanged) | 457 OnTextInputStateChanged) |
453 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 458 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
454 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 459 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
455 IPC_MESSAGE_UNHANDLED(handled = false) | 460 IPC_MESSAGE_UNHANDLED(handled = false) |
456 IPC_END_MESSAGE_MAP() | 461 IPC_END_MESSAGE_MAP() |
457 return handled; | 462 return handled; |
458 } | 463 } |
459 | 464 |
460 void BrowserPluginGuest::Attach( | 465 void BrowserPluginGuest::Attach( |
| 466 int browser_plugin_instance_id, |
461 WebContentsImpl* embedder_web_contents, | 467 WebContentsImpl* embedder_web_contents, |
462 const BrowserPluginHostMsg_Attach_Params& params, | 468 const BrowserPluginHostMsg_Attach_Params& params) { |
463 const base::DictionaryValue& extra_params) { | |
464 if (attached()) | 469 if (attached()) |
465 return; | 470 return; |
466 | 471 |
467 if (delegate_) | 472 delegate_->WillAttach(embedder_web_contents); |
468 delegate_->WillAttach(embedder_web_contents, extra_params); | |
469 | 473 |
470 // If a RenderView has already been created for this new window, then we need | 474 // If a RenderView has already been created for this new window, then we need |
471 // to initialize the browser-side state now so that the RenderFrameHostManager | 475 // to initialize the browser-side state now so that the RenderFrameHostManager |
472 // does not create a new RenderView on navigation. | 476 // does not create a new RenderView on navigation. |
473 if (has_render_view_) { | 477 if (has_render_view_) { |
474 static_cast<RenderViewHostImpl*>( | 478 static_cast<RenderViewHostImpl*>( |
475 GetWebContents()->GetRenderViewHost())->Init(); | 479 GetWebContents()->GetRenderViewHost())->Init(); |
476 WebContentsViewGuest* new_view = | 480 WebContentsViewGuest* new_view = |
477 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 481 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
478 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); | 482 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); |
479 } | 483 } |
480 | 484 |
481 Initialize(params, embedder_web_contents, extra_params); | 485 Initialize(browser_plugin_instance_id, params, embedder_web_contents); |
482 | 486 |
483 SendQueuedMessages(); | 487 SendQueuedMessages(); |
484 | 488 |
485 if (delegate_) | 489 delegate_->DidAttach(); |
486 delegate_->DidAttach(); | |
487 | 490 |
488 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 491 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
489 } | 492 } |
490 | 493 |
491 void BrowserPluginGuest::OnCompositorFrameSwappedACK( | 494 void BrowserPluginGuest::OnCompositorFrameSwappedACK( |
492 int instance_id, | 495 int browser_plugin_instance_id, |
493 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { | 496 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { |
494 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, | 497 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, |
495 params.output_surface_id, | 498 params.output_surface_id, |
496 params.producing_host_id, | 499 params.producing_host_id, |
497 params.ack); | 500 params.ack); |
498 } | 501 } |
499 | 502 |
500 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, | 503 void BrowserPluginGuest::OnDragStatusUpdate(int browser_plugin_instance_id, |
501 blink::WebDragStatus drag_status, | 504 blink::WebDragStatus drag_status, |
502 const DropData& drop_data, | 505 const DropData& drop_data, |
503 blink::WebDragOperationsMask mask, | 506 blink::WebDragOperationsMask mask, |
504 const gfx::Point& location) { | 507 const gfx::Point& location) { |
505 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); | 508 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
506 switch (drag_status) { | 509 switch (drag_status) { |
507 case blink::WebDragStatusEnter: | 510 case blink::WebDragStatusEnter: |
508 embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( | 511 embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( |
509 this); | 512 this); |
510 host->DragTargetDragEnter(drop_data, location, location, mask, 0); | 513 host->DragTargetDragEnter(drop_data, location, location, mask, 0); |
511 break; | 514 break; |
512 case blink::WebDragStatusOver: | 515 case blink::WebDragStatusOver: |
513 host->DragTargetDragOver(location, location, mask, 0); | 516 host->DragTargetDragOver(location, location, mask, 0); |
514 break; | 517 break; |
515 case blink::WebDragStatusLeave: | 518 case blink::WebDragStatusLeave: |
516 embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); | 519 embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); |
517 host->DragTargetDragLeave(); | 520 host->DragTargetDragLeave(); |
518 break; | 521 break; |
519 case blink::WebDragStatusDrop: | 522 case blink::WebDragStatusDrop: |
520 host->DragTargetDrop(location, location, 0); | 523 host->DragTargetDrop(location, location, 0); |
521 EndSystemDrag(); | 524 EndSystemDrag(); |
522 break; | 525 break; |
523 case blink::WebDragStatusUnknown: | 526 case blink::WebDragStatusUnknown: |
524 NOTREACHED(); | 527 NOTREACHED(); |
525 } | 528 } |
526 } | 529 } |
527 | 530 |
528 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id, | 531 void BrowserPluginGuest::OnExecuteEditCommand(int browser_plugin_instance_id, |
529 const std::string& name) { | 532 const std::string& name) { |
530 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); | 533 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); |
531 } | 534 } |
532 | 535 |
533 void BrowserPluginGuest::OnImeSetComposition( | 536 void BrowserPluginGuest::OnImeSetComposition( |
534 int instance_id, | 537 int browser_plugin_instance_id, |
535 const std::string& text, | 538 const std::string& text, |
536 const std::vector<blink::WebCompositionUnderline>& underlines, | 539 const std::vector<blink::WebCompositionUnderline>& underlines, |
537 int selection_start, | 540 int selection_start, |
538 int selection_end) { | 541 int selection_end) { |
539 Send(new InputMsg_ImeSetComposition(routing_id(), | 542 Send(new InputMsg_ImeSetComposition(routing_id(), |
540 base::UTF8ToUTF16(text), underlines, | 543 base::UTF8ToUTF16(text), underlines, |
541 selection_start, selection_end)); | 544 selection_start, selection_end)); |
542 } | 545 } |
543 | 546 |
544 void BrowserPluginGuest::OnImeConfirmComposition( | 547 void BrowserPluginGuest::OnImeConfirmComposition( |
545 int instance_id, | 548 int browser_plugin_instance_id, |
546 const std::string& text, | 549 const std::string& text, |
547 bool keep_selection) { | 550 bool keep_selection) { |
548 Send(new InputMsg_ImeConfirmComposition(routing_id(), | 551 Send(new InputMsg_ImeConfirmComposition(routing_id(), |
549 base::UTF8ToUTF16(text), | 552 base::UTF8ToUTF16(text), |
550 gfx::Range::InvalidRange(), | 553 gfx::Range::InvalidRange(), |
551 keep_selection)); | 554 keep_selection)); |
552 } | 555 } |
553 | 556 |
554 void BrowserPluginGuest::OnExtendSelectionAndDelete( | 557 void BrowserPluginGuest::OnExtendSelectionAndDelete( |
555 int instance_id, | 558 int browser_plugin_instance_id, |
556 int before, | 559 int before, |
557 int after) { | 560 int after) { |
558 RenderFrameHostImpl* rfh = static_cast<RenderFrameHostImpl*>( | 561 RenderFrameHostImpl* rfh = static_cast<RenderFrameHostImpl*>( |
559 web_contents()->GetFocusedFrame()); | 562 web_contents()->GetFocusedFrame()); |
560 if (rfh) | 563 if (rfh) |
561 rfh->ExtendSelectionAndDelete(before, after); | 564 rfh->ExtendSelectionAndDelete(before, after); |
562 } | 565 } |
563 | 566 |
564 void BrowserPluginGuest::OnReclaimCompositorResources( | 567 void BrowserPluginGuest::OnReclaimCompositorResources( |
565 int instance_id, | 568 int browser_plugin_instance_id, |
566 const FrameHostMsg_ReclaimCompositorResources_Params& params) { | 569 const FrameHostMsg_ReclaimCompositorResources_Params& params) { |
567 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, | 570 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, |
568 params.output_surface_id, | 571 params.output_surface_id, |
569 params.renderer_host_id, | 572 params.renderer_host_id, |
570 params.ack); | 573 params.ack); |
571 } | 574 } |
572 | 575 |
573 void BrowserPluginGuest::OnHandleInputEvent( | 576 void BrowserPluginGuest::OnHandleInputEvent( |
574 int instance_id, | 577 int browser_plugin_instance_id, |
575 const gfx::Rect& guest_window_rect, | 578 const gfx::Rect& guest_window_rect, |
576 const blink::WebInputEvent* event) { | 579 const blink::WebInputEvent* event) { |
577 guest_window_rect_ = guest_window_rect; | 580 guest_window_rect_ = guest_window_rect; |
578 // If the embedder's RWHV is destroyed then that means that the embedder's | 581 // If the embedder's RWHV is destroyed then that means that the embedder's |
579 // window has been closed but the embedder's WebContents has not yet been | 582 // window has been closed but the embedder's WebContents has not yet been |
580 // destroyed. Computing screen coordinates of a BrowserPlugin only makes sense | 583 // destroyed. Computing screen coordinates of a BrowserPlugin only makes sense |
581 // if there is a visible embedder. | 584 // if there is a visible embedder. |
582 if (embedder_web_contents_->GetRenderWidgetHostView()) { | 585 if (embedder_web_contents_->GetRenderWidgetHostView()) { |
583 guest_screen_rect_ = guest_window_rect; | 586 guest_screen_rect_ = guest_window_rect; |
584 guest_screen_rect_.Offset( | 587 guest_screen_rect_.Offset( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 640 |
638 pending_lock_request_ = true; | 641 pending_lock_request_ = true; |
639 | 642 |
640 delegate_->RequestPointerLockPermission( | 643 delegate_->RequestPointerLockPermission( |
641 user_gesture, | 644 user_gesture, |
642 last_unlocked_by_target, | 645 last_unlocked_by_target, |
643 base::Bind(&BrowserPluginGuest::PointerLockPermissionResponse, | 646 base::Bind(&BrowserPluginGuest::PointerLockPermissionResponse, |
644 weak_ptr_factory_.GetWeakPtr())); | 647 weak_ptr_factory_.GetWeakPtr())); |
645 } | 648 } |
646 | 649 |
647 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) { | 650 void BrowserPluginGuest::OnLockMouseAck(int browser_plugin_instance_id, |
| 651 bool succeeded) { |
648 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); | 652 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); |
649 pending_lock_request_ = false; | 653 pending_lock_request_ = false; |
650 if (succeeded) | 654 if (succeeded) |
651 mouse_locked_ = true; | 655 mouse_locked_ = true; |
652 } | 656 } |
653 | 657 |
654 void BrowserPluginGuest::OnPluginDestroyed(int instance_id) { | 658 void BrowserPluginGuest::OnPluginDestroyed(int browser_plugin_instance_id) { |
655 Destroy(); | 659 Destroy(); |
656 } | 660 } |
657 | 661 |
658 void BrowserPluginGuest::OnResizeGuest( | 662 void BrowserPluginGuest::OnResizeGuest( |
659 int instance_id, | 663 int browser_plugin_instance_id, |
660 const BrowserPluginHostMsg_ResizeGuest_Params& params) { | 664 const BrowserPluginHostMsg_ResizeGuest_Params& params) { |
661 if (!params.size_changed) | 665 if (!params.size_changed) |
662 return; | 666 return; |
663 // BrowserPlugin manages resize flow control itself and does not depend | 667 // BrowserPlugin manages resize flow control itself and does not depend |
664 // on RenderWidgetHost's mechanisms for flow control, so we reset those flags | 668 // on RenderWidgetHost's mechanisms for flow control, so we reset those flags |
665 // here. If we are setting the size for the first time before navigating then | 669 // here. If we are setting the size for the first time before navigating then |
666 // BrowserPluginGuest does not yet have a RenderViewHost. | 670 // BrowserPluginGuest does not yet have a RenderViewHost. |
667 if (GetWebContents()->GetRenderViewHost()) { | 671 if (GetWebContents()->GetRenderViewHost()) { |
668 RenderWidgetHostImpl* render_widget_host = | 672 RenderWidgetHostImpl* render_widget_host = |
669 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); | 673 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); |
(...skipping 11 matching lines...) Expand all Loading... |
681 last_seen_browser_plugin_size_ = params.view_size; | 685 last_seen_browser_plugin_size_ = params.view_size; |
682 } | 686 } |
683 | 687 |
684 // Just resize the WebContents and repaint if needed. | 688 // Just resize the WebContents and repaint if needed. |
685 if (!params.view_size.IsEmpty()) | 689 if (!params.view_size.IsEmpty()) |
686 GetWebContents()->GetView()->SizeContents(params.view_size); | 690 GetWebContents()->GetView()->SizeContents(params.view_size); |
687 if (params.repaint) | 691 if (params.repaint) |
688 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); | 692 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); |
689 } | 693 } |
690 | 694 |
691 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { | 695 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id, |
| 696 bool focused) { |
692 focused_ = focused; | 697 focused_ = focused; |
693 Send(new InputMsg_SetFocus(routing_id(), focused)); | 698 Send(new InputMsg_SetFocus(routing_id(), focused)); |
694 if (!focused && mouse_locked_) | 699 if (!focused && mouse_locked_) |
695 OnUnlockMouse(); | 700 OnUnlockMouse(); |
696 | 701 |
697 // Restore the last seen state of text input to the view. | 702 // Restore the last seen state of text input to the view. |
698 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( | 703 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( |
699 web_contents()->GetRenderWidgetHostView()); | 704 web_contents()->GetRenderWidgetHostView()); |
700 if (rwhv) { | 705 if (rwhv) { |
701 ViewHostMsg_TextInputState_Params params; | 706 ViewHostMsg_TextInputState_Params params; |
702 params.type = last_text_input_type_; | 707 params.type = last_text_input_type_; |
703 params.mode = last_input_mode_; | 708 params.mode = last_input_mode_; |
704 params.can_compose_inline = last_can_compose_inline_; | 709 params.can_compose_inline = last_can_compose_inline_; |
705 rwhv->TextInputStateChanged(params); | 710 rwhv->TextInputStateChanged(params); |
706 } | 711 } |
707 } | 712 } |
708 | 713 |
709 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( | 714 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( |
710 int instance_id, | 715 int browser_plugin_instance_id, |
711 const std::vector<EditCommand>& edit_commands) { | 716 const std::vector<EditCommand>& edit_commands) { |
712 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), | 717 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), |
713 edit_commands)); | 718 edit_commands)); |
714 } | 719 } |
715 | 720 |
716 void BrowserPluginGuest::OnSetContentsOpaque(int instance_id, bool opaque) { | 721 void BrowserPluginGuest::OnSetContentsOpaque(int browser_plugin_instance_id, |
| 722 bool opaque) { |
717 guest_opaque_ = opaque; | 723 guest_opaque_ = opaque; |
718 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_)); | 724 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_)); |
719 } | 725 } |
720 | 726 |
721 void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { | 727 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, |
| 728 bool visible) { |
722 guest_visible_ = visible; | 729 guest_visible_ = visible; |
723 if (embedder_visible_ && guest_visible_) | 730 if (embedder_visible_ && guest_visible_) |
724 GetWebContents()->WasShown(); | 731 GetWebContents()->WasShown(); |
725 else | 732 else |
726 GetWebContents()->WasHidden(); | 733 GetWebContents()->WasHidden(); |
727 } | 734 } |
728 | 735 |
729 void BrowserPluginGuest::OnUnlockMouse() { | 736 void BrowserPluginGuest::OnUnlockMouse() { |
730 SendMessageToEmbedder( | 737 SendMessageToEmbedder( |
731 new BrowserPluginMsg_SetMouseLock(instance_id(), false)); | 738 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), false)); |
732 } | 739 } |
733 | 740 |
734 void BrowserPluginGuest::OnUnlockMouseAck(int instance_id) { | 741 void BrowserPluginGuest::OnUnlockMouseAck(int browser_plugin_instance_id) { |
735 // mouse_locked_ could be false here if the lock attempt was cancelled due | 742 // mouse_locked_ could be false here if the lock attempt was cancelled due |
736 // to window focus, or for various other reasons before the guest was informed | 743 // to window focus, or for various other reasons before the guest was informed |
737 // of the lock's success. | 744 // of the lock's success. |
738 if (mouse_locked_) | 745 if (mouse_locked_) |
739 Send(new ViewMsg_MouseLockLost(routing_id())); | 746 Send(new ViewMsg_MouseLockLost(routing_id())); |
740 mouse_locked_ = false; | 747 mouse_locked_ = false; |
741 } | 748 } |
742 | 749 |
743 void BrowserPluginGuest::OnCopyFromCompositingSurfaceAck( | 750 void BrowserPluginGuest::OnCopyFromCompositingSurfaceAck( |
744 int instance_id, | 751 int browser_plugin_instance_id, |
745 int request_id, | 752 int request_id, |
746 const SkBitmap& bitmap) { | 753 const SkBitmap& bitmap) { |
747 CHECK(copy_request_callbacks_.count(request_id)); | 754 CHECK(copy_request_callbacks_.count(request_id)); |
748 if (!copy_request_callbacks_.count(request_id)) | 755 if (!copy_request_callbacks_.count(request_id)) |
749 return; | 756 return; |
750 const CopyRequestCallback& callback = copy_request_callbacks_[request_id]; | 757 const CopyRequestCallback& callback = copy_request_callbacks_[request_id]; |
751 callback.Run(!bitmap.empty() && !bitmap.isNull(), bitmap); | 758 callback.Run(!bitmap.empty() && !bitmap.isNull(), bitmap); |
752 copy_request_callbacks_.erase(request_id); | 759 copy_request_callbacks_.erase(request_id); |
753 } | 760 } |
754 | 761 |
755 void BrowserPluginGuest::OnUpdateGeometry(int instance_id, | 762 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, |
756 const gfx::Rect& view_rect) { | 763 const gfx::Rect& view_rect) { |
757 // The plugin has moved within the embedder without resizing or the | 764 // The plugin has moved within the embedder without resizing or the |
758 // embedder/container's view rect changing. | 765 // embedder/container's view rect changing. |
759 guest_window_rect_ = view_rect; | 766 guest_window_rect_ = view_rect; |
760 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 767 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
761 GetWebContents()->GetRenderViewHost()); | 768 GetWebContents()->GetRenderViewHost()); |
762 if (rvh) | 769 if (rvh) |
763 rvh->SendScreenRects(); | 770 rvh->SendScreenRects(); |
764 } | 771 } |
765 | 772 |
766 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { | 773 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { |
767 SendMessageToEmbedder( | 774 SendMessageToEmbedder( |
768 new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); | 775 new BrowserPluginMsg_ShouldAcceptTouchEvents( |
| 776 browser_plugin_instance_id(), accept)); |
769 } | 777 } |
770 | 778 |
771 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) { | 779 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) { |
772 SendMessageToEmbedder(new BrowserPluginMsg_SetCursor(instance_id(), cursor)); | 780 SendMessageToEmbedder( |
| 781 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor)); |
773 } | 782 } |
774 | 783 |
775 #if defined(OS_MACOSX) | 784 #if defined(OS_MACOSX) |
776 void BrowserPluginGuest::OnShowPopup( | 785 void BrowserPluginGuest::OnShowPopup( |
777 const ViewHostMsg_ShowPopup_Params& params) { | 786 const ViewHostMsg_ShowPopup_Params& params) { |
778 gfx::Rect translated_bounds(params.bounds); | 787 gfx::Rect translated_bounds(params.bounds); |
779 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); | 788 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); |
780 BrowserPluginPopupMenuHelper popup_menu_helper( | 789 BrowserPluginPopupMenuHelper popup_menu_helper( |
781 embedder_web_contents_->GetRenderViewHost(), | 790 embedder_web_contents_->GetRenderViewHost(), |
782 GetWebContents()->GetRenderViewHost()); | 791 GetWebContents()->GetRenderViewHost()); |
783 popup_menu_helper.ShowPopupMenu(translated_bounds, | 792 popup_menu_helper.ShowPopupMenu(translated_bounds, |
784 params.item_height, | 793 params.item_height, |
785 params.item_font_size, | 794 params.item_font_size, |
786 params.selected_item, | 795 params.selected_item, |
787 params.popup_items, | 796 params.popup_items, |
788 params.right_aligned, | 797 params.right_aligned, |
789 params.allow_multiple_selection); | 798 params.allow_multiple_selection); |
790 } | 799 } |
791 #endif | 800 #endif |
792 | 801 |
793 void BrowserPluginGuest::OnShowWidget(int route_id, | 802 void BrowserPluginGuest::OnShowWidget(int route_id, |
794 const gfx::Rect& initial_pos) { | 803 const gfx::Rect& initial_pos) { |
795 GetWebContents()->ShowCreatedWidget(route_id, initial_pos); | 804 GetWebContents()->ShowCreatedWidget(route_id, initial_pos); |
796 } | 805 } |
797 | 806 |
798 void BrowserPluginGuest::OnTakeFocus(bool reverse) { | 807 void BrowserPluginGuest::OnTakeFocus(bool reverse) { |
799 SendMessageToEmbedder( | 808 SendMessageToEmbedder( |
800 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); | 809 new BrowserPluginMsg_AdvanceFocus(browser_plugin_instance_id(), reverse)); |
801 } | 810 } |
802 | 811 |
803 void BrowserPluginGuest::OnUpdateRect( | 812 void BrowserPluginGuest::OnUpdateRect( |
804 const ViewHostMsg_UpdateRect_Params& params) { | 813 const ViewHostMsg_UpdateRect_Params& params) { |
805 BrowserPluginMsg_UpdateRect_Params relay_params; | 814 BrowserPluginMsg_UpdateRect_Params relay_params; |
806 relay_params.view_size = params.view_size; | 815 relay_params.view_size = params.view_size; |
807 relay_params.scale_factor = params.scale_factor; | 816 relay_params.scale_factor = params.scale_factor; |
808 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( | 817 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( |
809 params.flags); | 818 params.flags); |
810 | 819 |
811 if (last_seen_view_size_ != params.view_size) { | 820 if (last_seen_view_size_ != params.view_size) { |
812 delegate_->GuestSizeChanged(last_seen_view_size_, params.view_size); | 821 delegate_->GuestSizeChanged(last_seen_view_size_, params.view_size); |
813 last_seen_view_size_ = params.view_size; | 822 last_seen_view_size_ = params.view_size; |
814 } | 823 } |
815 | 824 |
816 SendMessageToEmbedder( | 825 SendMessageToEmbedder( |
817 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); | 826 new BrowserPluginMsg_UpdateRect(browser_plugin_instance_id(), |
| 827 relay_params)); |
818 } | 828 } |
819 | 829 |
820 void BrowserPluginGuest::OnTextInputStateChanged( | 830 void BrowserPluginGuest::OnTextInputStateChanged( |
821 const ViewHostMsg_TextInputState_Params& params) { | 831 const ViewHostMsg_TextInputState_Params& params) { |
822 // Save the state of text input so we can restore it on focus. | 832 // Save the state of text input so we can restore it on focus. |
823 last_text_input_type_ = params.type; | 833 last_text_input_type_ = params.type; |
824 last_input_mode_ = params.mode; | 834 last_input_mode_ = params.mode; |
825 last_can_compose_inline_ = params.can_compose_inline; | 835 last_can_compose_inline_ = params.can_compose_inline; |
826 | 836 |
827 static_cast<RenderWidgetHostViewBase*>( | 837 static_cast<RenderWidgetHostViewBase*>( |
828 web_contents()->GetRenderWidgetHostView())->TextInputStateChanged(params); | 838 web_contents()->GetRenderWidgetHostView())->TextInputStateChanged(params); |
829 } | 839 } |
830 | 840 |
831 void BrowserPluginGuest::OnImeCancelComposition() { | 841 void BrowserPluginGuest::OnImeCancelComposition() { |
832 static_cast<RenderWidgetHostViewBase*>( | 842 static_cast<RenderWidgetHostViewBase*>( |
833 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); | 843 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); |
834 } | 844 } |
835 | 845 |
836 #if defined(OS_MACOSX) || defined(USE_AURA) | 846 #if defined(OS_MACOSX) || defined(USE_AURA) |
837 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 847 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
838 const gfx::Range& range, | 848 const gfx::Range& range, |
839 const std::vector<gfx::Rect>& character_bounds) { | 849 const std::vector<gfx::Rect>& character_bounds) { |
840 static_cast<RenderWidgetHostViewBase*>( | 850 static_cast<RenderWidgetHostViewBase*>( |
841 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 851 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
842 range, character_bounds); | 852 range, character_bounds); |
843 } | 853 } |
844 #endif | 854 #endif |
845 | 855 |
846 } // namespace content | 856 } // namespace content |
OLD | NEW |