summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/content_browser_client_qt.cpp14
-rw-r--r--src/core/content_browser_client_qt.h4
-rw-r--r--src/core/web_contents_delegate_qt.cpp22
-rw-r--r--src/core/web_contents_delegate_qt.h8
4 files changed, 36 insertions, 12 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index c83b28c1a..d9f7e31be 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -399,7 +399,6 @@ void ContentBrowserClientQt::RequestPermission(content::PermissionType permissio
const base::Callback<void(bool)>& result_callback)
{
Q_UNUSED(bridge_id);
- Q_UNUSED(requesting_frame);
Q_UNUSED(user_gesture);
WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
Q_ASSERT(contentsDelegate);
@@ -409,6 +408,19 @@ void ContentBrowserClientQt::RequestPermission(content::PermissionType permissio
result_callback.Run(false);
}
+
+void ContentBrowserClientQt::CancelPermissionRequest(content::PermissionType permission,
+ content::WebContents* web_contents,
+ int bridge_id,
+ const GURL& requesting_frame)
+{
+ Q_UNUSED(bridge_id);
+ WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
+ Q_ASSERT(contentsDelegate);
+ if (permission == content::PERMISSION_GEOLOCATION)
+ contentsDelegate->cancelGeolocationPermissionRequest(requesting_frame);
+}
+
blink::WebNotificationPermission ContentBrowserClientQt::CheckDesktopNotificationPermission(const GURL&, content::ResourceContext *, int )
{
return blink::WebNotificationPermission::WebNotificationPermissionDenied;
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 4862ca704..42ee25907 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -102,6 +102,10 @@ public:
const GURL& requesting_frame,
bool user_gesture,
const base::Callback<void(bool)>& result_callback) Q_DECL_OVERRIDE;
+ virtual void CancelPermissionRequest(content::PermissionType permission,
+ content::WebContents* web_contents,
+ int bridge_id,
+ const GURL& requesting_frame) Q_DECL_OVERRIDE;
content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 41bcfe609..d24b8a2cd 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -312,15 +312,25 @@ void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<Certifica
m_viewClient->allowCertificateError(errorController);
}
-void WebContentsDelegateQt::requestGeolocationPermission(const GURL &requestingFrameOrigin, base::Callback<void (bool)> resultCallback)
+void WebContentsDelegateQt::requestGeolocationPermission(const GURL &requestingFrameOrigin, const base::Callback<void (bool)> &resultCallback)
{
- m_lastGeolocationPermissionRequest.url = toQt(requestingFrameOrigin);
- m_lastGeolocationPermissionRequest.callback = resultCallback;
- m_viewClient->runGeolocationPermissionRequest(m_lastGeolocationPermissionRequest.url);
+ QUrl url = toQt(requestingFrameOrigin);
+ bool newRequest = !m_geolocationPermissionRequests.contains(url);
+ m_geolocationPermissionRequests[url] = resultCallback;
+ if (newRequest)
+ m_viewClient->runGeolocationPermissionRequest(url);
+}
+
+void WebContentsDelegateQt::cancelGeolocationPermissionRequest(const GURL &requestingFrameOrigin)
+{
+ m_geolocationPermissionRequests.remove(toQt(requestingFrameOrigin));
+ // FIXME: Tell the API layer to cancel the permission request?
}
void WebContentsDelegateQt::geolocationPermissionReply(const QUrl &origin, bool permission)
{
- if (m_lastGeolocationPermissionRequest.url == origin)
- m_lastGeolocationPermissionRequest.callback.Run(permission);
+ if (m_geolocationPermissionRequests.contains(origin)) {
+ m_geolocationPermissionRequests[origin].Run(permission);
+ m_geolocationPermissionRequests.remove(origin);
+ }
}
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 324a191fb..cb006106e 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -92,16 +92,14 @@ public:
void overrideWebPreferences(content::WebContents *, content::WebPreferences*);
void allowCertificateError(const QSharedPointer<CertificateErrorController> &) ;
- void requestGeolocationPermission(const GURL &requestingFrameOrigin, base::Callback<void (bool)> resultCallback);
+ void requestGeolocationPermission(const GURL &requestingFrameOrigin, const base::Callback<void (bool)> &resultCallback);
+ void cancelGeolocationPermissionRequest(const GURL &requestingFrameOrigin);
void geolocationPermissionReply(const QUrl&, bool permission);
private:
WebContentsAdapter *createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
- struct {
- QUrl url;
- base::Callback<void (bool)> callback;
- } m_lastGeolocationPermissionRequest;
+ QHash<QUrl, base::Callback<void (bool)> > m_geolocationPermissionRequests;
WebContentsAdapterClient *m_viewClient;
QString m_lastSearchedString;