Initial external webview webapps on Linux.

This commit is contained in:
John Preston
2026-05-08 23:06:12 +04:00
parent 0270f7e3a1
commit a4d0aa5f54
3 changed files with 881 additions and 41 deletions
@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h"
#include "ui/vertical_list.h"
#include "ui/gl/gl_detection.h"
#include "ui/chat/attach/attach_bot_webview.h"
#include "ui/chat/chat_style_radius.h"
#include "ui/controls/compose_ai_button_factory.h"
#include "base/options.h"
@@ -251,6 +252,7 @@ void SetupExperimental(
addToggle(Info::Profile::kOptionShowPeerIdBelowAbout);
addToggle(Info::Profile::kOptionShowChannelJoinedBelowAbout);
addToggle(Ui::kOptionUseSmallMsgBubbleRadius);
addToggle(Ui::BotWebView::kOptionLinuxExternalBotWebApps);
addToggle(Media::Player::kOptionDisableAutoplayNext);
addToggle(Webview::kOptionWebviewDebugEnabled);
addToggle(Webview::kOptionWebviewLegacyEdge);
File diff suppressed because it is too large Load Diff
@@ -31,6 +31,8 @@ using LayerOptions = base::flags<LayerOption>;
namespace Webview {
struct Available;
struct PopupArgs;
struct PopupResult;
} // namespace Webview
namespace Ui::Text {
@@ -39,6 +41,8 @@ struct MarkedContext;
namespace Ui::BotWebView {
extern const char kOptionLinuxExternalBotWebApps[];
struct DownloadsProgress;
struct DownloadsEntry;
enum class DownloadsAction;
@@ -171,6 +175,20 @@ private:
bool showWebview(Args &&args, const Webview::ThemeParams &params);
bool createWebview(const Webview::ThemeParams &params);
void installExternalShellDocument();
void sendExternalShellBootstrap();
void sendExternalShellMethod(
const QByteArray &method,
const QJsonObject &data);
void sendExternalShellEvent(
const QString &event,
const QByteArray &data);
void sendExternalShellButton(
const char *name,
const QJsonObject &args);
void sendExternalShellChrome();
void setExternalShellBlocked(bool blocked);
Webview::PopupResult showBlockingPopup(Webview::PopupArgs &&args);
void createWebviewBottom();
void showWebviewProgress();
void hideWebviewProgress();
@@ -238,14 +256,24 @@ private:
[[nodiscard]] QRect progressRect() const;
void setupProgressGeometry();
void layoutButtons();
void finishExternalBox(not_null<SeparatePanel*> panel);
Webview::StorageId _storageId;
const not_null<Delegate*> _delegate;
QString _externalUrl;
QString _externalTitle;
int _externalBlockCount = 0;
bool _closeNeedConfirmation = false;
bool _hasSettingsButton = false;
bool _externalShell = false;
bool _externalShellBootstrapped = false;
bool _externalBackVisible = false;
MenuButtons _menuButtons = {};
std::unique_ptr<RpWidget> _externalPanelParent;
std::unique_ptr<SeparatePanel> _widget;
std::unique_ptr<WebviewWithLifetime> _webview;
std::vector<std::unique_ptr<SeparatePanel>> _externalBoxes;
std::unique_ptr<RpWidget> _externalWebviewParent;
std::unique_ptr<RpWidget> _webviewBottom;
QPointer<FlatLabel> _webviewBottomLabel;
rpl::variable<QString> _bottomText;