Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/system_message_window_win.h" | 5 #include "content/browser/system_message_window_win.h" |
| 6 | 6 |
| 7 #include <dbt.h> | 7 #include <dbt.h> |
| 8 #include <ks.h> | |
| 9 #include <ksmedia.h> | |
| 10 | 8 |
| 11 #include "base/logging.h" | 9 #include "base/logging.h" |
| 12 #include "base/system_monitor/system_monitor.h" | 10 #include "base/system_monitor/system_monitor.h" |
| 13 #include "base/win/wrapped_window_proc.h" | 11 #include "base/win/wrapped_window_proc.h" |
| 12 #include "media/audio/win/core_audio_util_win.h" | |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 17 | |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
no need for these whitespace changes.
no longer working on chromium
2012/12/13 14:54:58
Done.
| |
| 18 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow"; | 18 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow"; |
| 19 | 19 |
| 20 // A static map from a device category guid to base::SystemMonitor::DeviceType. | 20 // A static map from a device category guid to base::SystemMonitor::DeviceType. |
| 21 struct { | 21 struct { |
| 22 const GUID device_category; | 22 const GUID device_category; |
| 23 const base::SystemMonitor::DeviceType device_type; | 23 const base::SystemMonitor::DeviceType device_type; |
| 24 } const kDeviceCategoryMap[] = { | 24 } const kDeviceCategoryMap[] = { |
| 25 { KSCATEGORY_AUDIO, base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE }, | 25 { KSCATEGORY_AUDIO, base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE }, |
| 26 { KSCATEGORY_VIDEO, base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE }, | 26 { KSCATEGORY_VIDEO, base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE }, |
| 27 }; | 27 }; |
| 28 | |
| 28 } // namespace | 29 } // namespace |
| 29 | 30 |
| 30 // Manages the device notification handles for SystemMessageWindowWin. | 31 // Manages the device notification handles for SystemMessageWindowWin. |
| 31 class SystemMessageWindowWin::DeviceNotifications { | 32 class SystemMessageWindowWin::DeviceNotifications { |
| 32 public: | 33 public: |
| 33 explicit DeviceNotifications(HWND hwnd) : notifications_() { | 34 explicit DeviceNotifications(HWND hwnd) : notifications_() { |
| 34 Register(hwnd); | 35 Register(hwnd); |
| 35 } | 36 } |
| 36 | 37 |
| 37 ~DeviceNotifications() { | 38 ~DeviceNotifications() { |
| 38 Unregister(); | 39 Unregister(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void Register(HWND hwnd) { | 42 void Register(HWND hwnd) { |
| 42 // Request to receive device notifications. All applications receive basic | 43 // Request to receive device notifications. All applications receive basic |
| 43 // notifications via WM_DEVICECHANGE but in order to receive detailed device | 44 // notifications via WM_DEVICECHANGE but in order to receive detailed device |
| 44 // arrival and removal messages, we need to register. | 45 // arrival and removal messages, we need to register. |
| 45 DEV_BROADCAST_DEVICEINTERFACE filter = {0}; | 46 DEV_BROADCAST_DEVICEINTERFACE filter = {0}; |
| 46 filter.dbcc_size = sizeof(filter); | 47 filter.dbcc_size = sizeof(filter); |
| 47 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; | 48 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; |
| 48 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { | 49 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { |
| 50 // From Vista, we use a device listener in AudioDeviceListenerWin. | |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
The phrasing can be improved here and I think it's
no longer working on chromium
2012/12/13 14:54:58
Done.
| |
| 51 if (media::CoreAudioUtil::IsSupported() && | |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
nit: Just call this method once outside the loop a
no longer working on chromium
2012/12/13 14:54:58
Done.
| |
| 52 KSCATEGORY_AUDIO == kDeviceCategoryMap[i].device_category) | |
| 53 continue; | |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
use {} when an if clause spans more than 2 lines.
no longer working on chromium
2012/12/13 14:54:58
Done.
| |
| 54 | |
| 49 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; | 55 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; |
| 50 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL)); | 56 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL)); |
| 51 notifications_[i] = RegisterDeviceNotification( | 57 notifications_[i] = RegisterDeviceNotification( |
| 52 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE); | 58 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE); |
| 53 DPLOG_IF(ERROR, !notifications_[i]) | 59 DPLOG_IF(ERROR, !notifications_[i]) |
| 54 << "RegisterDeviceNotification failed"; | 60 << "RegisterDeviceNotification failed"; |
| 55 } | 61 } |
| 56 } | 62 } |
| 57 | 63 |
| 58 void Unregister() { | 64 void Unregister() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 case WM_DEVICECHANGE: | 152 case WM_DEVICECHANGE: |
| 147 return OnDeviceChange(static_cast<UINT>(wparam), lparam); | 153 return OnDeviceChange(static_cast<UINT>(wparam), lparam); |
| 148 default: | 154 default: |
| 149 break; | 155 break; |
| 150 } | 156 } |
| 151 | 157 |
| 152 return ::DefWindowProc(hwnd, message, wparam, lparam); | 158 return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 153 } | 159 } |
| 154 | 160 |
| 155 } // namespace content | 161 } // namespace content |
| OLD | NEW |