summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-05-15 16:10:58 +0200
committerPierre Rossi <pierre.rossi@theqtcompany.com>2015-05-15 16:13:09 +0200
commit2901cf88905cea575c6df41c3cbe06cd09491f60 (patch)
tree4d07d28864a31bd962809c067411f807c32168dd
parentb608101c1403323750f222b3c1a7240611ee65ca (diff)
parent3b585086049089224422e6f839485be5a4235524 (diff)
downloadqtwebengine-2901cf88905cea575c6df41c3cbe06cd09491f60.tar.gz
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I1fbcd05760cb287d1d8a0fba344ec7cfe8348c7d
-rw-r--r--.gitignore3
-rw-r--r--examples/webenginewidgets/browser/browserapplication.cpp28
-rw-r--r--examples/webenginewidgets/browser/browserapplication.h8
-rw-r--r--examples/webenginewidgets/browser/browsermainwindow.cpp31
-rw-r--r--examples/webenginewidgets/browser/browsermainwindow.h1
-rw-r--r--examples/webenginewidgets/browser/downloadmanager.cpp5
-rw-r--r--examples/webenginewidgets/browser/history.cpp5
-rw-r--r--examples/webenginewidgets/browser/history.h1
-rw-r--r--examples/webenginewidgets/browser/tabwidget.cpp21
-rw-r--r--examples/webenginewidgets/browser/tabwidget.h4
-rw-r--r--examples/webenginewidgets/browser/toolbarsearch.cpp7
-rw-r--r--examples/webenginewidgets/browser/webview.cpp29
-rw-r--r--examples/webenginewidgets/browser/webview.h3
-rw-r--r--src/core/browser_context_qt.cpp3
-rw-r--r--src/core/config/embedded_linux.pri7
-rw-r--r--src/core/resource_context_qt.cpp11
-rw-r--r--src/core/resource_context_qt.h5
-rw-r--r--src/core/url_request_custom_job.cpp42
-rw-r--r--src/core/url_request_custom_job.h5
-rw-r--r--src/core/url_request_custom_job_delegate.cpp37
-rw-r--r--src/core/url_request_custom_job_delegate.h13
-rw-r--r--src/webengine/ui/AlertDialog.qml2
-rw-r--r--src/webengine/ui/Menu.qml6
-rw-r--r--src/webengine/ui/MenuItem.qml4
-rw-r--r--src/webengine/ui/MenuSeparator.qml4
-rw-r--r--src/webengine/ui/MessageBubble.qml2
-rw-r--r--src/webengine/ui/PromptDialog.qml4
-rw-r--r--src/webenginewidgets/api/qwebengineurlrequestjob.cpp20
-rw-r--r--src/webenginewidgets/api/qwebengineurlrequestjob_p.h11
29 files changed, 235 insertions, 87 deletions
diff --git a/.gitignore b/.gitignore
index 53f5c6eb5..b66341f8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,8 +9,11 @@ src/core/core_generated.gyp
src/core/gypfiles
src/core/qmake_extras.gypi
examples/webengine/quicknanobrowser/quicknanobrowser
+examples/webengine/quicknanobrowser/quicknanobrowser.app
examples/webenginewidgets/browser/browser
+examples/webenginewidgets/browser/browser.app
examples/webenginewidgets/fancybrowser/fancybrowser
+examples/webenginewidgets/fancybrowser/fancybrowser.app
tests/quicktestbrowser/quicktestbrowser
tests/**/tst_*
diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp
index b1426ea24..3bc801295 100644
--- a/examples/webenginewidgets/browser/browserapplication.cpp
+++ b/examples/webenginewidgets/browser/browserapplication.cpp
@@ -116,6 +116,8 @@ static void setUserStyleSheet(QWebEngineProfile *profile, const QString &styleSh
BrowserApplication::BrowserApplication(int &argc, char **argv)
: QApplication(argc, argv)
, m_localServer(0)
+ , m_privateProfile(0)
+ , m_privateBrowsing(false)
{
QCoreApplication::setOrganizationName(QLatin1String("Qt"));
QCoreApplication::setApplicationName(QLatin1String("demobrowser"));
@@ -325,11 +327,8 @@ void BrowserApplication::clean()
void BrowserApplication::saveSession()
{
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+ if (m_privateBrowsing)
return;
-#endif
clean();
@@ -529,3 +528,24 @@ QIcon BrowserApplication::defaultIcon() const
m_defaultIcon = QIcon(QLatin1String(":defaulticon.png"));
return m_defaultIcon;
}
+
+void BrowserApplication::setPrivateBrowsing(bool privateBrowsing)
+{
+ if (m_privateBrowsing == privateBrowsing)
+ return;
+ m_privateBrowsing = privateBrowsing;
+ if (privateBrowsing) {
+ if (!m_privateProfile)
+ m_privateProfile = new QWebEngineProfile(this);
+ Q_FOREACH (BrowserMainWindow* window, mainWindows()) {
+ window->tabWidget()->setProfile(m_privateProfile);
+ }
+ } else {
+ Q_FOREACH (BrowserMainWindow* window, mainWindows()) {
+ window->tabWidget()->setProfile(QWebEngineProfile::defaultProfile());
+ window->m_lastSearch = QString::null;
+ window->tabWidget()->clear();
+ }
+ }
+ emit privateBrowsingChanged(privateBrowsing);
+}
diff --git a/examples/webenginewidgets/browser/browserapplication.h b/examples/webenginewidgets/browser/browserapplication.h
index 97df0e431..26557b8f9 100644
--- a/examples/webenginewidgets/browser/browserapplication.h
+++ b/examples/webenginewidgets/browser/browserapplication.h
@@ -52,6 +52,7 @@
QT_BEGIN_NAMESPACE
class QLocalServer;
class QNetworkAccessManager;
+class QWebEngineProfile;
QT_END_NAMESPACE
class BookmarksManager;
@@ -77,6 +78,7 @@ public:
void saveSession();
bool canRestoreSession() const;
+ bool privateBrowsing() const { return m_privateBrowsing; }
static HistoryManager *historyManager();
static CookieJar *cookieJar();
@@ -95,6 +97,10 @@ public slots:
void lastWindowClosed();
void quitBrowser();
#endif
+ void setPrivateBrowsing(bool);
+
+signals:
+ void privateBrowsingChanged(bool);
private slots:
void postLaunch();
@@ -113,6 +119,8 @@ private:
QList<QPointer<BrowserMainWindow> > m_mainWindows;
QLocalServer *m_localServer;
QByteArray m_lastSession;
+ QWebEngineProfile *m_privateProfile;
+ bool m_privateBrowsing;
mutable QIcon m_defaultIcon;
};
diff --git a/examples/webenginewidgets/browser/browsermainwindow.cpp b/examples/webenginewidgets/browser/browsermainwindow.cpp
index 98f61d6cb..9595ca7ba 100644
--- a/examples/webenginewidgets/browser/browsermainwindow.cpp
+++ b/examples/webenginewidgets/browser/browsermainwindow.cpp
@@ -68,6 +68,7 @@
#include <QtWidgets/QInputDialog>
#include <QWebEngineHistory>
+#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QtCore/QDebug>
@@ -304,11 +305,11 @@ void BrowserMainWindow::setupMenu()
fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print);
fileMenu->addSeparator();
#endif
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing()));
action->setCheckable(true);
+ action->setChecked(BrowserApplication::instance()->privateBrowsing());
+ connect(BrowserApplication::instance(), SIGNAL(privateBrowsingChanged(bool)), action, SLOT(setChecked(bool)));
fileMenu->addSeparator();
-#endif
#if defined(Q_OS_OSX)
fileMenu->addAction(tr("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q));
@@ -703,12 +704,11 @@ void BrowserMainWindow::printRequested(QWebEngineFrame *frame)
void BrowserMainWindow::slotPrivateBrowsing()
{
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *settings = QWebEngineSettings::globalSettings();
- bool pb = settings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled);
- if (!pb) {
+ if (!BrowserApplication::instance()->privateBrowsing()) {
QString title = tr("Are you sure you want to turn on private browsing?");
- QString text = tr("<b>%1</b><br><br>When private browsing in turned on,"
+ QString text = tr("<b>%1</b><br><br>"
+ "This action will reload all open tabs.<br>"
+ "When private browsing in turned on,"
" webpages are not added to the history,"
" items are automatically removed from the Downloads window," \
" new cookies are not stored, current cookies can't be accessed," \
@@ -720,20 +720,13 @@ void BrowserMainWindow::slotPrivateBrowsing()
QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text,
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
- if (button == QMessageBox::Ok) {
- settings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, true);
- }
- } else {
- settings->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, false);
- QList<BrowserMainWindow*> windows = BrowserApplication::instance()->mainWindows();
- for (int i = 0; i < windows.count(); ++i) {
- BrowserMainWindow *window = windows.at(i);
- window->m_lastSearch = QString::null;
- window->tabWidget()->clear();
- }
+ if (button == QMessageBox::Ok)
+ BrowserApplication::instance()->setPrivateBrowsing(true);
+ } else {
+ // TODO: Also ask here
+ BrowserApplication::instance()->setPrivateBrowsing(false);
}
-#endif
}
void BrowserMainWindow::closeEvent(QCloseEvent *event)
diff --git a/examples/webenginewidgets/browser/browsermainwindow.h b/examples/webenginewidgets/browser/browsermainwindow.h
index 831504700..a2bbc443f 100644
--- a/examples/webenginewidgets/browser/browsermainwindow.h
+++ b/examples/webenginewidgets/browser/browsermainwindow.h
@@ -170,6 +170,7 @@ private:
QIcon m_stopIcon;
QString m_lastSearch;
+ friend class BrowserApplication;
};
#endif // BROWSERMAINWINDOW_H
diff --git a/examples/webenginewidgets/browser/downloadmanager.cpp b/examples/webenginewidgets/browser/downloadmanager.cpp
index 9609589d7..90b0cec9d 100644
--- a/examples/webenginewidgets/browser/downloadmanager.cpp
+++ b/examples/webenginewidgets/browser/downloadmanager.cpp
@@ -352,12 +352,9 @@ void DownloadManager::updateRow()
downloadsView->setRowHeight(row, widget->minimumSizeHint().height());
bool remove = false;
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
if (!widget->downloading()
- && globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+ && BrowserApplication::instance()->privateBrowsing())
remove = true;
-#endif
if (widget->downloadedSuccessfully()
&& removePolicy() == DownloadManager::SuccessFullDownload) {
diff --git a/examples/webenginewidgets/browser/history.cpp b/examples/webenginewidgets/browser/history.cpp
index ffae0f55e..d9d76cd29 100644
--- a/examples/webenginewidgets/browser/history.cpp
+++ b/examples/webenginewidgets/browser/history.cpp
@@ -189,11 +189,8 @@ void HistoryManager::checkForExpired()
void HistoryManager::addHistoryItem(const HistoryItem &item)
{
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
+ if (BrowserApplication::instance()->privateBrowsing())
return;
-#endif
m_history.prepend(item);
emit entryAdded(item);
diff --git a/examples/webenginewidgets/browser/history.h b/examples/webenginewidgets/browser/history.h
index 5a747c942..3519d31b6 100644
--- a/examples/webenginewidgets/browser/history.h
+++ b/examples/webenginewidgets/browser/history.h
@@ -81,6 +81,7 @@ class AutoSaver;
class HistoryModel;
class HistoryFilterModel;
class HistoryTreeModel;
+
class HistoryManager
#if defined(QWEBENGINEHISTORYINTERFACE)
: public QWebEngineHistoryInterface
diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/browser/tabwidget.cpp
index 06ff59ac3..3df1628e0 100644
--- a/examples/webenginewidgets/browser/tabwidget.cpp
+++ b/examples/webenginewidgets/browser/tabwidget.cpp
@@ -217,6 +217,7 @@ TabWidget::TabWidget(QWidget *parent)
, m_lineEditCompleter(0)
, m_lineEdits(0)
, m_tabBar(new TabBar(this))
+ , m_profile(QWebEngineProfile::defaultProfile())
{
setElideMode(Qt::ElideRight);
@@ -456,6 +457,7 @@ WebView *TabWidget::newTab(bool makeCurrent)
// webview
WebView *webView = new WebView;
+ webView->setPage(new WebPage(m_profile, webView));
urlLineEdit->setWebView(webView);
connect(webView, SIGNAL(loadStarted()),
this, SLOT(webViewLoadStarted()));
@@ -581,11 +583,7 @@ void TabWidget::closeTab(int index)
#endif
hasFocus = tab->hasFocus();
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
-#endif
- {
+ if (m_profile == QWebEngineProfile::defaultProfile()) {
m_recentlyClosedTabsAction->setEnabled(true);
m_recentlyClosedTabs.prepend(tab->url());
if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
@@ -605,6 +603,19 @@ void TabWidget::closeTab(int index)
emit lastTabClosed();
}
+void TabWidget::setProfile(QWebEngineProfile *profile)
+{
+ m_profile = profile;
+ for (int i = 0; i < count(); ++i) {
+ QWidget *tabWidget = widget(i);
+ if (WebView *tab = qobject_cast<WebView*>(tabWidget)) {
+ WebPage* webPage = new WebPage(m_profile, tab);
+ webPage->load(tab->page()->url());
+ tab->setPage(webPage);
+ }
+ }
+}
+
void TabWidget::webViewLoadStarted()
{
WebView *webView = qobject_cast<WebView*>(sender());
diff --git a/examples/webenginewidgets/browser/tabwidget.h b/examples/webenginewidgets/browser/tabwidget.h
index 74e98f46c..5d7f1e2c5 100644
--- a/examples/webenginewidgets/browser/tabwidget.h
+++ b/examples/webenginewidgets/browser/tabwidget.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QWebEngineDownloadItem;
+class QWebEngineProfile;
QT_END_NAMESPACE
/*
@@ -182,6 +183,8 @@ public:
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
+ void setProfile(QWebEngineProfile *profile);
+
protected:
void mouseDoubleClickEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
@@ -226,6 +229,7 @@ private:
QCompleter *m_lineEditCompleter;
QStackedWidget *m_lineEdits;
TabBar *m_tabBar;
+ QWebEngineProfile *m_profile;
};
#endif // TABWIDGET_H
diff --git a/examples/webenginewidgets/browser/toolbarsearch.cpp b/examples/webenginewidgets/browser/toolbarsearch.cpp
index fa6e4f239..42cdaec18 100644
--- a/examples/webenginewidgets/browser/toolbarsearch.cpp
+++ b/examples/webenginewidgets/browser/toolbarsearch.cpp
@@ -41,6 +41,7 @@
#include "toolbarsearch.h"
#include "autosaver.h"
+#include "browserapplication.h"
#include <QtCore/QSettings>
#include <QtCore/QUrl>
@@ -109,11 +110,7 @@ void ToolbarSearch::searchNow()
if (newList.size() >= m_maxSavedSearches)
newList.removeLast();
-#if defined(QTWEBENGINE_PRIVATEBROWSING)
- QWebEngineSettings *globalSettings = QWebEngineSettings::globalSettings();
- if (!globalSettings->testAttribute(QWebEngineSettings::PrivateBrowsingEnabled))
-#endif
- {
+ if (!BrowserApplication::instance()->privateBrowsing()) {
m_stringListModel->setStringList(newList);
m_autosaver->changeOccurred();
}
diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp
index 29b0440f5..f9e75535f 100644
--- a/examples/webenginewidgets/browser/webview.cpp
+++ b/examples/webenginewidgets/browser/webview.cpp
@@ -68,8 +68,8 @@
#include <QtCore/QDebug>
#include <QtCore/QBuffer>
-WebPage::WebPage(QObject *parent)
- : QWebEnginePage(parent)
+WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
+ : QWebEnginePage(profile, parent)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
{
@@ -128,10 +128,11 @@ bool WebPage::certificateError(const QWebEngineCertificateError &error)
class PopupWindow : public QWidget {
Q_OBJECT
public:
- PopupWindow()
+ PopupWindow(QWebEngineProfile *profile)
: m_addressBar(new QLineEdit(this))
, m_view(new WebView(this))
{
+ m_view->setPage(new WebPage(profile, m_view));
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
setLayout(layout);
@@ -180,7 +181,7 @@ QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type)
BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
return mainWindow->currentTab()->page();
} else {
- PopupWindow *popup = new PopupWindow;
+ PopupWindow *popup = new PopupWindow(profile());
popup->setAttribute(Qt::WA_DeleteOnClose);
popup->show();
return popup->page();
@@ -304,18 +305,25 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
, m_progress(0)
- , m_page(new WebPage(this))
+ , m_page(0)
, m_iconReply(0)
{
- setPage(m_page);
-#if defined(QWEBENGINEPAGE_STATUSBARMESSAGE)
- connect(page(), SIGNAL(statusBarMessage(QString)),
- SLOT(setStatusBarText(QString)));
-#endif
connect(this, SIGNAL(loadProgress(int)),
this, SLOT(setProgress(int)));
connect(this, SIGNAL(loadFinished(bool)),
this, SLOT(loadFinished(bool)));
+}
+
+void WebView::setPage(WebPage *_page)
+{
+ if (m_page)
+ m_page->deleteLater();
+ m_page = _page;
+ QWebEngineView::setPage(_page);
+#if defined(QWEBENGINEPAGE_STATUSBARMESSAGE)
+ connect(page(), SIGNAL(statusBarMessage(QString)),
+ SLOT(setStatusBarText(QString)));
+#endif
connect(page(), SIGNAL(loadingUrl(QUrl)),
this, SIGNAL(urlChanged(QUrl)));
connect(page(), SIGNAL(iconUrlChanged(QUrl)),
@@ -324,7 +332,6 @@ WebView::WebView(QWidget* parent)
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
page()->setForwardUnsupportedContent(true);
#endif
-
}
void WebView::contextMenuEvent(QContextMenuEvent *event)
diff --git a/examples/webenginewidgets/browser/webview.h b/examples/webenginewidgets/browser/webview.h
index 288d48f17..2497bc1b9 100644
--- a/examples/webenginewidgets/browser/webview.h
+++ b/examples/webenginewidgets/browser/webview.h
@@ -61,7 +61,7 @@ signals:
void loadingUrl(const QUrl &url);
public:
- WebPage(QObject *parent = 0);
+ WebPage(QWebEngineProfile *profile, QObject *parent = 0);
BrowserMainWindow *mainWindow();
protected:
@@ -94,6 +94,7 @@ class WebView : public QWebEngineView {
public:
WebView(QWidget *parent = 0);
WebPage *webPage() const { return m_page; }
+ void setPage(WebPage *page);
void loadUrl(const QUrl &url);
QUrl url() const;
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp
index 3fa0f672d..7f285b1e5 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -78,7 +78,7 @@ bool BrowserContextQt::IsOffTheRecord() const
net::URLRequestContextGetter *BrowserContextQt::GetRequestContext()
{
- return GetDefaultStoragePartition(this)->GetURLRequestContext();
+ return url_request_getter_.get();
}
net::URLRequestContextGetter *BrowserContextQt::GetRequestContextForRenderProcess(int)
@@ -137,7 +137,6 @@ content::SSLHostStateDelegate* BrowserContextQt::GetSSLHostStateDelegate()
net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers)
{
url_request_getter_ = new URLRequestContextGetterQt(m_adapter, protocol_handlers);
- static_cast<ResourceContextQt*>(GetResourceContext())->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get();
}
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index a0d640c18..91b14003c 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -3,13 +3,11 @@ GYP_ARGS += "-D qt_os=\"embedded_linux\" -I config/embedded_linux.gypi"
GYP_CONFIG += \
build_ffmpegsumo=1 \
clang=0 \
- configuration_policy=0 \
desktop_linux=0 \
disable_nacl=1 \
embedded=1 \
enable_autofill_dialog=0 \
enable_automation=0 \
- enable_background=0 \
enable_captive_portal_detection=0 \
enable_extensions=0 \
enable_google_now=0 \
@@ -30,7 +28,6 @@ GYP_CONFIG += \
ozone_platform_test=0 \
p2p_apis=0 \
safe_browsing=0 \
- toolkit_uses_gtk=0 \
toolkit_views=1 \
use_ash=0 \
use_aura=1 \
@@ -46,11 +43,11 @@ GYP_CONFIG += \
use_openssl=1 \
use_ozone=1 \
use_pango=0 \
- use_pulseaudio=0 \
- use_system_harfbuzz=0 \
use_system_icu=1 \
icu_use_data_file_flag=0 \
use_x11=0 \
v8_use_snapshot=false \
want_separate_host_toolset=1 \
+contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
+!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0
diff --git a/src/core/resource_context_qt.cpp b/src/core/resource_context_qt.cpp
index acd8ba4b9..715d92aa2 100644
--- a/src/core/resource_context_qt.cpp
+++ b/src/core/resource_context_qt.cpp
@@ -44,20 +44,13 @@ namespace QtWebEngineCore {
net::HostResolver *ResourceContextQt::GetHostResolver()
{
- CHECK(getter_);
- return getter_->GetURLRequestContext()->host_resolver();
+ return GetRequestContext()->host_resolver();
}
net::URLRequestContext* ResourceContextQt::GetRequestContext()
{
- if (getter_)
- return getter_->GetURLRequestContext();
+ Q_ASSERT(context);
return context->GetRequestContext()->GetURLRequestContext();
}
-void ResourceContextQt::set_url_request_context_getter(net::URLRequestContextGetter *getter)
-{
- getter_ = getter;
-}
-
} // namespace QtWebEngineCore
diff --git a/src/core/resource_context_qt.h b/src/core/resource_context_qt.h
index 48dc3d583..22bceb8e7 100644
--- a/src/core/resource_context_qt.h
+++ b/src/core/resource_context_qt.h
@@ -55,18 +55,13 @@ class ResourceContextQt : public content::ResourceContext
public:
ResourceContextQt(BrowserContextQt *ctx)
: context(ctx)
- , getter_(0)
{}
virtual net::HostResolver* GetHostResolver() Q_DECL_OVERRIDE;
virtual net::URLRequestContext* GetRequestContext() Q_DECL_OVERRIDE;
-
- void set_url_request_context_getter(net::URLRequestContextGetter* getter);
-
private:
BrowserContextQt *context;
- net::URLRequestContextGetter* getter_;
DISALLOW_COPY_AND_ASSIGN(ResourceContextQt);
};
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index 0b8aaf9ba..cd71b6900 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -117,6 +117,18 @@ bool URLRequestCustomJob::GetCharset(std::string* charset)
return false;
}
+bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ QMutexLocker lock(&m_mutex);
+ if (m_redirect.is_valid()) {
+ *location = m_redirect;
+ *http_status_code = 303;
+ return true;
+ }
+ return false;
+}
+
void URLRequestCustomJob::setReplyMimeType(const std::string &mimeType)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -158,6 +170,36 @@ bool URLRequestCustomJob::ReadRawData(IOBuffer *buf, int bufSize, int *bytesRead
return false;
}
+void URLRequestCustomJob::redirect(const GURL &url)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (m_device || m_error)
+ return;
+
+ QMutexLocker lock(&m_mutex);
+ m_redirect = url;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactory.GetWeakPtr()));
+}
+
+void URLRequestCustomJob::abort()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ QMutexLocker lock(&m_mutex);
+ if (m_device && m_device->isOpen())
+ m_device->close();
+ m_device = 0;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactory.GetWeakPtr()));
+}
+
+void URLRequestCustomJob::notifyCanceled()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ if (m_started)
+ NotifyDone(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
+ else
+ NotifyStartError(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
+}
+
void URLRequestCustomJob::notifyStarted()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h
index ca20c719d..4975e71d2 100644
--- a/src/core/url_request_custom_job.h
+++ b/src/core/url_request_custom_job.h
@@ -60,18 +60,22 @@ public:
virtual bool ReadRawData(net::IOBuffer *buf, int bufSize, int *bytesRead) Q_DECL_OVERRIDE;
virtual bool GetMimeType(std::string *mimeType) const Q_DECL_OVERRIDE;
virtual bool GetCharset(std::string *charset) Q_DECL_OVERRIDE;
+ virtual bool IsRedirectResponse(GURL* location, int* http_status_code) Q_DECL_OVERRIDE;
void setReplyMimeType(const std::string &);
void setReplyCharset(const std::string &);
void setReplyDevice(QIODevice *);
+ void redirect(const GURL &url);
void fail(int);
+ void abort();
protected:
virtual ~URLRequestCustomJob();
void startAsync();
void notifyStarted();
void notifyFailure();
+ void notifyCanceled();
private:
QMutex m_mutex;
@@ -81,6 +85,7 @@ private:
std::string m_mimeType;
std::string m_charset;
int m_error;
+ GURL m_redirect;
bool m_started;
base::WeakPtrFactory<URLRequestCustomJob> m_weakFactory;
diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp
index d324da347..caf7a0e3e 100644
--- a/src/core/url_request_custom_job_delegate.cpp
+++ b/src/core/url_request_custom_job_delegate.cpp
@@ -38,6 +38,7 @@
#include "url_request_custom_job_delegate.h"
#include "type_conversion.h"
+#include "net/base/net_errors.h"
#include <QByteArray>
@@ -63,4 +64,40 @@ void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODev
m_job->setReplyDevice(device);
}
+void URLRequestCustomJobDelegate::abort()
+{
+ m_job->abort();
+}
+
+void URLRequestCustomJobDelegate::redirect(const QUrl &url)
+{
+ m_job->redirect(toGurl(url));
+}
+
+void URLRequestCustomJobDelegate::fail(Error error)
+{
+ int net_error = 0;
+ switch (error) {
+ case NoError:
+ break;
+ case UrlInvalid:
+ net_error = net::ERR_INVALID_URL;
+ break;
+ case UrlNotFound:
+ net_error = net::ERR_FILE_NOT_FOUND;
+ break;
+ case RequestAborted:
+ net_error = net::ERR_ABORTED;
+ break;
+ case RequestDenied:
+ net_error = net::ERR_ACCESS_DENIED;
+ break;
+ case RequestFailed:
+ net_error = net::ERR_FAILED;
+ break;
+ }
+ if (net_error)
+ m_job->fail(net_error);
+}
+
} // namespace
diff --git a/src/core/url_request_custom_job_delegate.h b/src/core/url_request_custom_job_delegate.h
index e0b802897..580149ecf 100644
--- a/src/core/url_request_custom_job_delegate.h
+++ b/src/core/url_request_custom_job_delegate.h
@@ -53,9 +53,22 @@ class QWEBENGINE_EXPORT URLRequestCustomJobDelegate : public QObject {
public:
~URLRequestCustomJobDelegate();
+ enum Error {
+ NoError = 0,
+ UrlNotFound,
+ UrlInvalid,
+ RequestAborted,
+ RequestDenied,
+ RequestFailed
+ };
+
QUrl url() const;
void setReply(const QByteArray &contentType, QIODevice *device);
+ void redirect(const QUrl& url);
+ void abort();
+
+ void fail(Error);
private:
URLRequestCustomJobDelegate(URLRequestCustomJob *job);
diff --git a/src/webengine/ui/AlertDialog.qml b/src/webengine/ui/AlertDialog.qml
index be74dc000..998c953cb 100644
--- a/src/webengine/ui/AlertDialog.qml
+++ b/src/webengine/ui/AlertDialog.qml
@@ -34,7 +34,7 @@
**
****************************************************************************/
-import QtQuick.Dialogs 1.1
+import QtQuick.Dialogs 1.2
MessageDialog {
icon: StandardIcon.Information
diff --git a/src/webengine/ui/Menu.qml b/src/webengine/ui/Menu.qml
index 7cc58f947..e6fec297f 100644
--- a/src/webengine/ui/Menu.qml
+++ b/src/webengine/ui/Menu.qml
@@ -34,12 +34,12 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtQuick.Controls 1.0 as Controls
+import QtQuick 2.5
+import QtQuick.Controls 1.4 as Controls
Controls.Menu {
signal done()
// Use private API for now
- on__MenuClosed: done();
+ onAboutToHide: done();
}
diff --git a/src/webengine/ui/MenuItem.qml b/src/webengine/ui/MenuItem.qml
index 2b17b6e27..7ed5bef41 100644
--- a/src/webengine/ui/MenuItem.qml
+++ b/src/webengine/ui/MenuItem.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtQuick.Controls 1.0 as Controls
+import QtQuick 2.5
+import QtQuick.Controls 1.4 as Controls
Controls.MenuItem { }
diff --git a/src/webengine/ui/MenuSeparator.qml b/src/webengine/ui/MenuSeparator.qml
index 2c1c2904f..115068870 100644
--- a/src/webengine/ui/MenuSeparator.qml
+++ b/src/webengine/ui/MenuSeparator.qml
@@ -34,7 +34,7 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtQuick.Controls 1.0 as Controls
+import QtQuick 2.5
+import QtQuick.Controls 1.4 as Controls
Controls.MenuSeparator { }
diff --git a/src/webengine/ui/MessageBubble.qml b/src/webengine/ui/MessageBubble.qml
index 4328eae40..17cf5b797 100644
--- a/src/webengine/ui/MessageBubble.qml
+++ b/src/webengine/ui/MessageBubble.qml
@@ -34,7 +34,7 @@
**
****************************************************************************/
-import QtQuick 2.1
+import QtQuick 2.5
Item {
id: bubble
diff --git a/src/webengine/ui/PromptDialog.qml b/src/webengine/ui/PromptDialog.qml
index 9ac2b9dc2..fb0881320 100644
--- a/src/webengine/ui/PromptDialog.qml
+++ b/src/webengine/ui/PromptDialog.qml
@@ -35,9 +35,9 @@
****************************************************************************/
// FIXME: prompt missing in Qt Quick Dialogs atm. Make our own for now.
-import QtQuick.Controls 1.1
+import QtQuick.Controls 1.4
import QtQuick.Layouts 1.0
-import QtQuick 2.0
+import QtQuick 2.5
ApplicationWindow {
signal input(string text);
diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
index 323cdcc72..4a813236c 100644
--- a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
+++ b/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
@@ -40,6 +40,8 @@
#include "url_request_custom_job_delegate.h"
+using QtWebEngineCore::URLRequestCustomJobDelegate;
+
QT_BEGIN_NAMESPACE
/*!
@@ -51,7 +53,7 @@ QT_BEGIN_NAMESPACE
A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must
be handled by the derived implementations of class.
- A job can be handled by calling setReply().
+ A job can be handled by calling either setReply(), redirect() or setError().
The class is owned by QtWebEngine and does not need to be deleted. Note QtWebEngine may delete
the job when it is no longer needed, so the signal QObject::destroyed() must be monitored if
@@ -63,7 +65,7 @@ QT_BEGIN_NAMESPACE
/*!
\internal
*/
-QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate * p)
+QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(URLRequestCustomJobDelegate * p)
: QObject(p) // owned by the jobdelegate and deleted when the job is done
, d_ptr(p)
{
@@ -92,6 +94,20 @@ void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice
d_ptr->setReply(contentType, device);
}
+/*!
+ Fails the request with error \a error.
+ */
+void QWebEngineUrlRequestJob::setError(Error r)
+{
+ d_ptr->fail((URLRequestCustomJobDelegate::Error)r);
+}
+/*!
+ Tell the request is redirected to \a url.
+ */
+void QWebEngineUrlRequestJob::setRedirect(const QUrl &url)
+{
+ d_ptr->redirect(url);
+}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h b/src/webenginewidgets/api/qwebengineurlrequestjob_p.h
index 72c9dc836..e496e4051 100644
--- a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h
+++ b/src/webenginewidgets/api/qwebengineurlrequestjob_p.h
@@ -56,8 +56,19 @@ class QWEBENGINEWIDGETS_EXPORT QWebEngineUrlRequestJob : public QObject {
public:
~QWebEngineUrlRequestJob();
+ enum Error {
+ NoError = 0,
+ UrlNotFound,
+ UrlInvalid,
+ RequestAborted,
+ RequestDenied,
+ RequestFailed
+ };
+
QUrl requestUrl() const;
void setReply(const QByteArray &contentType, QIODevice *device);
+ void setError(Error error);
+ void setRedirect(const QUrl &url);
private:
QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *);