Skip to content

Commit

Permalink
LaunchServer+Base: Stop using Browser as default protocol handler
Browse files Browse the repository at this point in the history
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...).
  • Loading branch information
linusg authored and awesomekling committed Dec 24, 2020
1 parent af007ce commit bed240d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Base/home/anon/.config/LaunchServer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Base/res/apps/Browser.af
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Category=Internet

[Launcher]
FileTypes=html,htm,md
Protocols=http,https
Protocols=gemini,http,https
8 changes: 5 additions & 3 deletions Services/LaunchServer/Launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Services/LaunchServer/Launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Launcher {
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);
};
}

0 comments on commit bed240d

Please sign in to comment.