Skip to content

Commit

Permalink
Give console warning for deprecation of DownloadInSandboxWithoutUserA…
Browse files Browse the repository at this point in the history
…ctivation

Add a method to cover features that was logged from the browser side.

Bug: 539938
Change-Id: I4b6cbdcb8e37afdd5862f15f2f7c877b13d30897
Reviewed-on: https://chromium-review.googlesource.com/c/1437775
Commit-Queue: Yao Xiao <[email protected]>
Reviewed-by: Charlie Harrison <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#626402}(cherry picked from commit 9b54c9a)
Reviewed-on: https://chromium-review.googlesource.com/c/1444238
Cr-Commit-Position: refs/branch-heads/3683@{#66}
Cr-Branched-From: e510299-refs/heads/master@{#625896}
  • Loading branch information
yaoxiachromium authored and csharrison committed Jan 30, 2019
1 parent e11e491 commit 7befe3c
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ void RecordUkmFeatures(const UkmFeatureList& features,
}
}

// It's always recommended to use the deprecation API in blink. If the feature
// was logged from the browser (or from both blink and the browser) where the
// deprecation API is not available, use this method for the console warning.
// Note that this doesn't generate the deprecation report.
void PossiblyWarnFeatureDeprecation(content::RenderFrameHost* rfh,
WebFeature feature) {
switch (feature) {
case WebFeature::kNavigationDownloadInSandboxWithoutUserGesture:
case WebFeature::kHTMLAnchorElementDownloadInSandboxWithoutUserGesture:
rfh->AddMessageToConsole(
content::CONSOLE_MESSAGE_LEVEL_WARNING,
"Download in sandbox without user activation is deprecated and will "
"be removed in M74. You may consider adding "
"'allow-downloads-without-user-activation' to the sandbox attribute "
"list. See https://www.chromestatus.com/feature/5706745674465280 for "
"more details.");
return;

default:
return;
}
}

void RecordMainFrameFeature(blink::mojom::WebFeature feature) {
UMA_HISTOGRAM_ENUMERATION(internal::kFeaturesHistogramMainFrameName, feature);
}
Expand Down Expand Up @@ -122,6 +145,7 @@ void UseCounterPageLoadMetricsObserver::OnFeaturesUsageObserved(

if (features_recorded_.test(static_cast<size_t>(feature)))
continue;
PossiblyWarnFeatureDeprecation(rfh, feature);
RecordFeature(feature);
features_recorded_.set(static_cast<size_t>(feature));
}
Expand Down

0 comments on commit 7befe3c

Please sign in to comment.