Changeset 23769 in webkit


Ignore:
Timestamp:
Jun 25, 2007 11:20:57 AM (17 years ago)
Author:
staikos
Message:

Some work on adding HTTP proxy and SSL errors to WebKitQt, as well as preparing
for upcoming patches to do authentication.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r23767 r23769  
     12007-06-25  George Staikos  <staikos@kde.org>
     2
     3        Reviewed by Zack.
     4
     5        Start to add proxy and SSL support to WebKitQt.  Proxying works.
     6
     7        * platform/network/ResourceHandleInternal.h:
     8        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
     9        * platform/network/qt/ResourceHandleQt.cpp:
     10        (WebCore::ResourceHandle::start):
     11
    1122007-06-25  Alp Toker  <alp.toker@collabora.co.uk>
    213
  • trunk/WebCore/platform/network/ResourceHandleInternal.h

    r21885 r23769  
    4646
    4747#if PLATFORM(QT)
     48class QWebFrame;
    4849class QWebNetworkJob;
    4950#endif
     
    9899#if PLATFORM(QT)
    99100            , m_job(0)
     101            , m_frame(0)
    100102#endif
    101103#if PLATFORM(MAC)
     
    150152#if PLATFORM(QT)
    151153        QWebNetworkJob *m_job;
     154        QWebFrame *m_frame;
    152155#endif
    153156#if PLATFORM(MAC)
  • trunk/WebCore/platform/network/qt/ResourceHandleQt.cpp

    r21827 r23769  
    2929#include "config.h"
    3030
    31 #include <QRegExp>
    32 
    3331#include "Frame.h"
    3432#include "DocLoader.h"
     
    3937#include "qwebpage_p.h"
    4038#include "ChromeClientQt.h"
     39#include "FrameLoaderClientQt.h"
    4140#include "Page.h"
    4241
     
    7271    }
    7372
    74     ChromeClientQt *client = static_cast<ChromeClientQt *>(page->chrome()->client());
    75     QWebPagePrivate *webPage = client->m_webPage->d;
    76     return QWebNetworkManager::self()->add(this, webPage->networkInterface);
     73    getInternal()->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame();
     74    return QWebNetworkManager::self()->add(this, getInternal()->m_frame->page()->d->networkInterface);
    7775}
    7876
  • trunk/WebKitQt/Api/qwebnetworkinterface.cpp

    r23588 r23769  
    2222*/
    2323#include <qglobal.h>
     24#include "qwebframe.h"
    2425#include "qwebnetworkinterface.h"
    2526#include "qwebnetworkinterface_p.h"
    2627#include "qwebobjectpluginconnector.h"
     28#include "qwebpage.h"
    2729#include <qdebug.h>
    2830#include <qfile.h>
     31#include <qnetworkproxy.h>
    2932#include <qurl.h>
    3033
     
    100103    url = u;
    101104    int port = url.port();
    102     if (port > 0 && port != 80)
     105    const QString scheme = u.scheme();
     106    if (port > 0 && (port != 80 || scheme != "http") && (port != 443 || scheme != "https"))
    103107        httpHeader.setValue(QLatin1String("Host"), url.host() + QLatin1Char(':') + QString::number(port));
    104108    else
     
    335339{
    336340    return d->interface;
     341}
     342
     343/*!
     344   Returns the network interface that is associated with this job.
     345*/
     346QWebFrame *QWebNetworkJob::frame() const
     347{
     348    if (d->resourceHandle) {
     349        ResourceHandleInternal *rhi = d->resourceHandle->getInternal();
     350        if (rhi) {
     351            return rhi->m_frame;
     352        }
     353    }
     354    return 0;
    337355}
    338356
     
    791809        connect(connection[i].http, SIGNAL(requestFinished(int, bool)),
    792810                this, SLOT(onRequestFinished(int, bool)));
     811        connect(connection[i].http, SIGNAL(done(bool)),
     812                this, SLOT(onDone(bool)));
    793813        connect(connection[i].http, SIGNAL(stateChanged(int)),
    794814                this, SLOT(onStateChanged(int)));
     815        connect(connection[i].http, SIGNAL(authenticationRequired(const QString&, quint16, QAuthenticator*)),
     816                this, SLOT(onAuthenticationRequired(const QString&, quint16, QAuthenticator*)));
     817        connect(connection[i].http, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
     818                this, SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));
     819        connect(connection[i].http, SIGNAL(sslErrors(const QList<QSslError>&)),
     820                this, SLOT(onSslErrors(const QList<QSslError>&)));
    795821    }
    796822}
     
    831857   
    832858    QHttp *http = connection[c].http;
     859
     860    connection[c].current = job;
     861    http->setProxy(job->frame()->page()->networkProxy());
     862    connection[c].proxyDone = false;
     863
    833864    QByteArray postData = job->postData();
    834865    if (!postData.isEmpty())
     
    836867    else
    837868        http->request(job->httpHeader());
    838     connection[c].current = job;
    839869
    840870    DEBUG() << "WebCoreHttp::scheduleNextRequest: using connection" << c;
     
    880910}
    881911
    882 void WebCoreHttp::onRequestFinished(int, bool error)
     912void WebCoreHttp::onRequestFinished(int id, bool error)
    883913{
    884914    int c = getConnection();
     915    if (!connection[c].proxyDone) {
     916        connection[c].proxyDone = true;
     917        return;
     918    }
    885919    QWebNetworkJob *req = connection[c].current;
    886920    if (!req) {
     
    888922        return;
    889923    }
     924
    890925    QHttp *http = connection[c].http;
    891926    DEBUG() << "WebCoreHttp::slotFinished connection=" << c << error << req;
    892 
    893927    if (error)
    894928        DEBUG() << "   error: " << http->errorString();
     
    901935    }
    902936    emit req->networkInterface()->finished(req, error ? 1 : 0);
     937}
     938
     939void WebCoreHttp::onDone(bool error)
     940{
     941    int c = getConnection();
     942    QWebNetworkJob *req = connection[c].current;
     943    if (!req) {
     944        scheduleNextRequest();
     945        return;
     946    }
     947
     948    DEBUG() << "WebCoreHttp::DONE connection=" << c << error << req;
     949    QHttp *http = connection[c].http;
     950
     951    if (error)
     952        DEBUG() << "   error: " << http->errorString();
    903953
    904954    connection[c].current = 0;
     
    937987}
    938988
     989void WebCoreHttp::onSslErrors(const QList<QSslError>& errors)
     990{
     991    int c = getConnection();
     992    QWebNetworkJob *req = connection[c].current;
     993    if (!req) {
     994        return;
     995    }
     996
     997    qDebug() << "SSL ERRORS";
     998    //emit req->frame()->page()->sslErrors(req->frame(), errors);
     999}
     1000
     1001void WebCoreHttp::onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *auth)
     1002{
     1003    int c = getConnection();
     1004    QWebNetworkJob *req = connection[c].current;
     1005    if (!req) {
     1006        return;
     1007    }
     1008
     1009    qDebug() << "AUTH REQUIRED" << hostname << port << auth;
     1010    //emit req->frame()->page()->authenticate(req->frame(), hostname, port, auth);
     1011}
     1012
     1013void WebCoreHttp::onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *auth)
     1014{
     1015}
     1016
    9391017HostInfo::HostInfo(const QUrl& url)
    9401018    : protocol(url.scheme())
  • trunk/WebKitQt/Api/qwebnetworkinterface.h

    r23500 r23769  
    3030#include <qwebkitglobal.h>
    3131
     32class QWebFrame;
    3233class QWebNetworkJobPrivate;
    3334class QWebNetworkInterface;
     
    9798    QWebNetworkInterface *networkInterface() const;
    9899   
     100    QWebFrame *frame() const;
     101
    99102private:
    100103    QWebNetworkJob();
  • trunk/WebKitQt/Api/qwebnetworkinterface_p.h

    r23490 r23769  
    130130        void onReadyRead();
    131131        void onRequestFinished(int, bool);
     132        void onDone(bool);
    132133        void onStateChanged(int);
     134        void onSslErrors(const QList<QSslError>&);
     135        void onAuthenticationRequired(const QString& hostname, quint16 port, QAuthenticator *);
     136        void onProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator *);
    133137
    134138        void scheduleNextRequest();
     
    143147            QHttp *http;
    144148            QWebNetworkJob *current;
     149            bool proxyDone;
    145150        };
    146151        HttpConnection connection[2];
  • trunk/WebKitQt/Api/qwebpage.cpp

    r23733 r23769  
    5555#include <QInputDialog>
    5656#include <QMessageBox>
     57#include <QNetworkProxy>
    5758#include <QUndoStack>
    5859#include <QUrl>
     
    449450}
    450451
     452void QWebPage::setNetworkProxy(const QNetworkProxy& proxy)
     453{
     454    d->networkProxy = proxy;
     455}
     456
     457QNetworkProxy QWebPage::networkProxy() const
     458{
     459    return d->networkProxy;
     460}
     461
  • trunk/WebKitQt/Api/qwebpage.h

    r23691 r23769  
    3030
    3131#include <qwidget.h>
    32 class QWebFrame;
     32class QNetworkProxy;
    3333class QUndoStack;
    3434class QUrl;
     35class QWebFrame;
    3536class QWebNetworkRequest;
    3637
     
    8586
    8687    QPixmap icon() const;
     88
     89    void setNetworkProxy(const QNetworkProxy& proxy);
     90    QNetworkProxy networkProxy() const;
    8791
    8892public slots:
  • trunk/WebKitQt/Api/qwebpage_p.h

    r23494 r23769  
    2323#define QWEBPAGE_P_H
    2424
     25#include <qnetworkproxy.h>
    2526#include <qpointer.h>
    2627
     
    6364    bool insideOpenCall;
    6465    QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request);
     66    QNetworkProxy networkProxy;
    6567};
    6668
  • trunk/WebKitQt/ChangeLog

    r23733 r23769  
     12007-06-25  George Staikos  <staikos@kde.org>
     2
     3        Reviewed by Zack.
     4
     5        Start to add proxy and SSL support to WebKit Qt.  Proxy works
     6        unauthenticated.  Added hooks to be able to add authentication.
     7        Also fixes some network errors.
     8
     9        * Api/qwebnetworkinterface.cpp:
     10        (QWebNetworkRequestPrivate::setURL):
     11        (QWebNetworkJob::frame):
     12        (WebCoreHttp::WebCoreHttp):
     13        (WebCoreHttp::scheduleNextRequest):
     14        (WebCoreHttp::onRequestFinished):
     15        (WebCoreHttp::onDone):
     16        (WebCoreHttp::onSslErrors):
     17        (WebCoreHttp::onAuthenticationRequired):
     18        (WebCoreHttp::onProxyAuthenticationRequired):
     19        * Api/qwebnetworkinterface.h:
     20        * Api/qwebnetworkinterface_p.h:
     21        * Api/qwebpage.cpp:
     22        (QWebPage::setNetworkProxy):
     23        (QWebPage::networkProxy):
     24        * Api/qwebpage.h:
     25        * Api/qwebpage_p.h:
     26
    1272007-06-21  Adam Treat  <adam@staikos.net>
    228
Note: See TracChangeset for help on using the changeset viewer.