Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / media_galleries / fileapi / media_file_validator_factory.cc
blob608f49f75c49435849cf4464a07bc9e5009a5dfa
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.
5 #include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h"
7 #include "base/files/file_path.h"
8 #include "chrome/browser/media_galleries/fileapi/supported_audio_video_checker.h"
9 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator.h"
10 #include "storage/browser/fileapi/copy_or_move_file_validator.h"
11 #include "storage/browser/fileapi/file_system_url.h"
13 namespace {
15 class InvalidFileValidator : public storage::CopyOrMoveFileValidator {
16 public:
17 ~InvalidFileValidator() override {}
18 void StartPreWriteValidation(
19 const storage::CopyOrMoveFileValidator::ResultCallback& result_callback)
20 override {
21 result_callback.Run(base::File::FILE_ERROR_SECURITY);
24 void StartPostWriteValidation(
25 const base::FilePath& dest_platform_path,
26 const storage::CopyOrMoveFileValidator::ResultCallback& result_callback)
27 override {
28 result_callback.Run(base::File::FILE_ERROR_SECURITY);
31 private:
32 friend class ::MediaFileValidatorFactory;
34 InvalidFileValidator() {}
36 DISALLOW_COPY_AND_ASSIGN(InvalidFileValidator);
39 } // namespace
41 MediaFileValidatorFactory::MediaFileValidatorFactory() {}
42 MediaFileValidatorFactory::~MediaFileValidatorFactory() {}
44 storage::CopyOrMoveFileValidator*
45 MediaFileValidatorFactory::CreateCopyOrMoveFileValidator(
46 const storage::FileSystemURL& src,
47 const base::FilePath& platform_path) {
48 base::FilePath src_path = src.virtual_path();
49 if (SupportedImageTypeValidator::SupportsFileType(src_path))
50 return new SupportedImageTypeValidator(platform_path);
51 if (SupportedAudioVideoChecker::SupportsFileType(src_path))
52 return new SupportedAudioVideoChecker(platform_path);
54 return new InvalidFileValidator();