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

Unified Diff: chrome/browser/media_galleries/fileapi/media_file_validator_factory.cc

Issue 15624003: Validate image files before writing them to media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and rebase 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/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..0428d1982343ac8675efdc1ff7438834184356e2
--- /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"
Lei Zhang 2013/05/25 00:09:01 not used? ditto with line 14.
vandebo (ex-Chrome) 2013/05/29 06:09:15 Done.
+#include "webkit/browser/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(
+ 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))
+ return new SupportedImageTypeValidator(platform_path);
+ // TODO(vandebo): Support other file types.
+
+ return new InvalidFileValidator();
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698