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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h"
16 class MediaFileValidatorFactory;
18 // Use ImageDecoder to determine if the file decodes without error. Handles
19 // image files supported by Chrome.
20 class SupportedImageTypeValidator : public AVScanningFileValidator {
22 virtual ~SupportedImageTypeValidator();
24 static bool SupportsFileType(const base::FilePath& path);
26 virtual void StartPreWriteValidation(
27 const ResultCallback& result_callback) OVERRIDE;
30 friend class MediaFileValidatorFactory;
32 explicit SupportedImageTypeValidator(const base::FilePath& file);
34 void OnFileOpen(scoped_ptr<std::string> data);
37 scoped_refptr<ImageDecoder> decoder_;
38 fileapi::CopyOrMoveFileValidator::ResultCallback callback_;
39 base::WeakPtrFactory<SupportedImageTypeValidator> weak_factory_;
41 DISALLOW_COPY_AND_ASSIGN(SupportedImageTypeValidator);
44 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_