Migrate last base::Contains() to .contains()

Commit: 7c2fca90 | 2026-01-13 02:19:42+00:00

← Back to List

Migrate last base::Contains() to .contains()

Minor
Commit Hash: 7c2fca90bb6b63819018ec9363b11a685910e844
Commit Time: 2026-01-13 02:19:42+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit is a large-scale code cleanup effort that replaces the last remaining base::Contains() calls throughout the Chromium codebase with the .contains() member method of C++ standard containers. The change affects 189 files, primarily converting calls from the form base::Contains(container, item) to container.contains(item). This migration is intended to use C++ standard library features (the .contains() method introduced in C++20) instead of Chromium's custom helper functions.

For remote_cocoa related code, the affected files include:
- components/remote_cocoa/app_shim/immersive_mode_controller_cocoa.mm: Replaces 3 instances of base::Contains() calls with .contains()
- Also removes the related #include "base/containers/contains.h" header file reference

This is a purely semantically equivalent replacement with no functional logic changes or behavior modifications.

🎯 Impact Analysis

The impact of this change on WebView2Mac is **Minor**.

**Impact Analysis:**
1. **Pure code style change**: This is a pure code refactoring that replaces Chromium's custom helper functions with standard library methods, with no logic changes involved
2. **Semantically equivalent**: .contains() and base::Contains() are functionally identical, differing only in call syntax
3. **No API or interface changes**: No modifications to any Mojo interfaces, class inheritance relationships, or public APIs
4. **No impact on WebView2Mac dependencies**: Core remote_cocoa classes that WebView2Mac depends on (such as NativeWidgetNSWindowBridge, ImmersiveModeControllerCocoa, etc.) maintain their functionality and behavior

**Affected remote_cocoa code:**
- In ImmersiveModeControllerCocoa::OnChildWindowAdded(), changed CHECK(!base::Contains(window_lock_received_, child)) to CHECK(!window_lock_received_.contains(child))
- In ImmersiveModeControllerCocoa::OnChildWindowRemoved(), changed CHECK(base::Contains(window_lock_received_, child)) to CHECK(window_lock_received_.contains(child)) (Edge-specific code path also includes a conditional check with base::Contains)

These changes only affect internal assertions and container lookup logic, and will not impact the behavior of immersive fullscreen mode or WebView2Mac's window management functionality.

**Conclusion:**
This is a standard code modernization effort with no functional impact on WebView2Mac. No action or code adaptation is required.

Impacted Classes:

remote_cocoa::ImmersiveModeControllerCocoa