Commit 785cd90b authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

ios: Block universal links during restore.

NOTRY=True
Bug: 1129875, 1132099

Change-Id: I901f4aea4a0df4e33c23c848289acb0aa2561369
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2430290
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810720}
parent 36f3ce82
...@@ -533,7 +533,11 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -533,7 +533,11 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
return; return;
} }
BOOL isOffTheRecord = self.webStateImpl->GetBrowserState()->IsOffTheRecord(); BOOL isOffTheRecord = self.webStateImpl->GetBrowserState()->IsOffTheRecord();
decisionHandler(web::GetAllowNavigationActionPolicy(isOffTheRecord)); BOOL isInRestoreSession =
self.webStateImpl->GetNavigationManager()->IsRestoreSessionInProgress();
BOOL isDocURLRestoringSession = IsRestoreSessionUrl(self.documentURL);
decisionHandler(web::GetAllowNavigationActionPolicy(
isOffTheRecord | isInRestoreSession | isDocURLRestoringSession));
} }
- (void)webView:(WKWebView*)webView - (void)webView:(WKWebView*)webView
......
...@@ -15,8 +15,9 @@ extern const WKNavigationActionPolicy ...@@ -15,8 +15,9 @@ extern const WKNavigationActionPolicy
kNavigationActionPolicyAllowAndBlockUniversalLinks; kNavigationActionPolicyAllowAndBlockUniversalLinks;
// Returns the WKNavigationActionPolicy for allowing navigations given the // Returns the WKNavigationActionPolicy for allowing navigations given the
// |off_the_record| state for the associated BrowserState. // |block_universal_links| state for the associated WebState.
WKNavigationActionPolicy GetAllowNavigationActionPolicy(bool off_the_record); WKNavigationActionPolicy GetAllowNavigationActionPolicy(
bool block_universal_links);
} // namespace web } // namespace web
......
...@@ -19,15 +19,17 @@ const WKNavigationActionPolicy ...@@ -19,15 +19,17 @@ const WKNavigationActionPolicy
static_cast<WKNavigationActionPolicy>(WKNavigationActionPolicyAllow + static_cast<WKNavigationActionPolicy>(WKNavigationActionPolicyAllow +
2); 2);
WKNavigationActionPolicy GetAllowNavigationActionPolicy(bool off_the_record) { WKNavigationActionPolicy GetAllowNavigationActionPolicy(
bool block_universal_links) {
// When both the |block_universal_links_in_off_the_record| gn arg and the // When both the |block_universal_links_in_off_the_record| gn arg and the
// |web::features::kBlockUniversalLinksInOffTheRecordMode| feature flag are // |web::features::kBlockUniversalLinksInOffTheRecordMode| feature flag are
// enabled, the returned value will block opening native applications if // enabled, the returned value will block opening native applications if
// |off_the_record| is true to prevent sharing off the record state. // |block_universal_links| is true to prevent sharing off the record state or
// opening an app unexpectedly during restore.
#if BUILDFLAG(BLOCK_UNIVERSAL_LINKS_IN_OFF_THE_RECORD_MODE) #if BUILDFLAG(BLOCK_UNIVERSAL_LINKS_IN_OFF_THE_RECORD_MODE)
bool block_universal_links_enabled = base::FeatureList::IsEnabled( bool block_universal_links_enabled = base::FeatureList::IsEnabled(
web::features::kBlockUniversalLinksInOffTheRecordMode); web::features::kBlockUniversalLinksInOffTheRecordMode);
if (off_the_record && block_universal_links_enabled) { if (block_universal_links && block_universal_links_enabled) {
return kNavigationActionPolicyAllowAndBlockUniversalLinks; return kNavigationActionPolicyAllowAndBlockUniversalLinks;
} }
#endif // BUILDFLAG(BLOCK_UNIVERSAL_LINKS_IN_OFF_THE_RECORD_MODE) #endif // BUILDFLAG(BLOCK_UNIVERSAL_LINKS_IN_OFF_THE_RECORD_MODE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment