Chromium Code Reviews| 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..93ee8b11a572a3ff73070dfacb0b18df8934f646 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" |
| @@ -78,12 +79,34 @@ int ExtensionApiFrameIdMap::GetFrameId(content::RenderFrameHost* rfh) { |
| return 0; // Main frame. |
| } |
|
Devlin
2016/02/09 17:35:40
nit: add // static (if you could also do this for
nasko
2016/02/09 17:53:54
Done.
|
| +int ExtensionApiFrameIdMap::GetFrameId( |
| + content::NavigationHandle* navigation_handle) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
|
Devlin
2016/02/09 17:35:40
Do these actually need to be done on the UI thread
nasko
2016/02/09 17:53:54
All the other Get* methods that access RFH also do
Devlin
2016/02/09 18:01:15
Let's remove it for all static methods, where by d
|
| + |
| + return navigation_handle->IsInMainFrame() |
| + ? 0 |
| + : navigation_handle->GetFrameTreeNodeId(); |
| +} |
| + |
| int ExtensionApiFrameIdMap::GetParentFrameId(content::RenderFrameHost* rfh) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| return rfh ? GetFrameId(rfh->GetParent()) : kInvalidFrameId; |
| } |
| +int ExtensionApiFrameIdMap::GetParentFrameId( |
| + content::NavigationHandle* navigation_handle) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + |
| + if (navigation_handle->IsInMainFrame()) |
| + return -1; |
| + |
| + if (navigation_handle->IsParentMainFrame()) |
| + return 0; |
| + |
| + return navigation_handle->GetParentFrameTreeNodeId(); |
| +} |
| + |
| content::RenderFrameHost* ExtensionApiFrameIdMap::GetRenderFrameHostById( |
| content::WebContents* web_contents, |
| int frame_id) { |