diff options
author | Linus Groh <mail@linusgroh.de> | 2020-12-24 01:32:14 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-24 10:25:18 +0100 |
commit | bed240d4b38fa33cf85dab1549cb78118bcfc238 (patch) | |
tree | ccce2c877d14fc359081420088d8cf7824351c2a | |
parent | af007ce126bd9076461038546293e13891435996 (diff) | |
download | serenity-bed240d4b38fa33cf85dab1549cb78118bcfc238.zip |
LaunchServer+Base: Stop using Browser as default protocol handler
Browser supports very few protocols (http, https, gemini, file) at the
moment, so there's no point in using it as a catch-all and default
protocol handler. I added an explicit association for gemini to
/bin/Browser instead.
This stops Desktop::Launcher::open() from reporting success for any URL,
which really isn't the case (Browser shows an error page...).
-rw-r--r-- | Base/home/anon/.config/LaunchServer.ini | 4 | ||||
-rw-r--r-- | Base/res/apps/Browser.af | 2 | ||||
-rw-r--r-- | Services/LaunchServer/Launcher.cpp | 8 | ||||
-rw-r--r-- | Services/LaunchServer/Launcher.h | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/Base/home/anon/.config/LaunchServer.ini b/Base/home/anon/.config/LaunchServer.ini index 57149940d8..2947b9e773 100644 --- a/Base/home/anon/.config/LaunchServer.ini +++ b/Base/home/anon/.config/LaunchServer.ini @@ -15,7 +15,7 @@ sheets=/bin/Spreadsheet *=/bin/TextEditor [Protocol] -irc=/bin/IRCClient +gemini=/bin/Browser http=/bin/Browser https=/bin/Browser -*=/bin/Browser +irc=/bin/IRCClient diff --git a/Base/res/apps/Browser.af b/Base/res/apps/Browser.af index 02a97b1e70..3a85bdb665 100644 --- a/Base/res/apps/Browser.af +++ b/Base/res/apps/Browser.af @@ -9,4 +9,4 @@ Category=Internet [Launcher] FileTypes=html,htm,md -Protocols=http,https +Protocols=gemini,http,https diff --git a/Services/LaunchServer/Launcher.cpp b/Services/LaunchServer/Launcher.cpp index 28a47b8949..2f796d7d9a 100644 --- a/Services/LaunchServer/Launcher.cpp +++ b/Services/LaunchServer/Launcher.cpp @@ -196,7 +196,7 @@ bool Launcher::open_url(const URL& url, const String& handler_name) if (url.protocol() == "file") return open_file_url(url); - return open_with_user_preferences(m_protocol_handlers, url.protocol(), url.to_string(), "/bin/Browser"); + return open_with_user_preferences(m_protocol_handlers, url.protocol(), url.to_string()); } bool Launcher::open_with_handler_name(const URL& url, const String& handler_name) @@ -252,9 +252,11 @@ bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_pr if (program_path.has_value()) return spawn(program_path.value(), argument); - // Absolute worst case, try the provided default + // Absolute worst case, try the provided default program, if any + if (!default_program.is_empty()) + return spawn(default_program, argument); - return spawn(default_program, argument); + return false; } void Launcher::for_each_handler(const String& key, HashMap<String, String>& user_preference, Function<bool(const Handler&)> f) diff --git a/Services/LaunchServer/Launcher.h b/Services/LaunchServer/Launcher.h index 2108ffd897..a4f5fd9ddb 100644 --- a/Services/LaunchServer/Launcher.h +++ b/Services/LaunchServer/Launcher.h @@ -72,7 +72,7 @@ private: void for_each_handler(const String& key, HashMap<String, String>& user_preferences, Function<bool(const Handler&)> f); void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f); bool open_file_url(const URL&); - bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String key, const String argument, const String default_program); + bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String key, const String argument, const String default_program = {}); bool open_with_handler_name(const URL&, const String& handler_name); }; } |