MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / default_chrome_user_data_dir

Function default_chrome_user_data_dir

src/browser.rs:68–110  ·  view source on GitHub ↗

Get the default Chrome user data directory for the given channel.

(channel: &str)

Source from the content-addressed store, hash-verified

66
67/// Get the default Chrome user data directory for the given channel.
68fn default_chrome_user_data_dir(channel: &str) -> Result<PathBuf> {
69 #[cfg(target_os = "macos")]
70 {
71 let home = dirs::home_dir().ok_or_else(|| anyhow!("Cannot determine home directory"))?;
72 let base = home.join("Library/Application Support/Google");
73 let dir = match channel {
74 "stable" | "chrome" => base.join("Chrome"),
75 "beta" => base.join("Chrome Beta"),
76 "canary" => base.join("Chrome Canary"),
77 "dev" => base.join("Chrome Dev"),
78 _ => bail!("Unknown Chrome channel: {channel}"),
79 };
80 Ok(dir)
81 }
82
83 #[cfg(target_os = "linux")]
84 {
85 let home = dirs::home_dir().ok_or_else(|| anyhow!("Cannot determine home directory"))?;
86 let dir = match channel {
87 "stable" | "chrome" => home.join(".config/google-chrome"),
88 "beta" => home.join(".config/google-chrome-beta"),
89 "canary" => home.join(".config/google-chrome-unstable"),
90 "dev" => home.join(".config/google-chrome-unstable"),
91 _ => bail!("Unknown Chrome channel: {channel}"),
92 };
93 Ok(dir)
94 }
95
96 #[cfg(target_os = "windows")]
97 {
98 let local_app_data =
99 std::env::var("LOCALAPPDATA").map_err(|_| anyhow!("LOCALAPPDATA not set"))?;
100 let base = PathBuf::from(local_app_data).join("Google");
101 let dir = match channel {
102 "stable" | "chrome" => base.join("Chrome/User Data"),
103 "beta" => base.join("Chrome Beta/User Data"),
104 "canary" => base.join("Chrome SxS/User Data"),
105 "dev" => base.join("Chrome Dev/User Data"),
106 _ => bail!("Unknown Chrome channel: {channel}"),
107 };
108 Ok(dir)
109 }
110}

Callers 1

resolve_ws_urlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected