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

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: Reverting the workaround from https://codereview.chromium.org/1656613002. Remove tests from exclusi… 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..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) {

Powered by Google App Engine
This is Rietveld 408576698