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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2856653004: Require a process ID when looking up RFHs by FrameTreeNode ID. (Closed)
Patch Set: Simplify ExtNavThrottle Created 3 years, 7 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 908 }
909 909
910 RenderFrameHostImpl* WebContentsImpl::GetFocusedFrame() { 910 RenderFrameHostImpl* WebContentsImpl::GetFocusedFrame() {
911 FrameTreeNode* focused_node = frame_tree_.GetFocusedFrame(); 911 FrameTreeNode* focused_node = frame_tree_.GetFocusedFrame();
912 if (!focused_node) 912 if (!focused_node)
913 return nullptr; 913 return nullptr;
914 return focused_node->current_frame_host(); 914 return focused_node->current_frame_host();
915 } 915 }
916 916
917 RenderFrameHostImpl* WebContentsImpl::FindFrameByFrameTreeNodeId( 917 RenderFrameHostImpl* WebContentsImpl::FindFrameByFrameTreeNodeId(
918 int frame_tree_node_id,
919 int process_id) {
920 FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id);
921
922 // Sanity check that this is in the caller's expected process. Otherwise a
923 // recent cross-process navigation may have led to a privilege change that the
924 // caller is not expecting.
925 if (!frame ||
926 frame->current_frame_host()->GetProcess()->GetID() != process_id)
927 return nullptr;
928
929 return frame->current_frame_host();
930 }
931
932 RenderFrameHostImpl* WebContentsImpl::UnsafeFindFrameByFrameTreeNodeId(
918 int frame_tree_node_id) { 933 int frame_tree_node_id) {
934 // Beware using this! The RenderFrameHost may have changed since the caller
935 // obtained frame_tree_node_id.
919 FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id); 936 FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id);
920 return frame ? frame->current_frame_host() : nullptr; 937 return frame ? frame->current_frame_host() : nullptr;
921 } 938 }
922 939
923 void WebContentsImpl::ForEachFrame( 940 void WebContentsImpl::ForEachFrame(
924 const base::Callback<void(RenderFrameHost*)>& on_frame) { 941 const base::Callback<void(RenderFrameHost*)>& on_frame) {
925 for (FrameTreeNode* node : frame_tree_.Nodes()) { 942 for (FrameTreeNode* node : frame_tree_.Nodes()) {
926 on_frame.Run(node->current_frame_host()); 943 on_frame.Run(node->current_frame_host());
927 } 944 }
928 } 945 }
(...skipping 4656 matching lines...) Expand 10 before | Expand all | Expand 10 after
5585 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5602 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5586 if (!render_view_host) 5603 if (!render_view_host)
5587 continue; 5604 continue;
5588 render_view_host_set.insert(render_view_host); 5605 render_view_host_set.insert(render_view_host);
5589 } 5606 }
5590 for (RenderViewHost* render_view_host : render_view_host_set) 5607 for (RenderViewHost* render_view_host : render_view_host_set)
5591 render_view_host->OnWebkitPreferencesChanged(); 5608 render_view_host->OnWebkitPreferencesChanged();
5592 } 5609 }
5593 5610
5594 } // namespace content 5611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698