diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/api/qwebengineurlrequestinfo.cpp | 8 | ||||
-rw-r--r-- | src/core/file_picker_controller.cpp | 17 | ||||
-rw-r--r-- | src/core/file_picker_controller.h | 8 | ||||
-rw-r--r-- | src/core/javascript_dialog_manager_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 1 | ||||
-rw-r--r-- | src/core/url_request_context_getter_qt.cpp | 7 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 78 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 5 | ||||
-rw-r--r-- | src/core/web_contents_adapter_p.h | 5 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 2 |
10 files changed, 52 insertions, 81 deletions
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp index a3806fc63..877b376b0 100644 --- a/src/core/api/qwebengineurlrequestinfo.cpp +++ b/src/core/api/qwebengineurlrequestinfo.cpp @@ -96,7 +96,7 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q interceptor on the profile enables intercepting, blocking, and modifying URL requests before they reach the networking stack of Chromium. - \sa QWebEngineUrlRequestInterceptor::interceptRequest, QWebEngineUrlRequestInfo + \sa interceptRequest(), QWebEngineUrlRequestInfo */ /*! @@ -115,7 +115,7 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q \a info contains the information about the URL request and will track internally whether its members have been altered. - \sa QWebEngineProfile::setRequestInterceptor + \sa QWebEngineProfile::setRequestInterceptor() */ @@ -183,7 +183,7 @@ QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPriva /*! Returns the resource type of the request. - \sa QWebEngineUrlRequestInfo::ResourceType + \sa ResourceType */ QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() const @@ -208,7 +208,7 @@ QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() /*! Returns the navigation type of the request. - \sa QWebEngineUrlRequestInfo::NavigationType + \sa NavigationType */ QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationType() const diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index 74b097ef6..158ff7f67 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -49,18 +49,18 @@ namespace QtWebEngineCore { -FilePickerController::FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject *parent) +FilePickerController::FilePickerController(FileChooserMode mode, content::RenderFrameHost *frameHost, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject *parent) : QObject(parent) , m_defaultFileName(defaultFileName) , m_acceptedMimeTypes(acceptedMimeTypes) - , m_contents(contents) + , m_frameHost(frameHost) , m_mode(mode) { } void FilePickerController::accepted(const QStringList &files) { - FilePickerController::filesSelectedInChooser(files, m_contents); + FilePickerController::filesSelectedInChooser(files, m_frameHost); } void FilePickerController::accepted(const QVariant &files) @@ -76,12 +76,12 @@ void FilePickerController::accepted(const QVariant &files) qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName()); } - FilePickerController::filesSelectedInChooser(stringList, m_contents); + FilePickerController::filesSelectedInChooser(stringList, m_frameHost); } void FilePickerController::rejected() { - FilePickerController::filesSelectedInChooser(QStringList(), m_contents); + FilePickerController::filesSelectedInChooser(QStringList(), m_frameHost); } static QStringList listRecursively(const QDir &dir) @@ -103,15 +103,14 @@ ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, content::FileChooserParam ASSERT_ENUMS_MATCH(FilePickerController::UploadFolder, content::FileChooserParams::UploadFolder) ASSERT_ENUMS_MATCH(FilePickerController::Save, content::FileChooserParams::Save) -void FilePickerController::filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents) +void FilePickerController::filesSelectedInChooser(const QStringList &filesList, content::RenderFrameHost *frameHost) { - content::RenderViewHost *rvh = contents->GetRenderViewHost(); - Q_ASSERT(rvh); + Q_ASSERT(frameHost); QStringList files(filesList); if (this->m_mode == UploadFolder && !filesList.isEmpty() && QFileInfo(filesList.first()).isDir()) // Enumerate the directory files = listRecursively(QDir(filesList.first())); - rvh->GetMainFrame()->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(this->m_mode)); + frameHost->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(this->m_mode)); } QStringList FilePickerController::acceptedMimeTypes() const diff --git a/src/core/file_picker_controller.h b/src/core/file_picker_controller.h index 14e8de42d..66f28c3fc 100644 --- a/src/core/file_picker_controller.h +++ b/src/core/file_picker_controller.h @@ -45,7 +45,7 @@ #include <QStringList> namespace content { - class WebContents; + class RenderFrameHost; } namespace QtWebEngineCore { @@ -60,7 +60,7 @@ public: Save }; - FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject * = 0); + FilePickerController(FileChooserMode mode, content::RenderFrameHost *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject * = 0); QStringList acceptedMimeTypes() const; QString defaultFileName() const; FileChooserMode mode() const; @@ -71,10 +71,10 @@ public Q_SLOTS: void rejected(); private: - void filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents); + void filesSelectedInChooser(const QStringList &filesList, content::RenderFrameHost *contents); QString m_defaultFileName; QStringList m_acceptedMimeTypes; - content::WebContents *m_contents; + content::RenderFrameHost *m_frameHost; FileChooserMode m_mode; }; diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp index 2844dba5d..5fac12dd3 100644 --- a/src/core/javascript_dialog_manager_qt.cpp +++ b/src/core/javascript_dialog_manager_qt.cpp @@ -71,7 +71,7 @@ void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webCon void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, bool isReload, const content::JavaScriptDialogManager::DialogClosedCallback &callback) { Q_UNUSED(isReload); - runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString()/*toQt(messageText).toHtmlEscaped()*/, QString() , QUrl(), callback); + runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, QString(), QString(), QUrl(), callback); } bool JavaScriptDialogManagerQt::HandleJavaScriptDialog(content::WebContents *contents, bool accept, const base::string16 *promptOverride) diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 870b19eef..f1c69fca3 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -238,6 +238,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget , m_needsDelegatedFrameAck(false) , m_loadVisuallyCommittedState(NotCommitted) , m_adapterClient(0) + , m_currentInputType(ui::TEXT_INPUT_TYPE_NONE) , m_imeInProgress(false) , m_receivedEmptyImeText(false) , m_initPending(false) diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index cabf44ac6..635b7c2d0 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -268,6 +268,7 @@ void URLRequestContextGetterQt::updateCookieStore() if (m_contextInitialized && !m_updateAllStorage && !m_updateCookieStore) { m_updateCookieStore = true; + m_updateHttpCache = true; content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateCookieStore, this)); } @@ -337,6 +338,12 @@ void URLRequestContextGetterQt::generateCookieStore() const std::vector<std::string> cookieableSchemes(kCookieableSchemes, kCookieableSchemes + arraysize(kCookieableSchemes)); cookieMonster->SetCookieableSchemes(cookieableSchemes); m_cookieDelegate->setCookieMonster(cookieMonster); + + if (!m_updateAllStorage) { + Q_ASSERT(m_updateHttpCache); + // HttpCache needs to be regenerated when we generate a new channel id service + generateHttpCache(); + } } void URLRequestContextGetterQt::updateUserAgent() diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 384724736..7b0712143 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -87,8 +87,8 @@ #include <QPageLayout> #include <QStringList> #include <QStyleHints> -#include <QTimer> #include <QVariant> +#include <QtCore/qelapsedtimer.h> #include <QtCore/qmimedata.h> #include <QtGui/qaccessible.h> #include <QtGui/qdrag.h> @@ -349,8 +349,6 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate() , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd) , lastFindRequestId(0) , currentDropAction(blink::WebDragOperationNone) - , inDragUpdateLoop(false) - , updateDragCursorMessagePollingTimer(new QTimer) { } @@ -393,7 +391,6 @@ WebContentsAdapter::WebContentsAdapter(content::WebContents *webContents) { Q_D(WebContentsAdapter); d->webContents.reset(webContents); - initUpdateDragCursorMessagePollingTimer(); } WebContentsAdapter::~WebContentsAdapter() @@ -1295,50 +1292,42 @@ Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const Q d->lastDragScreenPos = toGfx(screenPos); rvh->DragTargetDragOver(d->lastDragClientPos, d->lastDragScreenPos, toWeb(e->possibleActions()), toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers())); - - base::MessageLoop *currentMessageLoop = base::MessageLoop::current(); - DCHECK(currentMessageLoop); - if (!currentMessageLoop->NestableTasksAllowed()) { - // We're already inside a MessageLoop::RunTask call, and scheduled tasks will not be - // executed. That means, updateDragAction will never be called, and the RunLoop below will - // remain blocked forever. - qWarning("WebContentsAdapter::updateDragPosition called from MessageLoop::RunTask."); - return Qt::IgnoreAction; - } - - // Wait until we get notified via RenderViewHostDelegateView::UpdateDragCursor. This calls - // WebContentsAdapter::updateDragAction that will eventually quit the nested loop. - base::RunLoop loop; - d->inDragUpdateLoop = true; - d->dragUpdateLoopQuitClosure = loop.QuitClosure(); - - d->updateDragCursorMessagePollingTimer->start(); - loop.Run(); - d->updateDragCursorMessagePollingTimer->stop(); - + waitForUpdateDragActionCalled(); return toQt(d->currentDropAction); } -void WebContentsAdapter::updateDragAction(int action) +void WebContentsAdapter::waitForUpdateDragActionCalled() { Q_D(WebContentsAdapter); - d->currentDropAction = static_cast<blink::WebDragOperation>(action); - finishDragUpdate(); + const qint64 timeout = 3000; + QElapsedTimer t; + t.start(); + base::MessagePump::Delegate *delegate = base::MessageLoop::current(); + DCHECK(delegate); + d->updateDragActionCalled = false; + for (;;) { + while (delegate->DoWork() && !d->updateDragActionCalled) {} + if (d->updateDragActionCalled) + break; + if (t.hasExpired(timeout)) { + qWarning("WebContentsAdapter::updateDragAction was not called within %d ms.", + static_cast<int>(timeout)); + return; + } + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); + } } -void WebContentsAdapter::finishDragUpdate() +void WebContentsAdapter::updateDragAction(int action) { Q_D(WebContentsAdapter); - if (d->inDragUpdateLoop) { - d->dragUpdateLoopQuitClosure.Run(); - d->inDragUpdateLoop = false; - } + d->updateDragActionCalled = true; + d->currentDropAction = static_cast<blink::WebDragOperation>(action); } void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &screenPos) { Q_D(WebContentsAdapter); - finishDragUpdate(); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->FilterDropData(d->currentDropData.get()); d->lastDragClientPos = toGfx(clientPos); @@ -1350,32 +1339,11 @@ void WebContentsAdapter::endDragging(const QPoint &clientPos, const QPoint &scre void WebContentsAdapter::leaveDrag() { Q_D(WebContentsAdapter); - finishDragUpdate(); content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); rvh->DragTargetDragLeave(); d->currentDropData.reset(); } -void WebContentsAdapter::initUpdateDragCursorMessagePollingTimer() -{ - Q_D(WebContentsAdapter); - // Poll for drag cursor updated message 60 times per second. In practice, the timer is fired - // at most twice, after which it is stopped. - d->updateDragCursorMessagePollingTimer->setInterval(16); - d->updateDragCursorMessagePollingTimer->setSingleShot(false); - - QObject::connect(d->updateDragCursorMessagePollingTimer.data(), &QTimer::timeout, [](){ - base::MessagePump::Delegate *delegate = base::MessageLoop::current(); - DCHECK(delegate); - - // Execute Chromium tasks if there are any present. Specifically we are interested to handle - // the RenderViewHostImpl::OnUpdateDragCursor message, that gets sent from the render - // process. - while (delegate->DoWork()) {} - }); -} - - void WebContentsAdapter::replaceMisspelling(const QString &word) { #if defined(ENABLE_SPELLCHECK) diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 0accd3be5..10c65a6cb 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -169,10 +169,8 @@ public: void enterDrag(QDragEnterEvent *e, const QPoint &screenPos); Qt::DropAction updateDragPosition(QDragMoveEvent *e, const QPoint &screenPos); void updateDragAction(int action); - void finishDragUpdate(); void endDragging(const QPoint &clientPos, const QPoint &screenPos); void leaveDrag(); - void initUpdateDragCursorMessagePollingTimer(); void printToPDF(const QPageLayout&, const QString&); quint64 printToPDFCallbackResult(const QPageLayout &, const bool colorMode = true); @@ -188,8 +186,9 @@ public: private: Q_DISABLE_COPY(WebContentsAdapter) Q_DECLARE_PRIVATE(WebContentsAdapter) - QScopedPointer<WebContentsAdapterPrivate> d_ptr; + void waitForUpdateDragActionCalled(); + QScopedPointer<WebContentsAdapterPrivate> d_ptr; }; } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h index 9503b4401..f24070523 100644 --- a/src/core/web_contents_adapter_p.h +++ b/src/core/web_contents_adapter_p.h @@ -61,7 +61,6 @@ #include <QScopedPointer> #include <QSharedPointer> -QT_FORWARD_DECLARE_CLASS(QTimer) QT_FORWARD_DECLARE_CLASS(QWebChannel) class WebEngineContext; @@ -96,11 +95,9 @@ public: int lastFindRequestId; std::unique_ptr<content::DropData> currentDropData; blink::WebDragOperation currentDropAction; - bool inDragUpdateLoop; + bool updateDragActionCalled; gfx::Point lastDragClientPos; gfx::Point lastDragScreenPos; - base::Closure dragUpdateLoopQuitClosure; - QScopedPointer<QTimer> updateDragCursorMessagePollingTimer; }; } // namespace QtWebEngineCore diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index c7ad844a8..fb32ea813 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -327,7 +327,7 @@ void WebContentsDelegateQt::RunFileChooser(content::RenderFrameHost *frameHost, acceptedMimeTypes.append(toQt(*it)); m_filePickerController.reset(new FilePickerController(static_cast<FilePickerController::FileChooserMode>(params.mode), - web_contents(), toQt(params.default_file_name.value()), acceptedMimeTypes)); + frameHost, toQt(params.default_file_name.value()), acceptedMimeTypes)); // Defer the call to not block base::MessageLoop::RunTask with modal dialogs. QTimer::singleShot(0, [this] () { |