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

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

Issue 2566583002: Change allowed bindings to be per RenderFrame instead of per RenderView. (Closed)
Patch Set: Created 3 years, 11 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
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>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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(&params->initial_size); 315 GetWidget()->GetResizeParams(&params->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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 624 }
631 625
632 int RenderViewHostImpl::GetRoutingID() const { 626 int RenderViewHostImpl::GetRoutingID() const {
633 return GetWidget()->GetRoutingID(); 627 return GetWidget()->GetRoutingID();
634 } 628 }
635 629
636 RenderFrameHost* RenderViewHostImpl::GetMainFrame() { 630 RenderFrameHost* RenderViewHostImpl::GetMainFrame() {
637 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_); 631 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_);
638 } 632 }
639 633
640 void RenderViewHostImpl::AllowBindings(int bindings_flags) {
641 // Never grant any bindings to browser plugin guests.
642 if (GetProcess()->IsForGuestsOnly()) {
643 NOTREACHED() << "Never grant bindings to a guest process.";
644 return;
645 }
646
647 // Ensure we aren't granting WebUI bindings to a process that has already
648 // been used for non-privileged views.
649 if (bindings_flags & BINDINGS_POLICY_WEB_UI &&
650 GetProcess()->HasConnection() &&
651 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
652 GetProcess()->GetID())) {
653 // This process has no bindings yet. Make sure it does not have more
654 // than this single active view.
655 // --single-process only has one renderer.
656 if (GetProcess()->GetActiveViewCount() > 1 &&
657 !base::CommandLine::ForCurrentProcess()->HasSwitch(
658 switches::kSingleProcess))
659 return;
660 }
661
662 if (bindings_flags & BINDINGS_POLICY_WEB_UI) {
663 ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings(
664 GetProcess()->GetID());
665 }
666
667 enabled_bindings_ |= bindings_flags;
668 if (GetWidget()->renderer_initialized())
669 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_));
670 }
671
672 int RenderViewHostImpl::GetEnabledBindings() const {
673 return enabled_bindings_;
674 }
675
676 void RenderViewHostImpl::SetWebUIProperty(const std::string& name, 634 void RenderViewHostImpl::SetWebUIProperty(const std::string& name,
677 const std::string& value) { 635 const std::string& value) {
678 // This is a sanity check before telling the renderer to enable the property. 636 // This is a sanity check before telling the renderer to enable the property.
679 // It could lie and send the corresponding IPC messages anyway, but we will 637 // It could lie and send the corresponding IPC messages anyway, but we will
680 // not act on them if enabled_bindings_ doesn't agree. If we get here without 638 // not act on them if enabled_bindings_ doesn't agree. If we get here without
681 // WebUI bindings, kill the renderer process. 639 // WebUI bindings, kill the renderer process.
682 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) { 640 if (GetMainFrame()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI) {
683 Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value)); 641 Send(new ViewMsg_SetWebUIProperty(GetRoutingID(), name, value));
684 } else { 642 } else {
685 RecordAction( 643 RecordAction(
686 base::UserMetricsAction("BindingsMismatchTerminate_RVH_WebUI")); 644 base::UserMetricsAction("BindingsMismatchTerminate_RVH_WebUI"));
687 GetProcess()->Shutdown(content::RESULT_CODE_KILLED, false); 645 GetProcess()->Shutdown(content::RESULT_CODE_KILLED, false);
688 } 646 }
689 } 647 }
690 648
691 void RenderViewHostImpl::RenderWidgetGotFocus() { 649 void RenderViewHostImpl::RenderWidgetGotFocus() {
692 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 650 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } else { 961 } else {
1004 render_view_ready_on_process_launch_ = true; 962 render_view_ready_on_process_launch_ = true;
1005 } 963 }
1006 } 964 }
1007 965
1008 void RenderViewHostImpl::RenderViewReady() { 966 void RenderViewHostImpl::RenderViewReady() {
1009 delegate_->RenderViewReady(this); 967 delegate_->RenderViewReady(this);
1010 } 968 }
1011 969
1012 } // namespace content 970 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698