| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 routing_id, | 198 routing_id, |
| 199 hidden), | 199 hidden), |
| 200 frames_ref_count_(0), | 200 frames_ref_count_(0), |
| 201 delegate_(delegate), | 201 delegate_(delegate), |
| 202 instance_(static_cast<SiteInstanceImpl*>(instance)), | 202 instance_(static_cast<SiteInstanceImpl*>(instance)), |
| 203 waiting_for_drag_context_response_(false), | 203 waiting_for_drag_context_response_(false), |
| 204 enabled_bindings_(0), | 204 enabled_bindings_(0), |
| 205 navigations_suspended_(false), | 205 navigations_suspended_(false), |
| 206 has_accessed_initial_document_(false), | 206 has_accessed_initial_document_(false), |
| 207 main_frame_routing_id_(main_frame_routing_id), | 207 main_frame_routing_id_(main_frame_routing_id), |
| 208 run_modal_reply_msg_(NULL), |
| 209 run_modal_opener_id_(MSG_ROUTING_NONE), |
| 208 is_waiting_for_beforeunload_ack_(false), | 210 is_waiting_for_beforeunload_ack_(false), |
| 209 unload_ack_is_for_cross_site_transition_(false), | 211 unload_ack_is_for_cross_site_transition_(false), |
| 210 are_javascript_messages_suppressed_(false), | 212 are_javascript_messages_suppressed_(false), |
| 211 sudden_termination_allowed_(false), | 213 sudden_termination_allowed_(false), |
| 212 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 214 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 213 virtual_keyboard_requested_(false), | 215 virtual_keyboard_requested_(false), |
| 214 weak_factory_(this) { | 216 weak_factory_(this) { |
| 215 DCHECK(instance_.get()); | 217 DCHECK(instance_.get()); |
| 216 CHECK(delegate_); // http://crbug.com/82827 | 218 CHECK(delegate_); // http://crbug.com/82827 |
| 217 | 219 |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 if (delegate_->OnMessageReceived(this, msg)) | 1073 if (delegate_->OnMessageReceived(this, msg)) |
| 1072 return true; | 1074 return true; |
| 1073 | 1075 |
| 1074 bool handled = true; | 1076 bool handled = true; |
| 1075 bool msg_is_ok = true; | 1077 bool msg_is_ok = true; |
| 1076 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) | 1078 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) |
| 1077 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) | 1079 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) |
| 1078 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) | 1080 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| 1079 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, | 1081 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, |
| 1080 OnShowFullscreenWidget) | 1082 OnShowFullscreenWidget) |
| 1083 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnRunModal) |
| 1081 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) | 1084 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) |
| 1082 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) | 1085 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) |
| 1083 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) | 1086 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) |
| 1084 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnUpdateTitle) | 1087 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnUpdateTitle) |
| 1085 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnUpdateEncoding) | 1088 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnUpdateEncoding) |
| 1086 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) | 1089 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) |
| 1087 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, | 1090 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, |
| 1088 OnUpdateInspectorSetting) | 1091 OnUpdateInspectorSetting) |
| 1089 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 1092 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 1090 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 1093 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 GetProcess()->ReceivedBadMessage(); | 1157 GetProcess()->ReceivedBadMessage(); |
| 1155 } | 1158 } |
| 1156 | 1159 |
| 1157 return handled; | 1160 return handled; |
| 1158 } | 1161 } |
| 1159 | 1162 |
| 1160 void RenderViewHostImpl::Init() { | 1163 void RenderViewHostImpl::Init() { |
| 1161 RenderWidgetHostImpl::Init(); | 1164 RenderWidgetHostImpl::Init(); |
| 1162 } | 1165 } |
| 1163 | 1166 |
| 1167 void RenderViewHostImpl::Shutdown() { |
| 1168 // If we are being run modally (see RunModal), then we need to cleanup. |
| 1169 if (run_modal_reply_msg_) { |
| 1170 Send(run_modal_reply_msg_); |
| 1171 run_modal_reply_msg_ = NULL; |
| 1172 RenderViewHostImpl* opener = |
| 1173 RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_); |
| 1174 if (opener) { |
| 1175 opener->StartHangMonitorTimeout(TimeDelta::FromMilliseconds( |
| 1176 hung_renderer_delay_ms_)); |
| 1177 // Balance out the decrement when we got created. |
| 1178 opener->increment_in_flight_event_count(); |
| 1179 } |
| 1180 run_modal_opener_id_ = MSG_ROUTING_NONE; |
| 1181 } |
| 1182 |
| 1183 RenderWidgetHostImpl::Shutdown(); |
| 1184 } |
| 1185 |
| 1164 bool RenderViewHostImpl::IsRenderView() const { | 1186 bool RenderViewHostImpl::IsRenderView() const { |
| 1165 return true; | 1187 return true; |
| 1166 } | 1188 } |
| 1167 | 1189 |
| 1168 void RenderViewHostImpl::CreateNewWindow( | 1190 void RenderViewHostImpl::CreateNewWindow( |
| 1169 int route_id, | 1191 int route_id, |
| 1170 int main_frame_route_id, | 1192 int main_frame_route_id, |
| 1171 const ViewHostMsg_CreateWindow_Params& params, | 1193 const ViewHostMsg_CreateWindow_Params& params, |
| 1172 SessionStorageNamespace* session_storage_namespace) { | 1194 SessionStorageNamespace* session_storage_namespace) { |
| 1173 ViewHostMsg_CreateWindow_Params validated_params(params); | 1195 ViewHostMsg_CreateWindow_Params validated_params(params); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 delegate_->ShowCreatedWidget(route_id, initial_pos); | 1228 delegate_->ShowCreatedWidget(route_id, initial_pos); |
| 1207 Send(new ViewMsg_Move_ACK(route_id)); | 1229 Send(new ViewMsg_Move_ACK(route_id)); |
| 1208 } | 1230 } |
| 1209 | 1231 |
| 1210 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { | 1232 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
| 1211 if (IsRVHStateActive(rvh_state_)) | 1233 if (IsRVHStateActive(rvh_state_)) |
| 1212 delegate_->ShowCreatedFullscreenWidget(route_id); | 1234 delegate_->ShowCreatedFullscreenWidget(route_id); |
| 1213 Send(new ViewMsg_Move_ACK(route_id)); | 1235 Send(new ViewMsg_Move_ACK(route_id)); |
| 1214 } | 1236 } |
| 1215 | 1237 |
| 1238 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { |
| 1239 DCHECK(!run_modal_reply_msg_); |
| 1240 run_modal_reply_msg_ = reply_msg; |
| 1241 run_modal_opener_id_ = opener_id; |
| 1242 |
| 1243 RecordAction(base::UserMetricsAction("ShowModalDialog")); |
| 1244 |
| 1245 RenderViewHostImpl* opener = |
| 1246 RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_); |
| 1247 if (opener) { |
| 1248 opener->StopHangMonitorTimeout(); |
| 1249 // The ack for the mouse down won't come until the dialog closes, so fake it |
| 1250 // so that we don't get a timeout. |
| 1251 opener->decrement_in_flight_event_count(); |
| 1252 } |
| 1253 |
| 1254 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in |
| 1255 // an app-modal fashion. |
| 1256 } |
| 1257 |
| 1216 void RenderViewHostImpl::OnRenderViewReady() { | 1258 void RenderViewHostImpl::OnRenderViewReady() { |
| 1217 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; | 1259 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; |
| 1218 SendScreenRects(); | 1260 SendScreenRects(); |
| 1219 WasResized(); | 1261 WasResized(); |
| 1220 delegate_->RenderViewReady(this); | 1262 delegate_->RenderViewReady(this); |
| 1221 } | 1263 } |
| 1222 | 1264 |
| 1223 void RenderViewHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1265 void RenderViewHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| 1224 // Keep the termination status so we can get at it later when we | 1266 // Keep the termination status so we can get at it later when we |
| 1225 // need to know why it died. | 1267 // need to know why it died. |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 return true; | 1919 return true; |
| 1878 } | 1920 } |
| 1879 | 1921 |
| 1880 void RenderViewHostImpl::AttachToFrameTree() { | 1922 void RenderViewHostImpl::AttachToFrameTree() { |
| 1881 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1923 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1882 | 1924 |
| 1883 frame_tree->ResetForMainFrameSwap(); | 1925 frame_tree->ResetForMainFrameSwap(); |
| 1884 } | 1926 } |
| 1885 | 1927 |
| 1886 } // namespace content | 1928 } // namespace content |
| OLD | NEW |