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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 seen_embedder_system_drag_ended_(false), | 104 seen_embedder_system_drag_ended_(false), |
105 seen_embedder_drag_source_ended_at_(false), | 105 seen_embedder_drag_source_ended_at_(false), |
106 ignore_dragged_url_(true), | 106 ignore_dragged_url_(true), |
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 is_mime_handler_view_guest_ = delegate_->IsMimeHandlerViewGuest(); | |
lfg
2016/09/02 18:29:40
Let's initialize this with the other member variab
EhsanK
2016/09/02 21:01:06
Done.
| |
114 } | 115 } |
115 | 116 |
116 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 117 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
117 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 118 if (guest_mode::IsCrossProcessFrameGuest(GetWebContents())) { |
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 Loading... | |
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 (!guest_mode::IsCrossProcessFrameGuest(GetWebContents())) { |
294 new_view = | 295 new_view = |
295 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 296 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
296 } | 297 } |
297 | 298 |
298 if (owner_web_contents_ && new_view) | 299 if (owner_web_contents_ && new_view) |
299 new_view->OnGuestDetached(owner_web_contents_->GetView()); | 300 new_view->OnGuestDetached(owner_web_contents_->GetView()); |
300 | 301 |
301 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 302 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
302 // be attached. | 303 // be attached. |
303 owner_web_contents_ = owner_web_contents; | 304 owner_web_contents_ = owner_web_contents; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( | 367 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost( |
367 render_view_host))); | 368 render_view_host))); |
368 } | 369 } |
369 | 370 |
370 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { | 371 RenderWidgetHostView* BrowserPluginGuest::GetOwnerRenderWidgetHostView() { |
371 if (!owner_web_contents_) | 372 if (!owner_web_contents_) |
372 return nullptr; | 373 return nullptr; |
373 return owner_web_contents_->GetRenderWidgetHostView(); | 374 return owner_web_contents_->GetRenderWidgetHostView(); |
374 } | 375 } |
375 | 376 |
377 RenderWidgetHostView* BrowserPluginGuest::GetTopLevelRenderWidgetHostView() { | |
lfg
2016/09/02 18:29:40
Same comment as above.
EhsanK
2016/09/02 21:01:06
Done.
| |
378 if (!owner_web_contents_) | |
379 return nullptr; | |
380 return owner_web_contents_->GetTopLevelRenderWidgetHostView(); | |
381 } | |
382 | |
376 void BrowserPluginGuest::UpdateVisibility() { | 383 void BrowserPluginGuest::UpdateVisibility() { |
377 OnSetVisibility(browser_plugin_instance_id(), visible()); | 384 OnSetVisibility(browser_plugin_instance_id(), visible()); |
378 } | 385 } |
379 | 386 |
380 BrowserPluginGuestManager* | 387 BrowserPluginGuestManager* |
381 BrowserPluginGuest::GetBrowserPluginGuestManager() const { | 388 BrowserPluginGuest::GetBrowserPluginGuestManager() const { |
382 return GetWebContents()->GetBrowserContext()->GetGuestManager(); | 389 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
383 } | 390 } |
384 | 391 |
385 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { | 392 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 | 677 |
671 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { | 678 bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
672 bool handled = true; | 679 bool handled = true; |
673 // In --site-per-process, we do not need most of BrowserPluginGuest to drive | 680 // In --site-per-process, we do not need most of BrowserPluginGuest to drive |
674 // inner WebContents. | 681 // inner WebContents. |
675 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in | 682 // Right now InputHostMsg_ImeCompositionRangeChanged hits NOTREACHED() in |
676 // RWHVChildFrame, so we're disabling message handling entirely here. | 683 // RWHVChildFrame, so we're disabling message handling entirely here. |
677 // TODO(lazyboy): Fix this as part of http://crbug.com/330264. The required | 684 // 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 | 685 // parts of code from this class should be extracted to a separate class for |
679 // --site-per-process. | 686 // --site-per-process. |
680 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 687 if (guest_mode::IsCrossProcessFrameGuest(GetWebContents())) |
681 return false; | 688 return false; |
682 } | |
683 | 689 |
684 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 690 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
685 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, | 691 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, |
686 OnImeCancelComposition) | 692 OnImeCancelComposition) |
687 #if defined(OS_MACOSX) || defined(USE_AURA) | 693 #if defined(OS_MACOSX) || defined(USE_AURA) |
688 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, | 694 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, |
689 OnImeCompositionRangeChanged) | 695 OnImeCompositionRangeChanged) |
690 #endif | 696 #endif |
691 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 697 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
692 OnHasTouchEventHandlers) | 698 OnHasTouchEventHandlers) |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( | 926 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( |
921 int browser_plugin_instance_id, | 927 int browser_plugin_instance_id, |
922 const std::vector<EditCommand>& edit_commands) { | 928 const std::vector<EditCommand>& edit_commands) { |
923 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), | 929 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), |
924 edit_commands)); | 930 edit_commands)); |
925 } | 931 } |
926 | 932 |
927 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, | 933 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, |
928 bool visible) { | 934 bool visible) { |
929 // For OOPIF-<webivew>, the remote frame will handle visibility state. | 935 // For OOPIF-<webivew>, the remote frame will handle visibility state. |
930 if (BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) | 936 if (guest_mode::IsCrossProcessFrameGuest(GetWebContents())) |
931 return; | 937 return; |
932 | 938 |
933 guest_visible_ = visible; | 939 guest_visible_ = visible; |
934 if (embedder_visible_ && guest_visible_) | 940 if (embedder_visible_ && guest_visible_) |
935 GetWebContents()->WasShown(); | 941 GetWebContents()->WasShown(); |
936 else | 942 else |
937 GetWebContents()->WasHidden(); | 943 GetWebContents()->WasHidden(); |
938 } | 944 } |
939 | 945 |
940 void BrowserPluginGuest::OnUnlockMouse() { | 946 void BrowserPluginGuest::OnUnlockMouse() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 range, character_bounds); | 1023 range, character_bounds); |
1018 } | 1024 } |
1019 #endif | 1025 #endif |
1020 | 1026 |
1021 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1027 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1022 if (delegate_) | 1028 if (delegate_) |
1023 delegate_->SetContextMenuPosition(position); | 1029 delegate_->SetContextMenuPosition(position); |
1024 } | 1030 } |
1025 | 1031 |
1026 } // namespace content | 1032 } // namespace content |
OLD | NEW |