Home | History | Annotate | Download | only in fileapi
      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"
     12 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h"
     13 
     14 class ImageDecoder;
     15 
     16 class MediaFileValidatorFactory;
     17 
     18 // Use ImageDecoder to determine if the file decodes without error. Handles
     19 // image files supported by Chrome.
     20 class SupportedImageTypeValidator : public AVScanningFileValidator {
     21  public:
     22   virtual ~SupportedImageTypeValidator();
     23 
     24   static bool SupportsFileType(const base::FilePath& path);
     25 
     26   virtual void StartPreWriteValidation(
     27       const ResultCallback& result_callback) OVERRIDE;
     28 
     29  private:
     30   friend class MediaFileValidatorFactory;
     31 
     32   explicit SupportedImageTypeValidator(const base::FilePath& file);
     33 
     34   void OnFileOpen(scoped_ptr<std::string> data);
     35 
     36   base::FilePath path_;
     37   scoped_refptr<ImageDecoder> decoder_;
     38   storage::CopyOrMoveFileValidator::ResultCallback callback_;
     39   base::WeakPtrFactory<SupportedImageTypeValidator> weak_factory_;
     40 
     41   DISALLOW_COPY_AND_ASSIGN(SupportedImageTypeValidator);
     42 };
     43 
     44 #endif  // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
     45