Chromium Code Reviews| 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..97ec535a8e924eb72949722700295583ddb8fc13 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. |
| 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,24 @@ 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; |
| + |
| + FilePath path(it->second.location); |
| + // TODO(kinuko, kmadhusu): Revoke file system by path. |
| + // 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; |
|
kinuko
2012/08/02 20:33:44
nit: no need to have default (with NOTREACHED)? (h
kmadhusu
2012/08/02 22:05:39
NOTREACHED() is not required here. We don't need t
|
| + } |
| + device_id_map_.erase(it); |
| +} |