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 53363189fe649fa92040811ee9e858e9363f29e7..48883669d54ec7b7421b88fcaf7776e7b3d55bee 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -187,11 +187,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 0ddbd541f7ef4041aecc5693a366e6c87f74f313..a97f4cba4512ae1e7d34f9f29c33b366420b0822 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4591,7 +4591,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" ]
       sources += [ "certificate_viewer_stub.cc" ]
     }
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 9bd4a7f817389a1e6256b0570864ab5de5f541fb..66c42163f0d99eb447df4279eba47f4f50da3172 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -6297,7 +6297,6 @@ test("unit_tests") {
 
     deps += [
       "//chrome:other_version",
-      "//chrome:packed_resources_integrity",
       "//chrome//services/util_win:unit_tests",
       "//chrome/app:chrome_dll_resources",
       "//chrome/app:win_unit_tests",
@@ -6323,6 +6322,10 @@ test("unit_tests") {
       "//ui/resources",
     ]
 
+    if (!is_electron_build) {
+      deps += [ "//chrome:packed_resources_integrity" ]
+    }
+
     ldflags = [
       "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll",
       "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
@@ -7240,7 +7243,7 @@ test("unit_tests") {
     }
 
     deps += [
-      "//chrome:packed_resources_integrity_hash",
+    # "//chrome:packed_resources_integrity_hash",
       "//chrome/browser/apps/app_service",
       "//chrome/browser/apps/app_service:test_support",
       "//chrome/browser/enterprise/connectors/analysis:features",
@@ -7370,6 +7373,10 @@ test("unit_tests") {
     }
   }
 
+  if (!is_electron_build) {
+    deps += [ "//chrome:packed_resources_integrity_hash" ]
+  }
+
   if (is_chromeos_ash) {
     sources -= [
       "../browser/policy/cloud/user_policy_signin_service_unittest.cc",
