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 d0259c2702934d81bf592d07d20bc47783f44ced..459d9f3574e6411bd2c73254f7c5acf6aa5847a8 100644 |
| --- a/chrome/browser/intents/device_attached_intent_source.cc |
| +++ b/chrome/browser/intents/device_attached_intent_source.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/intents/device_attached_intent_source.h" |
| #include "base/file_path.h" |
| +#include "base/system_monitor/system_monitor.h" |
|
Lei Zhang
2012/08/01 23:49:05
nit: It's very unlikely you'll ever remove this in
kmadhusu
2012/08/02 16:59:03
Done.
|
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_window.h" |
| @@ -13,6 +14,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; |
| @@ -40,6 +48,7 @@ void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
| return; |
| // Only handle FilePaths for now. |
| + // TODO(kmadhusu): Handle all device types. |
| if (type != SystemMonitor::TYPE_PATH) |
| return; |
| @@ -48,6 +57,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. |
| @@ -66,3 +79,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: |
|
Lei Zhang
2012/08/01 23:49:05
This is currently dead code, since you've returned
kmadhusu
2012/08/02 16:59:03
I understand that this is a dead code now, but I a
|
| +#if defined(SUPPORT_MEDIA_FILESYSTEM) |
| + MediaDeviceMapService::GetInstance()->RemoveMediaDevice( |
|
Lei Zhang
2012/08/01 23:49:05
Also, why do this here? Don't you already call Rem
kmadhusu
2012/08/02 16:59:03
MediaFileSystemRegistry::RevokeMediaFileSystem han
|
| + it->second.location); |
| +#endif |
| + break; |
| + default: |
|
Lei Zhang
2012/08/01 23:49:05
You should use TYPE_PATH here, so if anyone ever a
kmadhusu
2012/08/02 16:59:03
Done.
|
| + break; |
| + } |
| + device_id_map_.erase(it); |
| +} |