Index: components/storage_monitor/volume_mount_watcher_win.cc |
diff --git a/components/storage_monitor/volume_mount_watcher_win.cc b/components/storage_monitor/volume_mount_watcher_win.cc |
index 101cbda2137b577731337b223184e163c504b825..8426cac84b8d3629ff47c4db6dc4a3e5bfdd0319 100644 |
--- a/components/storage_monitor/volume_mount_watcher_win.cc |
+++ b/components/storage_monitor/volume_mount_watcher_win.cc |
@@ -8,6 +8,7 @@ |
#include <dbt.h> |
#include <fileapi.h> |
+#include <shlobj.h> |
#include <winioctl.h> |
#include "base/bind_helpers.h" |
@@ -472,6 +473,30 @@ void VolumeMountWatcherWin::OnWindowMessage(UINT event_type, LPARAM data) { |
} |
} |
+void VolumeMountWatcherWin::OnMediaChange(WPARAM wparam, LPARAM lparam) { |
+ if (lparam == SHCNE_MEDIAINSERTED || lparam == SHCNE_MEDIAREMOVED) { |
+ struct _ITEMIDLIST* pidl = *reinterpret_cast<struct _ITEMIDLIST**>( |
+ wparam); |
+ wchar_t sPath[MAX_PATH]; |
+ if (!SHGetPathFromIDList(pidl, sPath)) { |
+ DVLOG(1) << "MediaInserted: SHGetPathFromIDList failed"; |
+ return; |
+ } |
+ switch (lparam) { |
+ case SHCNE_MEDIAINSERTED: { |
+ std::vector<base::FilePath> paths; |
+ paths.push_back(base::FilePath(sPath)); |
+ AddDevicesOnUIThread(paths); |
+ break; |
+ } |
+ case SHCNE_MEDIAREMOVED: { |
+ HandleDeviceDetachEventOnUIThread(sPath); |
+ break; |
+ } |
+ } |
+ } |
+} |
+ |
void VolumeMountWatcherWin::SetNotifications( |
StorageMonitor::Receiver* notifications) { |
notifications_ = notifications; |