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

Unified Diff: extensions/browser/extension_api_frame_id_map.cc

Issue 1670673003: Refactor the implementation of the webNavigation extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Bug-532666-NavigationHandleAPI
Patch Set: Remove UI thread DCHECKs. Created 4 years, 10 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 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) {
« no previous file with comments | « extensions/browser/extension_api_frame_id_map.h ('k') | testing/buildbot/filters/isolate-extensions.browser_tests.filter » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698