diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-02-28 22:04:23 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-02-28 22:04:23 +0100 |
commit | 8f8538f7262acb9c8c89c3ba301573db6dee8183 (patch) | |
tree | ce1d1e9f04a6b7ed609c0795f70b68b610184ddc /src | |
parent | Update bk toolbar action state (diff) | |
download | rekonq-8f8538f7262acb9c8c89c3ba301573db6dee8183.tar.xz |
clean up SSL data retrieve
Diffstat (limited to 'src')
-rw-r--r-- | src/webpage.cpp | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index 6a6f1bc9..a0bb5a6d 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -189,17 +189,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r _suggestedFileName.clear(); _loadingUrl = request.url(); - KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager()); - KIO::MetaData metaData = manager->requestMetaData(); - - // Get the SSL information sent, if any... - if (metaData.contains(QL1S("ssl_in_use"))) - { - WebSslInfo info; - info.restoreFrom(metaData.toVariant(), request.url()); - info.setUrl(request.url()); - _sslInfo = info; - } + const bool isMainFrameRequest = (frame == mainFrame()); if (frame) { @@ -232,6 +222,9 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r break; case QWebPage::NavigationTypeReload: + setRequestMetaData( QL1S("cache"), QL1S("reload") ); + break; + case QWebPage::NavigationTypeBackOrForward: case QWebPage::NavigationTypeOther: break; @@ -241,6 +234,31 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r break; } } + + // Get the SSL information sent, if any... + KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager()); + KIO::MetaData metaData = manager->requestMetaData(); + if (metaData.contains(QL1S("ssl_in_use"))) + { + WebSslInfo info; + info.restoreFrom(metaData.toVariant(), request.url()); + info.setUrl(request.url()); + _sslInfo = info; + } + + if (isMainFrameRequest) + { + setRequestMetaData(QL1S("main_frame_request"), QL1S("TRUE")); + if (_sslInfo.isValid() && !domainSchemeMatch(request.url(), _sslInfo.url())) + { + _sslInfo = WebSslInfo(); + } + } + else + { + setRequestMetaData(QL1S("main_frame_request"), QL1S("FALSE")); + } + return KWebPage::acceptNavigationRequest(frame, request, type); } @@ -428,26 +446,31 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) Q_ASSERT(reply); QWebFrame* frame = qobject_cast<QWebFrame *>(reply->request().originatingObject()); + if (!frame) + return; + const bool isMainFrameRequest = (frame == mainFrame()); - const bool isLoadingUrlReply = (mainFrame()->url() == reply->url()); - if (isMainFrameRequest - && _sslInfo.isValid() - && isLoadingUrlReply - && !domainSchemeMatch(reply->url(), _sslInfo.url()) - ) + // Only deal with non-redirect responses... + const QVariant redirectVar = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirectVar.isValid()) { - // Reseting cached SSL info... - _sslInfo = WebSslInfo(); + _sslInfo.restoreFrom(reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)), + reply->url()); + return; } - + + // We are just managing loading URLs errors + if (reply->request().url() != _loadingUrl) + return; + // NOTE: These are not all networkreply errors, // but just that supported directly by KIO switch (reply->error()) { case QNetworkReply::NoError: // no error. Simple :) - if (isMainFrameRequest && isLoadingUrlReply && !_sslInfo.isValid()) + if (isMainFrameRequest) { // Obtain and set the SSL information if any... _sslInfo.restoreFrom(reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)), reply->url()); @@ -459,7 +482,7 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) // ignore this.. return; - // WARNING: This is also typical adblocked element error: IGNORE THIS! + // WARNING: This is also typical adblocked element error: IGNORE THIS! case QNetworkReply::ContentAccessDenied: // access to remote content denied break; |