| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 SiteInstance* instance, | 193 SiteInstance* instance, |
| 194 std::unique_ptr<RenderWidgetHostImpl> widget, | 194 std::unique_ptr<RenderWidgetHostImpl> widget, |
| 195 RenderViewHostDelegate* delegate, | 195 RenderViewHostDelegate* delegate, |
| 196 int32_t main_frame_routing_id, | 196 int32_t main_frame_routing_id, |
| 197 bool swapped_out, | 197 bool swapped_out, |
| 198 bool has_initialized_audio_host) | 198 bool has_initialized_audio_host) |
| 199 : render_widget_host_(std::move(widget)), | 199 : render_widget_host_(std::move(widget)), |
| 200 frames_ref_count_(0), | 200 frames_ref_count_(0), |
| 201 delegate_(delegate), | 201 delegate_(delegate), |
| 202 instance_(static_cast<SiteInstanceImpl*>(instance)), | 202 instance_(static_cast<SiteInstanceImpl*>(instance)), |
| 203 enabled_bindings_(0), | |
| 204 is_active_(!swapped_out), | 203 is_active_(!swapped_out), |
| 205 is_swapped_out_(swapped_out), | 204 is_swapped_out_(swapped_out), |
| 206 main_frame_routing_id_(main_frame_routing_id), | 205 main_frame_routing_id_(main_frame_routing_id), |
| 207 is_waiting_for_close_ack_(false), | 206 is_waiting_for_close_ack_(false), |
| 208 sudden_termination_allowed_(false), | 207 sudden_termination_allowed_(false), |
| 209 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 208 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 210 updating_web_preferences_(false), | 209 updating_web_preferences_(false), |
| 211 render_view_ready_on_process_launch_(false), | 210 render_view_ready_on_process_launch_(false), |
| 212 weak_factory_(this) { | 211 weak_factory_(this) { |
| 213 DCHECK(instance_.get()); | 212 DCHECK(instance_.get()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 params->min_size = GetWidget()->min_size_for_auto_resize(); | 310 params->min_size = GetWidget()->min_size_for_auto_resize(); |
| 312 params->max_size = GetWidget()->max_size_for_auto_resize(); | 311 params->max_size = GetWidget()->max_size_for_auto_resize(); |
| 313 params->page_zoom_level = delegate_->GetPendingPageZoomLevel(); | 312 params->page_zoom_level = delegate_->GetPendingPageZoomLevel(); |
| 314 params->image_decode_color_space = gfx::ICCProfile::FromBestMonitor(); | 313 params->image_decode_color_space = gfx::ICCProfile::FromBestMonitor(); |
| 315 | 314 |
| 316 GetWidget()->GetResizeParams(¶ms->initial_size); | 315 GetWidget()->GetResizeParams(¶ms->initial_size); |
| 317 GetWidget()->SetInitialRenderSizeParams(params->initial_size); | 316 GetWidget()->SetInitialRenderSizeParams(params->initial_size); |
| 318 | 317 |
| 319 GetProcess()->GetRendererInterface()->CreateView(std::move(params)); | 318 GetProcess()->GetRendererInterface()->CreateView(std::move(params)); |
| 320 | 319 |
| 321 // If it's enabled, tell the renderer to set up the Javascript bindings for | |
| 322 // sending messages back to the browser. | |
| 323 if (GetProcess()->IsForGuestsOnly()) | |
| 324 DCHECK_EQ(0, enabled_bindings_); | |
| 325 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | |
| 326 // Let our delegate know that we created a RenderView. | 320 // Let our delegate know that we created a RenderView. |
| 327 delegate_->RenderViewCreated(this); | 321 delegate_->RenderViewCreated(this); |
| 328 | 322 |
| 329 // Since this method can create the main RenderFrame in the renderer process, | 323 // Since this method can create the main RenderFrame in the renderer process, |
| 330 // set the proper state on its corresponding RenderFrameHost. | 324 // set the proper state on its corresponding RenderFrameHost. |
| 331 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { | 325 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { |
| 332 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) | 326 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) |
| 333 ->SetRenderFrameCreated(true); | 327 ->SetRenderFrameCreated(true); |
| 334 } | 328 } |
| 335 GetWidget()->delegate()->SendScreenRects(); | 329 GetWidget()->delegate()->SendScreenRects(); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 } | 633 } |
| 640 | 634 |
| 641 int RenderViewHostImpl::GetRoutingID() const { | 635 int RenderViewHostImpl::GetRoutingID() const { |
| 642 return GetWidget()->GetRoutingID(); | 636 return GetWidget()->GetRoutingID(); |
| 643 } | 637 } |
| 644 | 638 |
| 645 RenderFrameHost* RenderViewHostImpl::GetMainFrame() { | 639 RenderFrameHost* RenderViewHostImpl::GetMainFrame() { |
| 646 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_); | 640 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_); |
| 647 } | 641 } |
| 648 | 642 |
| 649 void RenderViewHostImpl::AllowBindings(int bindings_flags) { | |
| 650 // Never grant any bindings to browser plugin guests. | |
| 651 if (GetProcess()->IsForGuestsOnly()) { | |
| 652 NOTREACHED() << "Never grant bindings to a guest process."; | |
| 653 return; | |
| 654 } | |
| 655 | |
| 656 // Ensure we aren't granting WebUI bindings to a process that has already | |
| 657 // been used for non-privileged views. | |
| 658 if (bindings_flags & BINDINGS_POLICY_WEB_UI && | |
| 659 GetProcess()->HasConnection() && | |
| 660 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | |
| 661 GetProcess()->GetID())) { | |
| 662 // This process has no bindings yet. Make sure it does not have more | |
| 663 // than this single active view. | |
| 664 // --single-process only has one renderer. | |
| 665 if (GetProcess()->GetActiveViewCount() > 1 && | |
| 666 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 667 switches::kSingleProcess)) | |
| 668 return; | |
| 669 } | |
| 670 | |
| 671 if (bindings_flags & BINDINGS_POLICY_WEB_UI) { | |
| 672 ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings( | |
| 673 GetProcess()->GetID()); | |
| 674 } | |
| 675 | |
| 676 enabled_bindings_ |= bindings_flags; | |
| 677 if (GetWidget()->renderer_initialized()) | |
| 678 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_)); | |
| 679 } | |
| 680 | |
| 681 int RenderViewHostImpl::GetEnabledBindings() const { | |
| 682 return enabled_bindings_; | |
| 683 } | |
| 684 | |
| 685 void RenderViewHostImpl::SetWebUIProperty(const std::string& name, | 643 void RenderViewHostImpl::SetWebUIProperty(const std::string& name, |
| 686 const std::string& value) { | 644 const std::string& value) { |
| 687 // This is a sanity check before telling the renderer to enable the property. | 645 // This is a sanity check before telling the renderer to enable the property. |
| 688 // It could lie and send the corresponding IPC messages anyway, but we will | 646 // It could lie and send the corresponding IPC messages anyway, but we will |
| 689 // not act on them if enabled_bindings_ doesn't agree. If we get here without | 647 // not act on them if enabled_bindings_ doesn't agree. If we get here without |
| 690 // WebUI bindings, kill the renderer process. | 648 // WebUI bindings, kill the renderer process. |
| 691 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) { | 649 if (GetMainFrame()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI) { |
| 692 Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value)); | 650 Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value)); |
| 693 } else { | 651 } else { |
| 694 RecordAction( | 652 RecordAction( |
| 695 base::UserMetricsAction("BindingsMismatchTerminate_RVH_WebUI")); | 653 base::UserMetricsAction("BindingsMismatchTerminate_RVH_WebUI")); |
| 696 GetProcess()->Shutdown(content::RESULT_CODE_KILLED, false); | 654 GetProcess()->Shutdown(content::RESULT_CODE_KILLED, false); |
| 697 } | 655 } |
| 698 } | 656 } |
| 699 | 657 |
| 700 void RenderViewHostImpl::RenderWidgetGotFocus() { | 658 void RenderViewHostImpl::RenderWidgetGotFocus() { |
| 701 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); | 659 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } else { | 942 } else { |
| 985 render_view_ready_on_process_launch_ = true; | 943 render_view_ready_on_process_launch_ = true; |
| 986 } | 944 } |
| 987 } | 945 } |
| 988 | 946 |
| 989 void RenderViewHostImpl::RenderViewReady() { | 947 void RenderViewHostImpl::RenderViewReady() { |
| 990 delegate_->RenderViewReady(this); | 948 delegate_->RenderViewReady(this); |
| 991 } | 949 } |
| 992 | 950 |
| 993 } // namespace content | 951 } // namespace content |
| OLD | NEW |