From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Thu, 27 May 2021 17:21:07 -0700
Subject: build: do not depend on packed_resource_integrity

This ensures we do not depend on a target that does not exist when
building Electron, electron generates its own .pak files via
electron_repack and therefore this integrity target which is generated
by the chrome_paks target does not exist.  This can not be upstreamed,
if we ever align our .pak file generation with Chrome we can remove this
patch.

diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index d4436b93723cac8b33a6ffab1437b221446a1fb0..3aef47b5f85c11845962e48efd75a1d5064b7412 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -165,11 +165,16 @@ if (!is_android && !is_mac) {
         "common/crash_keys.h",
       ]
 
+      if (!is_electron_build) {
+        deps += [
+          ":packed_resources_integrity",
+        ]
+      }
+
       deps += [
         ":chrome_dll",
         ":chrome_exe_version",
         ":copy_first_run",
-        ":packed_resources_integrity",
         ":visual_elements_resources",
         "//base",
         "//build:branding_buildflags",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 135ad9b24745f6d016806f3c95993efe65b370f3..c5e694cd56b9db940e8564c82e2773aa1a53d9dd 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4359,7 +4359,7 @@ static_library("browser") {
 
     # On Windows, the hashes are embedded in //chrome:chrome_initial rather
     # than here in :chrome_dll.
-    if (!is_win) {
+    if (!is_win && !is_electron_build) {
       deps += [ "//chrome:packed_resources_integrity" ]
     }
 
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 1004666505dc8c127bb2405571eba9ab60277e3f..700cc0d1f88d7873c1b29bc96e871983cc982403 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -5329,7 +5329,6 @@ test("unit_tests") {
     assert(toolkit_views)
     sources += [ "../browser/ui/startup/credential_provider_signin_info_fetcher_win_unittest.cc" ]
     deps += [
-      "//chrome:packed_resources_integrity",
       "//chrome/browser:chrome_process_finder",
       "//chrome/browser/safe_browsing/chrome_cleaner",
       "//chrome/browser/safe_browsing/chrome_cleaner:public",
@@ -5342,6 +5341,12 @@ test("unit_tests") {
       "//components/chrome_cleaner/public/proto",
       "//ui/events/devices:test_support",
     ]
+
+    if (!is_electron_build) {
+      deps += [
+        "//chrome:packed_resources_integrity",
+      ]
+    }
   }
 
   # TODO(crbug.com/931218): Ninja cannot handle certain characters appearing
@@ -5934,7 +5939,6 @@ test("unit_tests") {
     }
 
     deps += [
-      "//chrome:packed_resources_integrity_hash",
       "//chrome/browser:cart_db_content_proto",
       "//chrome/browser/media/router:test_support",
       "//chrome/browser/promo_browser_command:mojo_bindings",
@@ -5970,6 +5974,9 @@ test("unit_tests") {
       "//ui/color:test_support",
       "//ui/native_theme:test_support",
     ]
+    if (!is_electron_build) {
+      deps += [ "//chrome:packed_resources_integrity_hash" ]
+    }
     if (is_win) {
       deps += [ "//components/chrome_cleaner/public/proto:test_only_proto" ]
     }
