| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 guest_proxy_routing_id_(MSG_ROUTING_NONE), | 119 guest_proxy_routing_id_(MSG_ROUTING_NONE), |
| 120 last_drag_status_(blink::kWebDragStatusUnknown), | 120 last_drag_status_(blink::kWebDragStatusUnknown), |
| 121 seen_embedder_system_drag_ended_(false), | 121 seen_embedder_system_drag_ended_(false), |
| 122 seen_embedder_drag_source_ended_at_(false), | 122 seen_embedder_drag_source_ended_at_(false), |
| 123 ignore_dragged_url_(true), | 123 ignore_dragged_url_(true), |
| 124 delegate_(delegate), | 124 delegate_(delegate), |
| 125 can_use_cross_process_frames_(delegate->CanUseCrossProcessFrames()), | 125 can_use_cross_process_frames_(delegate->CanUseCrossProcessFrames()), |
| 126 weak_ptr_factory_(this) { | 126 weak_ptr_factory_(this) { |
| 127 DCHECK(web_contents); | 127 DCHECK(web_contents); |
| 128 DCHECK(delegate); | 128 DCHECK(delegate); |
| 129 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 129 base::RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
| 130 web_contents->SetBrowserPluginGuest(this); | 130 web_contents->SetBrowserPluginGuest(this); |
| 131 delegate->SetGuestHost(this); | 131 delegate->SetGuestHost(this); |
| 132 } | 132 } |
| 133 | 133 |
| 134 int BrowserPluginGuest::GetGuestProxyRoutingID() { | 134 int BrowserPluginGuest::GetGuestProxyRoutingID() { |
| 135 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) { | 135 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) { |
| 136 // We don't use the proxy to send postMessage in --site-per-process, since | 136 // We don't use the proxy to send postMessage in --site-per-process, since |
| 137 // we use the contentWindow directly from the frame element instead. | 137 // we use the contentWindow directly from the frame element instead. |
| 138 return MSG_ROUTING_NONE; | 138 return MSG_ROUTING_NONE; |
| 139 } | 139 } |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // https://crbug.com/714771). | 677 // https://crbug.com/714771). |
| 678 rwh->RequestCompositionUpdates( | 678 rwh->RequestCompositionUpdates( |
| 679 false, last_text_input_state_->type != ui::TEXT_INPUT_TYPE_NONE); | 679 false, last_text_input_state_->type != ui::TEXT_INPUT_TYPE_NONE); |
| 680 } | 680 } |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 | 683 |
| 684 void BrowserPluginGuest::DidFinishNavigation( | 684 void BrowserPluginGuest::DidFinishNavigation( |
| 685 NavigationHandle* navigation_handle) { | 685 NavigationHandle* navigation_handle) { |
| 686 if (navigation_handle->HasCommitted()) | 686 if (navigation_handle->HasCommitted()) |
| 687 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); | 687 base::RecordAction( |
| 688 base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); |
| 688 } | 689 } |
| 689 | 690 |
| 690 void BrowserPluginGuest::RenderViewReady() { | 691 void BrowserPluginGuest::RenderViewReady() { |
| 691 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) | 692 if (GuestMode::IsCrossProcessFrameGuest(GetWebContents())) |
| 692 return; | 693 return; |
| 693 | 694 |
| 694 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); | 695 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); |
| 695 // TODO(fsamuel): Investigate whether it's possible to update state earlier | 696 // TODO(fsamuel): Investigate whether it's possible to update state earlier |
| 696 // here (see http://crbug.com/158151). | 697 // here (see http://crbug.com/158151). |
| 697 RenderWidgetHostImpl::From(rvh->GetWidget()) | 698 RenderWidgetHostImpl::From(rvh->GetWidget()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 713 } | 714 } |
| 714 | 715 |
| 715 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { | 716 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { |
| 716 SendMessageToEmbedder(base::MakeUnique<BrowserPluginMsg_GuestGone>( | 717 SendMessageToEmbedder(base::MakeUnique<BrowserPluginMsg_GuestGone>( |
| 717 browser_plugin_instance_id())); | 718 browser_plugin_instance_id())); |
| 718 switch (status) { | 719 switch (status) { |
| 719 #if defined(OS_CHROMEOS) | 720 #if defined(OS_CHROMEOS) |
| 720 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 721 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
| 721 #endif | 722 #endif |
| 722 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 723 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
| 723 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed")); | 724 base::RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Killed")); |
| 724 break; | 725 break; |
| 725 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 726 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 726 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Crashed")); | 727 base::RecordAction( |
| 728 base::UserMetricsAction("BrowserPlugin.Guest.Crashed")); |
| 727 break; | 729 break; |
| 728 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 730 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 729 RecordAction( | 731 base::RecordAction( |
| 730 base::UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); | 732 base::UserMetricsAction("BrowserPlugin.Guest.AbnormalDeath")); |
| 731 break; | 733 break; |
| 732 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 734 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
| 733 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.LaunchFailed")); | 735 base::RecordAction( |
| 736 base::UserMetricsAction("BrowserPlugin.Guest.LaunchFailed")); |
| 734 break; | 737 break; |
| 735 default: | 738 default: |
| 736 break; | 739 break; |
| 737 } | 740 } |
| 738 } | 741 } |
| 739 | 742 |
| 740 // static | 743 // static |
| 741 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( | 744 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( |
| 742 const IPC::Message& message) { | 745 const IPC::Message& message) { |
| 743 return (message.type() != BrowserPluginHostMsg_Attach::ID) && | 746 return (message.type() != BrowserPluginHostMsg_Attach::ID) && |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 has_attached_since_surface_set_ = true; | 847 has_attached_since_surface_set_ = true; |
| 845 SendQueuedMessages(); | 848 SendQueuedMessages(); |
| 846 | 849 |
| 847 delegate_->DidAttach(GetGuestProxyRoutingID()); | 850 delegate_->DidAttach(GetGuestProxyRoutingID()); |
| 848 RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>( | 851 RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>( |
| 849 web_contents()->GetRenderWidgetHostView()); | 852 web_contents()->GetRenderWidgetHostView()); |
| 850 if (rwhv) | 853 if (rwhv) |
| 851 rwhv->RegisterFrameSinkId(); | 854 rwhv->RegisterFrameSinkId(); |
| 852 has_render_view_ = true; | 855 has_render_view_ = true; |
| 853 | 856 |
| 854 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 857 base::RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
| 855 } | 858 } |
| 856 | 859 |
| 857 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { | 860 void BrowserPluginGuest::OnDetach(int browser_plugin_instance_id) { |
| 858 if (!attached()) | 861 if (!attached()) |
| 859 return; | 862 return; |
| 860 | 863 |
| 861 // It is important that the WebContents is notified before detaching. | 864 // It is important that the WebContents is notified before detaching. |
| 862 GetWebContents()->BrowserPluginGuestWillDetach(); | 865 GetWebContents()->BrowserPluginGuestWillDetach(); |
| 863 | 866 |
| 864 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until | 867 // This tells BrowserPluginGuest to queue up all IPCs to BrowserPlugin until |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 range, character_bounds); | 1125 range, character_bounds); |
| 1123 } | 1126 } |
| 1124 #endif | 1127 #endif |
| 1125 | 1128 |
| 1126 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1129 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1127 if (delegate_) | 1130 if (delegate_) |
| 1128 delegate_->SetContextMenuPosition(position); | 1131 delegate_->SetContextMenuPosition(position); |
| 1129 } | 1132 } |
| 1130 | 1133 |
| 1131 } // namespace content | 1134 } // namespace content |
| OLD | NEW |