| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 routing_id, | 200 routing_id, |
| 201 hidden), | 201 hidden), |
| 202 frames_ref_count_(0), | 202 frames_ref_count_(0), |
| 203 delegate_(delegate), | 203 delegate_(delegate), |
| 204 instance_(static_cast<SiteInstanceImpl*>(instance)), | 204 instance_(static_cast<SiteInstanceImpl*>(instance)), |
| 205 waiting_for_drag_context_response_(false), | 205 waiting_for_drag_context_response_(false), |
| 206 enabled_bindings_(0), | 206 enabled_bindings_(0), |
| 207 navigations_suspended_(false), | 207 navigations_suspended_(false), |
| 208 has_accessed_initial_document_(false), | 208 has_accessed_initial_document_(false), |
| 209 main_frame_routing_id_(main_frame_routing_id), | 209 main_frame_routing_id_(main_frame_routing_id), |
| 210 run_modal_reply_msg_(NULL), | |
| 211 run_modal_opener_id_(MSG_ROUTING_NONE), | |
| 212 is_waiting_for_beforeunload_ack_(false), | 210 is_waiting_for_beforeunload_ack_(false), |
| 213 unload_ack_is_for_cross_site_transition_(false), | 211 unload_ack_is_for_cross_site_transition_(false), |
| 214 are_javascript_messages_suppressed_(false), | 212 are_javascript_messages_suppressed_(false), |
| 215 sudden_termination_allowed_(false), | 213 sudden_termination_allowed_(false), |
| 216 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 214 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 217 virtual_keyboard_requested_(false), | 215 virtual_keyboard_requested_(false), |
| 218 weak_factory_(this) { | 216 weak_factory_(this) { |
| 219 DCHECK(instance_.get()); | 217 DCHECK(instance_.get()); |
| 220 CHECK(delegate_); // http://crbug.com/82827 | 218 CHECK(delegate_); // http://crbug.com/82827 |
| 221 | 219 |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 if (delegate_->OnMessageReceived(this, msg)) | 1165 if (delegate_->OnMessageReceived(this, msg)) |
| 1168 return true; | 1166 return true; |
| 1169 | 1167 |
| 1170 bool handled = true; | 1168 bool handled = true; |
| 1171 bool msg_is_ok = true; | 1169 bool msg_is_ok = true; |
| 1172 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) | 1170 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) |
| 1173 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) | 1171 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) |
| 1174 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) | 1172 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| 1175 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, | 1173 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, |
| 1176 OnShowFullscreenWidget) | 1174 OnShowFullscreenWidget) |
| 1177 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnRunModal) | |
| 1178 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) | 1175 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) |
| 1179 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) | 1176 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) |
| 1180 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) | 1177 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) |
| 1181 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnUpdateTitle) | 1178 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnUpdateTitle) |
| 1182 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnUpdateEncoding) | 1179 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnUpdateEncoding) |
| 1183 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) | 1180 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) |
| 1184 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, | 1181 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, |
| 1185 OnUpdateInspectorSetting) | 1182 OnUpdateInspectorSetting) |
| 1186 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 1183 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
| 1187 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 1184 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 GetProcess()->ReceivedBadMessage(); | 1252 GetProcess()->ReceivedBadMessage(); |
| 1256 } | 1253 } |
| 1257 | 1254 |
| 1258 return handled; | 1255 return handled; |
| 1259 } | 1256 } |
| 1260 | 1257 |
| 1261 void RenderViewHostImpl::Init() { | 1258 void RenderViewHostImpl::Init() { |
| 1262 RenderWidgetHostImpl::Init(); | 1259 RenderWidgetHostImpl::Init(); |
| 1263 } | 1260 } |
| 1264 | 1261 |
| 1265 void RenderViewHostImpl::Shutdown() { | |
| 1266 // If we are being run modally (see RunModal), then we need to cleanup. | |
| 1267 if (run_modal_reply_msg_) { | |
| 1268 Send(run_modal_reply_msg_); | |
| 1269 run_modal_reply_msg_ = NULL; | |
| 1270 RenderViewHostImpl* opener = | |
| 1271 RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_); | |
| 1272 if (opener) { | |
| 1273 opener->StartHangMonitorTimeout(TimeDelta::FromMilliseconds( | |
| 1274 hung_renderer_delay_ms_)); | |
| 1275 // Balance out the decrement when we got created. | |
| 1276 opener->increment_in_flight_event_count(); | |
| 1277 } | |
| 1278 run_modal_opener_id_ = MSG_ROUTING_NONE; | |
| 1279 } | |
| 1280 | |
| 1281 RenderWidgetHostImpl::Shutdown(); | |
| 1282 } | |
| 1283 | |
| 1284 bool RenderViewHostImpl::IsRenderView() const { | 1262 bool RenderViewHostImpl::IsRenderView() const { |
| 1285 return true; | 1263 return true; |
| 1286 } | 1264 } |
| 1287 | 1265 |
| 1288 void RenderViewHostImpl::CreateNewWindow( | 1266 void RenderViewHostImpl::CreateNewWindow( |
| 1289 int route_id, | 1267 int route_id, |
| 1290 int main_frame_route_id, | 1268 int main_frame_route_id, |
| 1291 const ViewHostMsg_CreateWindow_Params& params, | 1269 const ViewHostMsg_CreateWindow_Params& params, |
| 1292 SessionStorageNamespace* session_storage_namespace) { | 1270 SessionStorageNamespace* session_storage_namespace) { |
| 1293 ViewHostMsg_CreateWindow_Params validated_params(params); | 1271 ViewHostMsg_CreateWindow_Params validated_params(params); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 delegate_->ShowCreatedWidget(route_id, initial_pos); | 1304 delegate_->ShowCreatedWidget(route_id, initial_pos); |
| 1327 Send(new ViewMsg_Move_ACK(route_id)); | 1305 Send(new ViewMsg_Move_ACK(route_id)); |
| 1328 } | 1306 } |
| 1329 | 1307 |
| 1330 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { | 1308 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
| 1331 if (IsRVHStateActive(rvh_state_)) | 1309 if (IsRVHStateActive(rvh_state_)) |
| 1332 delegate_->ShowCreatedFullscreenWidget(route_id); | 1310 delegate_->ShowCreatedFullscreenWidget(route_id); |
| 1333 Send(new ViewMsg_Move_ACK(route_id)); | 1311 Send(new ViewMsg_Move_ACK(route_id)); |
| 1334 } | 1312 } |
| 1335 | 1313 |
| 1336 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { | |
| 1337 DCHECK(!run_modal_reply_msg_); | |
| 1338 run_modal_reply_msg_ = reply_msg; | |
| 1339 run_modal_opener_id_ = opener_id; | |
| 1340 | |
| 1341 RecordAction(base::UserMetricsAction("ShowModalDialog")); | |
| 1342 | |
| 1343 RenderViewHostImpl* opener = | |
| 1344 RenderViewHostImpl::FromID(GetProcess()->GetID(), run_modal_opener_id_); | |
| 1345 if (opener) { | |
| 1346 opener->StopHangMonitorTimeout(); | |
| 1347 // The ack for the mouse down won't come until the dialog closes, so fake it | |
| 1348 // so that we don't get a timeout. | |
| 1349 opener->decrement_in_flight_event_count(); | |
| 1350 } | |
| 1351 | |
| 1352 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in | |
| 1353 // an app-modal fashion. | |
| 1354 } | |
| 1355 | |
| 1356 void RenderViewHostImpl::OnRenderViewReady() { | 1314 void RenderViewHostImpl::OnRenderViewReady() { |
| 1357 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; | 1315 render_view_termination_status_ = base::TERMINATION_STATUS_STILL_RUNNING; |
| 1358 SendScreenRects(); | 1316 SendScreenRects(); |
| 1359 WasResized(); | 1317 WasResized(); |
| 1360 delegate_->RenderViewReady(this); | 1318 delegate_->RenderViewReady(this); |
| 1361 } | 1319 } |
| 1362 | 1320 |
| 1363 void RenderViewHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1321 void RenderViewHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| 1364 // Keep the termination status so we can get at it later when we | 1322 // Keep the termination status so we can get at it later when we |
| 1365 // need to know why it died. | 1323 // need to know why it died. |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 return true; | 2050 return true; |
| 2093 } | 2051 } |
| 2094 | 2052 |
| 2095 void RenderViewHostImpl::AttachToFrameTree() { | 2053 void RenderViewHostImpl::AttachToFrameTree() { |
| 2096 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2054 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 2097 | 2055 |
| 2098 frame_tree->ResetForMainFrameSwap(); | 2056 frame_tree->ResetForMainFrameSwap(); |
| 2099 } | 2057 } |
| 2100 | 2058 |
| 2101 } // namespace content | 2059 } // namespace content |
| OLD | NEW |