Move crypto/wincrypt_shim.h to remove build dependency on crypto

The DEPS system and gn will enforce some kind of dependency on
//crypto if code needs to use crypto/wincrypt_shim.h. Now, that
header file will not in itself indicate a dependency on actual
code in //crypto so the dependency becomes a bit unexpected. By
moving it to base/win, code can avoid depending on //crypto just
to use that header file.

This became an issue when //printing needed to use wincrypt_shim.h

Change-Id: I68a3b8263da0d4307907a0b242444402675072a4
Reviewed-on: https://chromium-review.googlesource.com/c/1261024
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#597256}
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 0a48a16d..8dbcb04 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -1056,6 +1056,7 @@
     "win/wait_chain.h",
     "win/win_util.cc",
     "win/win_util.h",
+    "win/wincrypt_shim.h",
     "win/windows_defines.inc",
     "win/windows_types.h",
     "win/windows_undefines.inc",
diff --git a/crypto/wincrypt_shim.h b/base/win/wincrypt_shim.h
similarity index 88%
rename from crypto/wincrypt_shim.h
rename to base/win/wincrypt_shim.h
index dcfd4ad..ba94a87 100644
--- a/crypto/wincrypt_shim.h
+++ b/base/win/wincrypt_shim.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef CRYPTO_WINCRYPT_SHIM_H_
-#define CRYPTO_WINCRYPT_SHIM_H_
+#ifndef BASE_WIN_WINCRYPT_SHIM_H_
+#define BASE_WIN_WINCRYPT_SHIM_H_
 
 // wincrypt.h defines macros which conflict with OpenSSL's types. This header
 // includes wincrypt and undefines the OpenSSL macros which conflict. Any
@@ -22,4 +22,4 @@
 #define WINCRYPT_X509_EXTENSIONS ((LPCSTR) 5)
 #define WINCRYPT_X509_NAME ((LPCSTR) 7)
 
-#endif  // CRYPTO_WINCRYPT_SHIM_H_
+#endif  // BASE_WIN_WINCRYPT_SHIM_H_
diff --git a/chrome/browser/conflicts/module_info_util_win.cc b/chrome/browser/conflicts/module_info_util_win.cc
index 4b029cf4..9da05a0 100644
--- a/chrome/browser/conflicts/module_info_util_win.cc
+++ b/chrome/browser/conflicts/module_info_util_win.cc
@@ -20,8 +20,8 @@
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/scoped_handle.h"
+#include "base/win/wincrypt_shim.h"
 #include "chrome/common/safe_browsing/pe_image_reader_win.h"
-#include "crypto/wincrypt_shim.h"
 
 // This must be after wincrypt and wintrust.
 #include <mscat.h>
diff --git a/chrome/browser/ui/cryptuiapi_shim.h b/chrome/browser/ui/cryptuiapi_shim.h
index 404edcb..a6470d9 100644
--- a/chrome/browser/ui/cryptuiapi_shim.h
+++ b/chrome/browser/ui/cryptuiapi_shim.h
@@ -13,6 +13,6 @@
 #include <windows.h>
 #include <cryptuiapi.h>
 
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 #endif  // CHROME_BROWSER_UI_CRYPTUIAPI_SHIM_H_
diff --git a/chrome/chrome_cleaner/os/system_util.h b/chrome/chrome_cleaner/os/system_util.h
index 11b29b85..bb74ddd 100644
--- a/chrome/chrome_cleaner/os/system_util.h
+++ b/chrome/chrome_cleaner/os/system_util.h
@@ -9,7 +9,7 @@
 
 #include "base/strings/string16.h"
 #include "base/win/scoped_handle.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 namespace chrome_cleaner {
 
diff --git a/components/os_crypt/os_crypt_win.cc b/components/os_crypt/os_crypt_win.cc
index beff2c7..792233d 100644
--- a/components/os_crypt/os_crypt_win.cc
+++ b/components/os_crypt/os_crypt_win.cc
@@ -7,7 +7,7 @@
 #include <windows.h>
 
 #include "base/strings/utf_string_conversions.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 bool OSCrypt::EncryptString16(const base::string16& plaintext,
                               std::string* ciphertext) {
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index 4d68803..cfa8bb46 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -65,7 +65,7 @@
 // XpsObjectModel.h indirectly includes <wincrypt.h> which is
 // incompatible with Chromium's OpenSSL. By including wincrypt_shim.h
 // first, problems are avoided.
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 #include <XpsObjectModel.h>
 #include <objbase.h>
diff --git a/crypto/BUILD.gn b/crypto/BUILD.gn
index f8c9ba8..b7e91c73 100644
--- a/crypto/BUILD.gn
+++ b/crypto/BUILD.gn
@@ -67,7 +67,6 @@
     "signature_verifier.h",
     "symmetric_key.cc",
     "symmetric_key.h",
-    "wincrypt_shim.h",
   ]
 
   # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
diff --git a/crypto/scoped_capi_types.h b/crypto/scoped_capi_types.h
index 74e5765..6d2deb9 100644
--- a/crypto/scoped_capi_types.h
+++ b/crypto/scoped_capi_types.h
@@ -11,7 +11,7 @@
 
 #include "base/logging.h"
 #include "base/macros.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 namespace crypto {
 
diff --git a/net/cert/known_roots_win.h b/net/cert/known_roots_win.h
index e9f681b..8b9cd24 100644
--- a/net/cert/known_roots_win.h
+++ b/net/cert/known_roots_win.h
@@ -5,7 +5,7 @@
 #ifndef NET_CERT_KNOWN_ROOTS_WIN_H_
 #define NET_CERT_KNOWN_ROOTS_WIN_H_
 
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 
 namespace net {
 
diff --git a/net/cert/test_root_certs.h b/net/cert/test_root_certs.h
index bc211c5..8992af1 100644
--- a/net/cert/test_root_certs.h
+++ b/net/cert/test_root_certs.h
@@ -18,7 +18,7 @@
 #include "net/cert/scoped_nss_types.h"
 #elif defined(OS_WIN)
 #include <windows.h>
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 #elif defined(OS_MACOSX)
 #include <CoreFoundation/CFArray.h>
 #include <Security/SecTrust.h>
diff --git a/net/cert/x509_util_win.h b/net/cert/x509_util_win.h
index a6a234e..c1c8f49 100644
--- a/net/cert/x509_util_win.h
+++ b/net/cert/x509_util_win.h
@@ -11,7 +11,7 @@
 #include <windows.h>
 
 #include "base/memory/ref_counted.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 #include "net/base/hash_value.h"
 #include "net/base/net_export.h"
 #include "net/cert/x509_certificate.h"
diff --git a/net/ssl/client_cert_store_win.cc b/net/ssl/client_cert_store_win.cc
index 39ae3aa..2fcd502 100644
--- a/net/ssl/client_cert_store_win.cc
+++ b/net/ssl/client_cert_store_win.cc
@@ -20,7 +20,7 @@
 #include "base/single_thread_task_runner.h"
 #include "base/task_runner_util.h"
 #include "base/threading/thread_task_runner_handle.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 #include "net/cert/x509_util.h"
 #include "net/cert/x509_util_win.h"
 #include "net/ssl/ssl_platform_key_util.h"
diff --git a/net/ssl/ssl_platform_key_win.h b/net/ssl/ssl_platform_key_win.h
index d42cba8f57..70e7061 100644
--- a/net/ssl/ssl_platform_key_win.h
+++ b/net/ssl/ssl_platform_key_win.h
@@ -11,7 +11,7 @@
 #include <NCrypt.h>
 
 #include "base/memory/ref_counted.h"
-#include "crypto/wincrypt_shim.h"
+#include "base/win/wincrypt_shim.h"
 #include "net/base/net_export.h"
 
 namespace net {