Factor out common application logic into CrApplication base class in remote_cocoa/app_shim

提交: 168b5dd0 | 2026-05-18 20:49:04

← 返回列表

Factor out common application logic into CrApplication base class in remote_cocoa/app_shim

Minor
提交哈希: 168b5dd0ce7fbfcecb874c422feca7af3b48fcad
提交时间: 2026-05-18 20:49:04
影响等级: Minor
生成工具: chromium-watcher
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit introduces a new CrApplication base class in components/remote_cocoa/app_shim that consolidates duplicated Cocoa application infrastructure from BrowserCrApplication and AppShimApplication. The extracted logic includes: the handlingSendEvent getter/setter, the sendAction:to:from: safety check for _selectWindow: (protecting against freed window targets in Dock menus), the crash key annotation for sendAction, and the nextEventMatchingMask EH frame wrapper. Both BrowserCrApplication and AppShimApplication now inherit from CrApplication instead of NSApplication directly. This is a pure refactor with no behavioral changes.

🎯 影响分析

The impact on WebView2Mac is minor. Detailed analysis:
1. The new CrApplication class resides in components/remote_cocoa/app_shim, which WebView2Mac links against — so the new files will be included in WebView2's build graph.
2. WebView2Mac's browser process uses BrowserCrApplication as its NSApplication subclass. After refactoring, BrowserCrApplication inherits from CrApplication, indirectly affecting the WebView2 browser process — but since this is a pure refactor (no behavioral change), there is no functional risk.
3. WebView2Mac's hosting application (HostingApplicationBridge) does not subclass NSApplication and is unaffected by this change.
4. The downstream Edge repo does not yet contain cr_application.h/.mm; chrome_browser_application_mac.mm and app_shim_application.mm still retain the old duplicated implementations. When this commit merges downstream, it will produce merge conflicts requiring the introduction of the CrApplication files and BUILD.gn dependency updates.

受影响的类:

CrApplication (new base class in remote_cocoa/app_shim) BrowserCrApplication AppShimApplication