Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 457003002: [site isolation] cross-site transfers should track the RenderFrameHost, not the View (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self-review fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 27 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
29 #include "content/browser/frame_host/frame_tree.h" 28 #include "content/browser/frame_host/frame_tree.h"
30 #include "content/browser/gpu/compositor_util.h" 29 #include "content/browser/gpu/compositor_util.h"
31 #include "content/browser/gpu/gpu_data_manager_impl.h" 30 #include "content/browser/gpu/gpu_data_manager_impl.h"
32 #include "content/browser/gpu/gpu_process_host.h" 31 #include "content/browser/gpu/gpu_process_host.h"
33 #include "content/browser/gpu/gpu_surface_tracker.h" 32 #include "content/browser/gpu/gpu_surface_tracker.h"
34 #include "content/browser/host_zoom_map_impl.h" 33 #include "content/browser/host_zoom_map_impl.h"
35 #include "content/browser/loader/resource_dispatcher_host_impl.h" 34 #include "content/browser/loader/resource_dispatcher_host_impl.h"
36 #include "content/browser/renderer_host/dip_util.h" 35 #include "content/browser/renderer_host/dip_util.h"
37 #include "content/browser/renderer_host/input/timeout_monitor.h" 36 #include "content/browser/renderer_host/input/timeout_monitor.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 bool hidden) 181 bool hidden)
183 : RenderWidgetHostImpl(widget_delegate, 182 : RenderWidgetHostImpl(widget_delegate,
184 instance->GetProcess(), 183 instance->GetProcess(),
185 routing_id, 184 routing_id,
186 hidden), 185 hidden),
187 frames_ref_count_(0), 186 frames_ref_count_(0),
188 delegate_(delegate), 187 delegate_(delegate),
189 instance_(static_cast<SiteInstanceImpl*>(instance)), 188 instance_(static_cast<SiteInstanceImpl*>(instance)),
190 waiting_for_drag_context_response_(false), 189 waiting_for_drag_context_response_(false),
191 enabled_bindings_(0), 190 enabled_bindings_(0),
192 navigations_suspended_(false),
193 main_frame_routing_id_(main_frame_routing_id), 191 main_frame_routing_id_(main_frame_routing_id),
194 run_modal_reply_msg_(NULL), 192 run_modal_reply_msg_(NULL),
195 run_modal_opener_id_(MSG_ROUTING_NONE), 193 run_modal_opener_id_(MSG_ROUTING_NONE),
196 is_waiting_for_beforeunload_ack_(false), 194 is_waiting_for_beforeunload_ack_(false),
197 unload_ack_is_for_cross_site_transition_(false), 195 unload_ack_is_for_cross_site_transition_(false),
198 sudden_termination_allowed_(false), 196 sudden_termination_allowed_(false),
199 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), 197 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING),
200 virtual_keyboard_requested_(false), 198 virtual_keyboard_requested_(false),
201 weak_factory_(this), 199 weak_factory_(this),
202 is_focused_element_editable_(false), 200 is_focused_element_editable_(false),
(...skipping 30 matching lines...) Expand all
233 if (ResourceDispatcherHostImpl::Get()) { 231 if (ResourceDispatcherHostImpl::Get()) {
234 BrowserThread::PostTask( 232 BrowserThread::PostTask(
235 BrowserThread::IO, FROM_HERE, 233 BrowserThread::IO, FROM_HERE,
236 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, 234 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted,
237 base::Unretained(ResourceDispatcherHostImpl::Get()), 235 base::Unretained(ResourceDispatcherHostImpl::Get()),
238 GetProcess()->GetID(), GetRoutingID())); 236 GetProcess()->GetID(), GetRoutingID()));
239 } 237 }
240 238
241 delegate_->RenderViewDeleted(this); 239 delegate_->RenderViewDeleted(this);
242 240
243 // Be sure to clean up any leftover state from cross-site requests.
244 CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest(
245 GetProcess()->GetID(), GetRoutingID(), false);
246
247 // If this was swapped out, it already decremented the active view 241 // If this was swapped out, it already decremented the active view
248 // count of the SiteInstance it belongs to. 242 // count of the SiteInstance it belongs to.
249 if (IsRVHStateActive(rvh_state_)) 243 if (IsRVHStateActive(rvh_state_))
250 instance_->decrement_active_view_count(); 244 instance_->decrement_active_view_count();
251 } 245 }
252 246
253 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { 247 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const {
254 return delegate_; 248 return delegate_;
255 } 249 }
256 250
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 474
481 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { 475 void RenderViewHostImpl::Navigate(const FrameMsg_Navigate_Params& params) {
482 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); 476 TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate");
483 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params); 477 delegate_->GetFrameTree()->GetMainFrame()->Navigate(params);
484 } 478 }
485 479
486 void RenderViewHostImpl::NavigateToURL(const GURL& url) { 480 void RenderViewHostImpl::NavigateToURL(const GURL& url) {
487 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url); 481 delegate_->GetFrameTree()->GetMainFrame()->NavigateToURL(url);
488 } 482 }
489 483
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
518 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { 484 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() {
519 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); 485 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID()));
520 } 486 }
521 487
522 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { 488 void RenderViewHostImpl::OnSwappedOut(bool timed_out) {
523 // Ignore spurious swap out ack. 489 // Ignore spurious swap out ack.
524 if (!IsWaitingForUnloadACK()) 490 if (!IsWaitingForUnloadACK())
525 return; 491 return;
526 unload_event_monitor_timeout_->Stop(); 492 unload_event_monitor_timeout_->Stop();
527 if (timed_out) { 493 if (timed_out) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 594 }
629 595
630 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { 596 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() {
631 StopHangMonitorTimeout(); 597 StopHangMonitorTimeout();
632 is_waiting_for_beforeunload_ack_ = false; 598 is_waiting_for_beforeunload_ack_ = false;
633 599
634 sudden_termination_allowed_ = true; 600 sudden_termination_allowed_ = true;
635 delegate_->Close(this); 601 delegate_->Close(this);
636 } 602 }
637 603
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
649 #if defined(OS_ANDROID) 604 #if defined(OS_ANDROID)
650 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, 605 void RenderViewHostImpl::ActivateNearestFindResult(int request_id,
651 float x, 606 float x,
652 float y) { 607 float y) {
653 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), 608 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(),
654 request_id, x, y)); 609 request_id, x, y));
655 } 610 }
656 611
657 void RenderViewHostImpl::RequestFindMatchRects(int current_version) { 612 void RenderViewHostImpl::RequestFindMatchRects(int current_version) {
658 Send(new ViewMsg_FindMatchRects(GetRoutingID(), current_version)); 613 Send(new ViewMsg_FindMatchRects(GetRoutingID(), current_version));
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 FrameTree* frame_tree = delegate_->GetFrameTree(); 1553 FrameTree* frame_tree = delegate_->GetFrameTree();
1599 1554
1600 frame_tree->ResetForMainFrameSwap(); 1555 frame_tree->ResetForMainFrameSwap();
1601 } 1556 }
1602 1557
1603 void RenderViewHostImpl::SelectWordAroundCaret() { 1558 void RenderViewHostImpl::SelectWordAroundCaret() {
1604 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); 1559 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID()));
1605 } 1560 }
1606 1561
1607 } // namespace content 1562 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698