[CUPS Printing] Add feature flag for PPD attribute support.

This might take more than milestone to finish so putting this behind a
feature flag.

Bug: 964919
Change-Id: I11acaa377b282d9acd9788b2e1a54bf0d2297511
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617762
Commit-Queue: Vladislav Kuzkokov <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#662221}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index f6ed77e..2f657f8 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -164,6 +164,7 @@
 #include "chromeos/constants/chromeos_switches.h"
 #include "chromeos/services/assistant/public/features.h"
 #include "components/arc/arc_features.h"
+#include "printing/printing_features_chromeos.h"
 #include "third_party/cros_system_api/switches/chrome_switches.h"
 #endif  // OS_CHROMEOS
 
@@ -3733,6 +3734,12 @@
      flag_descriptions::kAllowPopupsDuringPageUnloadName,
      flag_descriptions::kAllowPopupsDuringPageUnloadDescription, kOsAll,
      SINGLE_VALUE_TYPE(switches::kAllowPopupsDuringPageUnload)},
+#if defined(OS_CHROMEOS)
+    {"enable-advanced-ppd-attributes",
+     flag_descriptions::kEnableAdvancedPpdAttributesName,
+     flag_descriptions::kEnableAdvancedPpdAttributesDescription, kOsCrOS,
+     FEATURE_VALUE_TYPE(printing::kAdvancedPpdAttributes)},
+#endif  // defined(OS_CHROMEOS)
 
     {"enable-forbid-sync-xhr-in-page-dismissal",
      flag_descriptions::kForbidSyncXHRInPageDismissalName,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index c813546..cd126ed 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -684,6 +684,11 @@
     "expiry_milestone": 76
   },
   {
+    "name": "enable-advanced-ppd-attributes",
+    "owners": [ "vkuzkokov", "skau" ],
+    "expiry_milestone": 80
+  },
+  {
     "name": "enable-android-autofill-accessibility",
     "owners": [ "ftirelo" ],
     "expiry_milestone": 73
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 4b79407..95350407 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -2918,6 +2918,11 @@
     "If Enabled, double tapping in webpages while in tablet mode will zoom the "
     "page.";
 
+const char kEnableAdvancedPpdAttributesName[] =
+    "Enables advanced PPD attributes";
+const char kEnableAdvancedPpdAttributesDescription[] =
+    "Enables advanced settings on CUPS printers";
+
 const char kEnableAppDataSearchName[] = "Enable app data search in launcher";
 const char kEnableAppDataSearchDescription[] =
     "Allow launcher search to access data available through Firebase App "
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index af61066..8078df3 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1748,6 +1748,9 @@
 extern const char kDoubleTapToZoomInTabletModeName[];
 extern const char kDoubleTapToZoomInTabletModeDescription[];
 
+extern const char kEnableAdvancedPpdAttributesName[];
+extern const char kEnableAdvancedPpdAttributesDescription[];
+
 extern const char kEnableAppDataSearchName[];
 extern const char kEnableAppDataSearchDescription[];
 
diff --git a/printing/BUILD.gn b/printing/BUILD.gn
index 39164b8..64fcd1c 100644
--- a/printing/BUILD.gn
+++ b/printing/BUILD.gn
@@ -229,6 +229,8 @@
       "printed_document_chromeos.cc",
       "printing_context_no_system_dialog.cc",
       "printing_context_no_system_dialog.h",
+      "printing_features_chromeos.cc",
+      "printing_features_chromeos.h",
     ]
   } else if (is_android) {
     sources += [
diff --git a/printing/printing_features_chromeos.cc b/printing/printing_features_chromeos.cc
new file mode 100644
index 0000000..b2826d6b
--- /dev/null
+++ b/printing/printing_features_chromeos.cc
@@ -0,0 +1,13 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/printing_features_chromeos.h"
+
+namespace printing {
+
+// Enables Advanced PPD Attributes.
+const base::Feature kAdvancedPpdAttributes{"AdvancedPpdAttributes",
+                                           base::FEATURE_DISABLED_BY_DEFAULT};
+
+}  // namespace printing
diff --git a/printing/printing_features_chromeos.h b/printing/printing_features_chromeos.h
new file mode 100644
index 0000000..59b1f07
--- /dev/null
+++ b/printing/printing_features_chromeos.h
@@ -0,0 +1,19 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PRINTING_PRINTING_FEATURES_CHROMEOS_H_
+#define PRINTING_PRINTING_FEATURES_CHROMEOS_H_
+
+#include "base/feature_list.h"
+#include "printing/printing_export.h"
+
+namespace printing {
+
+// All features in alphabetical order. The features should be documented
+// alongside the definition of their values in the .cc file.
+PRINTING_EXPORT extern const base::Feature kAdvancedPpdAttributes;
+
+}  // namespace printing
+
+#endif  // PRINTING_PRINTING_FEATURES_CHROMEOS_H_
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
index f52c644..e3d8d34 100644
--- a/tools/metrics/histograms/enums.xml
+++ b/tools/metrics/histograms/enums.xml
@@ -32945,11 +32945,13 @@
   <int value="-1855347512" label="FormControlsRefresh:disabled"/>
   <int value="-1854432127" label="ChromeHomePullToRefreshIphAtTop:disabled"/>
   <int value="-1854372227" label="VrBrowsingExperimentalFeatures:enabled"/>
+  <int value="-1853570433" label="AdvancedPpdAttributes:enabled"/>
   <int value="-1849706663" label="enable-password-force-saving:disabled"/>
   <int value="-1847835522" label="disable-touch-adjustment"/>
   <int value="-1847776781"
       label="enable-loading-ipc-optimization-for-small-resources"/>
   <int value="-1844754731" label="Mash:disabled"/>
+  <int value="-1840608422" label="AdvancedPpdAttributes:disabled"/>
   <int value="-1839874877" label="WebXROrientationSensorDevice:enabled"/>
   <int value="-1839496458" label="disable-file-manager-touch-mode"/>
   <int value="-1838482444" label="disable-settings-window"/>