| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p
rovider.h" | 5 #include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_p
rovider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" | 15 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/itunes/itunes_file_util.h" | 16 #include "chrome/browser/media_galleries/fileapi/itunes/itunes_file_util.h" |
| 17 #include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h" |
| 17 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 18 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 18 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" | 19 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 19 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" | 20 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" |
| 20 #include "webkit/blob/local_file_stream_reader.h" | 21 #include "webkit/blob/local_file_stream_reader.h" |
| 21 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 22 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
| 22 #include "webkit/browser/fileapi/isolated_file_util.h" | 23 #include "webkit/browser/fileapi/isolated_file_util.h" |
| 23 #include "webkit/browser/fileapi/native_file_util.h" | 24 #include "webkit/browser/fileapi/native_file_util.h" |
| 24 #include "webkit/fileapi/async_file_util_adapter.h" | 25 #include "webkit/fileapi/async_file_util_adapter.h" |
| 25 #include "webkit/fileapi/file_system_context.h" | 26 #include "webkit/fileapi/file_system_context.h" |
| 26 #include "webkit/fileapi/file_system_file_stream_reader.h" | 27 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 namespace chrome { | 40 namespace chrome { |
| 40 | 41 |
| 41 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = | 42 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = |
| 42 "MediaPathFilterKey"; | 43 "MediaPathFilterKey"; |
| 43 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = | 44 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = |
| 44 "MTPDeviceDelegateKey"; | 45 "MTPDeviceDelegateKey"; |
| 45 | 46 |
| 46 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( | 47 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( |
| 47 const base::FilePath& profile_path) | 48 const base::FilePath& profile_path) |
| 48 : profile_path_(profile_path), | 49 : profile_path_(profile_path), |
| 49 media_path_filter_(new MediaPathFilter()), | 50 media_path_filter_(new MediaPathFilter), |
| 51 media_copy_or_move_file_validator_factory_(new MediaFileValidatorFactory), |
| 50 native_media_file_util_( | 52 native_media_file_util_( |
| 51 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), | 53 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), |
| 52 device_media_async_file_util_( | 54 device_media_async_file_util_( |
| 53 DeviceMediaAsyncFileUtil::Create(profile_path_)), | 55 DeviceMediaAsyncFileUtil::Create(profile_path_)), |
| 54 picasa_file_util_( | 56 picasa_file_util_( |
| 55 new fileapi::AsyncFileUtilAdapter(new picasa::PicasaFileUtil())), | 57 new fileapi::AsyncFileUtilAdapter(new picasa::PicasaFileUtil())), |
| 56 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( | 58 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( |
| 57 new itunes::ItunesFileUtil())) { | 59 new itunes::ItunesFileUtil())) { |
| 58 } | 60 } |
| 59 | 61 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 124 } |
| 123 | 125 |
| 124 fileapi::CopyOrMoveFileValidatorFactory* | 126 fileapi::CopyOrMoveFileValidatorFactory* |
| 125 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( | 127 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( |
| 126 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | 128 fileapi::FileSystemType type, base::PlatformFileError* error_code) { |
| 127 DCHECK(error_code); | 129 DCHECK(error_code); |
| 128 *error_code = base::PLATFORM_FILE_OK; | 130 *error_code = base::PLATFORM_FILE_OK; |
| 129 switch (type) { | 131 switch (type) { |
| 130 case fileapi::kFileSystemTypeNativeMedia: | 132 case fileapi::kFileSystemTypeNativeMedia: |
| 131 case fileapi::kFileSystemTypeDeviceMedia: | 133 case fileapi::kFileSystemTypeDeviceMedia: |
| 134 case fileapi::kFileSystemTypeItunes: |
| 132 if (!media_copy_or_move_file_validator_factory_) { | 135 if (!media_copy_or_move_file_validator_factory_) { |
| 133 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 136 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; |
| 134 return NULL; | 137 return NULL; |
| 135 } | 138 } |
| 136 return media_copy_or_move_file_validator_factory_.get(); | 139 return media_copy_or_move_file_validator_factory_.get(); |
| 137 default: | 140 default: |
| 138 NOTREACHED(); | 141 NOTREACHED(); |
| 139 } | 142 } |
| 140 return NULL; | 143 return NULL; |
| 141 } | 144 } |
| 142 | 145 |
| 143 void | 146 void |
| 144 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( | 147 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( |
| 145 fileapi::FileSystemType type, | 148 fileapi::FileSystemType type, |
| 146 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { | 149 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { |
| 147 switch (type) { | 150 NOTREACHED(); |
| 148 case fileapi::kFileSystemTypeNativeMedia: | |
| 149 case fileapi::kFileSystemTypeDeviceMedia: | |
| 150 if (!media_copy_or_move_file_validator_factory_) | |
| 151 media_copy_or_move_file_validator_factory_.reset(factory.release()); | |
| 152 break; | |
| 153 default: | |
| 154 NOTREACHED(); | |
| 155 } | |
| 156 } | 151 } |
| 157 | 152 |
| 158 fileapi::FilePermissionPolicy | 153 fileapi::FilePermissionPolicy |
| 159 MediaFileSystemMountPointProvider::GetPermissionPolicy( | 154 MediaFileSystemMountPointProvider::GetPermissionPolicy( |
| 160 const FileSystemURL& url, int permissions) const { | 155 const FileSystemURL& url, int permissions) const { |
| 161 // Access to media file systems should be checked using per-filesystem | 156 // Access to media file systems should be checked using per-filesystem |
| 162 // access permission. | 157 // access permission. |
| 163 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; | 158 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; |
| 164 } | 159 } |
| 165 | 160 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 void MediaFileSystemMountPointProvider::DeleteFileSystem( | 208 void MediaFileSystemMountPointProvider::DeleteFileSystem( |
| 214 const GURL& origin_url, | 209 const GURL& origin_url, |
| 215 fileapi::FileSystemType type, | 210 fileapi::FileSystemType type, |
| 216 FileSystemContext* context, | 211 FileSystemContext* context, |
| 217 const DeleteFileSystemCallback& callback) { | 212 const DeleteFileSystemCallback& callback) { |
| 218 NOTREACHED(); | 213 NOTREACHED(); |
| 219 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 214 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
| 220 } | 215 } |
| 221 | 216 |
| 222 } // namespace chrome | 217 } // namespace chrome |
| OLD | NEW |