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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "base/values.h" | 24 #include "base/values.h" |
25 #include "cc/base/switches.h" | 25 #include "cc/base/switches.h" |
26 #include "content/browser/child_process_security_policy_impl.h" | 26 #include "content/browser/child_process_security_policy_impl.h" |
| 27 #include "content/browser/cross_site_request_manager.h" |
27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
28 #include "content/browser/frame_host/frame_tree.h" | 29 #include "content/browser/frame_host/frame_tree.h" |
29 #include "content/browser/gpu/compositor_util.h" | 30 #include "content/browser/gpu/compositor_util.h" |
30 #include "content/browser/gpu/gpu_data_manager_impl.h" | 31 #include "content/browser/gpu/gpu_data_manager_impl.h" |
31 #include "content/browser/gpu/gpu_process_host.h" | 32 #include "content/browser/gpu/gpu_process_host.h" |
32 #include "content/browser/gpu/gpu_surface_tracker.h" | 33 #include "content/browser/gpu/gpu_surface_tracker.h" |
33 #include "content/browser/host_zoom_map_impl.h" | 34 #include "content/browser/host_zoom_map_impl.h" |
34 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 35 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
35 #include "content/browser/renderer_host/dip_util.h" | 36 #include "content/browser/renderer_host/dip_util.h" |
36 #include "content/browser/renderer_host/input/timeout_monitor.h" | 37 #include "content/browser/renderer_host/input/timeout_monitor.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 bool hidden) | 182 bool hidden) |
182 : RenderWidgetHostImpl(widget_delegate, | 183 : RenderWidgetHostImpl(widget_delegate, |
183 instance->GetProcess(), | 184 instance->GetProcess(), |
184 routing_id, | 185 routing_id, |
185 hidden), | 186 hidden), |
186 frames_ref_count_(0), | 187 frames_ref_count_(0), |
187 delegate_(delegate), | 188 delegate_(delegate), |
188 instance_(static_cast<SiteInstanceImpl*>(instance)), | 189 instance_(static_cast<SiteInstanceImpl*>(instance)), |
189 waiting_for_drag_context_response_(false), | 190 waiting_for_drag_context_response_(false), |
190 enabled_bindings_(0), | 191 enabled_bindings_(0), |
| 192 navigations_suspended_(false), |
191 main_frame_routing_id_(main_frame_routing_id), | 193 main_frame_routing_id_(main_frame_routing_id), |
192 run_modal_reply_msg_(NULL), | 194 run_modal_reply_msg_(NULL), |
193 run_modal_opener_id_(MSG_ROUTING_NONE), | 195 run_modal_opener_id_(MSG_ROUTING_NONE), |
194 is_waiting_for_beforeunload_ack_(false), | 196 is_waiting_for_beforeunload_ack_(false), |
195 unload_ack_is_for_cross_site_transition_(false), | 197 unload_ack_is_for_cross_site_transition_(false), |
196 sudden_termination_allowed_(false), | 198 sudden_termination_allowed_(false), |
197 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 199 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
198 virtual_keyboard_requested_(false), | 200 virtual_keyboard_requested_(false), |
199 weak_factory_(this), | 201 weak_factory_(this), |
200 is_focused_element_editable_(false), | 202 is_focused_element_editable_(false), |
(...skipping 30 matching lines...) Expand all Loading... |
231 if (ResourceDispatcherHostImpl::Get()) { | 233 if (ResourceDispatcherHostImpl::Get()) { |
232 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
233 BrowserThread::IO, FROM_HERE, | 235 BrowserThread::IO, FROM_HERE, |
234 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 236 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
235 base::Unretained(ResourceDispatcherHostImpl::Get()), | 237 base::Unretained(ResourceDispatcherHostImpl::Get()), |
236 GetProcess()->GetID(), GetRoutingID())); | 238 GetProcess()->GetID(), GetRoutingID())); |
237 } | 239 } |
238 | 240 |
239 delegate_->RenderViewDeleted(this); | 241 delegate_->RenderViewDeleted(this); |
240 | 242 |
| 243 // Be sure to clean up any leftover state from cross-site requests. |
| 244 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 245 GetProcess()->GetID(), GetRoutingID(), false); |
| 246 |
241 // If this was swapped out, it already decremented the active view | 247 // If this was swapped out, it already decremented the active view |
242 // count of the SiteInstance it belongs to. | 248 // count of the SiteInstance it belongs to. |
243 if (IsRVHStateActive(rvh_state_)) | 249 if (IsRVHStateActive(rvh_state_)) |
244 instance_->decrement_active_view_count(); | 250 instance_->decrement_active_view_count(); |
245 } | 251 } |
246 | 252 |
247 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 253 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
248 return delegate_; | 254 return delegate_; |
249 } | 255 } |
250 | 256 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 480 |
475 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | 481 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
476 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); | 482 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); |
477 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); | 483 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); |
478 } | 484 } |
479 | 485 |
480 void RenderViewHostImpl::NavigateToURL(const GURL& url) { | 486 void RenderViewHostImpl::NavigateToURL(const GURL& url) { |
481 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); | 487 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); |
482 } | 488 } |
483 | 489 |
| 490 void RenderViewHostImpl::SetNavigationsSuspended( |
| 491 bool suspend, |
| 492 const base::TimeTicks& proceed_time) { |
| 493 // This should only be called to toggle the state. |
| 494 DCHECK(navigations_suspended_ != suspend); |
| 495 |
| 496 navigations_suspended_ = suspend; |
| 497 if (!suspend && suspended_nav_params_) { |
| 498 // There's navigation message params waiting to be sent. Now that we're not |
| 499 // suspended anymore, resume navigation by sending them. If we were swapped |
| 500 // out, we should also stop filtering out the IPC messages now. |
| 501 SetState(STATE_DEFAULT); |
| 502 |
| 503 DCHECK(!proceed_time.is_null()); |
| 504 suspended_nav_params_->browser_navigation_start = proceed_time; |
| 505 Send(new FrameMsg_Navigate( |
| 506 main_frame_routing_id_, *suspended_nav_params_.get())); |
| 507 suspended_nav_params_.reset(); |
| 508 } |
| 509 } |
| 510 |
| 511 void RenderViewHostImpl::CancelSuspendedNavigations() { |
| 512 // Clear any state if a pending navigation is canceled or pre-empted. |
| 513 if (suspended_nav_params_) |
| 514 suspended_nav_params_.reset(); |
| 515 navigations_suspended_ = false; |
| 516 } |
| 517 |
484 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { | 518 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
485 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); | 519 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
486 } | 520 } |
487 | 521 |
488 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { | 522 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
489 // Ignore spurious swap out ack. | 523 // Ignore spurious swap out ack. |
490 if (!IsWaitingForUnloadACK()) | 524 if (!IsWaitingForUnloadACK()) |
491 return; | 525 return; |
492 unload_event_monitor_timeout_->Stop(); | 526 unload_event_monitor_timeout_->Stop(); |
493 if (timed_out) { | 527 if (timed_out) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 628 } |
595 | 629 |
596 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { | 630 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { |
597 StopHangMonitorTimeout(); | 631 StopHangMonitorTimeout(); |
598 is_waiting_for_beforeunload_ack_ = false; | 632 is_waiting_for_beforeunload_ack_ = false; |
599 | 633 |
600 sudden_termination_allowed_ = true; | 634 sudden_termination_allowed_ = true; |
601 delegate_->Close(this); | 635 delegate_->Close(this); |
602 } | 636 } |
603 | 637 |
| 638 bool RenderViewHostImpl::HasPendingCrossSiteRequest() { |
| 639 return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
| 640 GetProcess()->GetID(), GetRoutingID()); |
| 641 } |
| 642 |
| 643 void RenderViewHostImpl::SetHasPendingCrossSiteRequest( |
| 644 bool has_pending_request) { |
| 645 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( |
| 646 GetProcess()->GetID(), GetRoutingID(), has_pending_request); |
| 647 } |
| 648 |
604 #if defined(OS_ANDROID) | 649 #if defined(OS_ANDROID) |
605 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, | 650 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, |
606 float x, | 651 float x, |
607 float y) { | 652 float y) { |
608 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), | 653 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), |
609 request_id, x, y)); | 654 request_id, x, y)); |
610 } | 655 } |
611 | 656 |
612 void RenderViewHostImpl::RequestFindMatchRects(int current_version) { | 657 void RenderViewHostImpl::RequestFindMatchRects(int current_version) { |
613 Send(new ViewMsg_FindMatchRects(GetRoutingID(), current_version)); | 658 Send(new ViewMsg_FindMatchRects(GetRoutingID(), current_version)); |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1598 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1554 | 1599 |
1555 frame_tree->ResetForMainFrameSwap(); | 1600 frame_tree->ResetForMainFrameSwap(); |
1556 } | 1601 } |
1557 | 1602 |
1558 void RenderViewHostImpl::SelectWordAroundCaret() { | 1603 void RenderViewHostImpl::SelectWordAroundCaret() { |
1559 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1604 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1560 } | 1605 } |
1561 | 1606 |
1562 } // namespace content | 1607 } // namespace content |
OLD | NEW |