summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp65
-rw-r--r--src/protocolhandler.cpp31
-rw-r--r--src/protocolhandler.h12
-rw-r--r--src/webpage.cpp9
4 files changed, 65 insertions, 52 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 3f08386b..e83a59bb 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -271,7 +271,8 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
if (url.isEmpty())
return;
- KUrl loadingUrl(url);
+ // sanitization
+ KUrl loadingUrl( url.toEncoded() );
if ( !loadingUrl.isValid() )
{
@@ -279,74 +280,41 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
return;
}
- if (loadingUrl.scheme() == QLatin1String("mailto"))
- {
- KToolInvocation::invokeMailer(loadingUrl);
- return;
- }
-
// first, create the webview(s) to not let hangs UI..
- WebTab *webView = 0;
+ WebTab *tab = 0;
MainWindow *w = 0;
- if(type == Rekonq::NewWindow)
- w = newMainWindow();
- else
- w = mainWindow();
+ w = (type == Rekonq::NewWindow)
+ ? newMainWindow()
+ : mainWindow();
switch(type)
{
case Rekonq::SettingOpenTab:
- webView = w->mainView()->newWebTab(!ReKonfig::openTabsBack(),
+ tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack(),
ReKonfig::openTabsNearCurrent());
break;
case Rekonq::NewCurrentTab:
- webView = w->mainView()->newWebTab(true);
+ tab = w->mainView()->newWebTab(true);
break;
case Rekonq::NewBackTab:
- webView = w->mainView()->newWebTab(false, ReKonfig::openTabsNearCurrent());
+ tab = w->mainView()->newWebTab(false, ReKonfig::openTabsNearCurrent());
break;
case Rekonq::NewWindow:
case Rekonq::CurrentTab:
- webView = w->mainView()->currentWebTab();
+ tab = w->mainView()->currentWebTab();
break;
};
- // WARNING this is just a temporary hack waiting for the new "awesome bar" (rekonq 0.4 target)
- // and it may not work in all cases.
- // Known issues are (add that here to test the awesome bar code):
- // - web shortcuts with space separator
- // - relative urls
- // - ...
- if (loadingUrl.isRelative())
- {
- QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash);
- if(loadingUrl.path().contains('.') && !loadingUrl.path().contains(' '))
- {
- loadingUrl.setUrl("//" + fn);
- loadingUrl.setScheme("http");
- }
- else
- {
- loadingUrl.setUrl(url.fileName());
- loadingUrl.setScheme("gg");
- }
- }
-
// this should let rekonq filtering URI info and supporting
// the beautiful KDE web browsing shortcuts
KUriFilterData data(loadingUrl.pathOrUrl());
- data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin"
- // are considered as executables
- if (KUriFilter::self()->filterUri(data))
- {
- loadingUrl = data.uri().url();
- }
- // ------------------- END WARNING --------------------------------------
+ data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" are considered as executables
+ loadingUrl = KUriFilter::self()->filterUri(data) ? data.uri().url() : QUrl::fromUserInput(loadingUrl.pathOrUrl());
// we are sure of the url now, let's add it to history
// anyway we store here just http sites because local and ftp ones are
// added trough the protocol handler and the other are ignored
- if( url.protocol() == QLatin1String("http") )
+ if( url.protocol() == QLatin1String("http") || url.protocol() == QLatin1String("https") )
historyManager()->addHistoryEntry( loadingUrl.prettyUrl() );
if (!ReKonfig::openTabsBack())
@@ -354,14 +322,15 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
w->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl());
}
- if (webView)
+ if (tab)
{
- webView->setFocus();
- webView->view()->load(loadingUrl);
+ tab->setFocus();
+ tab->view()->load(loadingUrl);
}
}
+
void Application::loadUrl(const QString& urlString, const Rekonq::OpenType& type)
{
return loadUrl( QUrl::fromUserInput(urlString), type );
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 602ac016..cd75d06f 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -25,6 +25,7 @@
// Self Includes
#include "protocolhandler.h"
+#include "protocolhandler.moc"
// Auto Includes
#include "rekonq.h"
@@ -74,13 +75,17 @@ ProtocolHandler::~ProtocolHandler()
}
-bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame)
+bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *frame)
{
_url = request.url();
_frame = frame;
kDebug() << "URL PROTOCOL: " << _url;
+ // relative urls
+ if(_url.isRelative())
+ return false;
+
// "http(s)" (fast) handling
if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") )
return false;
@@ -134,6 +139,29 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame)
return true;
}
}
+
+ return false;
+}
+
+
+bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *frame)
+{
+ _url = request.url();
+ _frame = frame;
+
+ kDebug() << "URL PROTOCOL: " << _url;
+
+ // "http(s)" (fast) handling
+ if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") )
+ return false;
+
+ // "mailto" handling: It needs to be handled both here(mail links clicked)
+ // and in prehandling (mail url launched)
+ if ( _url.protocol() == QLatin1String("mailto") )
+ {
+ KToolInvocation::invokeMailer(_url);
+ return true;
+ }
// "ftp" handling. A little bit "hard" handling this. Hope I found
// the best solution.
@@ -154,6 +182,7 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame)
if(fileInfo.isDir())
{
_lister->openUrl(_url);
+ Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url);
return true;
}
}
diff --git a/src/protocolhandler.h b/src/protocolhandler.h
index 532bd9c9..6ae47b74 100644
--- a/src/protocolhandler.h
+++ b/src/protocolhandler.h
@@ -49,8 +49,18 @@ public:
ProtocolHandler(QObject *parent = 0);
~ProtocolHandler();
- bool handle(const QNetworkRequest &request, QWebFrame *frame);
+ /**
+ * This function handles all the protocols that have to be handled before
+ * WebKit does
+ */
+ bool preHandling(const QNetworkRequest &request, QWebFrame *frame);
+ /**
+ * This function handles all the protocols that have to be handled after
+ * WebKit tried to
+ */
+ bool postHandling(const QNetworkRequest &request, QWebFrame *frame);
+
signals:
void downloadUrl( const KUrl &);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 70fca7c5..cfa5ff04 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -105,9 +105,11 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
return false;
}
- if(m_protHandler.handle(request,frame))
+ if (frame && m_protHandler.preHandling( request, frame ))
+ {
return false;
-
+ }
+
m_requestedUrl = request.url();
return KWebPage::acceptNavigationRequest(frame, request, type);
@@ -191,6 +193,9 @@ void WebPage::manageNetworkErrors(QNetworkReply* reply)
if( reply->error() == QNetworkReply::NoError )
return;
+ if(m_protHandler.postHandling( reply->request(), mainFrame() ))
+ return;
+
// don't bother on adblocked urls
if( reply->error() == QNetworkReply::ContentAccessDenied )
return;