mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-13 23:53:25 +00:00
feat: add tabId and windowId in each targetInfo
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
diff --git a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
||||
index 4173438cc19fb..b590826be0c7d 100644
|
||||
--- a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
||||
+++ b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "components/guest_view/browser/guest_view_base.h"
|
||||
#include "components/keep_alive_registry/keep_alive_types.h"
|
||||
#include "components/keep_alive_registry/scoped_keep_alive.h"
|
||||
+#include "components/sessions/content/session_tab_helper.h"
|
||||
#include "components/tabs/public/tab_interface.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
@@ -342,6 +343,20 @@ std::optional<bool> ChromeDevToolsManagerDelegate::ShouldReportAsTabTarget(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
+bool ChromeDevToolsManagerDelegate::GetTargetTabId(
|
||||
+ content::WebContents* web_contents,
|
||||
+ int* tab_id,
|
||||
+ int* window_id) {
|
||||
+ SessionID sid = sessions::SessionTabHelper::IdForTab(web_contents);
|
||||
+ if (!sid.is_valid())
|
||||
+ return false;
|
||||
+ *tab_id = sid.id();
|
||||
+ SessionID wid =
|
||||
+ sessions::SessionTabHelper::IdForWindowContainingTab(web_contents);
|
||||
+ *window_id = wid.is_valid() ? wid.id() : -1;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
std::string ChromeDevToolsManagerDelegate::GetTargetTitle(
|
||||
content::WebContents* web_contents) {
|
||||
if (auto iwa_name_version = GetIsolatedWebAppNameAndVersion(web_contents)) {
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/chrome/browser/devtools/chrome_devtools_manager_delegate.h b/chrome/browser/devtools/chrome_devtools_manager_delegate.h
|
||||
index a37b46861fb3d..af1e0e2602c88 100644
|
||||
--- a/chrome/browser/devtools/chrome_devtools_manager_delegate.h
|
||||
+++ b/chrome/browser/devtools/chrome_devtools_manager_delegate.h
|
||||
@@ -73,6 +73,9 @@ class ChromeDevToolsManagerDelegate : public content::DevToolsManagerDelegate,
|
||||
std::string GetTargetTitle(content::WebContents* web_contents) override;
|
||||
std::optional<bool> ShouldReportAsTabTarget(
|
||||
content::WebContents* web_contents) override;
|
||||
+ bool GetTargetTabId(content::WebContents* web_contents,
|
||||
+ int* tab_id,
|
||||
+ int* window_id) override;
|
||||
|
||||
content::BrowserContext* CreateBrowserContext() override;
|
||||
void DisposeBrowserContext(content::BrowserContext*,
|
||||
@@ -1,8 +1,28 @@
|
||||
diff --git a/content/browser/devtools/protocol/target_handler.cc b/content/browser/devtools/protocol/target_handler.cc
|
||||
index b1721338d7523..b63d11cb5fc2e 100644
|
||||
index 7568beca10c6c..4e4573c3ad32d 100644
|
||||
--- a/content/browser/devtools/protocol/target_handler.cc
|
||||
+++ b/content/browser/devtools/protocol/target_handler.cc
|
||||
@@ -1411,11 +1411,11 @@ void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* host) {
|
||||
@@ -119,6 +119,19 @@ std::unique_ptr<Target::TargetInfo> BuildTargetInfo(
|
||||
if (!subtype.empty()) {
|
||||
target_info->SetSubtype(subtype);
|
||||
}
|
||||
+ WebContents* web_contents = host->GetWebContents();
|
||||
+ if (web_contents) {
|
||||
+ DevToolsManagerDelegate* delegate =
|
||||
+ DevToolsManager::GetInstance()->delegate();
|
||||
+ int tab_id, window_id;
|
||||
+ if (delegate &&
|
||||
+ delegate->GetTargetTabId(web_contents, &tab_id, &window_id)) {
|
||||
+ target_info->SetTabId(tab_id);
|
||||
+ if (window_id >= 0) {
|
||||
+ target_info->SetWindowId(window_id);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
return target_info;
|
||||
}
|
||||
|
||||
@@ -1416,11 +1429,11 @@ void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* host) {
|
||||
}
|
||||
|
||||
void TargetHandler::DevToolsAgentHostAttached(DevToolsAgentHost* host) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
diff --git a/content/public/browser/devtools_manager_delegate.cc b/content/public/browser/devtools_manager_delegate.cc
|
||||
index 02e70247e20fd..098273cc00bdd 100644
|
||||
--- a/content/public/browser/devtools_manager_delegate.cc
|
||||
+++ b/content/public/browser/devtools_manager_delegate.cc
|
||||
@@ -57,6 +57,12 @@ std::optional<bool> DevToolsManagerDelegate::ShouldReportAsTabTarget(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
+bool DevToolsManagerDelegate::GetTargetTabId(WebContents* web_contents,
|
||||
+ int* tab_id,
|
||||
+ int* window_id) {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
DevToolsAgentHost::List DevToolsManagerDelegate::RemoteDebuggingTargets(
|
||||
DevToolsManagerDelegate::TargetType target_type) {
|
||||
return DevToolsAgentHost::GetOrCreateAll();
|
||||
@@ -0,0 +1,19 @@
|
||||
diff --git a/content/public/browser/devtools_manager_delegate.h b/content/public/browser/devtools_manager_delegate.h
|
||||
index e6e5ba7be2551..969c9a49db8cc 100644
|
||||
--- a/content/public/browser/devtools_manager_delegate.h
|
||||
+++ b/content/public/browser/devtools_manager_delegate.h
|
||||
@@ -91,6 +91,14 @@ class CONTENT_EXPORT DevToolsManagerDelegate {
|
||||
virtual std::optional<bool> ShouldReportAsTabTarget(
|
||||
WebContents* web_contents);
|
||||
|
||||
+ // Returns session-scoped tab and window identifiers for the given
|
||||
+ // |web_contents|. Embedders that support tab identity (e.g. Chrome)
|
||||
+ // should override this to populate tabId/windowId in TargetInfo.
|
||||
+ // Returns false if the web contents does not have tab identity.
|
||||
+ virtual bool GetTargetTabId(WebContents* web_contents,
|
||||
+ int* tab_id,
|
||||
+ int* window_id);
|
||||
+
|
||||
// Chrome Devtools Protocol Target type to use. Before MPArch frame targets
|
||||
// were used, which correspond to the primary outermost frame in the
|
||||
// WebContents. With prerender and other MPArch features, there could be
|
||||
@@ -0,0 +1,17 @@
|
||||
diff --git a/third_party/blink/public/devtools_protocol/domains/Target.pdl b/third_party/blink/public/devtools_protocol/domains/Target.pdl
|
||||
index 8d8ead638ece0..57f63cbaa0879 100644
|
||||
--- a/third_party/blink/public/devtools_protocol/domains/Target.pdl
|
||||
+++ b/third_party/blink/public/devtools_protocol/domains/Target.pdl
|
||||
@@ -33,6 +33,12 @@ domain Target
|
||||
# Provides additional details for specific target types. For example, for
|
||||
# the type of "page", this may be set to "prerender".
|
||||
experimental optional string subtype
|
||||
+ # Session-scoped tab id for targets associated with a browser tab.
|
||||
+ # Present for page and frame targets; absent for workers, browser, etc.
|
||||
+ experimental optional Browser.TabID tabId
|
||||
+ # Browser window id containing the tab. Present when tabId is present
|
||||
+ # and the tab is in a window.
|
||||
+ experimental optional Browser.WindowID windowId
|
||||
|
||||
# A filter used by target query/discovery/auto-attach operations.
|
||||
experimental type FilterEntry extends object
|
||||
Reference in New Issue
Block a user