Introduce MockActivationController class to emulate widget activation in tests (original commit)

提交: f92674ca | 2026-02-24 01:27:29

← 返回列表

Introduce MockActivationController class to emulate widget activation in tests (original commit)

Minor
提交哈希: f92674cad33d0849217a25d5c27a2d8848f8d713
提交时间: 2026-02-24 01:27:29
影响等级: Minor
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit introduces the MockActivationController class and WidgetActivationDelegate infrastructure for emulating widget activation in tests on Win/Mac/Linux. Changes include: new ui/views/widget/widget_activation_delegate.h/.cc defining a global singleton WidgetActivationDelegate interface; new ui/views/test/mock_activation_controller.h/.cc implementing a test activation controller; NativeWidgetMacNSWindowHost::IsWindowKey() changed from an inline function returning is_window_key_ to first querying WidgetActivationDelegate (if present), falling back to is_window_key_; corresponding query logic added to desktop_window_tree_host_platform.cc and desktop_window_tree_host_win.cc; glic_test_util updated to use MockActivationController. Note: this commit went through multiple revert/reland cycles (ca260c6e revert → 8a2462b4 reland → 3be941b0 revert again), with the final state being reverted.

🎯 影响分析

This change has minimal impact on WebView2Mac. The main modification changes NativeWidgetMacNSWindowHost::IsWindowKey() from an inline function to a non-inline method with WidgetActivationDelegate query logic. In production, WidgetActivationDelegate::Get() returns nullptr, so behavior remains identical — it still returns is_window_key_. The change only affects test infrastructure. Edge downstream has no references to IsWindowKey, WidgetActivationDelegate, or MockActivationController in edge_embedded_browser/ or components/edge_webview2/. Additionally, this commit has been ultimately reverted (3be941b0). No downstream patch is needed.

受影响的类:

views::NativeWidgetMacNSWindowHost views::WidgetActivationDelegate views::MockActivationController