Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions internal/auth/chrome_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,35 @@ func getChromePath() string {
}
return ""
}

// getBrowserPathForProfile returns the appropriate browser executable for a given browser type
func getBrowserPathForProfile(browserName string) string {
switch browserName {
case "Brave":
// Try Brave paths
bravePaths := []string{"brave-browser", "brave"}
for _, name := range bravePaths {
if path, err := exec.LookPath(name); err == nil {
return path
}
}
case "Chrome Canary":
// Chrome Canary is typically not available on Linux
// Fall back to regular Chrome
return getChromePath()
}

// Fallback to any Chrome-based browser
return getChromePath()
}

func getCanaryProfilePath() string {
// Chrome Canary is not typically available on Linux
// Return an empty string or fall back to regular Chrome profile path
return getProfilePath()
}

func getBraveProfilePath() string {
home, _ := os.UserHomeDir()
return filepath.Join(home, ".config", "BraveSoftware", "Brave-Browser")
}
48 changes: 48 additions & 0 deletions internal/auth/chrome_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,51 @@ func getChromePath() string {

return ""
}

// getBrowserPathForProfile returns the appropriate browser executable for a given browser type
func getBrowserPathForProfile(browserName string) string {
switch browserName {
case "Brave":
// Try Brave paths
bravePaths := []string{
filepath.Join(os.Getenv("PROGRAMFILES"), "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
filepath.Join(os.Getenv("PROGRAMFILES(X86)"), "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
filepath.Join(os.Getenv("LOCALAPPDATA"), "BraveSoftware", "Brave-Browser", "Application", "brave.exe"),
}
for _, path := range bravePaths {
if _, err := os.Stat(path); err == nil {
return path
}
}
case "Chrome Canary":
canaryPaths := []string{
filepath.Join(os.Getenv("LOCALAPPDATA"), "Google", "Chrome SxS", "Application", "chrome.exe"),
}
for _, path := range canaryPaths {
if _, err := os.Stat(path); err == nil {
return path
}
}
}

// Fallback to any Chrome-based browser
return getChromePath()
}

func getCanaryProfilePath() string {
localAppData := os.Getenv("LOCALAPPDATA")
if localAppData == "" {
home, _ := os.UserHomeDir()
localAppData = filepath.Join(home, "AppData", "Local")
}
return filepath.Join(localAppData, "Google", "Chrome SxS", "User Data")
}

func getBraveProfilePath() string {
localAppData := os.Getenv("LOCALAPPDATA")
if localAppData == "" {
home, _ := os.UserHomeDir()
localAppData = filepath.Join(home, "AppData", "Local")
}
return filepath.Join(localAppData, "BraveSoftware", "Brave-Browser", "User Data")
}