Commit 1cb9beb7 authored by vandebo@chromium.org's avatar vandebo@chromium.org

Validate image files before writing them to media galleries.

Review URL: https://chromiumcodereview.appspot.com/15624003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203038 0039d316-1c4b-4281-b951-d872f2087c98
parent d15e8a03
...@@ -2,4 +2,3 @@ estade@chromium.org ...@@ -2,4 +2,3 @@ estade@chromium.org
gbillock@chromium.org gbillock@chromium.org
thestig@chromium.org thestig@chromium.org
vandebo@chromium.org vandebo@chromium.org
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h"
#include "chrome/browser/media_galleries/fileapi/itunes/itunes_file_util.h" #include "chrome/browser/media_galleries/fileapi/itunes/itunes_file_util.h"
#include "chrome/browser/media_galleries/fileapi/media_file_validator_factory.h"
#include "chrome/browser/media_galleries/fileapi/media_path_filter.h" #include "chrome/browser/media_galleries/fileapi/media_path_filter.h"
#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
#include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h"
...@@ -45,7 +46,8 @@ const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] = ...@@ -45,7 +46,8 @@ const char MediaFileSystemMountPointProvider::kMTPDeviceDelegateURLKey[] =
MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider( MediaFileSystemMountPointProvider::MediaFileSystemMountPointProvider(
const base::FilePath& profile_path) const base::FilePath& profile_path)
: profile_path_(profile_path), : profile_path_(profile_path),
media_path_filter_(new MediaPathFilter()), media_path_filter_(new MediaPathFilter),
media_copy_or_move_file_validator_factory_(new MediaFileValidatorFactory),
native_media_file_util_( native_media_file_util_(
new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())), new fileapi::AsyncFileUtilAdapter(new NativeMediaFileUtil())),
device_media_async_file_util_( device_media_async_file_util_(
...@@ -119,6 +121,7 @@ MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory( ...@@ -119,6 +121,7 @@ MediaFileSystemMountPointProvider::GetCopyOrMoveFileValidatorFactory(
switch (type) { switch (type) {
case fileapi::kFileSystemTypeNativeMedia: case fileapi::kFileSystemTypeNativeMedia:
case fileapi::kFileSystemTypeDeviceMedia: case fileapi::kFileSystemTypeDeviceMedia:
case fileapi::kFileSystemTypeItunes:
if (!media_copy_or_move_file_validator_factory_) { if (!media_copy_or_move_file_validator_factory_) {
*error_code = base::PLATFORM_FILE_ERROR_SECURITY; *error_code = base::PLATFORM_FILE_ERROR_SECURITY;
return NULL; return NULL;
......
// 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 "webkit/browser/fileapi/copy_or_move_file_validator.h"
#include "webkit/browser/fileapi/file_system_url.h"
namespace chrome {
namespace {
class InvalidFileValidator : public fileapi::CopyOrMoveFileValidator {
public:
virtual ~InvalidFileValidator() {}
virtual void StartValidation(
const fileapi::CopyOrMoveFileValidator::ResultCallback&
result_callback) OVERRIDE {
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
// 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_MEDIA_FILE_VALIDATOR_FACTORY_H_
#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_VALIDATOR_FACTORY_H_
#include "base/basictypes.h"
#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
namespace base {
class FilePath;
}
namespace fileapi {
class FileSystemURL;
}
namespace chrome {
// A factory for media file validators. A media file validator will use various
// strategies (depending on the file type) to attempt to verify that the file
// is a valid media file.
class MediaFileValidatorFactory
: public fileapi::CopyOrMoveFileValidatorFactory {
public:
MediaFileValidatorFactory();
virtual ~MediaFileValidatorFactory();
// CopyOrMoveFileValidatorFactory implementation.
virtual fileapi::CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
const fileapi::FileSystemURL& src,
const base::FilePath& platform_path) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(MediaFileValidatorFactory);
};
} // namespace chrome
#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_FILE_VALIDATOR_FACTORY_H_
// 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 "base/basictypes.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop.h"
#include "chrome/browser/media_galleries/fileapi/media_file_system_mount_point_provider.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_mount_point_provider.h"
#include "webkit/browser/fileapi/file_system_operation.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/isolated_context.h"
#include "webkit/browser/fileapi/mock_file_system_context.h"
#include "webkit/browser/fileapi/test_mount_point_provider.h"
#include "webkit/common/fileapi/file_system_types.h"
namespace {
const char kOrigin[] = "http://foo";
const char kValidImage[] = "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A"
"\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0"
"\x05\xCE\xB3l\0\0\xFE\xD8\x80\0\0";
const char kInvalidImage[] = "Not an image";
const int64 kNoFileSize = -1;
void HandleCheckFileResult(int64 expected_size,
const base::Callback<void(bool success)>& callback,
base::PlatformFileError result,
const base::PlatformFileInfo& file_info,
const base::FilePath& /*platform_path*/) {
if (result == base::PLATFORM_FILE_OK) {
if (!file_info.is_directory && expected_size != kNoFileSize &&
file_info.size == expected_size) {
callback.Run(true);
return;
}
} else {
if (expected_size == kNoFileSize) {
callback.Run(true);
return;
}
}
callback.Run(false);
}
} // namespace
namespace chrome {
class MediaFileValidatorTest : public InProcessBrowserTest {
public:
MediaFileValidatorTest() : test_file_size_(0) {}
virtual ~MediaFileValidatorTest() {}
// Write |content| into |filename| in a test file system and try to move
// it into a media file system. The result is compared to |expected_result|.
void MoveTest(const std::string& filename, const std::string& content,
bool expected_result) {
content::BrowserThread::PostTask(
content::BrowserThread::FILE,
FROM_HERE,
base::Bind(&MediaFileValidatorTest::SetupOnFileThread,
base::Unretained(this), filename, content, expected_result));
loop_runner_ = new content::MessageLoopRunner;
loop_runner_->Run();
}
private:
// Create the test files, filesystem objects, etc.
void SetupOnFileThread(const std::string& filename,
const std::string& content,
bool expected_result) {
ASSERT_TRUE(base_dir_.CreateUniqueTempDir());
base::FilePath base = base_dir_.path();
base::FilePath src_path = base.AppendASCII("src_fs");
ASSERT_TRUE(file_util::CreateDirectory(src_path));
ScopedVector<fileapi::FileSystemMountPointProvider> additional_providers;
additional_providers.push_back(new fileapi::TestMountPointProvider(
base::MessageLoopProxy::current(), src_path));
additional_providers.push_back(
new MediaFileSystemMountPointProvider(base));
file_system_context_ =
fileapi::CreateFileSystemContextWithAdditionalProvidersForTesting(
NULL, additional_providers.Pass(), base);
move_src_ = file_system_context_->CreateCrackedFileSystemURL(
GURL(kOrigin), fileapi::kFileSystemTypeTest,
base::FilePath::FromUTF8Unsafe(filename));
test_file_size_ = content.size();
base::FilePath test_file = src_path.AppendASCII(filename);
ASSERT_EQ(test_file_size_,
file_util::WriteFile(test_file, content.data(), test_file_size_));
base::FilePath dest_path = base.AppendASCII("dest_fs");
ASSERT_TRUE(file_util::CreateDirectory(dest_path));
std::string dest_fsid =
fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForPath(
fileapi::kFileSystemTypeNativeMedia, dest_path, NULL);
size_t extension_index = filename.find_last_of(".");
ASSERT_NE(std::string::npos, extension_index);
std::string extension = filename.substr(extension_index);
std::string dest_root_fs_url = fileapi::GetIsolatedFileSystemRootURIString(
GURL(kOrigin), dest_fsid, "dest_fs/");
move_dest_ = file_system_context_->CrackURL(GURL(
dest_root_fs_url + "move_dest" + extension));
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&MediaFileValidatorTest::CheckFiles,
base::Unretained(this), true,
base::Bind(&MediaFileValidatorTest::OnTestFilesReady,
base::Unretained(this), expected_result)));
}
// Check that exactly one of |move_src_| and |move_dest_| exists.
// |src_expected| indicates which one should exist. When complete,
// |callback| is called with success/failure.
void CheckFiles(bool src_expected,
const base::Callback<void(bool success)>& callback) {
CheckFile(move_src_, src_expected ? test_file_size_ : kNoFileSize,
base::Bind(&MediaFileValidatorTest::OnCheckFilesFirstResult,
base::Unretained(this), !src_expected, callback));
}
// Helper that checks a file has the |expected_size|, which may be
// |kNoFileSize| if the file should not exist. |callback| is called
// with success/failure.
void CheckFile(fileapi::FileSystemURL url,
int64 expected_size,
const base::Callback<void(bool success)>& callback) {
CreateFSOp(url)->GetMetadata(url,
base::Bind(&HandleCheckFileResult,
expected_size, callback));
}
// Helper that checks the result of |move_src_| lookup and then checks
// |move_dest_| if all is as expected.
void OnCheckFilesFirstResult(bool dest_expected,
const base::Callback<void(bool)>& callback,
bool src_result) {
EXPECT_TRUE(src_result);
if (!src_result) {
callback.Run(false);
return;
}
CheckFile(move_dest_, dest_expected ? test_file_size_ : kNoFileSize,
callback);
}
// Assert |test_files_ready| and then do the actual test of moving
// |move_src_| to |move_dest_|.
void OnTestFilesReady(bool expected_result, bool test_files_ready) {
ASSERT_TRUE(test_files_ready);
CreateFSOp(move_dest_)->Move(
move_src_, move_dest_,
base::Bind(&MediaFileValidatorTest::OnMoveResult,
base::Unretained(this), expected_result));
}
// Check that the move succeeded/failed based on expectation and then
// check that the right file exists.
void OnMoveResult(bool expected_result, base::PlatformFileError result) {
if (expected_result)
EXPECT_EQ(base::PLATFORM_FILE_OK, result);
else
EXPECT_EQ(base::PLATFORM_FILE_ERROR_SECURITY, result);
CheckFiles(!expected_result,
base::Bind(&MediaFileValidatorTest::OnTestFilesCheckResult,
base::Unretained(this)));
}
// Check that the correct test file exists and then post the result back
// to the UI thread.
void OnTestFilesCheckResult(bool result) {
EXPECT_TRUE(result);
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
loop_runner_->QuitClosure());
}
fileapi::FileSystemOperation* CreateFSOp(const fileapi::FileSystemURL& url) {
return file_system_context_->CreateFileSystemOperation(url, NULL);
}
base::ScopedTempDir base_dir_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
int test_file_size_;
fileapi::FileSystemURL move_src_;
fileapi::FileSystemURL move_dest_;
scoped_refptr<content::MessageLoopRunner> loop_runner_;
DISALLOW_COPY_AND_ASSIGN(MediaFileValidatorTest);
};
IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidImage) {
MoveTest("a.webp", std::string(kValidImage, arraysize(kValidImage)), true);
}
IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, InvalidImage) {
MoveTest("a.webp", std::string(kInvalidImage, arraysize(kInvalidImage)),
false);
}
IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, UnsupportedExtension) {
MoveTest("a.txt", std::string(kValidImage, arraysize(kValidImage)), false);
}
} // namespace chrome
// 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/supported_image_type_validator.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/stl_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/image_decoder.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
namespace chrome {
namespace {
// Arbitrary limit to sanity check the file size.
const int kMaxImageFileSize = 50*1014*1024;
struct PlatformFileCloser {
void operator()(base::PlatformFile* file) const {
if (file && *file != base::kInvalidPlatformFileValue)
base::ClosePlatformFile(*file);
}
};
typedef scoped_ptr<base::PlatformFile, PlatformFileCloser>
ScopedPlatformFile;
scoped_ptr<std::string> ReadOnFileThread(const base::FilePath& path) {
base::ThreadRestrictions::AssertIOAllowed();
scoped_ptr<std::string> result;
base::PlatformFile file = base::CreatePlatformFile(
path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL);
ScopedPlatformFile file_closer(&file);
if (file == base::kInvalidPlatformFileValue)
return result.Pass();
base::PlatformFileInfo file_info;
if (!base::GetPlatformFileInfo(file, &file_info) ||
file_info.size > kMaxImageFileSize) {
return result.Pass();
}
result.reset(new std::string);
result->resize(file_info.size);
if (base::ReadPlatformFile(file, 0, string_as_array(result.get()),
file_info.size) != file_info.size) {
result.reset();
}
return result.Pass();
}
class ImageDecoderDelegateAdapter : public ImageDecoder::Delegate {
public:
ImageDecoderDelegateAdapter(
scoped_ptr<std::string> data,
const fileapi::CopyOrMoveFileValidator::ResultCallback& callback)
: data_(data.Pass()),
callback_(callback) {
DCHECK(data_);
}
const std::string& data() {
return *data_;
}
// ImageDecoder::Delegate methods.
virtual void OnImageDecoded(const ImageDecoder* /*decoder*/,
const SkBitmap& /*decoded_image*/) OVERRIDE {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(callback_, base::PLATFORM_FILE_OK));
delete this;
}
virtual void OnDecodeImageFailed(const ImageDecoder* /*decoder*/) OVERRIDE {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(callback_,
base::PLATFORM_FILE_ERROR_SECURITY));
delete this;
}
private:
scoped_ptr<std::string> data_;
fileapi::CopyOrMoveFileValidator::ResultCallback callback_;
DISALLOW_COPY_AND_ASSIGN(ImageDecoderDelegateAdapter);
};
} // namespace
SupportedImageTypeValidator::~SupportedImageTypeValidator() {}
// static
bool SupportedImageTypeValidator::SupportsFileType(const base::FilePath& path) {
base::FilePath::StringType extension = path.Extension();
return extension == FILE_PATH_LITERAL(".bmp") ||
extension == FILE_PATH_LITERAL(".gif") ||
extension == FILE_PATH_LITERAL(".jfif") ||
extension == FILE_PATH_LITERAL(".jpeg") ||
extension == FILE_PATH_LITERAL(".jpg") ||
extension == FILE_PATH_LITERAL(".pjp") ||
extension == FILE_PATH_LITERAL(".pjpeg") ||
extension == FILE_PATH_LITERAL(".png") ||
extension == FILE_PATH_LITERAL(".webp");
}
void SupportedImageTypeValidator::StartValidation(
const fileapi::CopyOrMoveFileValidator::ResultCallback& result_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(callback_.is_null());
callback_ = result_callback;
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::FILE,
FROM_HERE,
base::Bind(&ReadOnFileThread, path_),
base::Bind(&SupportedImageTypeValidator::OnFileOpen,
weak_factory_.GetWeakPtr()));
}
SupportedImageTypeValidator::SupportedImageTypeValidator(
const base::FilePath& path)
: path_(path),
weak_factory_(this) {
}
void SupportedImageTypeValidator::OnFileOpen(scoped_ptr<std::string> data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!data.get()) {
callback_.Run(base::PLATFORM_FILE_ERROR_SECURITY);
return;
}
// |adapter| will delete itself after a completion message is received.
ImageDecoderDelegateAdapter* adapter =
new ImageDecoderDelegateAdapter(data.Pass(), callback_);
decoder_ = new ImageDecoder(adapter, adapter->data(),
ImageDecoder::DEFAULT_CODEC);
base::SequencedWorkerPool* workerpool = BrowserThread::GetBlockingPool();
decoder_->Start(workerpool->GetSequencedTaskRunnerWithShutdownBehavior(
workerpool->GetSequenceToken(),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN));
}
} // namespace chrome
// 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_
...@@ -989,6 +989,8 @@ ...@@ -989,6 +989,8 @@
'browser/media_galleries/fileapi/itunes/itunes_file_util.h', 'browser/media_galleries/fileapi/itunes/itunes_file_util.h',
'browser/media_galleries/fileapi/media_file_system_mount_point_provider.cc', 'browser/media_galleries/fileapi/media_file_system_mount_point_provider.cc',
'browser/media_galleries/fileapi/media_file_system_mount_point_provider.h', 'browser/media_galleries/fileapi/media_file_system_mount_point_provider.h',
'browser/media_galleries/fileapi/media_file_validator_factory.h',
'browser/media_galleries/fileapi/media_file_validator_factory.cc',
'browser/media_galleries/fileapi/media_path_filter.cc', 'browser/media_galleries/fileapi/media_path_filter.cc',
'browser/media_galleries/fileapi/media_path_filter.h', 'browser/media_galleries/fileapi/media_path_filter.h',
'browser/media_galleries/fileapi/native_media_file_util.cc', 'browser/media_galleries/fileapi/native_media_file_util.cc',
...@@ -1008,6 +1010,8 @@ ...@@ -1008,6 +1010,8 @@
'browser/media_galleries/fileapi/picasa/pmp_constants.h', 'browser/media_galleries/fileapi/picasa/pmp_constants.h',
'browser/media_galleries/fileapi/picasa/pmp_table_reader.cc', 'browser/media_galleries/fileapi/picasa/pmp_table_reader.cc',
'browser/media_galleries/fileapi/picasa/pmp_table_reader.h', 'browser/media_galleries/fileapi/picasa/pmp_table_reader.h',
'browser/media_galleries/fileapi/supported_image_type_validator.h',
'browser/media_galleries/fileapi/supported_image_type_validator.cc',
'browser/media_galleries/imported_media_gallery_registry.cc', 'browser/media_galleries/imported_media_gallery_registry.cc',
'browser/media_galleries/imported_media_gallery_registry.h', 'browser/media_galleries/imported_media_gallery_registry.h',
'browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc', 'browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc',
......
...@@ -1473,6 +1473,7 @@ ...@@ -1473,6 +1473,7 @@
'browser/managed_mode/managed_mode_browsertest.cc', 'browser/managed_mode/managed_mode_browsertest.cc',
'browser/managed_mode/managed_mode_resource_throttle_browsertest.cc', 'browser/managed_mode/managed_mode_resource_throttle_browsertest.cc',
'browser/media/chrome_webrtc_browsertest.cc', 'browser/media/chrome_webrtc_browsertest.cc',
'browser/media_galleries/fileapi/media_file_validator_unittest.cc',
'browser/media_galleries/media_galleries_dialog_controller_mock.cc', 'browser/media_galleries/media_galleries_dialog_controller_mock.cc',
'browser/media_galleries/media_galleries_dialog_controller_mock.h', 'browser/media_galleries/media_galleries_dialog_controller_mock.h',
'browser/metrics/metrics_service_browsertest.cc', 'browser/metrics/metrics_service_browsertest.cc',
......
...@@ -22,6 +22,14 @@ FileSystemContext* CreateFileSystemContextForTesting( ...@@ -22,6 +22,14 @@ FileSystemContext* CreateFileSystemContextForTesting(
additional_providers.push_back( additional_providers.push_back(
new TestMountPointProvider( new TestMountPointProvider(
base::MessageLoopProxy::current(), base_path)); base::MessageLoopProxy::current(), base_path));
return CreateFileSystemContextWithAdditionalProvidersForTesting(
quota_manager_proxy, additional_providers.Pass(), base_path);
}
FileSystemContext* CreateFileSystemContextWithAdditionalProvidersForTesting(
quota::QuotaManagerProxy* quota_manager_proxy,
ScopedVector<FileSystemMountPointProvider> additional_providers,
const base::FilePath& base_path) {
return new FileSystemContext( return new FileSystemContext(
FileSystemTaskRunners::CreateMockTaskRunners(), FileSystemTaskRunners::CreateMockTaskRunners(),
ExternalMountPoints::CreateRefCounted().get(), ExternalMountPoints::CreateRefCounted().get(),
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define WEBKIT_BROWSER_FILEAPI_MOCK_FILE_SYSTEM_CONTEXT_H_ #define WEBKIT_BROWSER_FILEAPI_MOCK_FILE_SYSTEM_CONTEXT_H_
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/scoped_vector.h"
namespace quota { namespace quota {
class QuotaManagerProxy; class QuotaManagerProxy;
...@@ -15,11 +16,19 @@ class SpecialStoragePolicy; ...@@ -15,11 +16,19 @@ class SpecialStoragePolicy;
namespace fileapi { namespace fileapi {
class FileSystemContext; class FileSystemContext;
class FileSystemMountPointProvider;
FileSystemContext* CreateFileSystemContextForTesting( FileSystemContext* CreateFileSystemContextForTesting(
quota::QuotaManagerProxy* quota_manager_proxy, quota::QuotaManagerProxy* quota_manager_proxy,
const base::FilePath& base_path); const base::FilePath& base_path);
// The caller is responsible for including TestMountPointProvider in
// |additional_providers| if needed.
FileSystemContext* CreateFileSystemContextWithAdditionalProvidersForTesting(
quota::QuotaManagerProxy* quota_manager_proxy,
ScopedVector<FileSystemMountPointProvider> additional_providers,
const base::FilePath& base_path);
} // namespace fileapi } // namespace fileapi
#endif // WEBKIT_BROWSER_FILEAPI_MOCK_FILE_SYSTEM_CONTEXT_H_ #endif // WEBKIT_BROWSER_FILEAPI_MOCK_FILE_SYSTEM_CONTEXT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment