Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/media_file_validator_factory.cc |
| diff --git a/chrome/browser/media_galleries/fileapi/media_file_validator_factory.cc b/chrome/browser/media_galleries/fileapi/media_file_validator_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..72ea2636bab13c9aae116c0003b6042539901abe |
| --- /dev/null |
| +++ b/chrome/browser/media_galleries/fileapi/media_file_validator_factory.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h" |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/platform_file.h" |
| +#include "chrome/browser/media_galleries/fileapi/supported_image_type_validator.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "webkit/fileapi/copy_or_move_file_validator.h" |
| +#include "webkit/fileapi/file_system_url.h" |
| + |
| +using content::BrowserThread; |
| + |
| +namespace chrome { |
| + |
| +namespace { |
| + |
| +class InvalidFileValidator : public fileapi::CopyOrMoveFileValidator { |
| + public: |
| + virtual ~InvalidFileValidator() {} |
| + virtual void StartValidation( |
|
Greg Billock
2013/05/22 16:21:59
The signature I'd expect here is StartValidation($
vandebo (ex-Chrome)
2013/05/22 18:41:17
$FILE is passed into the factory so you can create
Greg Billock
2013/05/23 18:18:29
The same validator always gets created, right?
vandebo (ex-Chrome)
2013/05/24 01:13:05
Right now we only have one validator because that'
|
| + const fileapi::CopyOrMoveFileValidator::ResultCallback& result_callback) { |
| + result_callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); |
| + } |
| + |
| + private: |
| + friend class chrome::MediaFileValidatorFactory; |
| + |
| + InvalidFileValidator() {}; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InvalidFileValidator); |
| +}; |
| + |
| +} // namespace |
| + |
| +MediaFileValidatorFactory::MediaFileValidatorFactory() {} |
| +MediaFileValidatorFactory::~MediaFileValidatorFactory() {} |
| + |
| +fileapi::CopyOrMoveFileValidator* |
| +MediaFileValidatorFactory::CreateCopyOrMoveFileValidator( |
| + const fileapi::FileSystemURL& src, |
| + const base::FilePath& platform_path) { |
| + base::FilePath src_path = src.virtual_path(); |
| + if (SupportedImageTypeValidator::SupportsFileType(src_path)) |
|
Greg Billock
2013/05/22 16:21:59
I'd move all this logic to the SupportedImageTypeV
vandebo (ex-Chrome)
2013/05/22 18:41:17
Not sure what you mean, SupportsFileType is a memb
Greg Billock
2013/05/23 18:18:29
Meaning I'd have this method just return new Suppo
vandebo (ex-Chrome)
2013/05/24 01:13:05
Yes, there will be multiple validators and I will
|
| + return new SupportedImageTypeValidator(platform_path); |
| + // TODO(vandebo) Support other file types. |
|
Greg Billock
2013/05/22 16:21:59
":"
vandebo (ex-Chrome)
2013/05/22 18:41:17
Done.
|
| + |
| + return new InvalidFileValidator(); |
| +} |
| + |
| +} // namespace chrome |