diff --git a/internal/auth/chrome_linux.go b/internal/auth/chrome_linux.go index c14e50e..a781449 100644 --- a/internal/auth/chrome_linux.go +++ b/internal/auth/chrome_linux.go @@ -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") +} diff --git a/internal/auth/chrome_windows.go b/internal/auth/chrome_windows.go index 0e459d2..74cd567 100644 --- a/internal/auth/chrome_windows.go +++ b/internal/auth/chrome_windows.go @@ -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") +}