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

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 4 years 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 SiteInstance* instance, 195 SiteInstance* instance,
196 std::unique_ptr<RenderWidgetHostImpl> widget, 196 std::unique_ptr<RenderWidgetHostImpl> widget,
197 RenderViewHostDelegate* delegate, 197 RenderViewHostDelegate* delegate,
198 int32_t main_frame_routing_id, 198 int32_t main_frame_routing_id,
199 bool swapped_out, 199 bool swapped_out,
200 bool has_initialized_audio_host) 200 bool has_initialized_audio_host)
201 : render_widget_host_(std::move(widget)), 201 : render_widget_host_(std::move(widget)),
202 frames_ref_count_(0), 202 frames_ref_count_(0),
203 delegate_(delegate), 203 delegate_(delegate),
204 instance_(static_cast<SiteInstanceImpl*>(instance)), 204 instance_(static_cast<SiteInstanceImpl*>(instance)),
205 enabled_bindings_(0),
206 is_active_(!swapped_out), 205 is_active_(!swapped_out),
207 is_swapped_out_(swapped_out), 206 is_swapped_out_(swapped_out),
208 main_frame_routing_id_(main_frame_routing_id), 207 main_frame_routing_id_(main_frame_routing_id),
209 is_waiting_for_close_ack_(false), 208 is_waiting_for_close_ack_(false),
210 sudden_termination_allowed_(false), 209 sudden_termination_allowed_(false),
211 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), 210 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING),
212 is_focused_element_editable_(false), 211 is_focused_element_editable_(false),
213 updating_web_preferences_(false), 212 updating_web_preferences_(false),
214 render_view_ready_on_process_launch_(false), 213 render_view_ready_on_process_launch_(false),
215 weak_factory_(this) { 214 weak_factory_(this) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 params->min_size = GetWidget()->min_size_for_auto_resize(); 313 params->min_size = GetWidget()->min_size_for_auto_resize();
315 params->max_size = GetWidget()->max_size_for_auto_resize(); 314 params->max_size = GetWidget()->max_size_for_auto_resize();
316 params->page_zoom_level = delegate_->GetPendingPageZoomLevel(); 315 params->page_zoom_level = delegate_->GetPendingPageZoomLevel();
317 params->image_decode_color_space = gfx::ICCProfile::FromBestMonitor(); 316 params->image_decode_color_space = gfx::ICCProfile::FromBestMonitor();
318 317
319 GetWidget()->GetResizeParams(&params->initial_size); 318 GetWidget()->GetResizeParams(&params->initial_size);
320 GetWidget()->SetInitialRenderSizeParams(params->initial_size); 319 GetWidget()->SetInitialRenderSizeParams(params->initial_size);
321 320
322 GetProcess()->GetRendererInterface()->CreateView(std::move(params)); 321 GetProcess()->GetRendererInterface()->CreateView(std::move(params));
323 322
324 // If it's enabled, tell the renderer to set up the Javascript bindings for
325 // sending messages back to the browser.
326 if (GetProcess()->IsForGuestsOnly())
327 DCHECK_EQ(0, enabled_bindings_);
328 Send(new ViewMsg_AllowBindings(GetRoutingID(), enabled_bindings_));
329 // Let our delegate know that we created a RenderView. 323 // Let our delegate know that we created a RenderView.
330 delegate_->RenderViewCreated(this); 324 delegate_->RenderViewCreated(this);
331 325
332 // Since this method can create the main RenderFrame in the renderer process, 326 // Since this method can create the main RenderFrame in the renderer process,
333 // set the proper state on its corresponding RenderFrameHost. 327 // set the proper state on its corresponding RenderFrameHost.
334 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { 328 if (main_frame_routing_id_ != MSG_ROUTING_NONE) {
335 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_) 329 RenderFrameHostImpl::FromID(GetProcess()->GetID(), main_frame_routing_id_)
336 ->SetRenderFrameCreated(true); 330 ->SetRenderFrameCreated(true);
337 } 331 }
338 GetWidget()->delegate()->SendScreenRects(); 332 GetWidget()->delegate()->SendScreenRects();
(...skipping 291 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } else { 1046 } else {
1089 render_view_ready_on_process_launch_ = true; 1047 render_view_ready_on_process_launch_ = true;
1090 } 1048 }
1091 } 1049 }
1092 1050
1093 void RenderViewHostImpl::RenderViewReady() { 1051 void RenderViewHostImpl::RenderViewReady() {
1094 delegate_->RenderViewReady(this); 1052 delegate_->RenderViewReady(this);
1095 } 1053 }
1096 1054
1097 } // namespace content 1055 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698