Index: content/browser/gamepad/raw_input_data_fetcher_win.cc |
diff --git a/content/browser/gamepad/raw_input_data_fetcher_win.cc b/content/browser/gamepad/raw_input_data_fetcher_win.cc |
index 3a8788443fa939e97ba3a6388cb64d19db84f2cf..949e6fd10e235eb0d8b6084133414352c493ba48 100644 |
--- a/content/browser/gamepad/raw_input_data_fetcher_win.cc |
+++ b/content/browser/gamepad/raw_input_data_fetcher_win.cc |
@@ -41,6 +41,7 @@ RawInputDataFetcher::RawInputDataFetcher() |
, events_monitored_(false) {} |
RawInputDataFetcher::~RawInputDataFetcher() { |
+ ClearControllers(); |
DCHECK(!window_); |
DCHECK(!events_monitored_); |
} |
@@ -56,7 +57,7 @@ RAWINPUTDEVICE* RawInputDataFetcher::GetRawInputDevices(DWORD flags) { |
devices[i].dwFlags = flags; |
devices[i].usUsagePage = 1; |
devices[i].usUsage = DeviceUsages[i]; |
- devices[i].hwndTarget = window_->hwnd(); |
+ devices[i].hwndTarget = (flags & RIDEV_REMOVE) ? 0 : window_->hwnd(); |
} |
return devices.release(); |
} |
@@ -107,7 +108,6 @@ void RawInputDataFetcher::StopMonitor() { |
events_monitored_ = false; |
window_.reset(); |
- ClearControllers(); |
// Stop observing message loop destruction if no event is being monitored. |
base::MessageLoop::current()->RemoveDestructionObserver(this); |