| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/gfx/native_widget_types.h" | 10 #include "app/gfx/native_widget_types.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int routing_id) | 106 int routing_id) |
| 107 : RenderWidgetHost(instance->GetProcess(), routing_id), | 107 : RenderWidgetHost(instance->GetProcess(), routing_id), |
| 108 instance_(instance), | 108 instance_(instance), |
| 109 delegate_(delegate), | 109 delegate_(delegate), |
| 110 waiting_for_drag_context_response_(false), | 110 waiting_for_drag_context_response_(false), |
| 111 enabled_bindings_(0), | 111 enabled_bindings_(0), |
| 112 pending_request_id_(0), | 112 pending_request_id_(0), |
| 113 navigations_suspended_(false), | 113 navigations_suspended_(false), |
| 114 suspended_nav_message_(NULL), | 114 suspended_nav_message_(NULL), |
| 115 run_modal_reply_msg_(NULL), | 115 run_modal_reply_msg_(NULL), |
| 116 is_showing_before_unload_dialog_(false), | |
| 117 is_waiting_for_unload_ack_(false), | 116 is_waiting_for_unload_ack_(false), |
| 118 unload_ack_is_for_cross_site_transition_(false), | 117 unload_ack_is_for_cross_site_transition_(false), |
| 119 are_javascript_messages_suppressed_(false), | 118 are_javascript_messages_suppressed_(false), |
| 120 sudden_termination_allowed_(false), | 119 sudden_termination_allowed_(false), |
| 121 in_inspect_element_mode_(false) { | 120 in_inspect_element_mode_(false) { |
| 122 DCHECK(instance_); | 121 DCHECK(instance_); |
| 123 DCHECK(delegate_); | 122 DCHECK(delegate_); |
| 124 | 123 |
| 125 // TODO(mpcomplete): remove this notification (and registrar) when we figure | 124 // TODO(mpcomplete): remove this notification (and registrar) when we figure |
| 126 // out why we're crashing on process()->Init(). | 125 // out why we're crashing on process()->Init(). |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // browser. But we want to keep the throbber in sync with what's happening | 255 // browser. But we want to keep the throbber in sync with what's happening |
| 257 // in the UI. For example, we want to start throbbing immediately when the | 256 // in the UI. For example, we want to start throbbing immediately when the |
| 258 // user naivgates even if the renderer is delayed. There is also an issue | 257 // user naivgates even if the renderer is delayed. There is also an issue |
| 259 // with the throbber starting because the DOMUI (which controls whether the | 258 // with the throbber starting because the DOMUI (which controls whether the |
| 260 // favicon is displayed) happens synchronously. If the start loading | 259 // favicon is displayed) happens synchronously. If the start loading |
| 261 // messages was asynchronous, then the default favicon would flash in. | 260 // messages was asynchronous, then the default favicon would flash in. |
| 262 // | 261 // |
| 263 // WebKit doesn't send throb notifications for JavaScript URLs, so we | 262 // WebKit doesn't send throb notifications for JavaScript URLs, so we |
| 264 // don't want to either. | 263 // don't want to either. |
| 265 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) | 264 if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) |
| 266 delegate_->DidStartLoading(this); | 265 delegate_->DidStartLoading(); |
| 267 } | 266 } |
| 268 } | 267 } |
| 269 | 268 |
| 270 void RenderViewHost::NavigateToURL(const GURL& url) { | 269 void RenderViewHost::NavigateToURL(const GURL& url) { |
| 271 ViewMsg_Navigate_Params params; | 270 ViewMsg_Navigate_Params params; |
| 272 params.page_id = -1; | 271 params.page_id = -1; |
| 273 params.url = url; | 272 params.url = url; |
| 274 params.transition = PageTransition::LINK; | 273 params.transition = PageTransition::LINK; |
| 275 params.reload = false; | 274 params.reload = false; |
| 276 Navigate(params); | 275 Navigate(params); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 process()->set_ignore_input_events(false); | 579 process()->set_ignore_input_events(false); |
| 581 if (is_waiting_for_unload_ack_) { | 580 if (is_waiting_for_unload_ack_) { |
| 582 if (are_javascript_messages_suppressed_) { | 581 if (are_javascript_messages_suppressed_) { |
| 583 delegate_->RendererUnresponsive(this, is_waiting_for_unload_ack_); | 582 delegate_->RendererUnresponsive(this, is_waiting_for_unload_ack_); |
| 584 return; | 583 return; |
| 585 } | 584 } |
| 586 | 585 |
| 587 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 586 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 588 } | 587 } |
| 589 | 588 |
| 590 if (is_showing_before_unload_dialog_ && !success) { | |
| 591 // If a beforeunload dialog is canceled, we need to stop the throbber from | |
| 592 // spinning, since we forced it to start spinning in Navigate. | |
| 593 delegate_->DidStopLoading(this); | |
| 594 } | |
| 595 is_showing_before_unload_dialog_ = false; | |
| 596 | |
| 597 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, | 589 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, |
| 598 success, prompt); | 590 success, prompt); |
| 599 Send(reply_msg); | 591 Send(reply_msg); |
| 600 } | 592 } |
| 601 | 593 |
| 602 void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, | 594 void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, |
| 603 const std::string& json_retval) { | 595 const std::string& json_retval) { |
| 604 if (is_waiting_for_unload_ack_) | 596 if (is_waiting_for_unload_ack_) |
| 605 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 597 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 606 | 598 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 const GURL& target_url) { | 1011 const GURL& target_url) { |
| 1020 RenderViewHostDelegate::Resource* resource_delegate = | 1012 RenderViewHostDelegate::Resource* resource_delegate = |
| 1021 delegate_->GetResourceDelegate(); | 1013 delegate_->GetResourceDelegate(); |
| 1022 if (resource_delegate) { | 1014 if (resource_delegate) { |
| 1023 resource_delegate->DidRedirectProvisionalLoad(page_id, | 1015 resource_delegate->DidRedirectProvisionalLoad(page_id, |
| 1024 source_url, target_url); | 1016 source_url, target_url); |
| 1025 } | 1017 } |
| 1026 } | 1018 } |
| 1027 | 1019 |
| 1028 void RenderViewHost::OnMsgDidStartLoading() { | 1020 void RenderViewHost::OnMsgDidStartLoading() { |
| 1029 delegate_->DidStartLoading(this); | 1021 delegate_->DidStartLoading(); |
| 1030 } | 1022 } |
| 1031 | 1023 |
| 1032 void RenderViewHost::OnMsgDidStopLoading() { | 1024 void RenderViewHost::OnMsgDidStopLoading() { |
| 1033 delegate_->DidStopLoading(this); | 1025 delegate_->DidStopLoading(); |
| 1034 } | 1026 } |
| 1035 | 1027 |
| 1036 void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { | 1028 void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { |
| 1037 delegate_->DocumentAvailableInMainFrame(this); | 1029 delegate_->DocumentAvailableInMainFrame(this); |
| 1038 } | 1030 } |
| 1039 | 1031 |
| 1040 void RenderViewHost::OnMsgDidLoadResourceFromMemoryCache( | 1032 void RenderViewHost::OnMsgDidLoadResourceFromMemoryCache( |
| 1041 const GURL& url, | 1033 const GURL& url, |
| 1042 const std::string& frame_origin, | 1034 const std::string& frame_origin, |
| 1043 const std::string& main_frame_origin, | 1035 const std::string& main_frame_origin, |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 &are_javascript_messages_suppressed_); | 1321 &are_javascript_messages_suppressed_); |
| 1330 } | 1322 } |
| 1331 | 1323 |
| 1332 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, | 1324 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, |
| 1333 const std::wstring& message, | 1325 const std::wstring& message, |
| 1334 IPC::Message* reply_msg) { | 1326 IPC::Message* reply_msg) { |
| 1335 // While a JS before unload dialog is showing, tabs in the same process | 1327 // While a JS before unload dialog is showing, tabs in the same process |
| 1336 // shouldn't process input events. | 1328 // shouldn't process input events. |
| 1337 process()->set_ignore_input_events(true); | 1329 process()->set_ignore_input_events(true); |
| 1338 StopHangMonitorTimeout(); | 1330 StopHangMonitorTimeout(); |
| 1339 is_showing_before_unload_dialog_ = true; | |
| 1340 delegate_->RunBeforeUnloadConfirm(message, reply_msg); | 1331 delegate_->RunBeforeUnloadConfirm(message, reply_msg); |
| 1341 } | 1332 } |
| 1342 | 1333 |
| 1343 void RenderViewHost::OnMsgShowModalHTMLDialog( | 1334 void RenderViewHost::OnMsgShowModalHTMLDialog( |
| 1344 const GURL& url, int width, int height, const std::string& json_arguments, | 1335 const GURL& url, int width, int height, const std::string& json_arguments, |
| 1345 IPC::Message* reply_msg) { | 1336 IPC::Message* reply_msg) { |
| 1346 StopHangMonitorTimeout(); | 1337 StopHangMonitorTimeout(); |
| 1347 delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg); | 1338 delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg); |
| 1348 } | 1339 } |
| 1349 | 1340 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 #endif | 1727 #endif |
| 1737 } | 1728 } |
| 1738 | 1729 |
| 1739 void RenderViewHost::OnCSSInserted() { | 1730 void RenderViewHost::OnCSSInserted() { |
| 1740 delegate_->DidInsertCSS(); | 1731 delegate_->DidInsertCSS(); |
| 1741 } | 1732 } |
| 1742 | 1733 |
| 1743 void RenderViewHost::UpdateBrowserWindowId(int window_id) { | 1734 void RenderViewHost::UpdateBrowserWindowId(int window_id) { |
| 1744 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); | 1735 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); |
| 1745 } | 1736 } |
| OLD | NEW |