browser(webkit): fix geolocation overrides (#12534)
This commit is contained in:
parent
d61862094e
commit
6c4c62b674
|
|
@ -1,2 +1,2 @@
|
||||||
1615
|
1616
|
||||||
Changed: dpino@igalia.com Fri Feb 25 23:35:55 HKT 2022
|
Changed: yurys@chromium.org Fri 04 Mar 2022 02:50:28 PM PST
|
||||||
|
|
|
||||||
|
|
@ -14665,10 +14665,10 @@ index 0000000000000000000000000000000000000000..d0e11ed81a6257c011df23d5870da740
|
||||||
+} // namespace WebKit
|
+} // namespace WebKit
|
||||||
diff --git a/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
|
diff --git a/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d071b4d371
|
index 0000000000000000000000000000000000000000..f9389996a68338891a6d8702ec302c98033d3fd5
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
|
+++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgent.cpp
|
||||||
@@ -0,0 +1,905 @@
|
@@ -0,0 +1,950 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (C) 2019 Microsoft Corporation.
|
+ * Copyright (C) 2019 Microsoft Corporation.
|
||||||
+ *
|
+ *
|
||||||
|
|
@ -14699,6 +14699,7 @@ index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d0
|
||||||
+
|
+
|
||||||
+#if ENABLE(REMOTE_INSPECTOR)
|
+#if ENABLE(REMOTE_INSPECTOR)
|
||||||
+
|
+
|
||||||
|
+#include "APIGeolocationProvider.h"
|
||||||
+#include "APIPageConfiguration.h"
|
+#include "APIPageConfiguration.h"
|
||||||
+#include "FrameInfoData.h"
|
+#include "FrameInfoData.h"
|
||||||
+#include "InspectorPlaywrightAgentClient.h"
|
+#include "InspectorPlaywrightAgentClient.h"
|
||||||
|
|
@ -14792,8 +14793,48 @@ index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d0
|
||||||
+ WebPageProxy& m_page;
|
+ WebPageProxy& m_page;
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
|
+class OverridenGeolocationProvider final : public API::GeolocationProvider {
|
||||||
|
+public:
|
||||||
|
+ explicit OverridenGeolocationProvider(BrowserContext* browserContext)
|
||||||
|
+ : m_position(WebGeolocationPosition::create(WebCore::GeolocationPositionData()))
|
||||||
|
+ , m_browserContext(browserContext)
|
||||||
|
+ {
|
||||||
|
+ m_browserContext->geolocationProvider = this;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ~OverridenGeolocationProvider() override {
|
||||||
|
+ m_browserContext->geolocationProvider = nullptr;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void setPosition(const Ref<WebGeolocationPosition>& position) {
|
||||||
|
+ m_position = position;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+private:
|
||||||
|
+ void startUpdating(WebGeolocationManagerProxy& proxy) override
|
||||||
|
+ {
|
||||||
|
+ proxy.providerDidChangePosition(&m_position.get());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void stopUpdating(WebGeolocationManagerProxy&) override
|
||||||
|
+ {
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ void setEnableHighAccuracy(WebGeolocationManagerProxy&, bool enabled) override
|
||||||
|
+ {
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Ref<WebGeolocationPosition> m_position;
|
||||||
|
+ BrowserContext* m_browserContext;
|
||||||
|
+};
|
||||||
|
+
|
||||||
+namespace {
|
+namespace {
|
||||||
+
|
+
|
||||||
|
+void setGeolocationProvider(BrowserContext* browserContext) {
|
||||||
|
+ auto* geoManager = browserContext->processPool->supplement<WebGeolocationManagerProxy>();
|
||||||
|
+ geoManager->setProvider(makeUnique<OverridenGeolocationProvider>(browserContext));
|
||||||
|
+}
|
||||||
|
+
|
||||||
+String toBrowserContextIDProtocolString(const PAL::SessionID& sessionID)
|
+String toBrowserContextIDProtocolString(const PAL::SessionID& sessionID)
|
||||||
+{
|
+{
|
||||||
+ StringBuilder builder;
|
+ StringBuilder builder;
|
||||||
|
|
@ -15104,6 +15145,7 @@ index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d0
|
||||||
+ m_defaultContext = context.get();
|
+ m_defaultContext = context.get();
|
||||||
+ context->processPool = WebProcessPool::allProcessPools().first().ptr();
|
+ context->processPool = WebProcessPool::allProcessPools().first().ptr();
|
||||||
+ context->dataStore = defaultDataStore;
|
+ context->dataStore = defaultDataStore;
|
||||||
|
+ setGeolocationProvider(context.get());
|
||||||
+ // Add default context to the map so that we can easily find it for
|
+ // Add default context to the map so that we can easily find it for
|
||||||
+ // created/deleted pages.
|
+ // created/deleted pages.
|
||||||
+ PAL::SessionID sessionID = context->dataStore->sessionID();
|
+ PAL::SessionID sessionID = context->dataStore->sessionID();
|
||||||
|
|
@ -15198,7 +15240,7 @@ index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d0
|
||||||
+ // Ensure network process.
|
+ // Ensure network process.
|
||||||
+ browserContext->dataStore->networkProcess();
|
+ browserContext->dataStore->networkProcess();
|
||||||
+ browserContext->dataStore->setDownloadInstrumentation(this);
|
+ browserContext->dataStore->setDownloadInstrumentation(this);
|
||||||
+
|
+ setGeolocationProvider(browserContext.get());
|
||||||
+ PAL::SessionID sessionID = browserContext->dataStore->sessionID();
|
+ PAL::SessionID sessionID = browserContext->dataStore->sessionID();
|
||||||
+ String browserContextID = toBrowserContextIDProtocolString(sessionID);
|
+ String browserContextID = toBrowserContextIDProtocolString(sessionID);
|
||||||
+ m_browserContexts.set(browserContextID, WTFMove(browserContext));
|
+ m_browserContexts.set(browserContextID, WTFMove(browserContext));
|
||||||
|
|
@ -15501,6 +15543,9 @@ index 0000000000000000000000000000000000000000..653b372feb40867fd68f3934f38072d0
|
||||||
+ return makeUnexpected("Invalid geolocation format"_s);
|
+ return makeUnexpected("Invalid geolocation format"_s);
|
||||||
+
|
+
|
||||||
+ auto position = WebGeolocationPosition::create(WebCore::GeolocationPositionData(*timestamp, *latitude, *longitude, *accuracy));
|
+ auto position = WebGeolocationPosition::create(WebCore::GeolocationPositionData(*timestamp, *latitude, *longitude, *accuracy));
|
||||||
|
+ if (!browserContext->geolocationProvider)
|
||||||
|
+ return makeUnexpected("Internal error: geolocation provider has been destroyed."_s);
|
||||||
|
+ browserContext->geolocationProvider->setPosition(position);
|
||||||
+ geoManager->providerDidChangePosition(&position.get());
|
+ geoManager->providerDidChangePosition(&position.get());
|
||||||
+ } else {
|
+ } else {
|
||||||
+ geoManager->providerDidFailToDeterminePosition("Position unavailable"_s);
|
+ geoManager->providerDidFailToDeterminePosition("Position unavailable"_s);
|
||||||
|
|
@ -15708,10 +15753,10 @@ index 0000000000000000000000000000000000000000..27e1bf3c7fd32d676a09605604936fa5
|
||||||
+#endif // ENABLE(REMOTE_INSPECTOR)
|
+#endif // ENABLE(REMOTE_INSPECTOR)
|
||||||
diff --git a/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
|
diff --git a/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..11c8eadafca764aa549cb27c24967e15e6975774
|
index 0000000000000000000000000000000000000000..c3ff5fb7028a03fd697fe78e3f92ef9e2527037d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
|
+++ b/Source/WebKit/UIProcess/InspectorPlaywrightAgentClient.h
|
||||||
@@ -0,0 +1,66 @@
|
@@ -0,0 +1,68 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Copyright (C) 2019 Microsoft Corporation.
|
+ * Copyright (C) 2019 Microsoft Corporation.
|
||||||
+ *
|
+ *
|
||||||
|
|
@ -15750,6 +15795,7 @@ index 0000000000000000000000000000000000000000..11c8eadafca764aa549cb27c24967e15
|
||||||
+
|
+
|
||||||
+namespace WebKit {
|
+namespace WebKit {
|
||||||
+
|
+
|
||||||
|
+class OverridenGeolocationProvider;
|
||||||
+class WebsiteDataStore;
|
+class WebsiteDataStore;
|
||||||
+class WebPageProxy;
|
+class WebPageProxy;
|
||||||
+class WebProcessPool;
|
+class WebProcessPool;
|
||||||
|
|
@ -15764,6 +15810,7 @@ index 0000000000000000000000000000000000000000..11c8eadafca764aa549cb27c24967e15
|
||||||
+ RefPtr<WebsiteDataStore> dataStore;
|
+ RefPtr<WebsiteDataStore> dataStore;
|
||||||
+ RefPtr<WebProcessPool> processPool;
|
+ RefPtr<WebProcessPool> processPool;
|
||||||
+ HashSet<WebPageProxy*> pages;
|
+ HashSet<WebPageProxy*> pages;
|
||||||
|
+ OverridenGeolocationProvider* geolocationProvider { nullptr };
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
+class InspectorPlaywrightAgentClient {
|
+class InspectorPlaywrightAgentClient {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue