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.
This commit is contained in:
@@ -135,6 +135,15 @@ static const int32 kModifiers = B_SHIFT_KEY | B_COMMAND_KEY
|
|||||||
| B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY;
|
| B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY;
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kHandledProtocols[] = {
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
"file",
|
||||||
|
"about",
|
||||||
|
"data"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static BLayoutItem*
|
static BLayoutItem*
|
||||||
layoutItemFor(BView* view)
|
layoutItemFor(BView* view)
|
||||||
{
|
{
|
||||||
@@ -1519,6 +1528,27 @@ BrowserWindow::MainDocumentError(const BString& failingURL,
|
|||||||
if (!_ShowPage(view))
|
if (!_ShowPage(view))
|
||||||
return;
|
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);
|
BWebWindow::MainDocumentError(failingURL, localizedDescription, view);
|
||||||
|
|
||||||
// TODO: Remove the failing URL from the BrowsingHistory!
|
// 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
|
// Only process if this doesn't look like a full URL (http:// or
|
||||||
// file://, etc.)
|
// file://, etc.)
|
||||||
|
|
||||||
BString temp;
|
|
||||||
int32 at = url.FindFirst(":");
|
int32 at = url.FindFirst(":");
|
||||||
|
|
||||||
if (at != B_ERROR) {
|
if (at != B_ERROR) {
|
||||||
BString proto;
|
BString proto;
|
||||||
url.CopyInto(proto, 0, at);
|
url.CopyInto(proto, 0, at);
|
||||||
|
|
||||||
if (proto == "http" || proto == "https" || proto == "file"
|
bool handled = false;
|
||||||
|| proto == "about")
|
|
||||||
|
for (unsigned int i = 0; i < sizeof(kHandledProtocols) / sizeof(char*);
|
||||||
|
i++) {
|
||||||
|
handled = (proto == kHandledProtocols[i]);
|
||||||
|
if (handled)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handled)
|
||||||
_VisitURL(url);
|
_VisitURL(url);
|
||||||
else {
|
else {
|
||||||
|
BString temp;
|
||||||
temp = "application/x-vnd.Be.URL.";
|
temp = "application/x-vnd.Be.URL.";
|
||||||
temp += proto;
|
temp += proto;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user