Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: components/storage_monitor/volume_mount_watcher_win.cc

Issue 231063002: Add notification for media changed, and notify volume mount watcher when it occurs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Name and constant change Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698