Commit 80f5d675 authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Go back to reporting WCv0 deprecation messages for chrome://* URLs

Prior to this CL, if chrome://* URLs used deprecated Web Components
v0 features, they were neither reported as warnings, nor counted as
uses of those features. With this change, the warnings will now be
shown, but the use counters will still not be incremented.

Bug: 1057337
Change-Id: If3f631b01a205e2249421e809537da7ed5691df2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2113790
Commit-Queue: dpapad <dpapad@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752659}
parent b64b55c2
...@@ -8664,15 +8664,16 @@ void Document::CountDeprecation(mojom::WebFeature feature) { ...@@ -8664,15 +8664,16 @@ void Document::CountDeprecation(mojom::WebFeature feature) {
} }
} }
// Don't count or report usage of WebComponentsV0 for chrome:// URLs. // Don't count usage of WebComponentsV0 for chrome:// URLs, but still report
// the deprecation messages.
if (Url().ProtocolIs("chrome") && if (Url().ProtocolIs("chrome") &&
(feature == WebFeature::kHTMLImports || (feature == WebFeature::kHTMLImports ||
feature == WebFeature::kElementCreateShadowRoot || feature == WebFeature::kElementCreateShadowRoot ||
feature == WebFeature::kDocumentRegisterElement)) { feature == WebFeature::kDocumentRegisterElement)) {
return; Deprecation::DeprecationWarningOnly(Loader(), feature);
} } else {
Deprecation::CountDeprecation(Loader(), feature); Deprecation::CountDeprecation(Loader(), feature);
}
} }
void Document::CountProperty(CSSPropertyID property) const { void Document::CountProperty(CSSPropertyID property) const {
......
...@@ -611,6 +611,17 @@ void Deprecation::CountDeprecation(Document* document, WebFeature feature) { ...@@ -611,6 +611,17 @@ void Deprecation::CountDeprecation(Document* document, WebFeature feature) {
} }
void Deprecation::CountDeprecation(DocumentLoader* loader, WebFeature feature) { void Deprecation::CountDeprecation(DocumentLoader* loader, WebFeature feature) {
Deprecation::CountDeprecation(loader, feature, /*count_usage=*/true);
}
void Deprecation::DeprecationWarningOnly(DocumentLoader* loader,
WebFeature feature) {
Deprecation::CountDeprecation(loader, feature, /*count_usage=*/false);
}
void Deprecation::CountDeprecation(DocumentLoader* loader,
WebFeature feature,
bool count_usage) {
if (!loader) if (!loader)
return; return;
LocalFrame* frame = loader->GetFrame(); LocalFrame* frame = loader->GetFrame();
...@@ -622,6 +633,7 @@ void Deprecation::CountDeprecation(DocumentLoader* loader, WebFeature feature) { ...@@ -622,6 +633,7 @@ void Deprecation::CountDeprecation(DocumentLoader* loader, WebFeature feature) {
return; return;
page->GetDeprecation().SetReported(feature); page->GetDeprecation().SetReported(feature);
if (count_usage)
UseCounter::Count(loader, feature); UseCounter::Count(loader, feature);
GenerateReport(frame, feature); GenerateReport(frame, feature);
} }
......
...@@ -44,6 +44,7 @@ class CORE_EXPORT Deprecation final { ...@@ -44,6 +44,7 @@ class CORE_EXPORT Deprecation final {
static void CountDeprecation(ExecutionContext*, WebFeature); static void CountDeprecation(ExecutionContext*, WebFeature);
static void CountDeprecation(const Document&, WebFeature); static void CountDeprecation(const Document&, WebFeature);
static void CountDeprecation(DocumentLoader*, WebFeature); static void CountDeprecation(DocumentLoader*, WebFeature);
static void DeprecationWarningOnly(DocumentLoader*, WebFeature);
// TODO(crbug.com/1029822): Temporary helpers to ease migrating // TODO(crbug.com/1029822): Temporary helpers to ease migrating
// ExecutionContext to LocalDOMWindow. // ExecutionContext to LocalDOMWindow.
...@@ -69,6 +70,8 @@ class CORE_EXPORT Deprecation final { ...@@ -69,6 +70,8 @@ class CORE_EXPORT Deprecation final {
// ReportingObservers. Also sends the deprecation message to the console. // ReportingObservers. Also sends the deprecation message to the console.
static void GenerateReport(const LocalFrame*, WebFeature); static void GenerateReport(const LocalFrame*, WebFeature);
static void CountDeprecation(DocumentLoader*, WebFeature, bool count_usage);
// To minimize the report/console spam from frames coming and going, report // To minimize the report/console spam from frames coming and going, report
// each deprecation at most once per page load per renderer process. // each deprecation at most once per page load per renderer process.
std::bitset<static_cast<size_t>(WebFeature::kNumberOfFeatures)> std::bitset<static_cast<size_t>(WebFeature::kNumberOfFeatures)>
......
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