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

Unified Diff: chrome/browser/storage_monitor/portable_device_watcher_win.cc

Issue 23383009: [StorageMonitor] Handle EjectDevice call for MTP devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows MTP device name tweak Created 7 years, 3 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
Index: chrome/browser/storage_monitor/portable_device_watcher_win.cc
diff --git a/chrome/browser/storage_monitor/portable_device_watcher_win.cc b/chrome/browser/storage_monitor/portable_device_watcher_win.cc
index 2a2b9da9b0894bd04cad45dc3cf439aa525f60de..efa5b2ce0f44394059c6240d9cb392046004034c 100644
--- a/chrome/browser/storage_monitor/portable_device_watcher_win.cc
+++ b/chrome/browser/storage_monitor/portable_device_watcher_win.cc
@@ -555,7 +555,19 @@ void PortableDeviceWatcherWin::SetNotifications(
void PortableDeviceWatcherWin::EjectDevice(
const std::string& device_id,
base::Callback<void(StorageMonitor::EjectStatus)> callback) {
- callback.Run(chrome::StorageMonitor::EJECT_FAILURE);
+ // MTP devices on Windows don't have a detach API needed -- signal
+ // the object as if the device is gone and tell the caller it is OK
+ // to remove.
+ string16 device_location; // The device_map_ key.
+ string16 storage_object_id;
+ if (!GetMTPStorageInfoFromDeviceId(device_id,
+ &device_location, &storage_object_id)) {
+ callback.Run(chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE);
+ return;
+ }
+ HandleDeviceDetachEvent(device_location);
+
+ callback.Run(chrome::StorageMonitor::EJECT_OK);
}
void PortableDeviceWatcherWin::EnumerateAttachedDevices() {
@@ -623,7 +635,7 @@ void PortableDeviceWatcherWin::OnDidHandleDeviceAttachEvent(
string16 storage_name(name + L" (" + storage_iter->object_temporary_id +
L')');
StorageInfo info(storage_id, storage_name, location,
- string16(), string16(), string16(), 0);
+ storage_name, string16(), string16(), 0);
storage_map_[storage_id] = info;
if (storage_notifications_) {
info.set_location(GetStoragePathFromStorageId(storage_id));

Powered by Google App Engine
This is Rietveld 408576698