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

Side by Side Diff: chrome/browser/media_galleries/fileapi/media_file_validator_factory.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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h"
6
7 #include "base/files/file_path.h"
8 #include "base/platform_file.h"
9 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator. h"
10 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
11 #include "webkit/browser/fileapi/file_system_url.h"
12
13 namespace chrome {
14
15 namespace {
16
17 class InvalidFileValidator : public fileapi::CopyOrMoveFileValidator {
18 public:
19 virtual ~InvalidFileValidator() {}
20 virtual void StartValidation(
21 const fileapi::CopyOrMoveFileValidator::ResultCallback& result_callback) {
22 result_callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
23 }
24
25 private:
26 friend class chrome::MediaFileValidatorFactory;
27
28 InvalidFileValidator() {}
29
30 DISALLOW_COPY_AND_ASSIGN(InvalidFileValidator);
31 };
32
33 } // namespace
34
35 MediaFileValidatorFactory::MediaFileValidatorFactory() {}
36 MediaFileValidatorFactory::~MediaFileValidatorFactory() {}
37
38 fileapi::CopyOrMoveFileValidator*
39 MediaFileValidatorFactory::CreateCopyOrMoveFileValidator(
40 const fileapi::FileSystemURL& src,
41 const base::FilePath& platform_path) {
42 base::FilePath src_path = src.virtual_path();
43 if (SupportedImageTypeValidator::SupportsFileType(src_path))
44 return new SupportedImageTypeValidator(platform_path);
45 // TODO(vandebo): Support other file types.
46
47 return new InvalidFileValidator();
48 }
49
50 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698