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

Unified Diff: extensions/browser/extension_api_frame_id_map.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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/extension_api_frame_id_map.cc
diff --git a/extensions/browser/extension_api_frame_id_map.cc b/extensions/browser/extension_api_frame_id_map.cc
index bd0e19c8625cf687358a7c6ec2b8e4fce5880161..825cfa90be48106f087cc699acf0ba4b20f6afc4 100644
--- a/extensions/browser/extension_api_frame_id_map.cc
+++ b/extensions/browser/extension_api_frame_id_map.cc
@@ -128,7 +128,7 @@ int ExtensionApiFrameIdMap::GetParentFrameId(
if (navigation_handle->IsParentMainFrame())
return kTopFrameId;
- return navigation_handle->GetParentFrameTreeNodeId();
+ return navigation_handle->GetParentFrame()->GetFrameTreeNodeId();
}
// static
@@ -148,7 +148,12 @@ content::RenderFrameHost* ExtensionApiFrameIdMap::GetRenderFrameHostById(
return web_contents->GetMainFrame();
DCHECK_GE(frame_id, 1);
- return web_contents->FindFrameByFrameTreeNodeId(frame_id);
+
+ // Unfortunately, extension APIs do not know which process to expect for a
+ // given frame ID, so we must use an unsafe API here that could return a
+ // different RenderFrameHost than the caller may have expected (e.g., one that
+ // changed after a cross-process navigation).
+ return web_contents->UnsafeFindFrameByFrameTreeNodeId(frame_id);
}
ExtensionApiFrameIdMap::FrameData ExtensionApiFrameIdMap::KeyToValue(

Powered by Google App Engine
This is Rietveld 408576698