| 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 72949bea094e87dcfb49b0f7b97efab3738e7321..7571c938daf84c658400b6c1a02b5b8478ecae11 100644
|
| --- a/extensions/browser/extension_api_frame_id_map.cc
|
| +++ b/extensions/browser/extension_api_frame_id_map.cc
|
| @@ -7,6 +7,7 @@
|
| #include <tuple>
|
|
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/navigation_handle.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -64,13 +65,13 @@ ExtensionApiFrameIdMap::ExtensionApiFrameIdMap() {}
|
|
|
| ExtensionApiFrameIdMap::~ExtensionApiFrameIdMap() {}
|
|
|
| +// static
|
| ExtensionApiFrameIdMap* ExtensionApiFrameIdMap::Get() {
|
| return g_map_instance.Pointer();
|
| }
|
|
|
| +// static
|
| int ExtensionApiFrameIdMap::GetFrameId(content::RenderFrameHost* rfh) {
|
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| -
|
| if (!rfh)
|
| return kInvalidFrameId;
|
| if (rfh->GetParent())
|
| @@ -78,12 +79,32 @@ int ExtensionApiFrameIdMap::GetFrameId(content::RenderFrameHost* rfh) {
|
| return 0; // Main frame.
|
| }
|
|
|
| -int ExtensionApiFrameIdMap::GetParentFrameId(content::RenderFrameHost* rfh) {
|
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +// static
|
| +int ExtensionApiFrameIdMap::GetFrameId(
|
| + content::NavigationHandle* navigation_handle) {
|
| + return navigation_handle->IsInMainFrame()
|
| + ? 0
|
| + : navigation_handle->GetFrameTreeNodeId();
|
| +}
|
|
|
| +// static
|
| +int ExtensionApiFrameIdMap::GetParentFrameId(content::RenderFrameHost* rfh) {
|
| return rfh ? GetFrameId(rfh->GetParent()) : kInvalidFrameId;
|
| }
|
|
|
| +// static
|
| +int ExtensionApiFrameIdMap::GetParentFrameId(
|
| + content::NavigationHandle* navigation_handle) {
|
| + if (navigation_handle->IsInMainFrame())
|
| + return -1;
|
| +
|
| + if (navigation_handle->IsParentMainFrame())
|
| + return 0;
|
| +
|
| + return navigation_handle->GetParentFrameTreeNodeId();
|
| +}
|
| +
|
| +// static
|
| content::RenderFrameHost* ExtensionApiFrameIdMap::GetRenderFrameHostById(
|
| content::WebContents* web_contents,
|
| int frame_id) {
|
|
|