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 56fdbe358085dfbf2e515a962e90543c697e8ec7..cc971cd59c251471828a743aeb165c7a15b8c050 100644 |
--- a/chrome/browser/intents/device_attached_intent_source.cc |
+++ b/chrome/browser/intents/device_attached_intent_source.cc |
@@ -13,6 +13,7 @@ |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/intents/web_intents_registry.h" |
#include "chrome/browser/intents/web_intents_registry_factory.h" |
+#include "chrome/browser/media_gallery/media_storage_util.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_window.h" |
@@ -31,6 +32,7 @@ using fileapi::MediaDeviceMapService; |
#endif |
using base::SystemMonitor; |
+using chrome::MediaStorageUtil; |
using content::WebContentsDelegate; |
using webkit_glue::WebIntentServiceData; |
@@ -97,7 +99,6 @@ DeviceAttachedIntentSource::~DeviceAttachedIntentSource() { |
void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
const std::string& id, |
const string16& name, |
- base::SystemMonitor::MediaDeviceType device_type, |
const FilePath::StringType& location) { |
if (!browser_->window()->IsActive()) |
return; |
@@ -106,17 +107,20 @@ void DeviceAttachedIntentSource::OnMediaDeviceAttached( |
if (browser_->profile()->IsOffTheRecord()) |
return; |
- // Only handle FilePaths for now. |
+ // Only handle mass storage for now. |
// TODO(kmadhusu): Handle all device types. http://crbug.com/140353. |
- if (device_type != SystemMonitor::TYPE_PATH) |
+ MediaStorageUtil::Type type; |
+ MediaStorageUtil::CrackDeviceId(id, &type, NULL); |
+ if (type == MediaStorageUtil::USB_MTP) |
return; |
+ DCHECK(MediaStorageUtil::IsRemovableDevice(id)); |
// Sanity checks for |device_path|. |
const FilePath device_path(location); |
if (!device_path.IsAbsolute() || device_path.ReferencesParent()) |
return; |
- SystemMonitor::MediaDeviceInfo device_info(id, name, device_type, location); |
+ SystemMonitor::MediaDeviceInfo device_info(id, name, location); |
scoped_refptr<DispatchIntentTaskHelper> task = new DispatchIntentTaskHelper( |
AsWeakPtr(), device_info); |
WebIntentsRegistryFactory::GetForProfile(browser_->profile())-> |
@@ -152,19 +156,19 @@ void DeviceAttachedIntentSource::OnMediaDeviceDetached(const std::string& id) { |
if (it == device_id_map_.end()) |
return; |
- // TODO(kmadhusu, vandebo): Clean up this code. http://crbug.com/140340. |
- |
+ // TODO(kmadhusu) This should be something like |
+ // RevokeFileSystemByDevice(std::string) |
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; |
+ // TODO(kmadhusu, vandebo): Clean up this code. http://crbug.com/140340. |
+ MediaStorageUtil::Type type; |
+ MediaStorageUtil::CrackDeviceId(it->second.unique_id, &type, NULL); |
+ if (type == MediaStorageUtil::USB_MTP) { |
+ MediaDeviceMapService::GetInstance()->RemoveMediaDevice( |
+ it->second.location); |
} |
+#endif |
device_id_map_.erase(it); |
} |