| 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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "components/variations/variations_associated_data.h" | 31 #include "components/variations/variations_associated_data.h" |
| 32 #include "content/browser/bad_message.h" | 32 #include "content/browser/bad_message.h" |
| 33 #include "content/browser/child_process_security_policy_impl.h" | 33 #include "content/browser/child_process_security_policy_impl.h" |
| 34 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 34 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 35 #include "content/browser/frame_host/frame_tree.h" | 35 #include "content/browser/frame_host/frame_tree.h" |
| 36 #include "content/browser/gpu/compositor_util.h" | 36 #include "content/browser/gpu/compositor_util.h" |
| 37 #include "content/browser/gpu/gpu_data_manager_impl.h" | 37 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 38 #include "content/browser/gpu/gpu_process_host.h" | 38 #include "content/browser/gpu/gpu_process_host.h" |
| 39 #include "content/browser/host_zoom_map_impl.h" | 39 #include "content/browser/host_zoom_map_impl.h" |
| 40 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 40 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 41 #include "content/browser/renderer_host/dip_util.h" | |
| 42 #include "content/browser/renderer_host/render_process_host_impl.h" | 41 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 43 #include "content/browser/renderer_host/render_view_host_delegate.h" | 42 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 44 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 43 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 45 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 44 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 46 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 45 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 47 #include "content/common/browser_plugin/browser_plugin_messages.h" | 46 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 48 #include "content/common/content_switches_internal.h" | 47 #include "content/common/content_switches_internal.h" |
| 49 #include "content/common/frame_messages.h" | 48 #include "content/common/frame_messages.h" |
| 50 #include "content/common/input_messages.h" | 49 #include "content/common/input_messages.h" |
| 51 #include "content/common/inter_process_time_ticks_converter.h" | 50 #include "content/common/inter_process_time_ticks_converter.h" |
| 52 #include "content/common/render_message_filter.mojom.h" | 51 #include "content/common/render_message_filter.mojom.h" |
| 53 #include "content/common/renderer.mojom.h" | 52 #include "content/common/renderer.mojom.h" |
| 54 #include "content/common/site_isolation_policy.h" | 53 #include "content/common/site_isolation_policy.h" |
| 55 #include "content/common/speech_recognition_messages.h" | 54 #include "content/common/speech_recognition_messages.h" |
| 56 #include "content/common/swapped_out_messages.h" | 55 #include "content/common/swapped_out_messages.h" |
| 57 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
| 58 #include "content/public/browser/ax_event_notification_details.h" | 57 #include "content/public/browser/ax_event_notification_details.h" |
| 59 #include "content/public/browser/browser_accessibility_state.h" | 58 #include "content/public/browser/browser_accessibility_state.h" |
| 60 #include "content/public/browser/browser_context.h" | 59 #include "content/public/browser/browser_context.h" |
| 61 #include "content/public/browser/browser_message_filter.h" | 60 #include "content/public/browser/browser_message_filter.h" |
| 62 #include "content/public/browser/content_browser_client.h" | 61 #include "content/public/browser/content_browser_client.h" |
| 63 #include "content/public/browser/focused_node_details.h" | |
| 64 #include "content/public/browser/native_web_keyboard_event.h" | 62 #include "content/public/browser/native_web_keyboard_event.h" |
| 65 #include "content/public/browser/notification_details.h" | 63 #include "content/public/browser/notification_details.h" |
| 66 #include "content/public/browser/notification_service.h" | 64 #include "content/public/browser/notification_service.h" |
| 67 #include "content/public/browser/notification_types.h" | 65 #include "content/public/browser/notification_types.h" |
| 68 #include "content/public/browser/render_frame_host.h" | 66 #include "content/public/browser/render_frame_host.h" |
| 69 #include "content/public/browser/render_widget_host_iterator.h" | 67 #include "content/public/browser/render_widget_host_iterator.h" |
| 70 #include "content/public/browser/storage_partition.h" | 68 #include "content/public/browser/storage_partition.h" |
| 71 #include "content/public/browser/user_metrics.h" | 69 #include "content/public/browser/user_metrics.h" |
| 72 #include "content/public/common/bindings_policy.h" | 70 #include "content/public/common/bindings_policy.h" |
| 73 #include "content/public/common/content_constants.h" | 71 #include "content/public/common/content_constants.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 frames_ref_count_(0), | 200 frames_ref_count_(0), |
| 203 delegate_(delegate), | 201 delegate_(delegate), |
| 204 instance_(static_cast<SiteInstanceImpl*>(instance)), | 202 instance_(static_cast<SiteInstanceImpl*>(instance)), |
| 205 enabled_bindings_(0), | 203 enabled_bindings_(0), |
| 206 is_active_(!swapped_out), | 204 is_active_(!swapped_out), |
| 207 is_swapped_out_(swapped_out), | 205 is_swapped_out_(swapped_out), |
| 208 main_frame_routing_id_(main_frame_routing_id), | 206 main_frame_routing_id_(main_frame_routing_id), |
| 209 is_waiting_for_close_ack_(false), | 207 is_waiting_for_close_ack_(false), |
| 210 sudden_termination_allowed_(false), | 208 sudden_termination_allowed_(false), |
| 211 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 209 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 212 is_focused_element_editable_(false), | |
| 213 updating_web_preferences_(false), | 210 updating_web_preferences_(false), |
| 214 render_view_ready_on_process_launch_(false), | 211 render_view_ready_on_process_launch_(false), |
| 215 weak_factory_(this) { | 212 weak_factory_(this) { |
| 216 DCHECK(instance_.get()); | 213 DCHECK(instance_.get()); |
| 217 CHECK(delegate_); // http://crbug.com/82827 | 214 CHECK(delegate_); // http://crbug.com/82827 |
| 218 | 215 |
| 219 GetWidget()->set_owner_delegate(this); | 216 GetWidget()->set_owner_delegate(this); |
| 220 | 217 |
| 221 GetProcess()->AddObserver(this); | 218 GetProcess()->AddObserver(this); |
| 222 | 219 |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) | 765 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) |
| 769 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 766 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 770 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 767 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| 771 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 768 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
| 772 OnDocumentAvailableInMainFrame) | 769 OnDocumentAvailableInMainFrame) |
| 773 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 770 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
| 774 OnDidContentsPreferredSizeChange) | 771 OnDidContentsPreferredSizeChange) |
| 775 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, | 772 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, |
| 776 OnRouteCloseEvent) | 773 OnRouteCloseEvent) |
| 777 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 778 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | |
| 779 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 775 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 780 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 776 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 781 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 777 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
| 782 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) | |
| 783 IPC_MESSAGE_UNHANDLED(handled = false) | 778 IPC_MESSAGE_UNHANDLED(handled = false) |
| 784 IPC_END_MESSAGE_MAP() | 779 IPC_END_MESSAGE_MAP() |
| 785 | 780 |
| 786 return handled; | 781 return handled; |
| 787 } | 782 } |
| 788 | 783 |
| 789 void RenderViewHostImpl::RenderWidgetDidInit() { | 784 void RenderViewHostImpl::RenderWidgetDidInit() { |
| 790 PostRenderViewReady(); | 785 PostRenderViewReady(); |
| 791 } | 786 } |
| 792 | 787 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 // Have the delegate route this to the active RenderViewHost. | 909 // Have the delegate route this to the active RenderViewHost. |
| 915 delegate_->RouteCloseEvent(this); | 910 delegate_->RouteCloseEvent(this); |
| 916 } | 911 } |
| 917 | 912 |
| 918 void RenderViewHostImpl::OnTakeFocus(bool reverse) { | 913 void RenderViewHostImpl::OnTakeFocus(bool reverse) { |
| 919 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); | 914 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); |
| 920 if (view) | 915 if (view) |
| 921 view->TakeFocus(reverse); | 916 view->TakeFocus(reverse); |
| 922 } | 917 } |
| 923 | 918 |
| 924 void RenderViewHostImpl::OnFocusedNodeChanged( | |
| 925 bool is_editable_node, | |
| 926 const gfx::Rect& node_bounds_in_viewport) { | |
| 927 is_focused_element_editable_ = is_editable_node; | |
| 928 | |
| 929 // None of the rest makes sense without a view. | |
| 930 if (!GetWidget()->GetView()) | |
| 931 return; | |
| 932 | |
| 933 // Convert node_bounds to screen coordinates. | |
| 934 gfx::Rect view_bounds_in_screen = GetWidget()->GetView()->GetViewBounds(); | |
| 935 gfx::Point origin = node_bounds_in_viewport.origin(); | |
| 936 origin.Offset(view_bounds_in_screen.x(), view_bounds_in_screen.y()); | |
| 937 gfx::Rect node_bounds_in_screen(origin.x(), origin.y(), | |
| 938 node_bounds_in_viewport.width(), | |
| 939 node_bounds_in_viewport.height()); | |
| 940 | |
| 941 GetWidget()->GetView()->FocusedNodeChanged( | |
| 942 is_editable_node, node_bounds_in_screen); | |
| 943 | |
| 944 FocusedNodeDetails details = {is_editable_node, node_bounds_in_screen}; | |
| 945 NotificationService::current()->Notify(NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | |
| 946 Source<RenderViewHost>(this), | |
| 947 Details<FocusedNodeDetails>(&details)); | |
| 948 } | |
| 949 | |
| 950 void RenderViewHostImpl::OnClosePageACK() { | 919 void RenderViewHostImpl::OnClosePageACK() { |
| 951 GetWidget()->decrement_in_flight_event_count(); | 920 GetWidget()->decrement_in_flight_event_count(); |
| 952 ClosePageIgnoringUnloadEvents(); | 921 ClosePageIgnoringUnloadEvents(); |
| 953 } | 922 } |
| 954 | 923 |
| 955 void RenderViewHostImpl::OnFocus() { | 924 void RenderViewHostImpl::OnFocus() { |
| 956 // Note: We allow focus and blur from swapped out RenderViewHosts, even when | 925 // Note: We allow focus and blur from swapped out RenderViewHosts, even when |
| 957 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI). | 926 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI). |
| 958 delegate_->Activate(); | 927 delegate_->Activate(); |
| 959 } | 928 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 // UpdateWebkitPreferences() accidentally updating more preferences and thus | 962 // UpdateWebkitPreferences() accidentally updating more preferences and thus |
| 994 // calling back into this code. See crbug.com/398751 for one past example. | 963 // calling back into this code. See crbug.com/398751 for one past example. |
| 995 if (updating_web_preferences_) | 964 if (updating_web_preferences_) |
| 996 return; | 965 return; |
| 997 updating_web_preferences_ = true; | 966 updating_web_preferences_ = true; |
| 998 UpdateWebkitPreferences(ComputeWebkitPrefs()); | 967 UpdateWebkitPreferences(ComputeWebkitPrefs()); |
| 999 updating_web_preferences_ = false; | 968 updating_web_preferences_ = false; |
| 1000 } | 969 } |
| 1001 | 970 |
| 1002 void RenderViewHostImpl::ClearFocusedElement() { | 971 void RenderViewHostImpl::ClearFocusedElement() { |
| 1003 is_focused_element_editable_ = false; | 972 // TODO(ekaramad): We should move this to WebContents instead |
| 1004 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); | 973 // (https://crbug.com/675975). |
| 974 if (delegate_) |
| 975 delegate_->ClearFocusedElement(); |
| 1005 } | 976 } |
| 1006 | 977 |
| 1007 bool RenderViewHostImpl::IsFocusedElementEditable() { | 978 bool RenderViewHostImpl::IsFocusedElementEditable() { |
| 1008 return is_focused_element_editable_; | 979 // TODO(ekaramad): We should move this to WebContents instead |
| 980 // (https://crbug.com/675975). |
| 981 return delegate_ && delegate_->IsFocusedElementEditable(); |
| 1009 } | 982 } |
| 1010 | 983 |
| 1011 void RenderViewHostImpl::Zoom(PageZoom zoom) { | 984 void RenderViewHostImpl::Zoom(PageZoom zoom) { |
| 1012 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); | 985 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); |
| 1013 } | 986 } |
| 1014 | 987 |
| 1015 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { | 988 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { |
| 1016 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); | 989 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); |
| 1017 } | 990 } |
| 1018 | 991 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 const GURL& url) { | 1024 const GURL& url) { |
| 1052 HostZoomMapImpl* host_zoom_map = | 1025 HostZoomMapImpl* host_zoom_map = |
| 1053 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); | 1026 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); |
| 1054 | 1027 |
| 1055 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), | 1028 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), |
| 1056 GetRoutingID(), | 1029 GetRoutingID(), |
| 1057 zoom_level, | 1030 zoom_level, |
| 1058 net::GetHostOrSpecFromURL(url)); | 1031 net::GetHostOrSpecFromURL(url)); |
| 1059 } | 1032 } |
| 1060 | 1033 |
| 1061 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { | |
| 1062 #if defined(OS_WIN) | |
| 1063 // We use the cursor position to determine where the touch occurred. | |
| 1064 // TODO(ananta) | |
| 1065 // Pass this information from blink. | |
| 1066 // In site isolation mode, we may not have a RenderViewHostImpl instance | |
| 1067 // which means that displaying the OSK is not going to work. We should | |
| 1068 // probably move this to RenderWidgetHostImpl and call the view from there. | |
| 1069 // https://bugs.chromium.org/p/chromium/issues/detail?id=613326 | |
| 1070 POINT cursor_pos = {}; | |
| 1071 ::GetCursorPos(&cursor_pos); | |
| 1072 float scale = GetScaleFactorForView(GetWidget()->GetView()); | |
| 1073 gfx::Point location_dips_screen = | |
| 1074 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos)); | |
| 1075 if (GetWidget()->GetView()) | |
| 1076 GetWidget()->GetView()->FocusedNodeTouched(location_dips_screen, editable); | |
| 1077 #endif | |
| 1078 } | |
| 1079 | |
| 1080 void RenderViewHostImpl::SelectWordAroundCaret() { | 1034 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1081 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1035 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1082 } | 1036 } |
| 1083 | 1037 |
| 1084 void RenderViewHostImpl::PostRenderViewReady() { | 1038 void RenderViewHostImpl::PostRenderViewReady() { |
| 1085 if (GetProcess()->IsReady()) { | 1039 if (GetProcess()->IsReady()) { |
| 1086 BrowserThread::PostTask( | 1040 BrowserThread::PostTask( |
| 1087 BrowserThread::UI, | 1041 BrowserThread::UI, |
| 1088 FROM_HERE, | 1042 FROM_HERE, |
| 1089 base::Bind(&RenderViewHostImpl::RenderViewReady, | 1043 base::Bind(&RenderViewHostImpl::RenderViewReady, |
| 1090 weak_factory_.GetWeakPtr())); | 1044 weak_factory_.GetWeakPtr())); |
| 1091 } else { | 1045 } else { |
| 1092 render_view_ready_on_process_launch_ = true; | 1046 render_view_ready_on_process_launch_ = true; |
| 1093 } | 1047 } |
| 1094 } | 1048 } |
| 1095 | 1049 |
| 1096 void RenderViewHostImpl::RenderViewReady() { | 1050 void RenderViewHostImpl::RenderViewReady() { |
| 1097 delegate_->RenderViewReady(this); | 1051 delegate_->RenderViewReady(this); |
| 1098 } | 1052 } |
| 1099 | 1053 |
| 1100 } // namespace content | 1054 } // namespace content |
| OLD | NEW |