hrev47397 adds 1 changeset to branch 'master' old head: 69631a6a0564848e8231853a3de9757c3b8662d4 new head: e96676ab5a3ce2f18f76875427d685c223fc8d60 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=e96676a+%5E69631a6 ---------------------------------------------------------------------------- e96676a: Try opening URLs with the preferred app We already did this when the URL was entered in the address bar, now also do it when it comes from a link in a webpage. Makes mailto links work and fixes #6236. [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47397 Commit: e96676ab5a3ce2f18f76875427d685c223fc8d60 URL: http://cgit.haiku-os.org/haiku/commit/?id=e96676a Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Tue Jun 17 10:58:33 2014 UTC Ticket: https://dev.haiku-os.org/ticket/6236 ---------------------------------------------------------------------------- 1 file changed, 41 insertions(+), 3 deletions(-) src/apps/webpositive/BrowserWindow.cpp | 44 ++++++++++++++++++++++++++++-- ---------------------------------------------------------------------------- diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index e9d57ae..c177aa0 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -135,6 +135,15 @@ static const int32 kModifiers = B_SHIFT_KEY | B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY; +static const char* kHandledProtocols[] = { + "http", + "https", + "file", + "about", + "data" +}; + + static BLayoutItem* layoutItemFor(BView* view) { @@ -1519,6 +1528,27 @@ BrowserWindow::MainDocumentError(const BString& failingURL, if (!_ShowPage(view)) return; + // Try delegating the URL to an external app instead. + int32 at = failingURL.FindFirst(":"); + if (at != B_ERROR) { + BString proto; + failingURL.CopyInto(proto, 0, at); + + bool handled = false; + + for (unsigned int i = 0; i < sizeof(kHandledProtocols) / sizeof(char*); + i++) { + handled = (proto == kHandledProtocols[i]); + if (handled) + break; + } + + if (!handled) { + _SmartURLHandler(failingURL); + return; + } + } + BWebWindow::MainDocumentError(failingURL, localizedDescription, view); // TODO: Remove the failing URL from the BrowsingHistory! @@ -2421,17 +2451,25 @@ BrowserWindow::_SmartURLHandler(const BString& url) // Only process if this doesn't look like a full URL (http:// or // file://, etc.) - BString temp; int32 at = url.FindFirst(":"); if (at != B_ERROR) { BString proto; url.CopyInto(proto, 0, at); - if (proto == "http" || proto == "https" || proto == "file" - || proto == "about") + bool handled = false; + + for (unsigned int i = 0; i < sizeof(kHandledProtocols) / sizeof(char*); + i++) { + handled = (proto == kHandledProtocols[i]); + if (handled) + break; + } + + if (handled) _VisitURL(url); else { + BString temp; temp = "application/x-vnd.Be.URL."; temp += proto;