Avoid windows.h in shared_memory.h

shared_memory.h ends up being included by consumers of webrtc such as
Chromium so it causes namespace pollution. Specifically, it causes
SendMessageCallback to be defined as SendMessageCallbackW partway
through compilation of security_key_auth_handler_win_unittest.cc,
leading to renaming of SendMessageCallback when it is used but not when
it is defined.

Bug: Chromium:796644
Change-Id: Ib1acc0d736a0a6cf97e318e773b20d9a432f6b77
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229901
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#34887}
diff --git a/modules/desktop_capture/shared_memory.h b/modules/desktop_capture/shared_memory.h
index 2e2d2f3..49a9252 100644
--- a/modules/desktop_capture/shared_memory.h
+++ b/modules/desktop_capture/shared_memory.h
@@ -14,7 +14,9 @@
 #include <stddef.h>
 
 #if defined(WEBRTC_WIN)
-#include <windows.h>
+// Forward declare HANDLE in a windows.h compatible way so that we can avoid
+// including windows.h.
+typedef void* HANDLE;
 #endif
 
 #include <memory>
diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h
index 1e0541b..ac60c5a 100644
--- a/modules/desktop_capture/win/screen_capture_utils.h
+++ b/modules/desktop_capture/win/screen_capture_utils.h
@@ -11,6 +11,16 @@
 #ifndef MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
 #define MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
 
+#if defined(WEBRTC_WIN)
+// Forward declare HMONITOR in a windows.h compatible way so that we can avoid
+// including windows.h.
+#define WEBRTC_DECLARE_HANDLE(name) \
+struct name##__;                  \
+typedef struct name##__* name
+WEBRTC_DECLARE_HANDLE(HMONITOR);
+#undef WEBRTC_DECLARE_HANDLE
+#endif
+
 #include <string>
 #include <vector>