Merge pull request #5628 from ctrlaltdavid/webwindow-external-links

Make WebWindow hyperlinks with target="_blank" open in user's browser
This commit is contained in:
Brad Hefta-Gaub 2015-08-24 17:45:35 -07:00
commit 5ea6d2704a

View file

@ -32,12 +32,20 @@ void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumbe
}
bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) {
// Handle hifi:// links and links to files with particular extensions
QString urlString = request.url().toString();
if (Application::getInstance()->canAcceptURL(urlString)) {
if (Application::getInstance()->acceptURL(urlString)) {
return false; // we handled it, so QWebPage doesn't need to handle it
}
}
// Make hyperlinks with target="_blank" open in user's Web browser
if (type == QWebPage::NavigationTypeLinkClicked && frame == nullptr) {
Application::getInstance()->openUrl(request.url());
return false; // We handled it.
}
return true;
}