win7dep: Remove DWMComposition change handling

Bug: 1385856
Change-Id: I65087df74659d34a8ecd1f6e3a13167b55efd71f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4151326
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091353}
diff --git a/ui/base/win/shell.cc b/ui/base/win/shell.cc
index 36741dc95..ff10878 100644
--- a/ui/base/win/shell.cc
+++ b/ui/base/win/shell.cc
@@ -21,11 +21,9 @@
 #include "base/threading/scoped_blocking_call.h"
 #include "base/threading/scoped_thread_priority.h"
 #include "base/win/win_util.h"
-#include "base/win/windows_version.h"
 #include "ui/base/ui_base_switches.h"
 
-namespace ui {
-namespace win {
+namespace ui::win {
 
 namespace {
 
@@ -180,27 +178,14 @@
 }
 
 bool IsAeroGlassEnabled() {
-  // For testing in Win8 (where it is not possible to disable composition) the
+  // For testing in Win8+ (where it is not possible to disable composition) the
   // user can specify this command line switch to mimic the behavior.  In this
   // mode, cross-HWND transparency is not supported and various types of
   // widgets fallback to more simplified rendering behavior.
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kDisableDwmComposition))
-    return false;
-
-  // If composition is not enabled, we behave like on XP.
-  return IsDwmCompositionEnabled();
+  // TODO(https://crbug.com/1385856): See if this switch and the code to support
+  // it can be removed.
+  return !base::CommandLine::ForCurrentProcess()->HasSwitch(
+      switches::kDisableDwmComposition);
 }
 
-bool IsDwmCompositionEnabled() {
-  // As of Windows 8, DWM composition is always enabled.
-  // In Windows 7 this can change at runtime.
-  if (base::win::GetVersion() >= base::win::Version::WIN8) {
-    return true;
-  }
-  BOOL is_enabled;
-  return SUCCEEDED(DwmIsCompositionEnabled(&is_enabled)) && is_enabled;
-}
-
-}  // namespace win
-}  // namespace ui
+}  // namespace ui::win
diff --git a/ui/base/win/shell.h b/ui/base/win/shell.h
index 3a48c88..d7e5e7bb 100644
--- a/ui/base/win/shell.h
+++ b/ui/base/win/shell.h
@@ -15,8 +15,7 @@
 class FilePath;
 }
 
-namespace ui {
-namespace win {
+namespace ui::win {
 
 // Open the folder at |full_path| via the Windows shell. It is an error if
 // |full_path| does not refer to a folder.
@@ -81,11 +80,6 @@
 // This method supports a command-line override for testing.
 COMPONENT_EXPORT(UI_BASE) bool IsAeroGlassEnabled();
 
-// Returns true if dwm composition is available and turned on on the current
-// platform.
-COMPONENT_EXPORT(UI_BASE) bool IsDwmCompositionEnabled();
-
-}  // namespace win
-}  // namespace ui
+}  // namespace ui::win
 
 #endif  // UI_BASE_WIN_SHELL_H_
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 6ba506fc..2fda18f 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -232,13 +232,6 @@
   EnableMenuItem(menu, command, flags);
 }
 
-// Callback used to notify child windows that the top level window received a
-// DWMCompositionChanged message.
-BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) {
-  SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0);
-  return TRUE;
-}
-
 // The thickness of an auto-hide taskbar in pixels.
 constexpr int kAutoHideTaskbarThicknessPx = 2;
 
@@ -431,7 +424,6 @@
       touch_down_contexts_(0),
       last_mouse_hwheel_time_(0),
       dwm_transition_desired_(false),
-      dwm_composition_enabled_(ui::win::IsDwmCompositionEnabled()),
       sent_window_size_changing_(false),
       did_return_uia_object_(false),
       left_button_down_on_caption_(false),
@@ -1805,29 +1797,6 @@
   SendFrameChanged();
 }
 
-LRESULT HWNDMessageHandler::OnDwmCompositionChanged(UINT msg,
-                                                    WPARAM /* w_param */,
-                                                    LPARAM /* l_param */) {
-  TRACE_EVENT0("ui", "HWNDMessageHandler::OnDwmCompositionChanged");
-
-  if (!delegate_->HasNonClientView()) {
-    SetMsgHandled(FALSE);
-    return 0;
-  }
-
-  bool dwm_composition_enabled = ui::win::IsDwmCompositionEnabled();
-  if (dwm_composition_enabled_ != dwm_composition_enabled) {
-    // Do not cause the Window to be hidden and shown unless there was
-    // an actual change in the theme. This filter is necessary because
-    // Windows sends redundant WM_DWMCOMPOSITIONCHANGED messages when
-    // a laptop is reopened, and our theme change code causes wonky
-    // focus issues. See http://crbug.com/895855 for more information.
-    dwm_composition_enabled_ = dwm_composition_enabled;
-    FrameTypeChanged();
-  }
-  return 0;
-}
-
 LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg,
                                          WPARAM w_param,
                                          LPARAM l_param) {
@@ -3512,10 +3481,6 @@
     SetWindowPos(hwnd(), nullptr, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
     SetWindowPos(hwnd(), nullptr, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
   }
-  // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
-  // to notify our children too, since we can have MDI child windows who need to
-  // update their appearance.
-  EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
 }
 
 void HWNDMessageHandler::UpdateDwmFrame() {
diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h
index ef3ea5c..7d2cf25 100644
--- a/ui/views/win/hwnd_message_handler.h
+++ b/ui/views/win/hwnd_message_handler.h
@@ -368,9 +368,6 @@
     CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption)
     CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame)
 
-    // Vista and newer
-    CR_MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged)
-
     // Win 8.1 and newer
     CR_MESSAGE_HANDLER_EX(WM_DPICHANGED, OnDpiChanged)
 
@@ -480,7 +477,6 @@
   void OnDestroy();
   void OnDisplayChange(UINT bits_per_pixel, const gfx::Size& screen_size);
   LRESULT OnDpiChanged(UINT msg, WPARAM w_param, LPARAM l_param);
-  LRESULT OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param);
   void OnEnterMenuLoop(BOOL from_track_popup_menu);
   void OnEnterSizeMove();
   LRESULT OnEraseBkgnd(HDC dc);
@@ -743,11 +739,6 @@
   // glass. Defaults to false.
   bool dwm_transition_desired_;
 
-  // Is DWM composition currently enabled?
-  // Note: According to MSDN docs for DwmIsCompositionEnabled(), this is always
-  // true starting in Windows 8.
-  bool dwm_composition_enabled_;
-
   // True if HandleWindowSizeChanging has been called in the delegate, but not
   // HandleClientSizeChanged.
   bool sent_window_size_changing_;