Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 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 | #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_ |
| 6 | #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_ |
| 7 | |
| 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" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 12 | #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 13 | |
| 14 | class ImageDecoder; |
| 15 | |
| 16 | namespace chrome { |
| 17 | |
| 18 | class MediaFileValidatorFactory; |
| 19 | |
| 20 | // Use ImageDecoder to determine if the file decodes without error. Handles |
| 21 | // image files supported by Chrome. |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 22 | class SupportedImageTypeValidator : public AVScanningFileValidator { |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 23 | public: |
| 24 | virtual ~SupportedImageTypeValidator(); |
| 25 | |
| 26 | static bool SupportsFileType(const base::FilePath& path); |
| 27 | |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 28 | virtual void StartPreWriteValidation( |
| 29 | const ResultCallback& result_callback) OVERRIDE; |
| 30 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 31 | private: |
| 32 | friend class MediaFileValidatorFactory; |
| 33 | |
| 34 | explicit SupportedImageTypeValidator(const base::FilePath& file); |
| 35 | |
| 36 | void OnFileOpen(scoped_ptr<std::string> data); |
| 37 | |
| 38 | base::FilePath path_; |
| 39 | scoped_refptr<ImageDecoder> decoder_; |
| 40 | fileapi::CopyOrMoveFileValidator::ResultCallback callback_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 41 | base::WeakPtrFactory<SupportedImageTypeValidator> weak_factory_; |
| 42 | |
| 43 | DISALLOW_COPY_AND_ASSIGN(SupportedImageTypeValidator); |
| 44 | }; |
| 45 | |
| 46 | } // namespace chrome |
| 47 | |
| 48 | #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_ |