Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 1602663003: Framelet Prototype 2016 using Mojo IPC Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Disabled oilpan Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 WebContentsImpl* web_contents, 83 WebContentsImpl* web_contents,
84 BrowserPluginGuestDelegate* delegate) 84 BrowserPluginGuestDelegate* delegate)
85 : WebContentsObserver(web_contents), 85 : WebContentsObserver(web_contents),
86 owner_web_contents_(nullptr), 86 owner_web_contents_(nullptr),
87 attached_(false), 87 attached_(false),
88 has_attached_since_surface_set_(false), 88 has_attached_since_surface_set_(false),
89 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 89 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
90 focused_(false), 90 focused_(false),
91 mouse_locked_(false), 91 mouse_locked_(false),
92 pending_lock_request_(false), 92 pending_lock_request_(false),
93 guest_visible_(false), 93 container_visible_(false),
94 embedder_visible_(true), 94 embedder_visible_(true),
95 is_full_page_plugin_(false), 95 is_full_page_plugin_(false),
96 has_render_view_(has_render_view), 96 has_render_view_(has_render_view),
97 is_in_destruction_(false), 97 is_in_destruction_(false),
98 initialized_(false), 98 initialized_(false),
99 guest_proxy_routing_id_(MSG_ROUTING_NONE), 99 guest_proxy_routing_id_(MSG_ROUTING_NONE),
100 last_drag_status_(blink::WebDragStatusUnknown), 100 last_drag_status_(blink::WebDragStatusUnknown),
101 seen_embedder_system_drag_ended_(false), 101 seen_embedder_system_drag_ended_(false),
102 seen_embedder_drag_source_ended_at_(false), 102 seen_embedder_drag_source_ended_at_(false),
103 delegate_(delegate), 103 delegate_(delegate),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 owner_site_instance->GetProcess()->GetID(), proxy_routing_id) 138 owner_site_instance->GetProcess()->GetID(), proxy_routing_id)
139 ->GetRenderViewHost()->GetRoutingID(); 139 ->GetRenderViewHost()->GetRoutingID();
140 } else { 140 } else {
141 guest_proxy_routing_id_ = 141 guest_proxy_routing_id_ =
142 GetWebContents()->CreateSwappedOutRenderView(owner_site_instance); 142 GetWebContents()->CreateSwappedOutRenderView(owner_site_instance);
143 } 143 }
144 144
145 return guest_proxy_routing_id_; 145 return guest_proxy_routing_id_;
146 } 146 }
147 147
148 void BrowserPluginGuest::Attach(int element_instance_id,
149 WebContents* embedder_web_contents,
150 const GuestAttachParams& attach_params) {
151 browser_plugin_instance_id_ = element_instance_id;
152 // If a guest is detaching from one container and attaching to another
153 // container, then late arriving ACKs may be lost if the mapping from
154 // |browser_plugin_instance_id| to |guest_instance_id| changes. Thus we
155 // ensure that we always get new frames on attachment by ACKing the pending
156 // frame if it's still waiting on the ACK.
157 if (last_pending_frame_) {
158 cc::CompositorFrameAck ack;
159 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
160 last_pending_frame_->producing_route_id,
161 last_pending_frame_->output_surface_id,
162 last_pending_frame_->producing_host_id, ack);
163 last_pending_frame_.reset();
164 }
165
166 // The guest is owned by the embedder. Attach is queued up so we cannot
167 // change embedders before attach completes. If the embedder goes away,
168 // so does the guest and so we will never call WillAttachComplete because
169 // we have a weak ptr.
170 delegate_->WillAttach(
171 embedder_web_contents, element_instance_id, attach_params.is_full_page,
172 base::Bind(&BrowserPluginGuest::OnWillAttachComplete,
173 weak_ptr_factory_.GetWeakPtr(),
174 static_cast<WebContentsImpl*>(embedder_web_contents),
175 attach_params));
176 }
177
148 int BrowserPluginGuest::LoadURLWithParams( 178 int BrowserPluginGuest::LoadURLWithParams(
149 const NavigationController::LoadURLParams& load_params) { 179 const NavigationController::LoadURLParams& load_params) {
150 GetWebContents()->GetController().LoadURLWithParams(load_params); 180 GetWebContents()->GetController().LoadURLWithParams(load_params);
151 return GetGuestProxyRoutingID(); 181 return GetGuestProxyRoutingID();
152 } 182 }
153 183
154 void BrowserPluginGuest::GuestResizeDueToAutoResize(const gfx::Size& new_size) { 184 void BrowserPluginGuest::GuestResizeDueToAutoResize(const gfx::Size& new_size) {
155 if (last_seen_view_size_ != new_size) { 185 if (last_seen_view_size_ != new_size) {
156 delegate_->GuestSizeChanged(new_size); 186 delegate_->GuestSizeChanged(new_size);
157 last_seen_view_size_ = new_size; 187 last_seen_view_size_ = new_size;
158 } 188 }
159 } 189 }
160 190
191 void BrowserPluginGuest::SetContainerVisible(bool visible) {
192 container_visible_ = visible;
193 UpdateVisibility();
194 }
195
196 void BrowserPluginGuest::SetFocus(bool focused,
197 blink::WebFocusType focus_type) {
198 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView();
199 RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : nullptr;
200 SetFocusForRenderWidgetHost(rwh, focused, focus_type);
201 }
202
161 void BrowserPluginGuest::SizeContents(const gfx::Size& new_size) { 203 void BrowserPluginGuest::SizeContents(const gfx::Size& new_size) {
162 GetWebContents()->GetView()->SizeContents(new_size); 204 GetWebContents()->GetView()->SizeContents(new_size);
163 } 205 }
164 206
207 void BrowserPluginGuest::ForwardInputEvent(const blink::WebInputEvent* event) {
208 RenderWidgetHostImpl* embedder_host =
209 embedder_web_contents()->GetMainFrame()->GetRenderWidgetHost();
210 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView();
211 RenderWidgetHostImpl* host = static_cast<RenderWidgetHostImpl*>(
212 rwhv ? rwhv->GetRenderWidgetHost() : nullptr);
213 if (!host)
214 return;
215
216 if (blink::WebInputEvent::isMouseEventType(event->type)) {
217 host->ForwardMouseEvent(*static_cast<const blink::WebMouseEvent*>(event));
218 } else if (event->type == blink::WebInputEvent::MouseWheel) {
219 host->ForwardWheelEvent(
220 *static_cast<const blink::WebMouseWheelEvent*>(event));
221 } else if (blink::WebInputEvent::isGestureEventType(event->type)) {
222 host->ForwardGestureEvent(
223 *static_cast<const blink::WebGestureEvent*>(event));
224 } else if (blink::WebInputEvent::isKeyboardEventType(event->type)) {
225 if (!embedder_host->GetLastKeyboardEvent())
226 return;
227 NativeWebKeyboardEvent keyboard_event(
228 *embedder_host->GetLastKeyboardEvent());
229 host->ForwardKeyboardEvent(keyboard_event);
230 } else if (blink::WebInputEvent::isTouchEventType(event->type)) {
231 if (event->type == blink::WebInputEvent::TouchStart &&
232 !embedder_host->GetView()->HasFocus()) {
233 embedder_host->GetView()->Focus();
234 }
235 host->ForwardTouchEventWithLatencyInfo(
236 *static_cast<const blink::WebTouchEvent*>(event), ui::LatencyInfo());
237 }
238 }
239
165 void BrowserPluginGuest::WillDestroy() { 240 void BrowserPluginGuest::WillDestroy() {
166 is_in_destruction_ = true; 241 is_in_destruction_ = true;
167 owner_web_contents_ = nullptr; 242 owner_web_contents_ = nullptr;
168 attached_ = false; 243 attached_ = false;
169 } 244 }
170 245
171 void BrowserPluginGuest::Init() { 246 void BrowserPluginGuest::Init() {
172 if (initialized_) 247 if (initialized_)
173 return; 248 return;
174 initialized_ = true; 249 initialized_ = true;
175 250
176 // TODO(fsamuel): Initiailization prior to attachment should be behind a 251 // TODO(fsamuel): Initiailization prior to attachment should be behind a
177 // command line flag once we introduce experimental guest types that rely on 252 // command line flag once we introduce experimental guest types that rely on
178 // this functionality. 253 // this functionality.
179 if (!delegate_->CanRunInDetachedState()) 254 if (!delegate_->CanRunInDetachedState())
180 return; 255 return;
181 256
182 WebContentsImpl* owner_web_contents = static_cast<WebContentsImpl*>( 257 WebContentsImpl* owner_web_contents = static_cast<WebContentsImpl*>(
183 delegate_->GetOwnerWebContents()); 258 delegate_->GetOwnerWebContents());
184 owner_web_contents->CreateBrowserPluginEmbedderIfNecessary(); 259 owner_web_contents->CreateBrowserPluginEmbedderIfNecessary();
185 InitInternal(BrowserPluginHostMsg_Attach_Params(), owner_web_contents); 260 InitInternal(GuestAttachParams(), owner_web_contents);
186 } 261 }
187 262
188 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() { 263 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
189 return weak_ptr_factory_.GetWeakPtr(); 264 return weak_ptr_factory_.GetWeakPtr();
190 } 265 }
191 266
192 void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, 267 void BrowserPluginGuest::SetFocusForRenderWidgetHost(
193 bool focused, 268 RenderWidgetHost* rwh,
194 blink::WebFocusType focus_type) { 269 bool focused,
270 blink::WebFocusType focus_type) {
195 focused_ = focused; 271 focused_ = focused;
196 if (!rwh) 272 if (!rwh)
197 return; 273 return;
198 274
199 if ((focus_type == blink::WebFocusTypeForward) || 275 if ((focus_type == blink::WebFocusTypeForward) ||
200 (focus_type == blink::WebFocusTypeBackward)) { 276 (focus_type == blink::WebFocusTypeBackward)) {
201 static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))-> 277 static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))->
202 SetInitialFocus(focus_type == blink::WebFocusTypeBackward); 278 SetInitialFocus(focus_type == blink::WebFocusTypeBackward);
203 } 279 }
204 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused)); 280 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) 348 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility)
273 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) 349 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck)
274 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) 350 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry)
275 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SatisfySequence, OnSatisfySequence) 351 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SatisfySequence, OnSatisfySequence)
276 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_RequireSequence, OnRequireSequence) 352 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_RequireSequence, OnRequireSequence)
277 IPC_MESSAGE_UNHANDLED(handled = false) 353 IPC_MESSAGE_UNHANDLED(handled = false)
278 IPC_END_MESSAGE_MAP() 354 IPC_END_MESSAGE_MAP()
279 return handled; 355 return handled;
280 } 356 }
281 357
282 void BrowserPluginGuest::InitInternal( 358 void BrowserPluginGuest::InitInternal(const GuestAttachParams& params,
283 const BrowserPluginHostMsg_Attach_Params& params, 359 WebContentsImpl* owner_web_contents) {
284 WebContentsImpl* owner_web_contents) { 360 SetContainerVisible(params.visible);
285 focused_ = params.focused; 361 SetFocus(params.focused, blink::WebFocusTypeNone);
286 OnSetFocus(browser_plugin::kInstanceIDNone,
287 focused_,
288 blink::WebFocusTypeNone);
289 362
290 guest_visible_ = params.visible; 363 is_full_page_plugin_ = params.is_full_page;
291 UpdateVisibility();
292
293 is_full_page_plugin_ = params.is_full_page_plugin;
294 guest_window_rect_ = params.view_rect; 364 guest_window_rect_ = params.view_rect;
295 365
296 if (owner_web_contents_ != owner_web_contents) { 366 if (owner_web_contents_ != owner_web_contents) {
297 WebContentsViewGuest* new_view = nullptr; 367 WebContentsViewGuest* new_view = nullptr;
298 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 368 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) {
299 new_view = 369 new_view =
300 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 370 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
301 } 371 }
302 372
303 if (owner_web_contents_ && new_view) 373 if (owner_web_contents_ && new_view)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Initialize the device scale factor by calling |NotifyScreenInfoChanged|. 409 // Initialize the device scale factor by calling |NotifyScreenInfoChanged|.
340 auto render_widget_host = RenderWidgetHostImpl::From( 410 auto render_widget_host = RenderWidgetHostImpl::From(
341 GetWebContents()->GetRenderViewHost()->GetWidget()); 411 GetWebContents()->GetRenderViewHost()->GetWidget());
342 render_widget_host->NotifyScreenInfoChanged(); 412 render_widget_host->NotifyScreenInfoChanged();
343 413
344 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will 414 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will
345 // be reset again the next time preferences are updated. 415 // be reset again the next time preferences are updated.
346 WebPreferences prefs = 416 WebPreferences prefs =
347 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); 417 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences();
348 prefs.navigate_on_drag_drop = false; 418 prefs.navigate_on_drag_drop = false;
419 prefs.viewport_enabled = false;
420 prefs.viewport_meta_enabled = false;
349 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); 421 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs);
350 } 422 }
351 423
352 BrowserPluginGuest::~BrowserPluginGuest() { 424 BrowserPluginGuest::~BrowserPluginGuest() {
353 } 425 }
354 426
355 // static 427 // static
356 BrowserPluginGuest* BrowserPluginGuest::Create( 428 BrowserPluginGuest* BrowserPluginGuest::Create(
357 WebContentsImpl* web_contents, 429 WebContentsImpl* web_contents,
358 BrowserPluginGuestDelegate* delegate) { 430 BrowserPluginGuestDelegate* delegate) {
(...skipping 13 matching lines...) Expand all
372 render_view_host))); 444 render_view_host)));
373 } 445 }
374 446
375 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { 447 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() {
376 if (!owner_web_contents_) 448 if (!owner_web_contents_)
377 return nullptr; 449 return nullptr;
378 return owner_web_contents_->GetRenderWidgetHostView(); 450 return owner_web_contents_->GetRenderWidgetHostView();
379 } 451 }
380 452
381 void BrowserPluginGuest::UpdateVisibility() { 453 void BrowserPluginGuest::UpdateVisibility() {
382 OnSetVisibility(browser_plugin_instance_id(), visible()); 454 if (embedder_visible_ && container_visible_)
455 GetWebContents()->WasShown();
456 else
457 GetWebContents()->WasHidden();
383 } 458 }
384 459
385 BrowserPluginGuestManager* 460 BrowserPluginGuestManager*
386 BrowserPluginGuest::GetBrowserPluginGuestManager() const { 461 BrowserPluginGuest::GetBrowserPluginGuestManager() const {
387 return GetWebContents()->GetBrowserContext()->GetGuestManager(); 462 return GetWebContents()->GetBrowserContext()->GetGuestManager();
388 } 463 }
389 464
390 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { 465 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
391 embedder_visible_ = visible; 466 embedder_visible_ = visible;
392 UpdateVisibility(); 467 UpdateVisibility();
(...skipping 21 matching lines...) Expand all
414 new BrowserPluginMsg_CompositorFrameSwapped( 489 new BrowserPluginMsg_CompositorFrameSwapped(
415 browser_plugin_instance_id(), *last_pending_frame_)); 490 browser_plugin_instance_id(), *last_pending_frame_));
416 } 491 }
417 492
418 void BrowserPluginGuest::SetChildFrameSurface( 493 void BrowserPluginGuest::SetChildFrameSurface(
419 const cc::SurfaceId& surface_id, 494 const cc::SurfaceId& surface_id,
420 const gfx::Size& frame_size, 495 const gfx::Size& frame_size,
421 float scale_factor, 496 float scale_factor,
422 const cc::SurfaceSequence& sequence) { 497 const cc::SurfaceSequence& sequence) {
423 has_attached_since_surface_set_ = false; 498 has_attached_since_surface_set_ = false;
499 if (delegate_->SetChildFrameSurface(surface_id, frame_size, scale_factor,
500 sequence)) {
501 return;
502 }
424 SendMessageToEmbedder(new BrowserPluginMsg_SetChildFrameSurface( 503 SendMessageToEmbedder(new BrowserPluginMsg_SetChildFrameSurface(
425 browser_plugin_instance_id(), surface_id, frame_size, scale_factor, 504 browser_plugin_instance_id(), surface_id, frame_size, scale_factor,
426 sequence)); 505 sequence));
427 } 506 }
428 507
429 void BrowserPluginGuest::OnSatisfySequence( 508 void BrowserPluginGuest::OnSatisfySequence(
430 int instance_id, 509 int instance_id,
431 const cc::SurfaceSequence& sequence) { 510 const cc::SurfaceSequence& sequence) {
432 std::vector<uint32_t> sequences; 511 std::vector<uint32_t> sequences;
433 sequences.push_back(sequence.sequence); 512 sequences.push_back(sequence.sequence);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 769
691 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { 770 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
692 bool handled = true; 771 bool handled = true;
693 // In --site-per-process, we do not need most of BrowserPluginGuest to drive 772 // In --site-per-process, we do not need most of BrowserPluginGuest to drive
694 // inner WebContents. 773 // inner WebContents.
695 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in 774 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in
696 // RWHVChildFrame, so we're disabling message handling entirely here. 775 // RWHVChildFrame, so we're disabling message handling entirely here.
697 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required 776 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required
698 // parts of code from this class should be extracted to a separate class for 777 // parts of code from this class should be extracted to a separate class for
699 // --site-per-process. 778 // --site-per-process.
700 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 779 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests())
701 return false; 780 return false;
702 }
703 781
704 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 782 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
705 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 783 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
706 OnImeCancelComposition) 784 OnImeCancelComposition)
707 #if defined(OS_MACOSX) || defined(USE_AURA) 785 #if defined(OS_MACOSX) || defined(USE_AURA)
708 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 786 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
709 OnImeCompositionRangeChanged) 787 OnImeCompositionRangeChanged)
710 #endif 788 #endif
711 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, 789 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
712 OnHasTouchEventHandlers) 790 OnHasTouchEventHandlers)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 return handled; 822 return handled;
745 #else 823 #else
746 return false; 824 return false;
747 #endif 825 #endif
748 } 826 }
749 827
750 void BrowserPluginGuest::Attach( 828 void BrowserPluginGuest::Attach(
751 int browser_plugin_instance_id, 829 int browser_plugin_instance_id,
752 WebContentsImpl* embedder_web_contents, 830 WebContentsImpl* embedder_web_contents,
753 const BrowserPluginHostMsg_Attach_Params& params) { 831 const BrowserPluginHostMsg_Attach_Params& params) {
754 browser_plugin_instance_id_ = browser_plugin_instance_id; 832 GuestAttachParams attach_params;
755 // If a guest is detaching from one container and attaching to another 833 attach_params.focused = params.focused;
756 // container, then late arriving ACKs may be lost if the mapping from 834 attach_params.visible = params.visible;
757 // |browser_plugin_instance_id| to |guest_instance_id| changes. Thus we 835 attach_params.view_rect = params.view_rect;
758 // ensure that we always get new frames on attachment by ACKing the pending 836 attach_params.is_full_page = params.is_full_page_plugin;
759 // frame if it's still waiting on the ACK. 837 Attach(browser_plugin_instance_id, embedder_web_contents, attach_params);
760 if (last_pending_frame_) {
761 cc::CompositorFrameAck ack;
762 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
763 last_pending_frame_->producing_route_id,
764 last_pending_frame_->output_surface_id,
765 last_pending_frame_->producing_host_id,
766 ack);
767 last_pending_frame_.reset();
768 }
769
770 // The guest is owned by the embedder. Attach is queued up so we cannot
771 // change embedders before attach completes. If the embedder goes away,
772 // so does the guest and so we will never call WillAttachComplete because
773 // we have a weak ptr.
774 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id,
775 params.is_full_page_plugin,
776 base::Bind(&BrowserPluginGuest::OnWillAttachComplete,
777 weak_ptr_factory_.GetWeakPtr(),
778 embedder_web_contents, params));
779 } 838 }
780 839
781 void BrowserPluginGuest::OnWillAttachComplete( 840 void BrowserPluginGuest::OnWillAttachComplete(
782 WebContentsImpl* embedder_web_contents, 841 WebContentsImpl* embedder_web_contents,
783 const BrowserPluginHostMsg_Attach_Params& params) { 842 const GuestAttachParams& params) {
784 bool use_cross_process_frames = 843 bool use_cross_process_frames =
785 BrowserPluginGuestMode::UseCrossProcessFramesForGuests(); 844 BrowserPluginGuestMode::UseCrossProcessFramesForGuests();
786 // If a RenderView has already been created for this new window, then we need 845 // If a RenderView has already been created for this new window, then we need
787 // to initialize the browser-side state now so that the RenderFrameHostManager 846 // to initialize the browser-side state now so that the RenderFrameHostManager
788 // does not create a new RenderView on navigation. 847 // does not create a new RenderView on navigation.
789 if (!use_cross_process_frames && has_render_view_) { 848 if (!use_cross_process_frames && has_render_view_) {
790 // This will trigger a callback to RenderViewReady after a round-trip IPC. 849 // This will trigger a callback to RenderViewReady after a round-trip IPC.
791 static_cast<RenderViewHostImpl*>(GetWebContents()->GetRenderViewHost()) 850 static_cast<RenderViewHostImpl*>(GetWebContents()->GetRenderViewHost())
792 ->GetWidget() 851 ->GetWidget()
793 ->Init(); 852 ->Init();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 bool succeeded) { 1011 bool succeeded) {
953 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); 1012 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded));
954 pending_lock_request_ = false; 1013 pending_lock_request_ = false;
955 if (succeeded) 1014 if (succeeded)
956 mouse_locked_ = true; 1015 mouse_locked_ = true;
957 } 1016 }
958 1017
959 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id, 1018 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id,
960 bool focused, 1019 bool focused,
961 blink::WebFocusType focus_type) { 1020 blink::WebFocusType focus_type) {
962 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); 1021 SetFocus(focused, focus_type);
963 RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : nullptr;
964 SetFocus(rwh, focused, focus_type);
965 } 1022 }
966 1023
967 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 1024 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
968 int browser_plugin_instance_id, 1025 int browser_plugin_instance_id,
969 const std::vector<EditCommand>& edit_commands) { 1026 const std::vector<EditCommand>& edit_commands) {
970 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 1027 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
971 edit_commands)); 1028 edit_commands));
972 } 1029 }
973 1030
974 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, 1031 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id,
975 bool visible) { 1032 bool visible) {
976 guest_visible_ = visible; 1033 SetContainerVisible(visible);
977 if (embedder_visible_ && guest_visible_)
978 GetWebContents()->WasShown();
979 else
980 GetWebContents()->WasHidden();
981 } 1034 }
982 1035
983 void BrowserPluginGuest::OnUnlockMouse() { 1036 void BrowserPluginGuest::OnUnlockMouse() {
984 SendMessageToEmbedder( 1037 SendMessageToEmbedder(
985 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), false)); 1038 new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), false));
986 } 1039 }
987 1040
988 void BrowserPluginGuest::OnUnlockMouseAck(int browser_plugin_instance_id) { 1041 void BrowserPluginGuest::OnUnlockMouseAck(int browser_plugin_instance_id) {
989 // mouse_locked_ could be false here if the lock attempt was cancelled due 1042 // mouse_locked_ could be false here if the lock attempt was cancelled due
990 // to window focus, or for various other reasons before the guest was informed 1043 // to window focus, or for various other reasons before the guest was informed
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 range, character_bounds); 1116 range, character_bounds);
1064 } 1117 }
1065 #endif 1118 #endif
1066 1119
1067 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { 1120 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) {
1068 if (delegate_) 1121 if (delegate_)
1069 delegate_->SetContextMenuPosition(position); 1122 delegate_->SetContextMenuPosition(position);
1070 } 1123 }
1071 1124
1072 } // namespace content 1125 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/frame_host/render_widget_host_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698