Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / media_galleries / fileapi / media_file_validator_factory.cc
blobf7e94347a542c26b87a988934364b7908991aff9
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 "base/platform_file.h"
9 #include "chrome/browser/media_galleries/fileapi/supported_audio_video_checker.h"
10 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator.h"
11 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
12 #include "webkit/browser/fileapi/file_system_url.h"
14 namespace {
16 class InvalidFileValidator : public fileapi::CopyOrMoveFileValidator {
17 public:
18 virtual ~InvalidFileValidator() {}
19 virtual void StartPreWriteValidation(
20 const fileapi::CopyOrMoveFileValidator::ResultCallback&
21 result_callback) OVERRIDE {
22 result_callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
25 virtual void StartPostWriteValidation(
26 const base::FilePath& dest_platform_path,
27 const fileapi::CopyOrMoveFileValidator::ResultCallback&
28 result_callback) OVERRIDE {
29 result_callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
32 private:
33 friend class ::MediaFileValidatorFactory;
35 InvalidFileValidator() {}
37 DISALLOW_COPY_AND_ASSIGN(InvalidFileValidator);
40 } // namespace
42 MediaFileValidatorFactory::MediaFileValidatorFactory() {}
43 MediaFileValidatorFactory::~MediaFileValidatorFactory() {}
45 fileapi::CopyOrMoveFileValidator*
46 MediaFileValidatorFactory::CreateCopyOrMoveFileValidator(
47 const fileapi::FileSystemURL& src,
48 const base::FilePath& platform_path) {
49 base::FilePath src_path = src.virtual_path();
50 if (SupportedImageTypeValidator::SupportsFileType(src_path))
51 return new SupportedImageTypeValidator(platform_path);
52 if (SupportedAudioVideoChecker::SupportsFileType(src_path))
53 return new SupportedAudioVideoChecker(platform_path);
55 return new InvalidFileValidator();