summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-03-12 14:19:21 +0100
committerPierre Rossi <pierre.rossi@theqtcompany.com>2015-03-18 16:05:29 +0000
commitc2ea7b1babdb7748e08a1f2442f13abac357d194 (patch)
treebec21b22921b89e51ce1c5db11ae190d422de0b0
parenta8935efa82457dd8a137224371284776d7024f32 (diff)
Fix geolocation (and slight cleanup)
Cleanup is mostly to avoid tripping on an assert when calling GeolocationProvider::GetInstance() from outside the UI thread. Change-Id: Id9c964c1cf952a7c867e5154dd2c05e17733a842 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
-rw-r--r--src/core/content_browser_client_qt.cpp1
-rw-r--r--src/core/location_provider_qt.cpp11
-rw-r--r--src/core/location_provider_qt.h1
-rw-r--r--src/core/web_contents_delegate_qt.cpp7
4 files changed, 5 insertions, 15 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index b0badde99..a6a133271 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -69,7 +69,6 @@
#include "resource_dispatcher_host_delegate_qt.h"
#include "user_script_controller_host.h"
#include "web_contents_delegate_qt.h"
-#include "access_token_store_qt.h"
#include <QGuiApplication>
#include <QLocale>
diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp
index e33179412..d17fc3d21 100644
--- a/src/core/location_provider_qt.cpp
+++ b/src/core/location_provider_qt.cpp
@@ -188,7 +188,7 @@ void QtPositioningHelper::timeout()
inline void QtPositioningHelper::postToLocationProvider(const base::Closure &task)
{
- LocationProviderQt::messageLoop()->PostTask(FROM_HERE, task);
+ static_cast<content::GeolocationProviderImpl*>(content::GeolocationProvider::GetInstance())->message_loop()->PostTask(FROM_HERE, task);
}
LocationProviderQt::LocationProviderQt()
@@ -203,7 +203,6 @@ LocationProviderQt::~LocationProviderQt()
bool LocationProviderQt::StartProvider(bool highAccuracy)
{
- DCHECK(base::MessageLoop::current() == messageLoop());
QThread *guiThread = qApp->thread();
if (!m_positioningHelper) {
m_positioningHelper = new QtPositioningHelper(this);
@@ -216,7 +215,6 @@ bool LocationProviderQt::StartProvider(bool highAccuracy)
void LocationProviderQt::StopProvider()
{
- DCHECK(base::MessageLoop::current() == messageLoop());
if (m_positioningHelper)
BrowserThread::PostTask(BrowserThread::UI,FROM_HERE, base::Bind(&QtPositioningHelper::stop
, base::Unretained(m_positioningHelper)));
@@ -224,7 +222,6 @@ void LocationProviderQt::StopProvider()
void LocationProviderQt::RequestRefresh()
{
- DCHECK(base::MessageLoop::current() == messageLoop());
if (m_positioningHelper)
BrowserThread::PostTask(BrowserThread::UI,FROM_HERE, base::Bind(&QtPositioningHelper::refresh
, base::Unretained(m_positioningHelper)));
@@ -237,16 +234,10 @@ void LocationProviderQt::OnPermissionGranted()
void LocationProviderQt::updatePosition(const content::Geoposition &position)
{
- DCHECK(base::MessageLoop::current() == messageLoop());
m_lastKnownPosition = position;
NotifyCallback(position);
}
-base::MessageLoop *LocationProviderQt::messageLoop()
-{
- return static_cast<content::GeolocationProviderImpl*>(content::GeolocationProvider::GetInstance())->message_loop();
-}
-
} // namespace QtWebEngineCore
#include "location_provider_qt.moc"
diff --git a/src/core/location_provider_qt.h b/src/core/location_provider_qt.h
index 15b2e0520..66060479d 100644
--- a/src/core/location_provider_qt.h
+++ b/src/core/location_provider_qt.h
@@ -67,7 +67,6 @@ public:
private:
friend class QtPositioningHelper;
- static base::MessageLoop *messageLoop();
void updatePosition(const content::Geoposition &);
content::Geoposition m_lastKnownPosition;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 409514411..581a16adb 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -354,9 +354,10 @@ void WebContentsDelegateQt::cancelGeolocationPermissionRequest(const GURL &reque
void WebContentsDelegateQt::geolocationPermissionReply(const QUrl &origin, bool permission)
{
- if (m_geolocationPermissionRequests.contains(origin)) {
- m_geolocationPermissionRequests[origin].Run(permission);
- m_geolocationPermissionRequests.remove(origin);
+ auto it = m_geolocationPermissionRequests.find(origin);
+ if (it != m_geolocationPermissionRequests.end()) {
+ (*it).Run(permission);
+ m_geolocationPermissionRequests.erase(it);
}
}