diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 0e3d3b00a5774..e2d6fc46e7ba0 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1106,6 +1106,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) { void NativeWindowViews::SetContentProtection(bool enable) { #if defined(OS_WIN) HWND hwnd = GetAcceleratedWidget(); + DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE; + ::SetWindowDisplayAffinity(hwnd, affinity); if (!layered_) { // Workaround to prevent black window on screen capture after hiding and // showing the BrowserWindow. @@ -1114,8 +1116,6 @@ void NativeWindowViews::SetContentProtection(bool enable) { ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); layered_ = true; } - DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE; - ::SetWindowDisplayAffinity(hwnd, affinity); #endif }