Closed SpikeHD closed 1 month ago
Now, there is a api for choosing browser webui_show_browser
:
https://github.com/webui-dev/webui/blob/2a5f0c98fbb267a5aed921a8678f3f108bb12a6e/include/webui.h#L221
It will return whether the setting is successful, which can indeed achieve the effect you mentioned. But I think your proposal is better, it should provide an API to detect whether the browser is available
Totally! I think that the API you linked covers 90% of cases, but it would be good to have something that allows devs to know before the browser launches, in case they need to do any specific preparations (preloading a browser specific library, showing a warning/message asking the user if they want to use the browser that was detected, etc.)
Good point. We can probably create a new API like this:
WEBUI_EXPORT size_t webui_get_best_browser();
size_t webui_get_best_browser() {
return _webui_find_best_browser();
}
if (webui_get_best_browser() == Firefox) {
// Set XPI file in extensions to load
webui_show_browser(myWindow, HTML, Firefox);
} else if (webui_get_best_browser() == Chrome) {
// Set ZIP or whatever Chrome uses
webui_show_browser(myWindow, HTML, Chrome);
} else {
// ...
webui_show(myWindow, HTML);
}
I feel as though there may be some conditional logic developers may want to do based on the browser to use, BEFORE the window is shown. An example of this would be conditionally loading a Firefox XPI or Chromium extension, depending on which browser will be used (assuming #307 implements the feature for both platforms).
I imagine it would look something like this:
Perhaps the function should also be renamed to something like
webui_determine_browser
or something, just to make it more clear.