summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-30 16:01:24 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-03-01 12:06:32 +0000
commita6e3b9113ba28fee9f705bb93cddaadfec43a917 (patch)
tree624d9f2463e3a641e757c054a502b6a5e6fb3f15 /src/core
parent70d3a577aeefb298df97028acc7018b745116e98 (diff)
GeoLocation adaptations for Chromium 55
Restructures geolocation classes to fit new code Change-Id: Ic370bd4cef4ba3f7c98931761d180fccd0b82cb7 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/content_browser_client_qt.cpp66
-rw-r--r--src/core/content_browser_client_qt.h1
-rw-r--r--src/core/location_provider_qt.cpp30
-rw-r--r--src/core/location_provider_qt.h23
4 files changed, 53 insertions, 67 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 71e83a578..e305a4259 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -51,7 +51,6 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/geolocation_delegate.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/media_observer.h"
#include "content/public/browser/quota_permission_context.h"
@@ -63,6 +62,8 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h"
+#include "device/geolocation/geolocation_delegate.h"
+#include "device/geolocation/geolocation_provider.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/screen.h"
#include "ui/gl/gl_context.h"
@@ -230,7 +231,29 @@ std::unique_ptr<base::MessagePump> messagePumpFactory()
return base::WrapUnique(new MessagePumpForUIQt);
}
-} // namespace
+// A provider of services needed by Geolocation.
+class GeolocationDelegateQt : public device::GeolocationDelegate {
+public:
+ GeolocationDelegateQt() {}
+ scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final
+ {
+ return scoped_refptr<device::AccessTokenStore>(new AccessTokenStoreQt);
+ }
+
+ std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider() final
+ {
+#ifdef QT_USE_POSITIONING
+ return base::WrapUnique(new LocationProviderQt);
+#else
+ return nullptr;
+#endif
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(GeolocationDelegateQt);
+};
+
+} // anonymous namespace
class BrowserMainPartsQt : public content::BrowserMainParts
{
@@ -246,6 +269,7 @@ public:
void PreMainMessageLoopRun() Q_DECL_OVERRIDE
{
+ device::GeolocationProvider::SetGeolocationDelegate(new GeolocationDelegateQt());
}
void PostMainMessageLoopRun()
@@ -418,49 +442,11 @@ void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, c
static_cast<WebContentsDelegateQt*>(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs);
}
-namespace {
-
-// A provider of services needed by Geolocation.
-class GeolocationDelegateQt : public content::GeolocationDelegate {
-public:
- GeolocationDelegateQt() {}
- content::AccessTokenStore* CreateAccessTokenStore() final
- {
- return new AccessTokenStoreQt;
- }
-
- content::LocationProvider* OverrideSystemLocationProvider() final
- {
-#ifdef QT_USE_POSITIONING
- if (!m_location_provider)
- m_location_provider = base::WrapUnique(new LocationProviderQt);
- return m_location_provider.get();
-#else
- return nullptr;
-#endif
- }
-
-private:
-#ifdef QT_USE_POSITIONING
- std::unique_ptr<LocationProviderQt> m_location_provider;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(GeolocationDelegateQt);
-};
-
-} // anonymous namespace
-
-content::GeolocationDelegate *ContentBrowserClientQt::CreateGeolocationDelegate()
-{
- return new GeolocationDelegateQt;
-}
-
content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext()
{
return new QuotaPermissionContextQt;
}
-
void ContentBrowserClientQt::AllowCertificateError(content::WebContents *webContents,
int cert_error,
const net::SSLInfo& ssl_info,
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 86373e2b0..b20175439 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -87,7 +87,6 @@ public:
virtual void ResourceDispatcherHostCreated() Q_DECL_OVERRIDE;
virtual gl::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
virtual content::MediaObserver* GetMediaObserver() Q_DECL_OVERRIDE;
- virtual content::GeolocationDelegate* CreateGeolocationDelegate() Q_DECL_OVERRIDE;
virtual content::QuotaPermissionContext *CreateQuotaPermissionContext() Q_DECL_OVERRIDE;
virtual void OverrideWebkitPrefs(content::RenderViewHost *, content::WebPreferences *) Q_DECL_OVERRIDE;
virtual void AllowCertificateError(content::WebContents* web_contents,
diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp
index c07bd4b0c..a507f32d1 100644
--- a/src/core/location_provider_qt.cpp
+++ b/src/core/location_provider_qt.cpp
@@ -51,9 +51,9 @@
#include "base/bind.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "content/browser/geolocation/geolocation_provider_impl.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/geolocation_provider.h"
+#include "device/geolocation/geolocation_provider.h"
+#include "device/geolocation/geolocation_provider_impl.h"
namespace QtWebEngineCore {
@@ -161,8 +161,8 @@ void QtPositioningHelper::updatePosition(const QGeoPositionInfo &pos)
if (!pos.isValid())
return;
Q_ASSERT(m_positionInfoSource->error() == QGeoPositionInfoSource::NoError);
- content::Geoposition newPos;
- newPos.error_code = content::Geoposition::ERROR_CODE_NONE;
+ device::Geoposition newPos;
+ newPos.error_code = device::Geoposition::ERROR_CODE_NONE;
newPos.error_message.clear();
newPos.timestamp = toTime(pos.timestamp());
@@ -195,15 +195,15 @@ void QtPositioningHelper::updatePosition(const QGeoPositionInfo &pos)
void QtPositioningHelper::error(QGeoPositionInfoSource::Error positioningError)
{
Q_ASSERT(positioningError != QGeoPositionInfoSource::NoError);
- content::Geoposition newPos;
+ device::Geoposition newPos;
switch (positioningError) {
case QGeoPositionInfoSource::AccessError:
- newPos.error_code = content::Geoposition::ERROR_CODE_PERMISSION_DENIED;
+ newPos.error_code = device::Geoposition::ERROR_CODE_PERMISSION_DENIED;
break;
case QGeoPositionInfoSource::ClosedError:
case QGeoPositionInfoSource::UnknownSourceError: // position unavailable is as good as it gets in Geoposition
default:
- newPos.error_code = content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ newPos.error_code = device::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
break;
}
if (m_locationProvider)
@@ -212,18 +212,18 @@ void QtPositioningHelper::error(QGeoPositionInfoSource::Error positioningError)
void QtPositioningHelper::timeout()
{
- content::Geoposition newPos;
+ device::Geoposition newPos;
// content::Geoposition::ERROR_CODE_TIMEOUT is not handled properly in the renderer process, and the timeout
// argument used in JS never comes all the way to the browser process.
// Let's just treat it like any other error where the position is unavailable.
- newPos.error_code = content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ newPos.error_code = device::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
if (m_locationProvider)
postToLocationProvider(base::Bind(&LocationProviderQt::updatePosition, m_locationProviderFactory.GetWeakPtr(), newPos));
}
inline void QtPositioningHelper::postToLocationProvider(const base::Closure &task)
{
- static_cast<content::GeolocationProviderImpl*>(content::GeolocationProvider::GetInstance())->message_loop()->PostTask(FROM_HERE, task);
+ static_cast<device::GeolocationProviderImpl*>(device::GeolocationProvider::GetInstance())->task_runner()->PostTask(FROM_HERE, task);
}
LocationProviderQt::LocationProviderQt()
@@ -258,21 +258,21 @@ void LocationProviderQt::StopProvider()
QMetaObject::invokeMethod(m_positioningHelper, "stop", Qt::QueuedConnection);
}
-void LocationProviderQt::RequestRefresh()
+void LocationProviderQt::OnPermissionGranted()
{
if (m_positioningHelper)
QMetaObject::invokeMethod(m_positioningHelper, "refresh", Qt::QueuedConnection);
}
-void LocationProviderQt::OnPermissionGranted()
+void LocationProviderQt::SetUpdateCallback(const LocationProviderUpdateCallback& callback)
{
- RequestRefresh();
+ m_callback = callback;
}
-void LocationProviderQt::updatePosition(const content::Geoposition &position)
+void LocationProviderQt::updatePosition(const device::Geoposition &position)
{
m_lastKnownPosition = position;
- NotifyCallback(position);
+ m_callback.Run(this, position);
}
} // namespace QtWebEngineCore
diff --git a/src/core/location_provider_qt.h b/src/core/location_provider_qt.h
index b35dcddf9..b1ff354a0 100644
--- a/src/core/location_provider_qt.h
+++ b/src/core/location_provider_qt.h
@@ -42,8 +42,8 @@
#include <QtCore/qcompilerdetection.h>
-#include "content/browser/geolocation/location_provider_base.h"
-#include "content/public/common/geoposition.h"
+#include "device/geolocation/geoposition.h"
+#include "device/geolocation/location_provider.h"
QT_FORWARD_DECLARE_CLASS(QThread)
@@ -54,25 +54,26 @@ class MessageLoop;
namespace QtWebEngineCore {
class QtPositioningHelper;
-class LocationProviderQt : public content::LocationProviderBase
+class LocationProviderQt : public device::LocationProvider
{
public:
LocationProviderQt();
virtual ~LocationProviderQt();
- // LocationProviderBase
- virtual bool StartProvider(bool highAccuracy) Q_DECL_OVERRIDE;
- virtual void StopProvider() Q_DECL_OVERRIDE;
- virtual void GetPosition(content::Geoposition *position) Q_DECL_OVERRIDE { *position = m_lastKnownPosition; }
- virtual void RequestRefresh() Q_DECL_OVERRIDE;
- virtual void OnPermissionGranted() Q_DECL_OVERRIDE;
+ // LocationProvider
+ bool StartProvider(bool high_accuracy) override;
+ void StopProvider() override;
+ const device::Geoposition& GetPosition() override { return m_lastKnownPosition; }
+ void OnPermissionGranted() override;
+ void SetUpdateCallback(const LocationProviderUpdateCallback& callback) override;
private:
friend class QtPositioningHelper;
- void updatePosition(const content::Geoposition &);
+ void updatePosition(const device::Geoposition &);
- content::Geoposition m_lastKnownPosition;
+ device::Geoposition m_lastKnownPosition;
+ LocationProviderUpdateCallback m_callback;
QtPositioningHelper *m_positioningHelper;
};
//#define QT_USE_POSITIONING 1