Skip to content

Commit

Permalink
[M111] Add feature flag for preventing navigation
Browse files Browse the repository at this point in the history
This new logic was added in crrev.com/c/4206652. Adding a new flag to be
used as a killswitch in case there are any unintended side effects of
this change which are not observed before stable.

(cherry picked from commit 7ab182a)

Bug: 1408799
Change-Id: I22110d7c4a5f1f839c9cb0dd3725e5a854947d5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4215894
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Ali Juma <ajuma@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1100500}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4218202
Commit-Queue: Ali Juma <ajuma@chromium.org>
Auto-Submit: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/branch-heads/5563@{#126}
Cr-Branched-From: 3ac59a6-refs/heads/main@{#1097615}
  • Loading branch information
michaeldo1 authored and Chromium LUCI CQ committed Feb 3, 2023
1 parent ccc169a commit 1dfa550
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ios/web/common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ BASE_DECLARE_FEATURE(kLongPressSurroundingText);
// the old one.
BASE_DECLARE_FEATURE(kScrollViewProxyScrollEnabledWorkaround);

// Feature flag to prevent navigation without user interaction.
BASE_DECLARE_FEATURE(kPreventNavigationWithoutUserInteraction);

// When true, user control for camera and/or microphone access should be
// enabled.
bool IsMediaPermissionsControlEnabled();
Expand Down
4 changes: 4 additions & 0 deletions ios/web/common/features.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
"ScrollViewProxyScrollEnabledWorkaround",
base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kPreventNavigationWithoutUserInteraction,
"PreventNavigationWithoutUserInteraction",
base::FEATURE_ENABLED_BY_DEFAULT);

bool IsMediaPermissionsControlEnabled() {
if (@available(iOS 15, *)) {
return base::FeatureList::IsEnabled(kMediaPermissionsControl);
Expand Down
4 changes: 3 additions & 1 deletion ios/web/navigation/crw_wk_navigation_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ - (void)webView:(WKWebView*)webView
}

// Ref: crbug.com/1408799
if (isMainFrameNavigationAction && isCrossOriginTargetFrame &&
if (base::FeatureList::IsEnabled(
web::features::kPreventNavigationWithoutUserInteraction) &&
isMainFrameNavigationAction && isCrossOriginTargetFrame &&
!hasTappedRecently) {
decisionHandler(WKNavigationActionPolicyCancel);
return;
Expand Down

0 comments on commit 1dfa550

Please sign in to comment.