Chromium Code Reviews| Index: chrome/browser/media_gallery/media_file_system_registry.cc |
| diff --git a/chrome/browser/media_gallery/media_file_system_registry.cc b/chrome/browser/media_gallery/media_file_system_registry.cc |
| index 455b4a180a96f6b9051e59f4604dd18388db04b8..4e3b2d106bbc8d637e2f6a1bd3dc3b431482e154 100644 |
| --- a/chrome/browser/media_gallery/media_file_system_registry.cc |
| +++ b/chrome/browser/media_gallery/media_file_system_registry.cc |
| @@ -20,6 +20,13 @@ |
| #include "content/public/browser/render_process_host.h" |
| #include "webkit/fileapi/file_system_types.h" |
| #include "webkit/fileapi/isolated_context.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 |
| namespace chrome { |
| @@ -75,7 +82,8 @@ MediaFileSystemRegistry::GetMediaFileSystems( |
| if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) && |
| IsGalleryPermittedForExtension(extension, SystemMonitor::TYPE_PATH, |
| pictures_path.value())) { |
| - std::string fsid = RegisterPathAsFileSystem(pictures_path); |
| + std::string fsid = RegisterPathAsFileSystem(pictures_path, |
| + SystemMonitor::TYPE_PATH); |
| child_it->second.insert(std::make_pair(pictures_path, fsid)); |
| } |
| } |
| @@ -90,7 +98,8 @@ MediaFileSystemRegistry::GetMediaFileSystems( |
| media_devices[i].location)) { |
| FilePath path(media_devices[i].location); |
| device_id_map_.insert(std::make_pair(media_devices[i].unique_id, path)); |
| - const std::string fsid = RegisterPathAsFileSystem(path); |
| + const std::string fsid = RegisterPathAsFileSystem(path, |
| + media_devices[i].type); |
| child_it->second.insert(std::make_pair(path, fsid)); |
| } |
| } |
| @@ -106,12 +115,19 @@ MediaFileSystemRegistry::GetMediaFileSystems( |
| return results; |
| } |
| -void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { |
| +void MediaFileSystemRegistry::OnMediaDeviceDetached( |
| + const std::string& id, |
| + const FilePath::StringType& location) { |
|
Lei Zhang
2012/07/31 20:48:18
I don't think you need to change SystemMonitor to
kmadhusu
2012/08/01 01:43:59
Fixed. I realized that I also need type informati
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); |
| if (it == device_id_map_.end()) |
| return; |
| + |
| +#if defined(SUPPORT_MEDIA_FILESYSTEM) |
| + MediaDeviceMapService::GetInstance()->RemoveMediaDevice(location); |
| +#endif |
| + |
| RevokeMediaFileSystem(it->second); |
| device_id_map_.erase(it); |
| } |
| @@ -161,19 +177,23 @@ void MediaFileSystemRegistry::UnregisterForRPHGoneNotifications( |
| } |
| std::string MediaFileSystemRegistry::RegisterPathAsFileSystem( |
| - const FilePath& path) { |
| + const FilePath& path, const SystemMonitor::MediaDeviceType& device_type) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| // Sanity checks for |path|. |
| CHECK(path.IsAbsolute()); |
| CHECK(!path.ReferencesParent()); |
| + fileapi::FileSystemType type = fileapi::kFileSystemTypeIsolated; |
|
Lei Zhang
2012/07/31 20:48:18
This block probably should be a switch statement.
kinuko
2012/07/31 23:29:54
I'm afraid if we change this to a switch statement
Lei Zhang
2012/07/31 23:34:41
I meant a switch for SystemMonitor::MediaDeviceTyp
kmadhusu
2012/08/01 01:43:59
Done.
|
| + if (device_type == SystemMonitor::TYPE_MTP) |
| + type = fileapi::kFileSystemTypeDeviceMedia; |
| + |
| // The directory name is not exposed to the js layer and we simply use |
| // a fixed name (as we only register a single directory per file system). |
| std::string register_name("_"); |
| const std::string fsid = |
| IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| - fileapi::kFileSystemTypeIsolated, path, ®ister_name); |
| + type, path, ®ister_name); |
| CHECK(!fsid.empty()); |
| return fsid; |
| } |