Make WebWindow hyperlinks with target="_blank" open in user's browser

This commit is contained in:
David Rowe 2015-08-21 10:28:47 -07:00
parent 0fb2390877
commit b1db7e5ed2

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;
}