From b352c97479f8fb0e05fc4d993d16129799c7dafd Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 19 Aug 2025 02:16:55 +0400 Subject: [PATCH] Switch from custom URI scheme to local HTTP server for webview on Linux --- Telegram/Resources/picker_html/picker.js | 4 ++-- .../SourceFiles/ui/controls/location_picker.cpp | 13 +------------ Telegram/lib_webview | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/picker_html/picker.js b/Telegram/Resources/picker_html/picker.js index e44fd51a95..628a224637 100644 --- a/Telegram/Resources/picker_html/picker.js +++ b/Telegram/Resources/picker_html/picker.js @@ -51,8 +51,8 @@ var LocationPicker = { }, init: function (params) { mapboxgl.accessToken = params.token; - if (params.protocol) { - mapboxgl.config.API_URL = params.protocol + '://domain/api.mapbox.com'; + if (location.hostname != 'desktop-app-resource') { + mapboxgl.config.API_URL = location.protocol + '//' + location.host + '/api.mapbox.com'; } var options = { container: 'map', config: { diff --git a/Telegram/SourceFiles/ui/controls/location_picker.cpp b/Telegram/SourceFiles/ui/controls/location_picker.cpp index 6d69efebd3..1ce682318e 100644 --- a/Telegram/SourceFiles/ui/controls/location_picker.cpp +++ b/Telegram/SourceFiles/ui/controls/location_picker.cpp @@ -58,12 +58,6 @@ namespace { constexpr auto kResolveAddressDelay = 3 * crl::time(1000); constexpr auto kSearchDebounceDelay = crl::time(900); -#if defined Q_OS_MAC || defined Q_OS_LINUX -const auto kProtocolOverride = "mapboxapihelper"; -#else // Q_OS_MAC -const auto kProtocolOverride = ""; -#endif // Q_OS_MAC - Core::GeoLocation LastExactLocation; using VenueData = Data::InputVenue; @@ -923,7 +917,6 @@ void LocationPicker::setupWebview() { Webview::WindowConfig{ .opaqueBg = st::windowBg->c, .storageId = _webviewStorageId, - .dataProtocolOverride = kProtocolOverride, }); const auto raw = _webview.get(); @@ -1104,13 +1097,9 @@ void LocationPicker::mapReady() { const auto token = _config.mapsToken.toUtf8(); const auto center = DefaultCenter(_initialProvided); const auto bounds = DefaultBounds(); - const auto protocol = *kProtocolOverride - ? "'"_q + kProtocolOverride + "'" - : "null"; const auto params = "token: '" + token + "'" + ", center: " + center - + ", bounds: " + bounds - + ", protocol: " + protocol; + + ", bounds: " + bounds; _webview->eval("LocationPicker.init({ " + params + " });"); const auto handle = _window->window()->windowHandle(); diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 2a29edd9fc..24764a61d4 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 2a29edd9fcc98efaecb968eb73667a00ea1c6cdd +Subproject commit 24764a61d4cb6575e775af044af3824dff30b01a