appcache: add feature for gating AppCache on origin trials

The state of features with this patch is:

(1) kAppCache feature

Enabled by default until we finally turn off AppCache just prior to
removal.

If this is disabled, then AppCache is forced disabled everywhere and
will not be turned on, even by the origin trial.

If this is enabled, then the AppCache is enabled, but access may be
gated on the origin trial if kAppCacheOriginTrial is enabled.

This can currently be set by about:flags, and from WebView for testing
purposes.

(2) kAppCacheRequireOriginTrial feature (new)

Disabled by default.  This will switch to enabled by default,
most likely in M85.  Followup patches will add settings to enterprise
and WebView to disable this feature optionally.

If enabled, then it will gate the API on origin trial tokens in meta
tags / http headers, and will gate the browser code on origin trial
tokens in manifests.

Bug: 582750
Change-Id: I4d87c702d419030cd3f382a2c2796ce406a7437e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142615
Commit-Queue: enne <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766086}
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index f4724ca1..59d11c5 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -499,7 +499,15 @@
 const base::Feature kKeepScriptResourceAlive{"KeepScriptResourceAlive",
                                              base::FEATURE_DISABLED_BY_DEFAULT};
 
+// The AppCache feature is a kill-switch for the entire AppCache feature,
+// both backend and API.  If disabled, then it will turn off the backend and
+// api, regardless of the presence of valid origin trial tokens.
 const base::Feature kAppCache{"AppCache", base::FEATURE_ENABLED_BY_DEFAULT};
+// If AppCacheRequireOriginTrial is enabled, then the AppCache backend in the
+// browser will require origin trial tokens in order to load or store manifests
+// and their contents.
+const base::Feature kAppCacheRequireOriginTrial{
+    "AppCacheRequireOriginTrial", base::FEATURE_DISABLED_BY_DEFAULT};
 
 // Enables the AV1 Image File Format (AVIF).
 const base::Feature kAVIF{"AVIF", base::FEATURE_DISABLED_BY_DEFAULT};