Index: chrome/browser/intents/device_attached_intent_source.cc |
diff --git a/chrome/browser/intents/device_attached_intent_source.cc b/chrome/browser/intents/device_attached_intent_source.cc |
index 3a2e5d530cb6b06f0803e45b1d0798ffa4e40f52..1526606e44caf26a374a5657cb83ce8359ae79a3 100644 |
--- a/chrome/browser/intents/device_attached_intent_source.cc |
+++ b/chrome/browser/intents/device_attached_intent_source.cc |
@@ -15,6 +15,13 @@ |
#include "webkit/fileapi/file_system_types.h" |
#include "webkit/fileapi/isolated_context.h" |
#include "webkit/glue/web_intent_data.h" |
+#include "webkit/fileapi/media/media_file_system_config.h" |
+ |
+#if defined(SUPPORT_MEDIA_FILESYSTEM) |
+#include "webkit/fileapi/media/media_device_map_service.h" |
+ |
+using fileapi::MediaDeviceMapService; |
+#endif |
using base::SystemMonitor; |
using content::WebContentsDelegate; |
@@ -42,6 +49,7 @@ void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
return; |
// Only handle FilePaths for now. |
+ // TODO(kmadhusu): Handle all device types. http://crbug.com/140353. |
if (type != SystemMonitor::TYPE_PATH) |
return; |
@@ -50,6 +58,10 @@ void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
if (!device_path.IsAbsolute() || device_path.ReferencesParent()) |
return; |
+ // Store the media device info locally. |
+ SystemMonitor::MediaDeviceInfo device_info(id, name, type, location); |
+ device_id_map_.insert(std::make_pair(id, device_info)); |
+ |
std::string device_name; |
// Register device path as an isolated file system. |
@@ -68,3 +80,25 @@ void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
delegate_->WebIntentDispatch(NULL /* no WebContents */, |
content::WebIntentsDispatcher::Create(intent)); |
} |
+ |
+void DeviceAttachedIntentSource::OnMediaDeviceDetached(const std::string& id) { |
+ DeviceIdToInfoMap::iterator it = device_id_map_.find(id); |
+ if (it == device_id_map_.end()) |
+ return; |
+ |
+ // TODO(kmadhusu, vandebo): Clean up this code. http://crbug.com/140340. |
+ |
+ FilePath path(it->second.location); |
+ fileapi::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path); |
+ switch (it->second.type) { |
+ case SystemMonitor::TYPE_MTP: |
+#if defined(SUPPORT_MEDIA_FILESYSTEM) |
+ MediaDeviceMapService::GetInstance()->RemoveMediaDevice( |
+ it->second.location); |
+#endif |
+ break; |
+ case SystemMonitor::TYPE_PATH: |
+ break; |
+ } |
+ device_id_map_.erase(it); |
+} |