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