Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Unified Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ebeca1a5bb4e959de449d0b218c6d4c1ce1af0a5..7617cc8630faf5970ab5853bd0f6daa4273ac5a2 100644
--- a/chrome/browser/media_gallery/media_file_system_registry.cc
+++ b/chrome/browser/media_gallery/media_file_system_registry.cc
@@ -21,6 +21,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 {
@@ -76,7 +83,8 @@ MediaFileSystemRegistry::GetMediaFileSystemsForExtension(
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));
}
}
@@ -89,9 +97,11 @@ MediaFileSystemRegistry::GetMediaFileSystemsForExtension(
if (media_devices[i].type == SystemMonitor::TYPE_PATH &&
IsGalleryPermittedForExtension(extension, media_devices[i].type,
media_devices[i].location)) {
+ device_id_map_.insert(std::make_pair(media_devices[i].unique_id,
+ media_devices[i]));
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));
}
}
@@ -113,10 +123,19 @@ MediaFileSystemRegistry::GetMediaFileSystemsForExtension(
void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id);
+ DeviceIdToInfoMap::iterator it = device_id_map_.find(id);
if (it == device_id_map_.end())
return;
- RevokeMediaFileSystem(it->second);
+
+#if defined(SUPPORT_MEDIA_FILESYSTEM)
+ if (it->second.type == SystemMonitor::TYPE_MTP) {
+ MediaDeviceMapService::GetInstance()->RemoveMediaDevice(
+ it->second.location);
+ }
+#endif
+
+ FilePath path(it->second.location);
+ RevokeMediaFileSystem(path);
kinuko 2012/08/01 04:24:27 For the file system we register in DeviceAttachedI
kmadhusu 2012/08/01 23:39:35 As we discussed, modified device intent source no
device_id_map_.erase(it);
}
@@ -165,19 +184,30 @@ 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;
+ switch (device_type) {
+ case SystemMonitor::TYPE_MTP:
+ type = fileapi::kFileSystemTypeDeviceMedia;
+ break;
+ case SystemMonitor::TYPE_PATH:
+ // TODO(kmadhusu): This should be kFileSystemTypeNativeMedia.
+ type = fileapi::kFileSystemTypeIsolated;
+ break;
+ }
+
// 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(extension_misc::kMediaFileSystemPathPart);
const std::string fsid =
IsolatedContext::GetInstance()->RegisterFileSystemForPath(
- fileapi::kFileSystemTypeIsolated, path, &register_name);
+ type, path, &register_name);
CHECK(!fsid.empty());
return fsid;
}

Powered by Google App Engine
This is Rietveld 408576698