Add PdfLocalFileAccessAllowedForDomains Policy

Enterprise customers want to be able to access file:// protocol links.
For security reasons, this should be a policy that enterprise can set
for specific domains. Add a new policy that grants an allowlist of
domains access to file:// links from the PDF Viewer.

Bug: 1302465
Change-Id: Ibbb5cfa61c795b9bce949c3ca8a17e31fa3fc5bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4003999
Commit-Queue: Andy Phan <[email protected]>
Reviewed-by: Alexander Hendrich <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1076995}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index a92551b9..f82adfa 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -161,6 +161,7 @@
 #include "content/public/browser/render_process_host.h"
 #include "extensions/buildflags/buildflags.h"
 #include "net/http/http_server_properties_manager.h"
+#include "pdf/buildflags.h"
 #include "ppapi/buildflags/buildflags.h"
 #include "printing/buildflags/buildflags.h"
 #include "rlz/buildflags/buildflags.h"
@@ -211,6 +212,10 @@
 #include "components/offline_pages/core/prefetch/prefetch_prefs.h"
 #endif
 
+#if BUILDFLAG(ENABLE_PDF)
+#include "chrome/browser/pdf/pdf_pref_names.h"
+#endif  // BUILDFLAG(ENABLE_PDF)
+
 #if BUILDFLAG(ENABLE_PLUGINS)
 #include "chrome/browser/plugins/plugin_info_host_impl.h"
 #endif
@@ -1394,6 +1399,11 @@
   offline_pages::prefetch_prefs::RegisterPrefs(registry);
 #endif
 
+#if BUILDFLAG(ENABLE_PDF)
+  registry->RegisterListPref(prefs::kPdfLocalFileAccessAllowedForDomains,
+                             base::Value::List());
+#endif  // BUILDFLAG(ENABLE_PDF)
+
 #if BUILDFLAG(ENABLE_PLUGINS)
   PluginInfoHostImpl::RegisterUserPrefs(registry);
 #endif