summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index c8bb10fd6..0f2f21f83 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1372,20 +1372,40 @@ void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, P
m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed);
}
-void WebContentsAdapter::grantMouseLockPermission(bool granted)
+void WebContentsAdapter::grantMouseLockPermission(const QUrl &securityOrigin, bool granted)
{
CHECK_INITIALIZED();
+ if (securityOrigin != toQt(m_webContents->GetLastCommittedURL().GetOrigin()))
+ return;
if (granted) {
- if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
rwhv->Focus();
- else
+ if (!rwhv->HasFocus()) {
+ // We tried to activate our RWHVQtDelegate, but we failed. This probably means that
+ // the permission was granted from a modal dialog and the windowing system is not ready
+ // to set focus on the originating view. Since pointer lock strongly requires it, we just
+ // wait until the next FocusIn event.
+ m_pendingMouseLockPermissions.insert(securityOrigin, granted);
+ return;
+ }
+ } else
granted = false;
}
m_webContents->GotResponseToLockMouseRequest(granted);
}
+void WebContentsAdapter::handlePendingMouseLockPermission()
+{
+ CHECK_INITIALIZED();
+ auto it = m_pendingMouseLockPermissions.find(toQt(m_webContents->GetLastCommittedURL().GetOrigin()));
+ if (it != m_pendingMouseLockPermissions.end()) {
+ m_webContents->GotResponseToLockMouseRequest(it.value());
+ m_pendingMouseLockPermissions.erase(it);
+ }
+}
+
void WebContentsAdapter::setBackgroundColor(const QColor &color)
{
CHECK_INITIALIZED();