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

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

Issue 1199963011: Force new surface on BrowserPluginGuest reattach. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test, and add check for null surface id in test. Created 5 years, 5 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 <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/pickle.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 DISALLOW_COPY_AND_ASSIGN(EmbedderVisibilityObserver); 72 DISALLOW_COPY_AND_ASSIGN(EmbedderVisibilityObserver);
73 }; 73 };
74 74
75 BrowserPluginGuest::BrowserPluginGuest(bool has_render_view, 75 BrowserPluginGuest::BrowserPluginGuest(bool has_render_view,
76 WebContentsImpl* web_contents, 76 WebContentsImpl* web_contents,
77 BrowserPluginGuestDelegate* delegate) 77 BrowserPluginGuestDelegate* delegate)
78 : WebContentsObserver(web_contents), 78 : WebContentsObserver(web_contents),
79 owner_web_contents_(nullptr), 79 owner_web_contents_(nullptr),
80 attached_(false), 80 attached_(false),
81 has_attached_since_surface_set_(false),
81 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 82 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
82 focused_(false), 83 focused_(false),
83 mouse_locked_(false), 84 mouse_locked_(false),
84 pending_lock_request_(false), 85 pending_lock_request_(false),
85 guest_visible_(false), 86 guest_visible_(false),
86 embedder_visible_(true), 87 embedder_visible_(true),
87 is_full_page_plugin_(false), 88 is_full_page_plugin_(false),
88 has_render_view_(has_render_view), 89 has_render_view_(has_render_view),
89 is_in_destruction_(false), 90 is_in_destruction_(false),
90 initialized_(false), 91 initialized_(false),
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 SendMessageToEmbedder( 398 SendMessageToEmbedder(
398 new BrowserPluginMsg_CompositorFrameSwapped( 399 new BrowserPluginMsg_CompositorFrameSwapped(
399 browser_plugin_instance_id(), *last_pending_frame_)); 400 browser_plugin_instance_id(), *last_pending_frame_));
400 } 401 }
401 402
402 void BrowserPluginGuest::SetChildFrameSurface( 403 void BrowserPluginGuest::SetChildFrameSurface(
403 const cc::SurfaceId& surface_id, 404 const cc::SurfaceId& surface_id,
404 const gfx::Size& frame_size, 405 const gfx::Size& frame_size,
405 float scale_factor, 406 float scale_factor,
406 const cc::SurfaceSequence& sequence) { 407 const cc::SurfaceSequence& sequence) {
408 has_attached_since_surface_set_ = false;
407 SendMessageToEmbedder(new BrowserPluginMsg_SetChildFrameSurface( 409 SendMessageToEmbedder(new BrowserPluginMsg_SetChildFrameSurface(
408 browser_plugin_instance_id(), surface_id, frame_size, scale_factor, 410 browser_plugin_instance_id(), surface_id, frame_size, scale_factor,
409 sequence)); 411 sequence));
410 } 412 }
411 413
412 void BrowserPluginGuest::OnSatisfySequence( 414 void BrowserPluginGuest::OnSatisfySequence(
413 int instance_id, 415 int instance_id,
414 const cc::SurfaceSequence& sequence) { 416 const cc::SurfaceSequence& sequence) {
415 std::vector<uint32_t> sequences; 417 std::vector<uint32_t> sequences;
416 sequences.push_back(sequence.sequence); 418 sequences.push_back(sequence.sequence);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 screen_pos += guest_window_rect_.OffsetFromOrigin(); 462 screen_pos += guest_window_rect_.OffsetFromOrigin();
461 if (embedder_web_contents()->GetBrowserPluginGuest()) { 463 if (embedder_web_contents()->GetBrowserPluginGuest()) {
462 BrowserPluginGuest* embedder_guest = 464 BrowserPluginGuest* embedder_guest =
463 embedder_web_contents()->GetBrowserPluginGuest(); 465 embedder_web_contents()->GetBrowserPluginGuest();
464 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); 466 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin();
465 } 467 }
466 return screen_pos; 468 return screen_pos;
467 } 469 }
468 470
469 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 471 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
470 if (!attached()) { 472 // During tests, attache() may be true when there is no owner_web_contents_;
473 // in this case just queue any messages we receive.
474 if (!attached() || !owner_web_contents_) {
471 // Some pages such as data URLs, javascript URLs, and about:blank 475 // Some pages such as data URLs, javascript URLs, and about:blank
472 // do not load external resources and so they load prior to attachment. 476 // do not load external resources and so they load prior to attachment.
473 // As a result, we must save all these IPCs until attachment and then 477 // As a result, we must save all these IPCs until attachment and then
474 // forward them so that the embedder gets a chance to see and process 478 // forward them so that the embedder gets a chance to see and process
475 // the load events. 479 // the load events.
476 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); 480 pending_messages_.push_back(linked_ptr<IPC::Message>(msg));
477 return; 481 return;
478 } 482 }
479 owner_web_contents_->Send(msg); 483 owner_web_contents_->Send(msg);
480 } 484 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 708 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
705 if (!web_contents()->GetRenderViewHost()->GetView()) { 709 if (!web_contents()->GetRenderViewHost()->GetView()) {
706 web_contents_view->CreateViewForWidget( 710 web_contents_view->CreateViewForWidget(
707 web_contents()->GetRenderViewHost(), true); 711 web_contents()->GetRenderViewHost(), true);
708 } 712 }
709 } 713 }
710 714
711 InitInternal(params, embedder_web_contents); 715 InitInternal(params, embedder_web_contents);
712 716
713 attached_ = true; 717 attached_ = true;
718 has_attached_since_surface_set_ = true;
714 SendQueuedMessages(); 719 SendQueuedMessages();
715 720
716 delegate_->DidAttach(GetGuestProxyRoutingID()); 721 delegate_->DidAttach(GetGuestProxyRoutingID());
717 722
718 has_render_view_ = true; 723 has_render_view_ = true;
719 724
720 // Enable input method for guest if it's enabled for the embedder. 725 // Enable input method for guest if it's enabled for the embedder.
721 if (static_cast<RenderViewHostImpl*>( 726 if (static_cast<RenderViewHostImpl*>(
722 owner_web_contents_->GetRenderViewHost())->input_method_active()) { 727 owner_web_contents_->GetRenderViewHost())->input_method_active()) {
723 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( 728 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 void BrowserPluginGuest::OnImeCompositionRangeChanged( 974 void BrowserPluginGuest::OnImeCompositionRangeChanged(
970 const gfx::Range& range, 975 const gfx::Range& range,
971 const std::vector<gfx::Rect>& character_bounds) { 976 const std::vector<gfx::Rect>& character_bounds) {
972 static_cast<RenderWidgetHostViewBase*>( 977 static_cast<RenderWidgetHostViewBase*>(
973 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 978 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
974 range, character_bounds); 979 range, character_bounds);
975 } 980 }
976 #endif 981 #endif
977 982
978 } // namespace content 983 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698