1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/basictypes.h"
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/files/file_path.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/weak_ptr.h"
12bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h"
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class ImageDecoder;
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class MediaFileValidatorFactory;
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use ImageDecoder to determine if the file decodes without error. Handles
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// image files supported by Chrome.
20bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochclass SupportedImageTypeValidator : public AVScanningFileValidator {
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~SupportedImageTypeValidator();
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static bool SupportsFileType(const base::FilePath& path);
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
26a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch  virtual void StartPreWriteValidation(
27a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch      const ResultCallback& result_callback) OVERRIDE;
28a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  friend class MediaFileValidatorFactory;
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit SupportedImageTypeValidator(const base::FilePath& file);
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void OnFileOpen(scoped_ptr<std::string> data);
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::FilePath path_;
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<ImageDecoder> decoder_;
3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  storage::CopyOrMoveFileValidator::ResultCallback callback_;
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::WeakPtrFactory<SupportedImageTypeValidator> weak_factory_;
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(SupportedImageTypeValidator);
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif  // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
45