Chromium Code Reviews| 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/itunes/itunes_file_util.h" | 15 #include "chrome/browser/media_galleries/fileapi/itunes/itunes_file_util.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h" | |
| 16 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 17 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 17 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" | 18 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 18 #include "webkit/blob/local_file_stream_reader.h" | 19 #include "webkit/blob/local_file_stream_reader.h" |
| 19 #include "webkit/fileapi/async_file_util_adapter.h" | 20 #include "webkit/fileapi/async_file_util_adapter.h" |
| 20 #include "webkit/fileapi/copy_or_move_file_validator.h" | 21 #include "webkit/fileapi/copy_or_move_file_validator.h" |
| 21 #include "webkit/fileapi/file_system_context.h" | 22 #include "webkit/fileapi/file_system_context.h" |
| 22 #include "webkit/fileapi/file_system_file_stream_reader.h" | 23 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 23 #include "webkit/fileapi/file_system_operation_context.h" | 24 #include "webkit/fileapi/file_system_operation_context.h" |
| 24 #include "webkit/fileapi/file_system_task_runners.h" | 25 #include "webkit/fileapi/file_system_task_runners.h" |
| 25 #include "webkit/fileapi/file_system_types.h" | 26 #include "webkit/fileapi/file_system_types.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 42 namespace chrome { | 43 namespace chrome { |
| 43 | 44 |
| 44 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = | 45 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = |
| 45 "MediaPathFilterKey"; | 46 "MediaPathFilterKey"; |
| 46 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = | 47 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = |
| 47 "MTPDeviceDelegateKey"; | 48 "MTPDeviceDelegateKey"; |
| 48 | 49 |
| 49 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( | 50 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( |
| 50 const base::FilePath& profile_path) | 51 const base::FilePath& profile_path) |
| 51 : profile_path_(profile_path), | 52 : profile_path_(profile_path), |
| 52 media_path_filter_(new MediaPathFilter()), | 53 media_path_filter_(new MediaPathFilter), |
| 54 media_copy_or_move_file_validator_factory_(new MediaFileValidatorFactory), | |
| 53 native_media_file_util_( | 55 native_media_file_util_( |
| 54 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), | 56 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), |
| 55 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( | 57 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( |
| 56 new itunes::ItunesFileUtil())) { | 58 new itunes::ItunesFileUtil())) { |
| 57 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) | 59 #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| 58 // TODO(kmadhusu): Initialize |device_media_file_util_| in | 60 // TODO(kmadhusu): Initialize |device_media_file_util_| in |
| 59 // initialization list. | 61 // initialization list. |
| 60 device_media_async_file_util_.reset( | 62 device_media_async_file_util_.reset( |
| 61 DeviceMediaAsyncFileUtil::Create(profile_path_)); | 63 DeviceMediaAsyncFileUtil::Create(profile_path_)); |
| 62 #endif | 64 #endif |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 } | 128 } |
| 127 | 129 |
| 128 fileapi::CopyOrMoveFileValidatorFactory* | 130 fileapi::CopyOrMoveFileValidatorFactory* |
| 129 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( | 131 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( |
| 130 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | 132 fileapi::FileSystemType type, base::PlatformFileError* error_code) { |
| 131 DCHECK(error_code); | 133 DCHECK(error_code); |
| 132 *error_code = base::PLATFORM_FILE_OK; | 134 *error_code = base::PLATFORM_FILE_OK; |
| 133 switch (type) { | 135 switch (type) { |
| 134 case fileapi::kFileSystemTypeNativeMedia: | 136 case fileapi::kFileSystemTypeNativeMedia: |
| 135 case fileapi::kFileSystemTypeDeviceMedia: | 137 case fileapi::kFileSystemTypeDeviceMedia: |
| 138 case fileapi::kFileSystemTypeItunes: | |
|
Greg Billock
2013/05/22 16:21:59
Bad merge?
vandebo (ex-Chrome)
2013/05/22 18:41:17
No, we'll need this to support writing to iTunes's
| |
| 136 if (!media_copy_or_move_file_validator_factory_) { | 139 if (!media_copy_or_move_file_validator_factory_) { |
| 137 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 140 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; |
| 138 return NULL; | 141 return NULL; |
| 139 } | 142 } |
| 140 return media_copy_or_move_file_validator_factory_.get(); | 143 return media_copy_or_move_file_validator_factory_.get(); |
| 141 default: | 144 default: |
| 142 NOTREACHED(); | 145 NOTREACHED(); |
| 143 } | 146 } |
| 144 return NULL; | 147 return NULL; |
| 145 } | 148 } |
| 146 | 149 |
| 147 void | 150 void |
| 148 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( | 151 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( |
|
Greg Billock
2013/05/22 16:21:59
How about just removing this and call sites?
vandebo (ex-Chrome)
2013/05/22 18:41:17
CopyorMoveValidator was added as a generic mechani
| |
| 149 fileapi::FileSystemType type, | 152 fileapi::FileSystemType type, |
| 150 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { | 153 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { |
| 151 switch (type) { | 154 NOTREACHED(); |
| 152 case fileapi::kFileSystemTypeNativeMedia: | |
| 153 case fileapi::kFileSystemTypeDeviceMedia: | |
| 154 if (!media_copy_or_move_file_validator_factory_) | |
| 155 media_copy_or_move_file_validator_factory_.reset(factory.release()); | |
| 156 break; | |
| 157 default: | |
| 158 NOTREACHED(); | |
| 159 } | |
| 160 } | 155 } |
| 161 | 156 |
| 162 fileapi::FilePermissionPolicy | 157 fileapi::FilePermissionPolicy |
| 163 MediaFileSystemMountPointProvider::GetPermissionPolicy( | 158 MediaFileSystemMountPointProvider::GetPermissionPolicy( |
| 164 const FileSystemURL& url, int permissions) const { | 159 const FileSystemURL& url, int permissions) const { |
| 165 // Access to media file systems should be checked using per-filesystem | 160 // Access to media file systems should be checked using per-filesystem |
| 166 // access permission. | 161 // access permission. |
| 167 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; | 162 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; |
| 168 } | 163 } |
| 169 | 164 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 void MediaFileSystemMountPointProvider::DeleteFileSystem( | 214 void MediaFileSystemMountPointProvider::DeleteFileSystem( |
| 220 const GURL& origin_url, | 215 const GURL& origin_url, |
| 221 fileapi::FileSystemType type, | 216 fileapi::FileSystemType type, |
| 222 FileSystemContext* context, | 217 FileSystemContext* context, |
| 223 const DeleteFileSystemCallback& callback) { | 218 const DeleteFileSystemCallback& callback) { |
| 224 NOTREACHED(); | 219 NOTREACHED(); |
| 225 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 220 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
| 226 } | 221 } |
| 227 | 222 |
| 228 } // namespace chrome | 223 } // namespace chrome |
| OLD | NEW |