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

Side by Side Diff: chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.cc

Issue 15624003: Validate image files before writing them to media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, address comments, unit test. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/blob/local_file_stream_reader.h" 21 #include "webkit/browser/blob/local_file_stream_reader.h"
21 #include "webkit/browser/fileapi/async_file_util_adapter.h" 22 #include "webkit/browser/fileapi/async_file_util_adapter.h"
22 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" 23 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
23 #include "webkit/browser/fileapi/file_system_context.h" 24 #include "webkit/browser/fileapi/file_system_context.h"
24 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" 25 #include "webkit/browser/fileapi/file_system_file_stream_reader.h"
25 #include "webkit/browser/fileapi/file_system_operation_context.h" 26 #include "webkit/browser/fileapi/file_system_operation_context.h"
26 #include "webkit/browser/fileapi/file_system_task_runners.h" 27 #include "webkit/browser/fileapi/file_system_task_runners.h"
(...skipping 11 matching lines...) Expand all
38 namespace chrome { 39 namespace chrome {
39 40
40 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] = 41 const char MediaFileSystemMountPointProvider::kMediaPathFilterKey[] =
41 "MediaPathFilterKey"; 42 "MediaPathFilterKey";
42 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = 43 const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] =
43 "MTPDeviceDelegateKey"; 44 "MTPDeviceDelegateKey";
44 45
45 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( 46 MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider(
46 const base::FilePath& profile_path) 47 const base::FilePath& profile_path)
47 : profile_path_(profile_path), 48 : profile_path_(profile_path),
48 media_path_filter_(new MediaPathFilter()), 49 media_path_filter_(new MediaPathFilter),
50 media_copy_or_move_file_validator_factory_(new MediaFileValidatorFactory),
49 native_media_file_util_( 51 native_media_file_util_(
50 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), 52 new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())),
51 device_media_async_file_util_( 53 device_media_async_file_util_(
52 DeviceMediaAsyncFileUtil::Create(profile_path_)), 54 DeviceMediaAsyncFileUtil::Create(profile_path_)),
53 picasa_file_util_( 55 picasa_file_util_(
54 new fileapi::AsyncFileUtilAdapter(new picasa::PicasaFileUtil())), 56 new fileapi::AsyncFileUtilAdapter(new picasa::PicasaFileUtil())),
55 itunes_file_util_(new fileapi::AsyncFileUtilAdapter( 57 itunes_file_util_(new fileapi::AsyncFileUtilAdapter(
56 new itunes::ItunesFileUtil())) { 58 new itunes::ItunesFileUtil())) {
57 } 59 }
58 60
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 114 }
113 115
114 fileapi::CopyOrMoveFileValidatorFactory* 116 fileapi::CopyOrMoveFileValidatorFactory*
115 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( 117 MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory(
116 fileapi::FileSystemType type, base::PlatformFileError* error_code) { 118 fileapi::FileSystemType type, base::PlatformFileError* error_code) {
117 DCHECK(error_code); 119 DCHECK(error_code);
118 *error_code = base::PLATFORM_FILE_OK; 120 *error_code = base::PLATFORM_FILE_OK;
119 switch (type) { 121 switch (type) {
120 case fileapi::kFileSystemTypeNativeMedia: 122 case fileapi::kFileSystemTypeNativeMedia:
121 case fileapi::kFileSystemTypeDeviceMedia: 123 case fileapi::kFileSystemTypeDeviceMedia:
124 case fileapi::kFileSystemTypeItunes:
122 if (!media_copy_or_move_file_validator_factory_) { 125 if (!media_copy_or_move_file_validator_factory_) {
123 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; 126 *error_code = base::PLATFORM_FILE_ERROR_SECURITY;
124 return NULL; 127 return NULL;
125 } 128 }
126 return media_copy_or_move_file_validator_factory_.get(); 129 return media_copy_or_move_file_validator_factory_.get();
127 default: 130 default:
128 NOTREACHED(); 131 NOTREACHED();
129 } 132 }
130 return NULL; 133 return NULL;
131 } 134 }
132 135
133 void 136 void
134 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory( 137 MediaFileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory(
135 fileapi::FileSystemType type, 138 fileapi::FileSystemType type,
136 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) { 139 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) {
137 switch (type) { 140 NOTREACHED();
Lei Zhang 2013/05/29 09:40:58 This method is gone now. (Just landed)
vandebo (ex-Chrome) 2013/05/29 18:56:05 Done.
138 case fileapi::kFileSystemTypeNativeMedia:
139 case fileapi::kFileSystemTypeDeviceMedia:
140 if (!media_copy_or_move_file_validator_factory_)
141 media_copy_or_move_file_validator_factory_.reset(factory.release());
142 break;
143 default:
144 NOTREACHED();
145 }
146 } 141 }
147 142
148 fileapi::FilePermissionPolicy 143 fileapi::FilePermissionPolicy
149 MediaFileSystemMountPointProvider::GetPermissionPolicy( 144 MediaFileSystemMountPointProvider::GetPermissionPolicy(
150 const FileSystemURL& url, int permissions) const { 145 const FileSystemURL& url, int permissions) const {
151 // Access to media file systems should be checked using per-filesystem 146 // Access to media file systems should be checked using per-filesystem
152 // access permission. 147 // access permission.
153 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; 148 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION;
154 } 149 }
155 150
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void MediaFileSystemMountPointProvider::DeleteFileSystem( 198 void MediaFileSystemMountPointProvider::DeleteFileSystem(
204 const GURL& origin_url, 199 const GURL& origin_url,
205 fileapi::FileSystemType type, 200 fileapi::FileSystemType type,
206 FileSystemContext* context, 201 FileSystemContext* context,
207 const DeleteFileSystemCallback& callback) { 202 const DeleteFileSystemCallback& callback) {
208 NOTREACHED(); 203 NOTREACHED();
209 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 204 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
210 } 205 }
211 206
212 } // namespace chrome 207 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698