[WebLayer] Actually filter components_chromium_strings.

Updates to the build.gn configuration per feedback here:
https://chromium-review.googlesource.com/c/chromium/src/+/2166162/1/weblayer/BUILD.gn#67

Bug: 1052375
Change-Id: I6cfac8ff7f7d744e7ad024f42b0955ac94c822b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2171076
Reviewed-by: Andrew Grieve <[email protected]>
Reviewed-by: Clark DuVall <[email protected]>
Commit-Queue: Mugdha Lakhani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#764178}
diff --git a/weblayer/BUILD.gn b/weblayer/BUILD.gn
index 6d797142..7dff4f29 100644
--- a/weblayer/BUILD.gn
+++ b/weblayer/BUILD.gn
@@ -59,17 +59,35 @@
                               [ "components_strings_{{source_name_part}}.pak" ])
   }
 
+  grit("generate_components_chromium_strings") {
+    source = "../components/components_chromium_strings.grd"
+
+    # components_chromium_strings contains Chromium-specific strings. WebLayer
+    # will never display most of them, so we try to limit the included
+    # strings.
+    whitelist = rebase_path("grit_strings_whitelist.txt", root_build_dir)
+    inputs = [ "//weblayer/grit_strings_whitelist.txt" ]
+    grit_flags = [
+      "-w",
+      whitelist,
+    ]
+    outputs = [ "grit/components_chromium_strings.h" ] +
+              process_file_template(
+                  locales_with_fake_bidi,
+                  [ "components_chromium_strings_{{source_name_part}}.pak" ])
+  }
+
   repack_locales("weblayer_locales") {
     input_locales = locales
     output_locales = locales
     source_patterns = [
-      "${root_gen_dir}/components/strings/components_chromium_strings_",
       "${root_gen_dir}/components/strings/components_locale_settings_",
+      "${root_gen_dir}/weblayer/components_chromium_strings_",
       "${root_gen_dir}/weblayer/components_strings_",
     ]
     deps = [
+      ":generate_components_chromium_strings",
       ":generate_components_strings",
-      "//components/strings:components_chromium_strings",
       "//components/strings:components_locale_settings",
     ]
     output_dir = "$root_out_dir/weblayer/locales"