Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: chrome/browser/media_galleries/fileapi/supported_image_type_validator.h

Issue 15624003: Validate image files before writing them to media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Override Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_galleries/fileapi/supported_image_type_validator.h
diff --git a/chrome/browser/media_galleries/fileapi/supported_image_type_validator.h b/chrome/browser/media_galleries/fileapi/supported_image_type_validator.h
new file mode 100644
index 0000000000000000000000000000000000000000..8c655b5542065b2dd4e27e30a28210d937c8e351
--- /dev/null
+++ b/chrome/browser/media_galleries/fileapi/supported_image_type_validator.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
+#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_
+
+#include "base/basictypes.h"
+#include "base/files/file_path.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
+
+class ImageDecoder;
+
+namespace chrome {
+
+class MediaFileValidatorFactory;
+
+// Use ImageDecoder to determine if the file decodes without error. Handles
+// image files supported by Chrome.
+class SupportedImageTypeValidator : public fileapi::CopyOrMoveFileValidator {
+ public:
+ virtual ~SupportedImageTypeValidator();
+
+ static bool SupportsFileType(const base::FilePath& path);
+
+ virtual void StartValidation(
+ const fileapi::CopyOrMoveFileValidator::ResultCallback&
+ result_callback) OVERRIDE;
+
+ private:
+ friend class MediaFileValidatorFactory;
+
+ explicit SupportedImageTypeValidator(const base::FilePath& file);
+
+ void OnFileOpen(scoped_ptr<std::string> data);
+
+ base::FilePath path_;
+ scoped_refptr<ImageDecoder> decoder_;
+ fileapi::CopyOrMoveFileValidator::ResultCallback callback_;
+ base::WeakPtrFactory<SupportedImageTypeValidator> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupportedImageTypeValidator);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SUPPORTED_IMAGE_TYPE_VALIDATOR_H_

Powered by Google App Engine
This is Rietveld 408576698