Commit 8d4e5e65 authored by kenneth@webkit.org's avatar kenneth@webkit.org

Rubberstamped by Simon Hausmann

[Qt] Refactor the code in the QtLauncher dealing with HTTP proxy.

* QtLauncher/main.cpp:
(MainWindow::MainWindow):
* QtLauncher/webpage.cpp:
(WebPage::WebPage):
(WebPage::applyProxy):
* QtLauncher/webpage.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@53919 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c4b9b00d
2010-01-27 Kenneth Rohde Christiansen <kenneth@webkit.org>
Rubberstamped by Simon Hausmann
[Qt] Refactor the code in the QtLauncher dealing with HTTP proxy.
* QtLauncher/main.cpp:
(MainWindow::MainWindow):
* QtLauncher/webpage.cpp:
(WebPage::WebPage):
(WebPage::applyProxy):
* QtLauncher/webpage.h:
2010-01-26 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2010-01-26 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
Reviewed by Tor Arne Vestbø. Reviewed by Tor Arne Vestbø.
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
*/ */
#include <QtGui> #include <QtGui>
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkRequest>
#if !defined(QT_NO_PRINTER) #if !defined(QT_NO_PRINTER)
#include <QPrintPreviewDialog> #include <QPrintPreviewDialog>
...@@ -138,14 +137,6 @@ public: ...@@ -138,14 +137,6 @@ public:
setupUI(); setupUI();
// set the proxy to the http_proxy env variable - if present
QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy"));
if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) {
int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080;
page->networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort));
}
QFileInfo fi(url); QFileInfo fi(url);
if (fi.exists() && fi.isRelative()) if (fi.exists() && fi.isRelative())
url = fi.absoluteFilePath(); url = fi.absoluteFilePath();
......
...@@ -35,6 +35,23 @@ ...@@ -35,6 +35,23 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QtGui> #include <QtGui>
#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkProxy>
WebPage::WebPage(QObject* parent)
: QWebPage(parent)
{
applyProxy();
}
void WebPage::applyProxy()
{
QUrl proxyUrl(qgetenv("http_proxy"));
if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) {
int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080;
networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort));
}
}
bool WebPage::supportsExtension(QWebPage::Extension extension) const bool WebPage::supportsExtension(QWebPage::Extension extension) const
{ {
...@@ -85,3 +102,5 @@ void WebPage::openUrlInDefaultBrowser(const QUrl& url) ...@@ -85,3 +102,5 @@ void WebPage::openUrlInDefaultBrowser(const QUrl& url)
else else
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
class WebPage : public QWebPage { class WebPage : public QWebPage {
public: public:
WebPage(QWidget* parent) : QWebPage(parent) {} WebPage(QObject* parent = 0);
virtual QWebPage* createWindow(QWebPage::WebWindowType); virtual QWebPage* createWindow(QWebPage::WebWindowType);
virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&); virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&);
...@@ -49,6 +49,9 @@ public: ...@@ -49,6 +49,9 @@ public:
public slots: public slots:
void openUrlInDefaultBrowser(const QUrl& url = QUrl()); void openUrlInDefaultBrowser(const QUrl& url = QUrl());
private:
void applyProxy();
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment