| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 frames_ref_count_(0), | 199 frames_ref_count_(0), |
| 202 delegate_(delegate), | 200 delegate_(delegate), |
| 203 instance_(static_cast<SiteInstanceImpl*>(instance)), | 201 instance_(static_cast<SiteInstanceImpl*>(instance)), |
| 204 enabled_bindings_(0), | 202 enabled_bindings_(0), |
| 205 is_active_(!swapped_out), | 203 is_active_(!swapped_out), |
| 206 is_swapped_out_(swapped_out), | 204 is_swapped_out_(swapped_out), |
| 207 main_frame_routing_id_(main_frame_routing_id), | 205 main_frame_routing_id_(main_frame_routing_id), |
| 208 is_waiting_for_close_ack_(false), | 206 is_waiting_for_close_ack_(false), |
| 209 sudden_termination_allowed_(false), | 207 sudden_termination_allowed_(false), |
| 210 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 208 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 211 is_focused_element_editable_(false), | |
| 212 updating_web_preferences_(false), | 209 updating_web_preferences_(false), |
| 213 render_view_ready_on_process_launch_(false), | 210 render_view_ready_on_process_launch_(false), |
| 214 weak_factory_(this) { | 211 weak_factory_(this) { |
| 215 DCHECK(instance_.get()); | 212 DCHECK(instance_.get()); |
| 216 CHECK(delegate_); // http://crbug.com/82827 | 213 CHECK(delegate_); // http://crbug.com/82827 |
| 217 | 214 |
| 218 GetWidget()->set_owner_delegate(this); | 215 GetWidget()->set_owner_delegate(this); |
| 219 | 216 |
| 220 GetProcess()->AddObserver(this); | 217 GetProcess()->AddObserver(this); |
| 221 | 218 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) | 746 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) |
| 750 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 747 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 751 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 748 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| 752 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 749 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
| 753 OnDocumentAvailableInMainFrame) | 750 OnDocumentAvailableInMainFrame) |
| 754 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 751 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
| 755 OnDidContentsPreferredSizeChange) | 752 OnDidContentsPreferredSizeChange) |
| 756 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, | 753 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, |
| 757 OnRouteCloseEvent) | 754 OnRouteCloseEvent) |
| 758 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 755 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 759 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | |
| 760 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 756 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 761 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 757 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 762 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 758 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
| 763 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) | |
| 764 IPC_MESSAGE_UNHANDLED(handled = false) | 759 IPC_MESSAGE_UNHANDLED(handled = false) |
| 765 IPC_END_MESSAGE_MAP() | 760 IPC_END_MESSAGE_MAP() |
| 766 | 761 |
| 767 return handled; | 762 return handled; |
| 768 } | 763 } |
| 769 | 764 |
| 770 void RenderViewHostImpl::RenderWidgetDidInit() { | 765 void RenderViewHostImpl::RenderWidgetDidInit() { |
| 771 PostRenderViewReady(); | 766 PostRenderViewReady(); |
| 772 } | 767 } |
| 773 | 768 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 // Have the delegate route this to the active RenderViewHost. | 890 // Have the delegate route this to the active RenderViewHost. |
| 896 delegate_->RouteCloseEvent(this); | 891 delegate_->RouteCloseEvent(this); |
| 897 } | 892 } |
| 898 | 893 |
| 899 void RenderViewHostImpl::OnTakeFocus(bool reverse) { | 894 void RenderViewHostImpl::OnTakeFocus(bool reverse) { |
| 900 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); | 895 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); |
| 901 if (view) | 896 if (view) |
| 902 view->TakeFocus(reverse); | 897 view->TakeFocus(reverse); |
| 903 } | 898 } |
| 904 | 899 |
| 905 void RenderViewHostImpl::OnFocusedNodeChanged( | |
| 906 bool is_editable_node, | |
| 907 const gfx::Rect& node_bounds_in_viewport) { | |
| 908 is_focused_element_editable_ = is_editable_node; | |
| 909 | |
| 910 // None of the rest makes sense without a view. | |
| 911 if (!GetWidget()->GetView()) | |
| 912 return; | |
| 913 | |
| 914 // Convert node_bounds to screen coordinates. | |
| 915 gfx::Rect view_bounds_in_screen = GetWidget()->GetView()->GetViewBounds(); | |
| 916 gfx::Point origin = node_bounds_in_viewport.origin(); | |
| 917 origin.Offset(view_bounds_in_screen.x(), view_bounds_in_screen.y()); | |
| 918 gfx::Rect node_bounds_in_screen(origin.x(), origin.y(), | |
| 919 node_bounds_in_viewport.width(), | |
| 920 node_bounds_in_viewport.height()); | |
| 921 | |
| 922 GetWidget()->GetView()->FocusedNodeChanged( | |
| 923 is_editable_node, node_bounds_in_screen); | |
| 924 | |
| 925 FocusedNodeDetails details = {is_editable_node, node_bounds_in_screen}; | |
| 926 NotificationService::current()->Notify(NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | |
| 927 Source<RenderViewHost>(this), | |
| 928 Details<FocusedNodeDetails>(&details)); | |
| 929 } | |
| 930 | |
| 931 void RenderViewHostImpl::OnClosePageACK() { | 900 void RenderViewHostImpl::OnClosePageACK() { |
| 932 GetWidget()->decrement_in_flight_event_count(); | 901 GetWidget()->decrement_in_flight_event_count(); |
| 933 ClosePageIgnoringUnloadEvents(); | 902 ClosePageIgnoringUnloadEvents(); |
| 934 } | 903 } |
| 935 | 904 |
| 936 void RenderViewHostImpl::OnFocus() { | 905 void RenderViewHostImpl::OnFocus() { |
| 937 // Note: We allow focus and blur from swapped out RenderViewHosts, even when | 906 // Note: We allow focus and blur from swapped out RenderViewHosts, even when |
| 938 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI). | 907 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI). |
| 939 delegate_->Activate(); | 908 delegate_->Activate(); |
| 940 } | 909 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 // UpdateWebkitPreferences() accidentally updating more preferences and thus | 943 // UpdateWebkitPreferences() accidentally updating more preferences and thus |
| 975 // calling back into this code. See crbug.com/398751 for one past example. | 944 // calling back into this code. See crbug.com/398751 for one past example. |
| 976 if (updating_web_preferences_) | 945 if (updating_web_preferences_) |
| 977 return; | 946 return; |
| 978 updating_web_preferences_ = true; | 947 updating_web_preferences_ = true; |
| 979 UpdateWebkitPreferences(ComputeWebkitPrefs()); | 948 UpdateWebkitPreferences(ComputeWebkitPrefs()); |
| 980 updating_web_preferences_ = false; | 949 updating_web_preferences_ = false; |
| 981 } | 950 } |
| 982 | 951 |
| 983 void RenderViewHostImpl::ClearFocusedElement() { | 952 void RenderViewHostImpl::ClearFocusedElement() { |
| 984 is_focused_element_editable_ = false; | 953 // TODO(ekaramad): We should move this to WebContents instead |
| 985 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); | 954 // (https://crbug.com/675975). |
| 955 if (delegate_) |
| 956 delegate_->ClearFocusedElement(); |
| 986 } | 957 } |
| 987 | 958 |
| 988 bool RenderViewHostImpl::IsFocusedElementEditable() { | 959 bool RenderViewHostImpl::IsFocusedElementEditable() { |
| 989 return is_focused_element_editable_; | 960 // TODO(ekaramad): We should move this to WebContents instead |
| 961 // (https://crbug.com/675975). |
| 962 return delegate_ && delegate_->IsFocusedElementEditable(); |
| 990 } | 963 } |
| 991 | 964 |
| 992 void RenderViewHostImpl::Zoom(PageZoom zoom) { | 965 void RenderViewHostImpl::Zoom(PageZoom zoom) { |
| 993 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); | 966 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); |
| 994 } | 967 } |
| 995 | 968 |
| 996 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { | 969 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { |
| 997 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); | 970 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); |
| 998 } | 971 } |
| 999 | 972 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 const GURL& url) { | 1005 const GURL& url) { |
| 1033 HostZoomMapImpl* host_zoom_map = | 1006 HostZoomMapImpl* host_zoom_map = |
| 1034 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); | 1007 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); |
| 1035 | 1008 |
| 1036 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), | 1009 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), |
| 1037 GetRoutingID(), | 1010 GetRoutingID(), |
| 1038 zoom_level, | 1011 zoom_level, |
| 1039 net::GetHostOrSpecFromURL(url)); | 1012 net::GetHostOrSpecFromURL(url)); |
| 1040 } | 1013 } |
| 1041 | 1014 |
| 1042 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { | |
| 1043 #if defined(OS_WIN) | |
| 1044 // We use the cursor position to determine where the touch occurred. | |
| 1045 // TODO(ananta) | |
| 1046 // Pass this information from blink. | |
| 1047 // In site isolation mode, we may not have a RenderViewHostImpl instance | |
| 1048 // which means that displaying the OSK is not going to work. We should | |
| 1049 // probably move this to RenderWidgetHostImpl and call the view from there. | |
| 1050 // https://bugs.chromium.org/p/chromium/issues/detail?id=613326 | |
| 1051 POINT cursor_pos = {}; | |
| 1052 ::GetCursorPos(&cursor_pos); | |
| 1053 float scale = GetScaleFactorForView(GetWidget()->GetView()); | |
| 1054 gfx::Point location_dips_screen = | |
| 1055 gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos)); | |
| 1056 if (GetWidget()->GetView()) | |
| 1057 GetWidget()->GetView()->FocusedNodeTouched(location_dips_screen, editable); | |
| 1058 #endif | |
| 1059 } | |
| 1060 | |
| 1061 void RenderViewHostImpl::SelectWordAroundCaret() { | 1015 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1062 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1016 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1063 } | 1017 } |
| 1064 | 1018 |
| 1065 void RenderViewHostImpl::PostRenderViewReady() { | 1019 void RenderViewHostImpl::PostRenderViewReady() { |
| 1066 if (GetProcess()->IsReady()) { | 1020 if (GetProcess()->IsReady()) { |
| 1067 BrowserThread::PostTask( | 1021 BrowserThread::PostTask( |
| 1068 BrowserThread::UI, | 1022 BrowserThread::UI, |
| 1069 FROM_HERE, | 1023 FROM_HERE, |
| 1070 base::Bind(&RenderViewHostImpl::RenderViewReady, | 1024 base::Bind(&RenderViewHostImpl::RenderViewReady, |
| 1071 weak_factory_.GetWeakPtr())); | 1025 weak_factory_.GetWeakPtr())); |
| 1072 } else { | 1026 } else { |
| 1073 render_view_ready_on_process_launch_ = true; | 1027 render_view_ready_on_process_launch_ = true; |
| 1074 } | 1028 } |
| 1075 } | 1029 } |
| 1076 | 1030 |
| 1077 void RenderViewHostImpl::RenderViewReady() { | 1031 void RenderViewHostImpl::RenderViewReady() { |
| 1078 delegate_->RenderViewReady(this); | 1032 delegate_->RenderViewReady(this); |
| 1079 } | 1033 } |
| 1080 | 1034 |
| 1081 } // namespace content | 1035 } // namespace content |
| OLD | NEW |