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

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

Issue 2165523004: Force MimeHandlerView to always use BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return Top-Level WebContents View's NativeView rather than Owners Created 4 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 delegate_(delegate), 107 delegate_(delegate),
108 weak_ptr_factory_(this) { 108 weak_ptr_factory_(this) {
109 DCHECK(web_contents); 109 DCHECK(web_contents);
110 DCHECK(delegate); 110 DCHECK(delegate);
111 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); 111 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create"));
112 web_contents->SetBrowserPluginGuest(this); 112 web_contents->SetBrowserPluginGuest(this);
113 delegate->SetGuestHost(this); 113 delegate->SetGuestHost(this);
114 } 114 }
115 115
116 int BrowserPluginGuest::GetGuestProxyRoutingID() { 116 int BrowserPluginGuest::GetGuestProxyRoutingID() {
117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() &&
118 !IsMimeHandlerViewGuest()) {
118 // We don't use the proxy to send postMessage in --site-per-process, since 119 // We don't use the proxy to send postMessage in --site-per-process, since
119 // we use the contentWindow directly from the frame element instead. 120 // we use the contentWindow directly from the frame element instead.
120 return MSG_ROUTING_NONE; 121 return MSG_ROUTING_NONE;
121 } 122 }
122 123
123 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) 124 if (guest_proxy_routing_id_ != MSG_ROUTING_NONE)
124 return guest_proxy_routing_id_; 125 return guest_proxy_routing_id_;
125 126
126 // Create a RenderFrameProxyHost for the guest in the embedder renderer 127 // Create a RenderFrameProxyHost for the guest in the embedder renderer
127 // process, so that the embedder can access the guest's window object. 128 // process, so that the embedder can access the guest's window object.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 blink::WebFocusTypeNone); 284 blink::WebFocusTypeNone);
284 285
285 guest_visible_ = params.visible; 286 guest_visible_ = params.visible;
286 UpdateVisibility(); 287 UpdateVisibility();
287 288
288 is_full_page_plugin_ = params.is_full_page_plugin; 289 is_full_page_plugin_ = params.is_full_page_plugin;
289 guest_window_rect_ = params.view_rect; 290 guest_window_rect_ = params.view_rect;
290 291
291 if (owner_web_contents_ != owner_web_contents) { 292 if (owner_web_contents_ != owner_web_contents) {
292 WebContentsViewGuest* new_view = nullptr; 293 WebContentsViewGuest* new_view = nullptr;
293 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 294 if (!BrowserPluginGuestMode::UseCrossProcessFramesForGuests() ||
295 IsMimeHandlerViewGuest()) {
294 new_view = 296 new_view =
295 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); 297 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
296 } 298 }
297 299
298 if (owner_web_contents_ && new_view) 300 if (owner_web_contents_ && new_view)
299 new_view->OnGuestDetached(owner_web_contents_->GetView()); 301 new_view->OnGuestDetached(owner_web_contents_->GetView());
300 302
301 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to 303 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to
302 // be attached. 304 // be attached.
303 owner_web_contents_ = owner_web_contents; 305 owner_web_contents_ = owner_web_contents;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( 368 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(
367 render_view_host))); 369 render_view_host)));
368 } 370 }
369 371
370 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { 372 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() {
371 if (!owner_web_contents_) 373 if (!owner_web_contents_)
372 return nullptr; 374 return nullptr;
373 return owner_web_contents_->GetRenderWidgetHostView(); 375 return owner_web_contents_->GetRenderWidgetHostView();
374 } 376 }
375 377
378 RenderWidgetHostView* BrowserPluginGuest::GetTopLevelRenderWidgetHostView() {
379 if (!owner_web_contents_)
380 return nullptr;
381 return owner_web_contents_->GetTopLevelRenderWidgetHostView();
382 }
383
376 void BrowserPluginGuest::UpdateVisibility() { 384 void BrowserPluginGuest::UpdateVisibility() {
377 OnSetVisibility(browser_plugin_instance_id(), visible()); 385 OnSetVisibility(browser_plugin_instance_id(), visible());
378 } 386 }
379 387
380 BrowserPluginGuestManager* 388 BrowserPluginGuestManager*
381 BrowserPluginGuest::GetBrowserPluginGuestManager() const { 389 BrowserPluginGuest::GetBrowserPluginGuestManager() const {
382 return GetWebContents()->GetBrowserContext()->GetGuestManager(); 390 return GetWebContents()->GetBrowserContext()->GetGuestManager();
383 } 391 }
384 392
385 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { 393 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 resent_wheel_event.resendingPluginId = browser_plugin_instance_id_; 471 resent_wheel_event.resendingPluginId = browser_plugin_instance_id_;
464 // TODO(wjmaclean): Initialize latency info correctly for OOPIFs. 472 // TODO(wjmaclean): Initialize latency info correctly for OOPIFs.
465 // https://crbug.com/613628 473 // https://crbug.com/613628
466 ui::LatencyInfo latency_info; 474 ui::LatencyInfo latency_info;
467 view->ProcessMouseWheelEvent(resent_wheel_event, latency_info); 475 view->ProcessMouseWheelEvent(resent_wheel_event, latency_info);
468 } else { 476 } else {
469 NOTIMPLEMENTED(); 477 NOTIMPLEMENTED();
470 } 478 }
471 } 479 }
472 480
481 bool BrowserPluginGuest::IsMimeHandlerViewGuest() const {
482 return !!delegate_ && delegate_->IsMimeHandlerViewGuest();
483 }
484
473 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { 485 WebContentsImpl* BrowserPluginGuest::GetWebContents() const {
474 return static_cast<WebContentsImpl*>(web_contents()); 486 return static_cast<WebContentsImpl*>(web_contents());
475 } 487 }
476 488
477 gfx::Point BrowserPluginGuest::GetScreenCoordinates( 489 gfx::Point BrowserPluginGuest::GetScreenCoordinates(
478 const gfx::Point& relative_position) const { 490 const gfx::Point& relative_position) const {
479 if (!attached()) 491 if (!attached())
480 return relative_position; 492 return relative_position;
481 493
482 gfx::Point screen_pos(relative_position); 494 gfx::Point screen_pos(relative_position);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 682
671 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { 683 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
672 bool handled = true; 684 bool handled = true;
673 // In --site-per-process, we do not need most of BrowserPluginGuest to drive 685 // In --site-per-process, we do not need most of BrowserPluginGuest to drive
674 // inner WebContents. 686 // inner WebContents.
675 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in 687 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in
676 // RWHVChildFrame, so we're disabling message handling entirely here. 688 // RWHVChildFrame, so we're disabling message handling entirely here.
677 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required 689 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required
678 // parts of code from this class should be extracted to a separate class for 690 // parts of code from this class should be extracted to a separate class for
679 // --site-per-process. 691 // --site-per-process.
680 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { 692 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() &&
693 !IsMimeHandlerViewGuest()) {
681 return false; 694 return false;
682 } 695 }
683 696
684 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 697 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
685 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 698 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
686 OnImeCancelComposition) 699 OnImeCancelComposition)
687 #if defined(OS_MACOSX) || defined(USE_AURA) 700 #if defined(OS_MACOSX) || defined(USE_AURA)
688 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 701 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
689 OnImeCompositionRangeChanged) 702 OnImeCompositionRangeChanged)
690 #endif 703 #endif
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 933 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
921 int browser_plugin_instance_id, 934 int browser_plugin_instance_id,
922 const std::vector<EditCommand>& edit_commands) { 935 const std::vector<EditCommand>& edit_commands) {
923 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 936 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
924 edit_commands)); 937 edit_commands));
925 } 938 }
926 939
927 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, 940 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id,
928 bool visible) { 941 bool visible) {
929 // For OOPIF-<webivew>, the remote frame will handle visibility state. 942 // For OOPIF-<webivew>, the remote frame will handle visibility state.
930 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) 943 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests() &&
944 !IsMimeHandlerViewGuest())
931 return; 945 return;
932 946
933 guest_visible_ = visible; 947 guest_visible_ = visible;
934 if (embedder_visible_ && guest_visible_) 948 if (embedder_visible_ && guest_visible_)
935 GetWebContents()->WasShown(); 949 GetWebContents()->WasShown();
936 else 950 else
937 GetWebContents()->WasHidden(); 951 GetWebContents()->WasHidden();
938 } 952 }
939 953
940 void BrowserPluginGuest::OnUnlockMouse() { 954 void BrowserPluginGuest::OnUnlockMouse() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 range, character_bounds); 1031 range, character_bounds);
1018 } 1032 }
1019 #endif 1033 #endif
1020 1034
1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { 1035 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) {
1022 if (delegate_) 1036 if (delegate_)
1023 delegate_->SetContextMenuPosition(position); 1037 delegate_->SetContextMenuPosition(position);
1024 } 1038 }
1025 1039
1026 } // namespace content 1040 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698