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 0223183c4e869e835429a52ad7d9eb381a2d21f5..47162ccaa75ea637b7ce5ed0fed976862b14c427 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -176,11 +176,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 e1274ce21a8d794b7753c0017b0558cfd92f9530..ba723ec8f05e03981a273a3890a775c151aaed99 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4639,7 +4639,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 9e848b82105112f95a77ad87f23d9ffc762bd88b..4f10f85a7a4a9951b0a11fef0419f5301564e378 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -6065,7 +6065,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:crash_reporter_client_win_unit_tests",
@@ -6090,6 +6089,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",
@@ -7018,7 +7021,7 @@ test("unit_tests") {
     }
 
     deps += [
-      "//chrome:packed_resources_integrity_hash",
+    # "//chrome:packed_resources_integrity_hash",
       "//chrome/browser/autofill_assistant/password_change/vector_icons:vector_icons",
       "//chrome/browser/enterprise/connectors/analysis:features",
       "//chrome/browser/media/router:test_support",
@@ -7140,6 +7143,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",
