| 961 | } |
| 962 | |
| 963 | static char *web_chrome_executable(void) { |
| 964 | const char *env = getenv("DS4_CHROME"); |
| 965 | if (env && env[0]) return web_xstrdup(env); |
| 966 | #ifdef __APPLE__ |
| 967 | if (access("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", X_OK) == 0) |
| 968 | return web_xstrdup("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"); |
| 969 | if (access("/Applications/Chromium.app/Contents/MacOS/Chromium", X_OK) == 0) |
| 970 | return web_xstrdup("/Applications/Chromium.app/Contents/MacOS/Chromium"); |
| 971 | #endif |
| 972 | const char *paths[] = { |
| 973 | "/usr/bin/google-chrome", |
| 974 | "/usr/bin/google-chrome-stable", |
| 975 | "/usr/bin/chromium", |
| 976 | "/usr/bin/chromium-browser", |
| 977 | "/snap/bin/chromium", |
| 978 | "/opt/google/chrome/chrome", |
| 979 | NULL |
| 980 | }; |
| 981 | for (int i = 0; paths[i]; i++) { |
| 982 | if (access(paths[i], X_OK) == 0) return web_xstrdup(paths[i]); |
| 983 | } |
| 984 | |
| 985 | const char *names[] = { |
| 986 | "google-chrome", |
| 987 | "google-chrome-stable", |
| 988 | "chromium", |
| 989 | "chromium-browser", |
| 990 | NULL |
| 991 | }; |
| 992 | const char *pathenv = getenv("PATH"); |
| 993 | if (pathenv) { |
| 994 | char *path = web_xstrdup(pathenv); |
| 995 | char *save = NULL; |
| 996 | for (char *dir = strtok_r(path, ":", &save); dir; dir = strtok_r(NULL, ":", &save)) { |
| 997 | for (int i = 0; names[i]; i++) { |
| 998 | char candidate[PATH_MAX]; |
| 999 | snprintf(candidate, sizeof(candidate), "%s/%s", dir[0] ? dir : ".", names[i]); |
| 1000 | if (access(candidate, X_OK) == 0) { |
| 1001 | char *res = web_xstrdup(candidate); |
| 1002 | free(path); |
| 1003 | return res; |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | free(path); |
| 1008 | } |
| 1009 | return web_xstrdup("google-chrome"); |
| 1010 | } |
| 1011 | |
| 1012 | #ifdef __APPLE__ |
| 1013 | static const char *web_macos_chrome_app_name(void) { |
no test coverage detected