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 16 matching lines...) Expand all Loading... | |
27 #include "content/browser/child_process_security_policy_impl.h" | 27 #include "content/browser/child_process_security_policy_impl.h" |
28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
29 #include "content/browser/frame_host/frame_tree.h" | 29 #include "content/browser/frame_host/frame_tree.h" |
30 #include "content/browser/gpu/compositor_util.h" | 30 #include "content/browser/gpu/compositor_util.h" |
31 #include "content/browser/gpu/gpu_data_manager_impl.h" | 31 #include "content/browser/gpu/gpu_data_manager_impl.h" |
32 #include "content/browser/gpu/gpu_process_host.h" | 32 #include "content/browser/gpu/gpu_process_host.h" |
33 #include "content/browser/gpu/gpu_surface_tracker.h" | 33 #include "content/browser/gpu/gpu_surface_tracker.h" |
34 #include "content/browser/host_zoom_map_impl.h" | 34 #include "content/browser/host_zoom_map_impl.h" |
35 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 35 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
36 #include "content/browser/renderer_host/dip_util.h" | 36 #include "content/browser/renderer_host/dip_util.h" |
37 #include "content/browser/renderer_host/input/timeout_monitor.h" | |
38 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 37 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
39 #include "content/browser/renderer_host/render_process_host_impl.h" | 38 #include "content/browser/renderer_host/render_process_host_impl.h" |
40 #include "content/browser/renderer_host/render_view_host_delegate.h" | 39 #include "content/browser/renderer_host/render_view_host_delegate.h" |
41 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 40 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
42 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 41 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
43 #include "content/common/browser_plugin/browser_plugin_messages.h" | 42 #include "content/common/browser_plugin/browser_plugin_messages.h" |
44 #include "content/common/content_switches_internal.h" | 43 #include "content/common/content_switches_internal.h" |
45 #include "content/common/drag_messages.h" | 44 #include "content/common/drag_messages.h" |
46 #include "content/common/frame_messages.h" | 45 #include "content/common/frame_messages.h" |
47 #include "content/common/input_messages.h" | 46 #include "content/common/input_messages.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 128 |
130 } // namespace | 129 } // namespace |
131 | 130 |
132 // static | 131 // static |
133 const int RenderViewHostImpl::kUnloadTimeoutMS = 1000; | 132 const int RenderViewHostImpl::kUnloadTimeoutMS = 1000; |
134 | 133 |
135 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
136 // RenderViewHost, public: | 135 // RenderViewHost, public: |
137 | 136 |
138 // static | 137 // static |
139 bool RenderViewHostImpl::IsRVHStateActive(RenderViewHostImplState rvh_state) { | |
140 if (rvh_state == STATE_DEFAULT || | |
141 rvh_state == STATE_WAITING_FOR_CLOSE) | |
142 return true; | |
143 return false; | |
144 } | |
145 | |
146 // static | |
147 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 138 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
148 int render_view_id) { | 139 int render_view_id) { |
149 return RenderViewHostImpl::FromID(render_process_id, render_view_id); | 140 return RenderViewHostImpl::FromID(render_process_id, render_view_id); |
150 } | 141 } |
151 | 142 |
152 // static | 143 // static |
153 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { | 144 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { |
154 DCHECK(rwh->IsRenderView()); | 145 DCHECK(rwh->IsRenderView()); |
155 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); | 146 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); |
156 } | 147 } |
(...skipping 22 matching lines...) Expand all Loading... | |
179 : RenderWidgetHostImpl(widget_delegate, | 170 : RenderWidgetHostImpl(widget_delegate, |
180 instance->GetProcess(), | 171 instance->GetProcess(), |
181 routing_id, | 172 routing_id, |
182 hidden), | 173 hidden), |
183 frames_ref_count_(0), | 174 frames_ref_count_(0), |
184 delegate_(delegate), | 175 delegate_(delegate), |
185 instance_(static_cast<SiteInstanceImpl*>(instance)), | 176 instance_(static_cast<SiteInstanceImpl*>(instance)), |
186 waiting_for_drag_context_response_(false), | 177 waiting_for_drag_context_response_(false), |
187 enabled_bindings_(0), | 178 enabled_bindings_(0), |
188 page_id_(-1), | 179 page_id_(-1), |
180 is_active_(!swapped_out), | |
181 is_swapped_out_(swapped_out), | |
189 main_frame_routing_id_(main_frame_routing_id), | 182 main_frame_routing_id_(main_frame_routing_id), |
190 run_modal_reply_msg_(NULL), | 183 run_modal_reply_msg_(NULL), |
191 run_modal_opener_id_(MSG_ROUTING_NONE), | 184 run_modal_opener_id_(MSG_ROUTING_NONE), |
192 is_waiting_for_beforeunload_ack_(false), | 185 is_waiting_for_close_ack_(false), |
193 unload_ack_is_for_cross_site_transition_(false), | |
194 sudden_termination_allowed_(false), | 186 sudden_termination_allowed_(false), |
195 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 187 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
196 virtual_keyboard_requested_(false), | 188 virtual_keyboard_requested_(false), |
197 is_focused_element_editable_(false), | 189 is_focused_element_editable_(false), |
198 updating_web_preferences_(false), | 190 updating_web_preferences_(false), |
199 weak_factory_(this) { | 191 weak_factory_(this) { |
200 DCHECK(instance_.get()); | 192 DCHECK(instance_.get()); |
201 CHECK(delegate_); // http://crbug.com/82827 | 193 CHECK(delegate_); // http://crbug.com/82827 |
202 | 194 |
203 GetProcess()->EnableSendQueue(); | 195 GetProcess()->EnableSendQueue(); |
204 | 196 |
205 if (swapped_out) { | |
206 rvh_state_ = STATE_SWAPPED_OUT; | |
207 } else { | |
208 rvh_state_ = STATE_DEFAULT; | |
209 instance_->increment_active_view_count(); | |
210 } | |
211 | |
212 if (ResourceDispatcherHostImpl::Get()) { | 197 if (ResourceDispatcherHostImpl::Get()) { |
213 BrowserThread::PostTask( | 198 BrowserThread::PostTask( |
214 BrowserThread::IO, FROM_HERE, | 199 BrowserThread::IO, FROM_HERE, |
215 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, | 200 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, |
216 base::Unretained(ResourceDispatcherHostImpl::Get()), | 201 base::Unretained(ResourceDispatcherHostImpl::Get()), |
217 GetProcess()->GetID(), GetRoutingID(), !is_hidden())); | 202 GetProcess()->GetID(), GetRoutingID(), !is_hidden())); |
218 } | 203 } |
219 | 204 |
220 #if defined(ENABLE_BROWSER_CDMS) | 205 #if defined(ENABLE_BROWSER_CDMS) |
221 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 206 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
222 #endif | 207 #endif |
223 | |
224 unload_event_monitor_timeout_.reset(new TimeoutMonitor(base::Bind( | |
225 &RenderViewHostImpl::OnSwappedOut, weak_factory_.GetWeakPtr(), true))); | |
226 } | 208 } |
227 | 209 |
228 RenderViewHostImpl::~RenderViewHostImpl() { | 210 RenderViewHostImpl::~RenderViewHostImpl() { |
229 if (ResourceDispatcherHostImpl::Get()) { | 211 if (ResourceDispatcherHostImpl::Get()) { |
230 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
231 BrowserThread::IO, FROM_HERE, | 213 BrowserThread::IO, FROM_HERE, |
232 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, | 214 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, |
233 base::Unretained(ResourceDispatcherHostImpl::Get()), | 215 base::Unretained(ResourceDispatcherHostImpl::Get()), |
234 GetProcess()->GetID(), GetRoutingID())); | 216 GetProcess()->GetID(), GetRoutingID())); |
235 } | 217 } |
236 | 218 |
237 delegate_->RenderViewDeleted(this); | 219 delegate_->RenderViewDeleted(this); |
238 | |
239 // If this was swapped out, it already decremented the active view | |
240 // count of the SiteInstance it belongs to. | |
241 if (IsRVHStateActive(rvh_state_)) | |
242 instance_->decrement_active_view_count(); | |
243 } | 220 } |
244 | 221 |
245 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { | 222 RenderViewHostDelegate* RenderViewHostImpl::GetDelegate() const { |
246 return delegate_; | 223 return delegate_; |
247 } | 224 } |
248 | 225 |
249 SiteInstance* RenderViewHostImpl::GetSiteInstance() const { | 226 SiteInstanceImpl* RenderViewHostImpl::GetSiteInstance() const { |
250 return instance_.get(); | 227 return instance_.get(); |
251 } | 228 } |
252 | 229 |
253 bool RenderViewHostImpl::CreateRenderView( | 230 bool RenderViewHostImpl::CreateRenderView( |
254 const base::string16& frame_name, | 231 const base::string16& frame_name, |
255 int opener_route_id, | 232 int opener_route_id, |
256 int proxy_route_id, | 233 int proxy_route_id, |
257 int32 max_page_id, | 234 int32 max_page_id, |
258 bool window_was_created_with_opener) { | 235 bool window_was_created_with_opener) { |
259 TRACE_EVENT0("renderer_host,navigation", | 236 TRACE_EVENT0("renderer_host,navigation", |
(...skipping 25 matching lines...) Expand all Loading... | |
285 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 262 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
286 params.web_preferences = GetWebkitPreferences(); | 263 params.web_preferences = GetWebkitPreferences(); |
287 params.view_id = GetRoutingID(); | 264 params.view_id = GetRoutingID(); |
288 params.main_frame_routing_id = main_frame_routing_id_; | 265 params.main_frame_routing_id = main_frame_routing_id_; |
289 params.surface_id = surface_id(); | 266 params.surface_id = surface_id(); |
290 params.session_storage_namespace_id = | 267 params.session_storage_namespace_id = |
291 delegate_->GetSessionStorageNamespace(instance_.get())->id(); | 268 delegate_->GetSessionStorageNamespace(instance_.get())->id(); |
292 params.frame_name = frame_name; | 269 params.frame_name = frame_name; |
293 // Ensure the RenderView sets its opener correctly. | 270 // Ensure the RenderView sets its opener correctly. |
294 params.opener_route_id = opener_route_id; | 271 params.opener_route_id = opener_route_id; |
295 params.swapped_out = !IsRVHStateActive(rvh_state_); | 272 params.swapped_out = !is_active_; |
296 params.proxy_routing_id = proxy_route_id; | 273 params.proxy_routing_id = proxy_route_id; |
297 params.hidden = is_hidden(); | 274 params.hidden = is_hidden(); |
298 params.never_visible = delegate_->IsNeverVisible(); | 275 params.never_visible = delegate_->IsNeverVisible(); |
299 params.window_was_created_with_opener = window_was_created_with_opener; | 276 params.window_was_created_with_opener = window_was_created_with_opener; |
300 params.next_page_id = next_page_id; | 277 params.next_page_id = next_page_id; |
301 GetWebScreenInfo(¶ms.screen_info); | 278 GetWebScreenInfo(¶ms.screen_info); |
302 | 279 |
303 Send(new ViewMsg_New(params)); | 280 Send(new ViewMsg_New(params)); |
304 | 281 |
305 // If it's enabled, tell the renderer to set up the Javascript bindings for | 282 // If it's enabled, tell the renderer to set up the Javascript bindings for |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 base::FieldTrialList::FindFullName("V8ScriptStreaming") == "Enabled"; | 460 base::FieldTrialList::FindFullName("V8ScriptStreaming") == "Enabled"; |
484 | 461 |
485 GetContentClient()->browser()->OverrideWebkitPrefs(this, url, &prefs); | 462 GetContentClient()->browser()->OverrideWebkitPrefs(this, url, &prefs); |
486 return prefs; | 463 return prefs; |
487 } | 464 } |
488 | 465 |
489 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { | 466 void RenderViewHostImpl::SuppressDialogsUntilSwapOut() { |
490 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); | 467 Send(new ViewMsg_SuppressDialogsUntilSwapOut(GetRoutingID())); |
491 } | 468 } |
492 | 469 |
493 void RenderViewHostImpl::OnSwappedOut(bool timed_out) { | |
494 // Ignore spurious swap out ack. | |
495 if (!IsWaitingForUnloadACK()) | |
496 return; | |
497 | |
498 TRACE_EVENT0("navigation", "RenderViewHostImpl::OnSwappedOut"); | |
499 unload_event_monitor_timeout_->Stop(); | |
500 if (timed_out) { | |
Charlie Reis
2014/09/29 16:52:57
All this is basically a no-op leftover from 104346
| |
501 base::ProcessHandle process_handle = GetProcess()->GetHandle(); | |
502 int views = 0; | |
503 | |
504 // Count the number of active widget hosts for the process, which | |
505 // is equivalent to views using the process as of this writing. | |
506 scoped_ptr<RenderWidgetHostIterator> widgets( | |
507 RenderWidgetHost::GetRenderWidgetHosts()); | |
508 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | |
509 if (widget->GetProcess()->GetID() == GetProcess()->GetID()) | |
510 ++views; | |
511 } | |
512 | |
513 if (!RenderProcessHost::run_renderer_in_process() && | |
514 process_handle && views <= 1) { | |
515 // The process can safely be terminated, only if WebContents sets | |
516 // SuddenTerminationAllowed, which indicates that the timer has expired. | |
517 // This is not the case if we load data URLs or about:blank. The reason | |
518 // is that those have no network requests and this code is hit without | |
519 // setting the unresponsiveness timer. This allows a corner case where a | |
520 // navigation to a data URL will leave a process running, if the | |
521 // beforeunload handler completes fine, but the unload handler hangs. | |
522 // At this time, the complexity to solve this edge case is not worthwhile. | |
523 if (SuddenTerminationAllowed()) { | |
524 // We should kill the process, but for now, just log the data so we can | |
525 // diagnose the kill rate and investigate if separate timer is needed. | |
526 // http://crbug.com/104346. | |
527 | |
528 // Log a histogram point to help us diagnose how many of those kills | |
529 // we have performed. 1 is the enum value for RendererType Normal for | |
530 // the histogram. | |
531 UMA_HISTOGRAM_PERCENTAGE( | |
532 "BrowserRenderProcessHost.ChildKillsUnresponsive", 1); | |
533 } | |
534 } | |
535 // This is going to be incorrect for subframes and will only hit if | |
536 // --site-per-process is specified. | |
537 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | |
538 } | |
539 | |
540 switch (rvh_state_) { | |
541 case STATE_PENDING_SWAP_OUT: | |
542 SetState(STATE_SWAPPED_OUT); | |
543 break; | |
544 case STATE_PENDING_SHUTDOWN: | |
545 DCHECK(!pending_shutdown_on_swap_out_.is_null()); | |
546 pending_shutdown_on_swap_out_.Run(); | |
547 break; | |
548 default: | |
549 NOTREACHED(); | |
550 } | |
551 } | |
552 | |
553 void RenderViewHostImpl::SetPendingShutdown(const base::Closure& on_swap_out) { | |
554 pending_shutdown_on_swap_out_ = on_swap_out; | |
555 SetState(STATE_PENDING_SHUTDOWN); | |
556 } | |
557 | |
558 void RenderViewHostImpl::ClosePage() { | 470 void RenderViewHostImpl::ClosePage() { |
559 SetState(STATE_WAITING_FOR_CLOSE); | 471 is_waiting_for_close_ack_ = true; |
560 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 472 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
561 | 473 |
562 if (IsRenderViewLive()) { | 474 if (IsRenderViewLive()) { |
563 // Since we are sending an IPC message to the renderer, increase the event | 475 // Since we are sending an IPC message to the renderer, increase the event |
564 // count to prevent the hang monitor timeout from being stopped by input | 476 // count to prevent the hang monitor timeout from being stopped by input |
565 // event acknowledgements. | 477 // event acknowledgements. |
566 increment_in_flight_event_count(); | 478 increment_in_flight_event_count(); |
567 | 479 |
568 // TODO(creis): Should this be moved to Shutdown? It may not be called for | 480 // TODO(creis): Should this be moved to Shutdown? It may not be called for |
569 // RenderViewHosts that have been swapped out. | 481 // RenderViewHosts that have been swapped out. |
570 NotificationService::current()->Notify( | 482 NotificationService::current()->Notify( |
571 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 483 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
572 Source<RenderViewHost>(this), | 484 Source<RenderViewHost>(this), |
573 NotificationService::NoDetails()); | 485 NotificationService::NoDetails()); |
574 | 486 |
575 Send(new ViewMsg_ClosePage(GetRoutingID())); | 487 Send(new ViewMsg_ClosePage(GetRoutingID())); |
576 } else { | 488 } else { |
577 // This RenderViewHost doesn't have a live renderer, so just skip the unload | 489 // This RenderViewHost doesn't have a live renderer, so just skip the unload |
578 // event and close the page. | 490 // event and close the page. |
579 ClosePageIgnoringUnloadEvents(); | 491 ClosePageIgnoringUnloadEvents(); |
580 } | 492 } |
581 } | 493 } |
582 | 494 |
583 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { | 495 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { |
584 StopHangMonitorTimeout(); | 496 StopHangMonitorTimeout(); |
585 is_waiting_for_beforeunload_ack_ = false; | 497 is_waiting_for_close_ack_ = false; |
586 | 498 |
587 sudden_termination_allowed_ = true; | 499 sudden_termination_allowed_ = true; |
588 delegate_->Close(this); | 500 delegate_->Close(this); |
589 } | 501 } |
590 | 502 |
591 #if defined(OS_ANDROID) | 503 #if defined(OS_ANDROID) |
592 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, | 504 void RenderViewHostImpl::ActivateNearestFindResult(int request_id, |
593 float x, | 505 float x, |
594 float y) { | 506 float y) { |
595 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), | 507 Send(new InputMsg_ActivateNearestFindResult(GetRoutingID(), |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 | 778 |
867 /////////////////////////////////////////////////////////////////////////////// | 779 /////////////////////////////////////////////////////////////////////////////// |
868 // RenderViewHostImpl, IPC message handlers: | 780 // RenderViewHostImpl, IPC message handlers: |
869 | 781 |
870 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { | 782 bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
871 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 783 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
872 return true; | 784 return true; |
873 | 785 |
874 // Filter out most IPC messages if this renderer is swapped out. | 786 // Filter out most IPC messages if this renderer is swapped out. |
875 // We still want to handle certain ACKs to keep our state consistent. | 787 // We still want to handle certain ACKs to keep our state consistent. |
876 if (IsSwappedOut()) { | 788 if (is_swapped_out_) { |
877 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { | 789 if (!SwappedOutMessages::CanHandleWhileSwappedOut(msg)) { |
878 // If this is a synchronous message and we decided not to handle it, | 790 // If this is a synchronous message and we decided not to handle it, |
879 // we must send an error reply, or else the renderer will be stuck | 791 // we must send an error reply, or else the renderer will be stuck |
880 // and won't respond to future requests. | 792 // and won't respond to future requests. |
881 if (msg.is_sync()) { | 793 if (msg.is_sync()) { |
882 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 794 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
883 reply->set_reply_error(); | 795 reply->set_reply_error(); |
884 Send(reply); | 796 Send(reply); |
885 } | 797 } |
886 // Don't continue looking for someone to handle it. | 798 // Don't continue looking for someone to handle it. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 } | 922 } |
1011 | 923 |
1012 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { | 924 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { |
1013 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); | 925 delegate_->CreateNewFullscreenWidget(GetProcess()->GetID(), route_id); |
1014 } | 926 } |
1015 | 927 |
1016 void RenderViewHostImpl::OnShowView(int route_id, | 928 void RenderViewHostImpl::OnShowView(int route_id, |
1017 WindowOpenDisposition disposition, | 929 WindowOpenDisposition disposition, |
1018 const gfx::Rect& initial_pos, | 930 const gfx::Rect& initial_pos, |
1019 bool user_gesture) { | 931 bool user_gesture) { |
1020 if (IsRVHStateActive(rvh_state_)) { | 932 if (is_active_) { |
1021 delegate_->ShowCreatedWindow( | 933 delegate_->ShowCreatedWindow( |
1022 route_id, disposition, initial_pos, user_gesture); | 934 route_id, disposition, initial_pos, user_gesture); |
1023 } | 935 } |
1024 Send(new ViewMsg_Move_ACK(route_id)); | 936 Send(new ViewMsg_Move_ACK(route_id)); |
1025 } | 937 } |
1026 | 938 |
1027 void RenderViewHostImpl::OnShowWidget(int route_id, | 939 void RenderViewHostImpl::OnShowWidget(int route_id, |
1028 const gfx::Rect& initial_pos) { | 940 const gfx::Rect& initial_pos) { |
1029 if (IsRVHStateActive(rvh_state_)) | 941 if (is_active_) |
1030 delegate_->ShowCreatedWidget(route_id, initial_pos); | 942 delegate_->ShowCreatedWidget(route_id, initial_pos); |
1031 Send(new ViewMsg_Move_ACK(route_id)); | 943 Send(new ViewMsg_Move_ACK(route_id)); |
1032 } | 944 } |
1033 | 945 |
1034 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { | 946 void RenderViewHostImpl::OnShowFullscreenWidget(int route_id) { |
1035 if (IsRVHStateActive(rvh_state_)) | 947 if (is_active_) |
1036 delegate_->ShowCreatedFullscreenWidget(route_id); | 948 delegate_->ShowCreatedFullscreenWidget(route_id); |
1037 Send(new ViewMsg_Move_ACK(route_id)); | 949 Send(new ViewMsg_Move_ACK(route_id)); |
1038 } | 950 } |
1039 | 951 |
1040 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { | 952 void RenderViewHostImpl::OnRunModal(int opener_id, IPC::Message* reply_msg) { |
1041 DCHECK(!run_modal_reply_msg_); | 953 DCHECK(!run_modal_reply_msg_); |
1042 run_modal_reply_msg_ = reply_msg; | 954 run_modal_reply_msg_ = reply_msg; |
1043 run_modal_opener_id_ = opener_id; | 955 run_modal_opener_id_ = opener_id; |
1044 | 956 |
1045 RecordAction(base::UserMetricsAction("ShowModalDialog")); | 957 RecordAction(base::UserMetricsAction("ShowModalDialog")); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 // filenames it can't access in a future session restore. | 1000 // filenames it can't access in a future session restore. |
1089 if (!CanAccessFilesOfPageState(state)) { | 1001 if (!CanAccessFilesOfPageState(state)) { |
1090 GetProcess()->ReceivedBadMessage(); | 1002 GetProcess()->ReceivedBadMessage(); |
1091 return; | 1003 return; |
1092 } | 1004 } |
1093 | 1005 |
1094 delegate_->UpdateState(this, page_id, state); | 1006 delegate_->UpdateState(this, page_id, state); |
1095 } | 1007 } |
1096 | 1008 |
1097 void RenderViewHostImpl::OnUpdateTargetURL(const GURL& url) { | 1009 void RenderViewHostImpl::OnUpdateTargetURL(const GURL& url) { |
1098 if (IsRVHStateActive(rvh_state_)) | 1010 if (is_active_) |
1099 delegate_->UpdateTargetURL(url); | 1011 delegate_->UpdateTargetURL(url); |
1100 | 1012 |
1101 // Send a notification back to the renderer that we are ready to | 1013 // Send a notification back to the renderer that we are ready to |
1102 // receive more target urls. | 1014 // receive more target urls. |
1103 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); | 1015 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); |
1104 } | 1016 } |
1105 | 1017 |
1106 void RenderViewHostImpl::OnClose() { | 1018 void RenderViewHostImpl::OnClose() { |
1107 // If the renderer is telling us to close, it has already run the unload | 1019 // If the renderer is telling us to close, it has already run the unload |
1108 // events, and we can take the fast path. | 1020 // events, and we can take the fast path. |
1109 ClosePageIgnoringUnloadEvents(); | 1021 ClosePageIgnoringUnloadEvents(); |
1110 } | 1022 } |
1111 | 1023 |
1112 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { | 1024 void RenderViewHostImpl::OnRequestMove(const gfx::Rect& pos) { |
1113 if (IsRVHStateActive(rvh_state_)) | 1025 if (is_active_) |
1114 delegate_->RequestMove(pos); | 1026 delegate_->RequestMove(pos); |
1115 Send(new ViewMsg_Move_ACK(GetRoutingID())); | 1027 Send(new ViewMsg_Move_ACK(GetRoutingID())); |
1116 } | 1028 } |
1117 | 1029 |
1118 void RenderViewHostImpl::OnDocumentAvailableInMainFrame( | 1030 void RenderViewHostImpl::OnDocumentAvailableInMainFrame( |
1119 bool uses_temporary_zoom_level) { | 1031 bool uses_temporary_zoom_level) { |
1120 delegate_->DocumentAvailableInMainFrame(this); | 1032 delegate_->DocumentAvailableInMainFrame(this); |
1121 | 1033 |
1122 if (!uses_temporary_zoom_level) | 1034 if (!uses_temporary_zoom_level) |
1123 return; | 1035 return; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 void RenderViewHostImpl::OnUserGesture() { | 1165 void RenderViewHostImpl::OnUserGesture() { |
1254 delegate_->OnUserGesture(); | 1166 delegate_->OnUserGesture(); |
1255 } | 1167 } |
1256 | 1168 |
1257 void RenderViewHostImpl::OnClosePageACK() { | 1169 void RenderViewHostImpl::OnClosePageACK() { |
1258 decrement_in_flight_event_count(); | 1170 decrement_in_flight_event_count(); |
1259 ClosePageIgnoringUnloadEvents(); | 1171 ClosePageIgnoringUnloadEvents(); |
1260 } | 1172 } |
1261 | 1173 |
1262 void RenderViewHostImpl::NotifyRendererUnresponsive() { | 1174 void RenderViewHostImpl::NotifyRendererUnresponsive() { |
1263 delegate_->RendererUnresponsive( | 1175 delegate_->RendererUnresponsive(this); |
1264 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK()); | |
1265 } | 1176 } |
1266 | 1177 |
1267 void RenderViewHostImpl::NotifyRendererResponsive() { | 1178 void RenderViewHostImpl::NotifyRendererResponsive() { |
1268 delegate_->RendererResponsive(this); | 1179 delegate_->RendererResponsive(this); |
1269 } | 1180 } |
1270 | 1181 |
1271 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, | 1182 void RenderViewHostImpl::RequestToLockMouse(bool user_gesture, |
1272 bool last_unlocked_by_target) { | 1183 bool last_unlocked_by_target) { |
1273 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); | 1184 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target); |
1274 } | 1185 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 void RenderViewHostImpl::ForwardKeyboardEvent( | 1239 void RenderViewHostImpl::ForwardKeyboardEvent( |
1329 const NativeWebKeyboardEvent& key_event) { | 1240 const NativeWebKeyboardEvent& key_event) { |
1330 if (ignore_input_events()) { | 1241 if (ignore_input_events()) { |
1331 if (key_event.type == WebInputEvent::RawKeyDown) | 1242 if (key_event.type == WebInputEvent::RawKeyDown) |
1332 delegate_->OnIgnoredUIEvent(); | 1243 delegate_->OnIgnoredUIEvent(); |
1333 return; | 1244 return; |
1334 } | 1245 } |
1335 RenderWidgetHostImpl::ForwardKeyboardEvent(key_event); | 1246 RenderWidgetHostImpl::ForwardKeyboardEvent(key_event); |
1336 } | 1247 } |
1337 | 1248 |
1338 bool RenderViewHostImpl::IsWaitingForUnloadACK() const { | |
1339 return rvh_state_ == STATE_WAITING_FOR_CLOSE || | |
1340 rvh_state_ == STATE_PENDING_SHUTDOWN || | |
1341 rvh_state_ == STATE_PENDING_SWAP_OUT; | |
1342 } | |
1343 | |
1344 void RenderViewHostImpl::OnTextSurroundingSelectionResponse( | 1249 void RenderViewHostImpl::OnTextSurroundingSelectionResponse( |
1345 const base::string16& content, | 1250 const base::string16& content, |
1346 size_t start_offset, | 1251 size_t start_offset, |
1347 size_t end_offset) { | 1252 size_t end_offset) { |
1348 if (!view_) | 1253 if (!view_) |
1349 return; | 1254 return; |
1350 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); | 1255 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); |
1351 } | 1256 } |
1352 | 1257 |
1353 void RenderViewHostImpl::ExitFullscreen() { | 1258 void RenderViewHostImpl::ExitFullscreen() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 #if defined(OS_WIN) | 1367 #if defined(OS_WIN) |
1463 if (editable) { | 1368 if (editable) { |
1464 virtual_keyboard_requested_ = base::win::DisplayVirtualKeyboard(); | 1369 virtual_keyboard_requested_ = base::win::DisplayVirtualKeyboard(); |
1465 } else { | 1370 } else { |
1466 virtual_keyboard_requested_ = false; | 1371 virtual_keyboard_requested_ = false; |
1467 base::win::DismissVirtualKeyboard(); | 1372 base::win::DismissVirtualKeyboard(); |
1468 } | 1373 } |
1469 #endif | 1374 #endif |
1470 } | 1375 } |
1471 | 1376 |
1472 void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { | |
1473 // We update the number of RenderViews in a SiteInstance when the | |
1474 // swapped out status of this RenderView gets flipped to/from live. | |
1475 if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) | |
1476 instance_->increment_active_view_count(); | |
1477 else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) | |
1478 instance_->decrement_active_view_count(); | |
1479 | |
1480 // Whenever we change the RVH state to and from live or swapped out state, we | |
1481 // should not be waiting for beforeunload or unload acks. We clear them here | |
1482 // to be safe, since they can cause navigations to be ignored in OnNavigate. | |
1483 if (rvh_state == STATE_DEFAULT || | |
1484 rvh_state == STATE_SWAPPED_OUT || | |
1485 rvh_state_ == STATE_DEFAULT || | |
1486 rvh_state_ == STATE_SWAPPED_OUT) { | |
1487 is_waiting_for_beforeunload_ack_ = false; | |
1488 } | |
1489 rvh_state_ = rvh_state; | |
1490 | |
1491 } | |
1492 | |
1493 bool RenderViewHostImpl::CanAccessFilesOfPageState( | 1377 bool RenderViewHostImpl::CanAccessFilesOfPageState( |
1494 const PageState& state) const { | 1378 const PageState& state) const { |
1495 ChildProcessSecurityPolicyImpl* policy = | 1379 ChildProcessSecurityPolicyImpl* policy = |
1496 ChildProcessSecurityPolicyImpl::GetInstance(); | 1380 ChildProcessSecurityPolicyImpl::GetInstance(); |
1497 | 1381 |
1498 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); | 1382 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); |
1499 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); | 1383 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); |
1500 file != file_paths.end(); ++file) { | 1384 file != file_paths.end(); ++file) { |
1501 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) | 1385 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) |
1502 return false; | 1386 return false; |
1503 } | 1387 } |
1504 return true; | 1388 return true; |
1505 } | 1389 } |
1506 | 1390 |
1507 void RenderViewHostImpl::AttachToFrameTree() { | 1391 void RenderViewHostImpl::AttachToFrameTree() { |
1508 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1392 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1509 | 1393 |
1510 frame_tree->ResetForMainFrameSwap(); | 1394 frame_tree->ResetForMainFrameSwap(); |
1511 } | 1395 } |
1512 | 1396 |
1513 void RenderViewHostImpl::SelectWordAroundCaret() { | 1397 void RenderViewHostImpl::SelectWordAroundCaret() { |
1514 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1398 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
1515 } | 1399 } |
1516 | 1400 |
1517 } // namespace content | 1401 } // namespace content |
OLD | NEW |