feat: add Brave Browser support to auto-connect CDP discovery (#817)
Brave Browser is Chromium-based and uses the same DevToolsActivePort mechanism. Add its user-data-dir paths to get_chrome_user_data_dirs() and its executable paths to find_chrome() on all three platforms (macOS, Linux, Windows). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
02d1a7ad7c
commit
5ea508a917
@@ -366,6 +366,7 @@ pub fn find_chrome() -> Option<PathBuf> {
|
|||||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||||
"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
|
"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
|
||||||
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
||||||
|
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
||||||
];
|
];
|
||||||
for c in &candidates {
|
for c in &candidates {
|
||||||
let p = PathBuf::from(c);
|
let p = PathBuf::from(c);
|
||||||
@@ -382,6 +383,8 @@ pub fn find_chrome() -> Option<PathBuf> {
|
|||||||
"google-chrome-stable",
|
"google-chrome-stable",
|
||||||
"chromium-browser",
|
"chromium-browser",
|
||||||
"chromium",
|
"chromium",
|
||||||
|
"brave-browser",
|
||||||
|
"brave-browser-stable",
|
||||||
];
|
];
|
||||||
for name in &candidates {
|
for name in &candidates {
|
||||||
if let Ok(output) = Command::new("which").arg(name).output() {
|
if let Ok(output) = Command::new("which").arg(name).output() {
|
||||||
@@ -402,9 +405,14 @@ pub fn find_chrome() -> Option<PathBuf> {
|
|||||||
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
|
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
|
||||||
];
|
];
|
||||||
if let Ok(local) = std::env::var("LOCALAPPDATA") {
|
if let Ok(local) = std::env::var("LOCALAPPDATA") {
|
||||||
let p = PathBuf::from(&local).join(r"Google\Chrome\Application\chrome.exe");
|
let chrome = PathBuf::from(&local).join(r"Google\Chrome\Application\chrome.exe");
|
||||||
if p.exists() {
|
if chrome.exists() {
|
||||||
return Some(p);
|
return Some(chrome);
|
||||||
|
}
|
||||||
|
let brave =
|
||||||
|
PathBuf::from(&local).join(r"BraveSoftware\Brave-Browser\Application\brave.exe");
|
||||||
|
if brave.exists() {
|
||||||
|
return Some(brave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for c in &candidates {
|
for c in &candidates {
|
||||||
@@ -468,7 +476,12 @@ fn get_chrome_user_data_dirs() -> Vec<PathBuf> {
|
|||||||
{
|
{
|
||||||
if let Some(home) = dirs::home_dir() {
|
if let Some(home) = dirs::home_dir() {
|
||||||
let base = home.join("Library/Application Support");
|
let base = home.join("Library/Application Support");
|
||||||
for name in ["Google/Chrome", "Google/Chrome Canary", "Chromium"] {
|
for name in [
|
||||||
|
"Google/Chrome",
|
||||||
|
"Google/Chrome Canary",
|
||||||
|
"Chromium",
|
||||||
|
"BraveSoftware/Brave-Browser",
|
||||||
|
] {
|
||||||
dirs.push(base.join(name));
|
dirs.push(base.join(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,7 +491,12 @@ fn get_chrome_user_data_dirs() -> Vec<PathBuf> {
|
|||||||
{
|
{
|
||||||
if let Some(home) = dirs::home_dir() {
|
if let Some(home) = dirs::home_dir() {
|
||||||
let config = home.join(".config");
|
let config = home.join(".config");
|
||||||
for name in ["google-chrome", "google-chrome-unstable", "chromium"] {
|
for name in [
|
||||||
|
"google-chrome",
|
||||||
|
"google-chrome-unstable",
|
||||||
|
"chromium",
|
||||||
|
"BraveSoftware/Brave-Browser",
|
||||||
|
] {
|
||||||
dirs.push(config.join(name));
|
dirs.push(config.join(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,6 +510,7 @@ fn get_chrome_user_data_dirs() -> Vec<PathBuf> {
|
|||||||
r"Google\Chrome\User Data",
|
r"Google\Chrome\User Data",
|
||||||
r"Google\Chrome SxS\User Data",
|
r"Google\Chrome SxS\User Data",
|
||||||
r"Chromium\User Data",
|
r"Chromium\User Data",
|
||||||
|
r"BraveSoftware\Brave-Browser\User Data",
|
||||||
] {
|
] {
|
||||||
dirs.push(base.join(name));
|
dirs.push(base.join(name));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user