Adds flag for enabling/disabling file handling.

This will enable starting implementation on file-handling
behind the flag.

https://chromium-review.googlesource.com/c/chromium/src/+/1589675
is an early prototype of what the implementation might look like.

Bug: 829689
Change-Id: If92cfd86a115ea9cb2985a2cf360b3ba41097089
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1593883
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Commit-Queue: Jay Harris <harrisjay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656729}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 6fda5c2..ec52e2b 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -3734,6 +3734,10 @@
      flag_descriptions::kNativeFileSystemAPIDescription, kOsAll,
      FEATURE_VALUE_TYPE(blink::features::kNativeFileSystemAPI)},
 
+    {"file-handling-api", flag_descriptions::kFileHandlingAPIName,
+     flag_descriptions::kFileHandlingAPIDescription, kOsCrOS,
+     FEATURE_VALUE_TYPE(blink::features::kFileHandlingAPI)},
+
 #if !defined(OS_ANDROID)
     {"enable-intent-picker", flag_descriptions::kIntentPickerName,
      flag_descriptions::kIntentPickerDescription, kOsMac | kOsWin | kOsLinux,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 222428c..1f47551f 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -1997,6 +1997,11 @@
     "expiry_milestone": 76
   },
   {
+    "name": "file-handling-api",
+    "owners": ["harrisjay@chromium.org", "raymes@chromium.org"],
+    "expiry_milestone": 79
+  },
+  {
     "name": "file-manager-feedback-panel",
     "owners": [ "adanilo" ],
     "expiry_milestone": 77
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 43b4c9f..c80708f 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -991,6 +991,11 @@
 const char kEffectiveConnectionType3GDescription[] = "3G";
 const char kEffectiveConnectionType4GDescription[] = "4G";
 
+const char kFileHandlingAPIName[] = "File Handling API";
+const char kFileHandlingAPIDescription[] =
+    "Enables the file handling API, allowing websites to register as file "
+    "handlers. This depends on native-file-system";
+
 const char kFillOnAccountSelectName[] = "Fill passwords on account selection";
 const char kFillOnAccountSelectDescription[] =
     "Filling of passwords when an account is explicitly selected by the user "
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index f644266..6fdcabc 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -600,6 +600,9 @@
 extern const char kEffectiveConnectionType3GDescription[];
 extern const char kEffectiveConnectionType4GDescription[];
 
+extern const char kFileHandlingAPIName[];
+extern const char kFileHandlingAPIDescription[];
+
 extern const char kFillOnAccountSelectName[];
 extern const char kFillOnAccountSelectDescription[];
 
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
index 73af4e8..ca20e7e8 100644
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -218,6 +218,10 @@
 const base::Feature kNativeFileSystemAPI{"NativeFileSystemAPI",
                                          base::FEATURE_DISABLED_BY_DEFAULT};
 
+// File handling integration. https://crbug.com/829689
+const base::Feature kFileHandlingAPI{"FileHandlingAPI",
+                                     base::FEATURE_DISABLED_BY_DEFAULT};
+
 // Allows for synchronous XHR requests during page dismissal
 const base::Feature kForbidSyncXHRInPageDismissal{
     "ForbidSyncXHRInPageDismissal", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h
index 139c5c1..d2213d3 100644
--- a/third_party/blink/public/common/features.h
+++ b/third_party/blink/public/common/features.h
@@ -64,6 +64,7 @@
 BLINK_COMMON_EXPORT extern const base::Feature kTextFragmentAnchor;
 BLINK_COMMON_EXPORT extern const base::Feature kWasmCodeCache;
 BLINK_COMMON_EXPORT extern const base::Feature kNativeFileSystemAPI;
+BLINK_COMMON_EXPORT extern const base::Feature kFileHandlingAPI;
 BLINK_COMMON_EXPORT extern const base::Feature kForbidSyncXHRInPageDismissal;
 BLINK_COMMON_EXPORT extern const base::Feature
     kRestrictDeviceSensorEventsToSecureContexts;
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index 93eabbe..116076f 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -32923,6 +32923,7 @@
   <int value="-1455852875" label="WebAuthentication:disabled"/>
   <int value="-1455559065"
       label="OmniboxUIExperimentShowPlaceholderWhenCaretShowing:disabled"/>
+  <int value="-1454479680" label="FileHandlingAPI:enabled"/>
   <int value="-1454397907" label="OptimizationHints:disabled"/>
   <int value="-1451644187" label="OverviewSwipeToClose:enabled"/>
   <int value="-1450576851" label="OmniboxUIExperimentVerticalLayout:enabled"/>
@@ -33791,6 +33792,7 @@
       label="OmniboxUIExperimentBoldUserTextOnSearchSuggestions:disabled"/>
   <int value="-135223364" label="AutofillShowTypePredictions:disabled"/>
   <int value="-133098377" label="SyncPseudoUSSSearchEngines:disabled"/>
+  <int value="-131673218" label="FileHandlingAPI:disabled"/>
   <int value="-128687277"
       label="OmniboxUIExperimentHideSteadyStateUrlPathQueryAndRef:disabled"/>
   <int value="-127666141" label="TabGroups:disabled"/>