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

Unified Diff: chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.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/media_transfer_protocol_device_observer_linux.cc
diff --git a/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc b/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
index f84ace5779efafa7b5b900ade4a026b3574dfab5..afb9a78a6c99104b2a7584c964cb682503023738 100644
--- a/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
+++ b/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
@@ -165,6 +165,21 @@ bool MediaTransferProtocolDeviceObserverLinux::GetStorageInfoForPath(
return true;
}
+void MediaTransferProtocolDeviceObserverLinux::EjectDevice(
+ const std::string& device_id,
+ base::Callback<void(StorageMonitor::EjectStatus)> callback) {
+ std::string location;
+ if (!GetLocationForDeviceId(device_id, &location)) {
+ callback.Run(StorageMonitor::EJECT_NO_SUCH_DEVICE);
+ return;
+ }
+
+ // TODO(thestig): Change this to tell the mtp manager to eject the device.
+
+ StorageChanged(false, location);
+ callback.Run(StorageMonitor::EJECT_OK);
+}
+
// device::MediaTransferProtocolManager::Observer override.
void MediaTransferProtocolDeviceObserverLinux::StorageChanged(
bool is_attached,
@@ -211,4 +226,17 @@ void MediaTransferProtocolDeviceObserverLinux::EnumerateStorages() {
}
}
+bool MediaTransferProtocolDeviceObserverLinux::GetLocationForDeviceId(
+ const std::string& device_id, std::string* location) const {
+ for (StorageLocationToInfoMap::const_iterator it = storage_map_.begin();
+ it != storage_map_.end(); ++it) {
+ if (it->second.device_id() == device_id) {
+ *location = it->first;
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698