Skip to content

Commit 5ac66da

Browse files
committed
_webui_custom_browser_exist - Windows Implementation
We still need macOS and Linux Implementation.
1 parent 92324ed commit 5ac66da

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

src/webui.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5800,6 +5800,51 @@ static bool _webui_is_google_chrome_folder(const char* folder) {
58005800
return true;
58015801
}
58025802

5803+
static bool _webui_custom_browser_exist(_webui_window_t* win, size_t browser) {
5804+
5805+
#ifdef WEBUI_LOG
5806+
printf("[Core]\t\t_webui_custom_browser_exist([%zu])\n", browser);
5807+
#endif
5808+
5809+
if (!_webui.custom_browser_folder_path)
5810+
return false;
5811+
5812+
#ifdef _WIN32
5813+
char* executable = NULL;
5814+
if (browser == Chrome) executable = "chrome.exe";
5815+
else if (browser == Edge) executable = "msedge.exe";
5816+
else if (browser == Epic) executable = "epic.exe";
5817+
else if (browser == Vivaldi) executable = "vivaldi.exe";
5818+
else if (browser == Brave) executable = "brave.exe";
5819+
else if (browser == Firefox) executable = "firefox.exe";
5820+
else if (browser == Yandex) executable = "browser.exe";
5821+
else if (browser == Chromium) executable = "chrome.exe";
5822+
else return false;
5823+
if (_webui_folder_exist(_webui.custom_browser_folder_path)) {
5824+
char full_path[WEBUI_MAX_PATH] = {0};
5825+
WEBUI_SN_PRINTF_STATIC(
5826+
full_path, WEBUI_MAX_PATH,
5827+
"%s\\%s", _webui.custom_browser_folder_path, executable
5828+
);
5829+
if (_webui_file_exist(full_path)) {
5830+
// Browser Found
5831+
if(win) WEBUI_SN_PRINTF_DYN(win->browser_path, WEBUI_MAX_PATH, "\"%s\"", full_path);
5832+
return true;
5833+
}
5834+
}
5835+
#elif __APPLE__
5836+
// TODO: Custom browser path macOS
5837+
// `Chromium.app`...
5838+
// `Firefox.app`...
5839+
#else
5840+
// TODO: Custom browser path Linux
5841+
// `google-chrome`...
5842+
// `firefox`...
5843+
#endif
5844+
5845+
return false;
5846+
}
5847+
58035848
static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
58045849

58055850
#ifdef WEBUI_LOG
@@ -5818,6 +5863,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
58185863
return true;
58195864
}
58205865

5866+
// Custom user browser path
5867+
if (_webui_custom_browser_exist(win, browser)) {
5868+
ChromeExist = true;
5869+
return true;
5870+
}
5871+
58215872
#ifdef _WIN32
58225873

58235874
// Google Chrome on Windows
@@ -5900,6 +5951,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
59005951
return true;
59015952
}
59025953

5954+
// Custom user browser path
5955+
if (_webui_custom_browser_exist(win, browser)) {
5956+
EdgeExist = true;
5957+
return true;
5958+
}
5959+
59035960
#ifdef _WIN32
59045961

59055962
// Edge on Windows
@@ -5987,6 +6044,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
59876044
return true;
59886045
}
59896046

6047+
// Custom user browser path
6048+
if (_webui_custom_browser_exist(win, browser)) {
6049+
EpicExist = true;
6050+
return true;
6051+
}
6052+
59906053
#ifdef _WIN32
59916054

59926055
// Epic on Windows
@@ -6062,6 +6125,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
60626125
return true;
60636126
}
60646127

6128+
// Custom user browser path
6129+
if (_webui_custom_browser_exist(win, browser)) {
6130+
VivaldiExist = true;
6131+
return true;
6132+
}
6133+
60656134
#ifdef _WIN32
60666135

60676136
// Vivaldi on Windows
@@ -6147,6 +6216,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
61476216
return true;
61486217
}
61496218

6219+
// Custom user browser path
6220+
if (_webui_custom_browser_exist(win, browser)) {
6221+
BraveExist = true;
6222+
return true;
6223+
}
6224+
61506225
#ifdef _WIN32
61516226

61526227
// Brave on Windows
@@ -6222,6 +6297,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
62226297
return true;
62236298
}
62246299

6300+
// Custom user browser path
6301+
if (_webui_custom_browser_exist(win, browser)) {
6302+
FirefoxExist = true;
6303+
return true;
6304+
}
6305+
62256306
#ifdef _WIN32
62266307

62276308
// Firefox on Windows
@@ -6300,6 +6381,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
63006381
return true;
63016382
}
63026383

6384+
// Custom user browser path
6385+
if (_webui_custom_browser_exist(win, browser)) {
6386+
YandexExist = true;
6387+
return true;
6388+
}
6389+
63036390
#ifdef _WIN32
63046391

63056392
// Yandex on Windows
@@ -6375,6 +6462,12 @@ static bool _webui_browser_exist(_webui_window_t* win, size_t browser) {
63756462
return true;
63766463
}
63776464

6465+
// Custom user browser path
6466+
if (_webui_custom_browser_exist(win, browser)) {
6467+
ChromiumExist = true;
6468+
return true;
6469+
}
6470+
63786471
#ifdef _WIN32
63796472

63806473
// Chromium on Windows

0 commit comments

Comments
 (0)