diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 11:45:55 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 11:45:55 +0000 |
commit | e7e46736cc27f6499d89141eb9e546866ba24754 (patch) | |
tree | 49ef8f4acebc8e0a6949802dec6fac9ff8369f71 /webkit | |
parent | 3465d85d92cf1e3e90f882806fd1758d3132441b (diff) | |
download | chromium_src-e7e46736cc27f6499d89141eb9e546866ba24754.zip chromium_src-e7e46736cc27f6499d89141eb9e546866ba24754.tar.gz chromium_src-e7e46736cc27f6499d89141eb9e546866ba24754.tar.bz2 |
Cleanup: Removing FileSystemPathManager
- Deprecating FileSystemPathManager, which I believe no longer has a lot of reasons to exist
* Changed GetFileSystemTypeString to a regular function in file_system_util
* Added GetFileUtil(FileSystemType), GetMountPointProvider(FileSystemType), external_provider() to FileSystemContext
* Moved all the tests in file_system_path_manager_unittest to file_system_mount_point_provider_unittest
- Also replaced two boolean values in FileSystemContext with a thin FileSystemOptions interface
BUG=none
TEST=no functional changes
Review URL: http://codereview.chromium.org/9004019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
43 files changed, 499 insertions, 561 deletions
diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.cc b/webkit/chromeos/fileapi/cros_mount_point_provider.cc index 68c5024..4c16e44 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.cc +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -16,7 +16,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "webkit/chromeos/fileapi/file_access_permissions.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/native_file_util.h" #include "webkit/glue/webkit_glue.h" @@ -83,7 +82,7 @@ void CrosMountPointProvider::ValidateFileSystemRootAndGetURL( const GURL& origin_url, fileapi::FileSystemType type, bool create, - const fileapi::FileSystemPathManager::GetRootPathCallback& callback) { + const GetRootPathCallback& callback) { DCHECK(type == fileapi::kFileSystemTypeExternal); std::string name(GetOriginIdentifierFromURL(origin_url)); name += ':'; diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.h b/webkit/chromeos/fileapi/cros_mount_point_provider.h index 7405bf5..dca885b 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.h +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -28,6 +28,9 @@ class FileAccessPermissions; class CrosMountPointProvider : public fileapi::ExternalFileSystemMountPointProvider { public: + typedef fileapi::FileSystemMountPointProvider::GetRootPathCallback + GetRootPathCallback; + CrosMountPointProvider( scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); virtual ~CrosMountPointProvider(); @@ -40,7 +43,7 @@ class CrosMountPointProvider const GURL& origin_url, fileapi::FileSystemType type, bool create, - const fileapi::FileSystemPathManager::GetRootPathCallback& callback) + const GetRootPathCallback& callback) OVERRIDE; virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( const GURL& origin_url, diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc index a88afce..efd56f2 100644 --- a/webkit/fileapi/file_system_context.cc +++ b/webkit/fileapi/file_system_context.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,23 +7,32 @@ #include "base/file_util.h" #include "base/message_loop_proxy.h" #include "googleurl/src/gurl.h" -#include "webkit/fileapi/file_system_path_manager.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h" +#include "webkit/fileapi/file_system_file_util.h" +#include "webkit/fileapi/file_system_options.h" +#include "webkit/fileapi/file_system_quota_client.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" -#include "webkit/fileapi/file_system_quota_client.h" #include "webkit/quota/quota_manager.h" +#include "webkit/quota/special_storage_policy.h" + +#if defined(OS_CHROMEOS) +#include "webkit/chromeos/fileapi/cros_mount_point_provider.h" +#endif using quota::QuotaClient; namespace fileapi { namespace { + QuotaClient* CreateQuotaClient( scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* context, bool is_incognito) { return new FileSystemQuotaClient(file_message_loop, context, is_incognito); } + } // anonymous namespace FileSystemContext::FileSystemContext( @@ -32,22 +41,23 @@ FileSystemContext::FileSystemContext( scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, const FilePath& profile_path, - bool is_incognito, - bool allow_file_access_from_files, - FileSystemPathManager* path_manager) + const FileSystemOptions& options) : file_message_loop_(file_message_loop), io_message_loop_(io_message_loop), quota_manager_proxy_(quota_manager_proxy), - path_manager_(path_manager) { - if (!path_manager) { - path_manager_.reset(new FileSystemPathManager( - file_message_loop, profile_path, special_storage_policy, - is_incognito, allow_file_access_from_files)); - } + sandbox_provider_( + new SandboxMountPointProvider( + file_message_loop, + profile_path, + options)) { if (quota_manager_proxy) { quota_manager_proxy->RegisterClient(CreateQuotaClient( - file_message_loop, this, is_incognito)); + file_message_loop, this, options.is_incognito())); } +#if defined(OS_CHROMEOS) + external_provider_.reset( + new chromeos::CrosMountPointProvider(special_storage_policy)); +#endif } FileSystemContext::~FileSystemContext() { @@ -88,6 +98,40 @@ FileSystemContext::GetQuotaUtil(FileSystemType type) const { return NULL; } +FileSystemFileUtil* FileSystemContext::GetFileUtil( + FileSystemType type) const { + FileSystemMountPointProvider* mount_point_provider = + GetMountPointProvider(type); + if (!mount_point_provider) + return NULL; + return mount_point_provider->GetFileUtil(); +} + +FileSystemMountPointProvider* FileSystemContext::GetMountPointProvider( + FileSystemType type) const { + switch (type) { + case kFileSystemTypeTemporary: + case kFileSystemTypePersistent: + return sandbox_provider_.get(); + case kFileSystemTypeExternal: + return external_provider_.get(); + case kFileSystemTypeUnknown: + default: + NOTREACHED(); + return NULL; + } +} + +SandboxMountPointProvider* +FileSystemContext::sandbox_provider() const { + return sandbox_provider_.get(); +} + +ExternalFileSystemMountPointProvider* +FileSystemContext::external_provider() const { + return external_provider_.get(); +} + void FileSystemContext::DeleteOnCorrectThread() const { if (!io_message_loop_->BelongsToCurrentThread()) { io_message_loop_->DeleteSoon(FROM_HERE, this); @@ -96,8 +140,11 @@ void FileSystemContext::DeleteOnCorrectThread() const { delete this; } -SandboxMountPointProvider* FileSystemContext::sandbox_provider() const { - return path_manager_->sandbox_provider(); -} - } // namespace fileapi + +COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeTemporary) == \ + int(fileapi::kFileSystemTypeTemporary), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebFileSystem::TypePersistent) == \ + int(fileapi::kFileSystemTypePersistent), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebFileSystem::TypeExternal) == \ + int(fileapi::kFileSystemTypeExternal), mismatching_enums); diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h index a797ceb..d7203c6 100644 --- a/webkit/fileapi/file_system_context.h +++ b/webkit/fileapi/file_system_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -23,7 +23,11 @@ class QuotaManagerProxy; namespace fileapi { +class ExternalFileSystemMountPointProvider; class FileSystemContext; +class FileSystemFileUtil; +class FileSystemMountPointProvider; +class FileSystemOptions; class FileSystemPathManager; class FileSystemQuotaUtil; class SandboxMountPointProvider; @@ -42,9 +46,7 @@ class FileSystemContext scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, const FilePath& profile_path, - bool is_incognito, - bool allow_file_access_from_files, - FileSystemPathManager* path_manager); + const FileSystemOptions& options); ~FileSystemContext(); // This method can be called on any thread. @@ -52,7 +54,6 @@ class FileSystemContext bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, FileSystemType type); - FileSystemPathManager* path_manager() const { return path_manager_.get(); } quota::QuotaManagerProxy* quota_manager_proxy() const { return quota_manager_proxy_.get(); } @@ -62,17 +63,39 @@ class FileSystemContext // it is not a quota-managed storage. FileSystemQuotaUtil* GetQuotaUtil(FileSystemType type) const; + // Returns the appropriate FileUtil instance for the given |type|. + // This may return NULL if it is given an invalid or unsupported filesystem + // type. + FileSystemFileUtil* GetFileUtil(FileSystemType type) const; + + // Returns the mount point provider instance for the given |type|. + // This may return NULL if it is given an invalid or unsupported filesystem + // type. + FileSystemMountPointProvider* GetMountPointProvider( + FileSystemType type) const; + + // Returns a FileSystemMountPointProvider instance for sandboxed filesystem + // types (e.g. TEMPORARY or PERSISTENT). This is equivalent to calling + // GetMountPointProvider(kFileSystemType{Temporary, Persistent}). + SandboxMountPointProvider* sandbox_provider() const; + + // Returns a FileSystemMountPointProvider instance for external filesystem + // type, which is used only by chromeos for now. This is equivalent to + // calling GetMountPointProvider(kFileSystemTypeExternal). + ExternalFileSystemMountPointProvider* external_provider() const; + private: friend struct DefaultContextDeleter; void DeleteOnCorrectThread() const; - SandboxMountPointProvider* sandbox_provider() const; scoped_refptr<base::MessageLoopProxy> file_message_loop_; scoped_refptr<base::MessageLoopProxy> io_message_loop_; scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<FileSystemPathManager> path_manager_; + // Mount point providers. + scoped_ptr<SandboxMountPointProvider> sandbox_provider_; + scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); }; diff --git a/webkit/fileapi/file_system_dir_url_request_job.cc b/webkit/fileapi/file_system_dir_url_request_job.cc index b0ce0e0..9fbe27a 100644 --- a/webkit/fileapi/file_system_dir_url_request_job.cc +++ b/webkit/fileapi/file_system_dir_url_request_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -22,7 +22,6 @@ #include "net/url_request/url_request.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_operation.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_util.h" using net::URLRequest; diff --git a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc index e7871c8..adac9a89 100644 --- a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -32,7 +32,7 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/quota/mock_special_storage_policy.h" @@ -60,15 +60,13 @@ class FileSystemDirURLRequestJobTest : public testing::Test { special_storage_policy_ = new quota::MockSpecialStoragePolicy; file_system_context_ = new FileSystemContext( - base::MessageLoopProxy::current(), + file_thread_proxy_, base::MessageLoopProxy::current(), special_storage_policy_, NULL, - FilePath(), false /* is_incognito */, true /* allow_file_access */, - new FileSystemPathManager( - file_thread_proxy_, temp_dir_.path(), - NULL, false, false)); + temp_dir_.path(), + CreateAllowFileAccessOptions()); - file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( + file_system_context_->sandbox_provider()->ValidateFileSystemRootAndGetURL( GURL("http://remote/"), kFileSystemTypeTemporary, true, // create base::Bind(&FileSystemDirURLRequestJobTest::OnGetRootPath, weak_factory_.GetWeakPtr())); @@ -201,8 +199,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { } FileSystemFileUtil* file_util() { - return file_system_context_->path_manager()->sandbox_provider()-> - GetFileUtil(); + return file_system_context_->sandbox_provider()->GetFileUtil(); } // Put the message loop at the top, so that it's the last thing deleted. diff --git a/webkit/fileapi/file_system_file_util_unittest.cc b/webkit/fileapi/file_system_file_util_unittest.cc index 8837cfa..4095986 100644 --- a/webkit/fileapi/file_system_file_util_unittest.cc +++ b/webkit/fileapi/file_system_file_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -82,7 +82,6 @@ class FileSystemFileUtilTest : public testing::Test { new ObfuscatedFileUtil(base_dir.path(), new NativeFileUtil())); FileSystemTestOriginHelper src_helper(src_origin, src_type); src_helper.SetUp(base_dir.path(), - false, // incognito false, // unlimited quota NULL, // quota::QuotaManagerProxy file_util.get()); diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h index 36768e3..7a08532 100644 --- a/webkit/fileapi/file_system_mount_point_provider.h +++ b/webkit/fileapi/file_system_mount_point_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,17 +8,30 @@ #include <string> #include <vector> +#include "base/callback_forward.h" #include "base/file_path.h" -#include "googleurl/src/gurl.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_types.h" +class GURL; + namespace fileapi { +class FileSystemFileUtil; + // An interface to provide mount-point-specific path-related utilities // and specialized FileSystemFileUtil instance. class FileSystemMountPointProvider { public: + // Callback for GetFileSystemRootPath. + // If the request is accepted and the root filesystem for the origin exists + // the callback is called with success=true and valid root_path and name. + // If the request is accepted, |create| is specified for + // GetFileSystemRootPath, and the root directory does not exist, it creates + // a new one and calls back with success=true if the creation has succeeded. + typedef base::Callback<void(bool /* success */, + const FilePath& /* root_path */, + const std::string& /* name */)> + GetRootPathCallback; virtual ~FileSystemMountPointProvider() {} // Checks if access to |virtual_path| is allowed from |origin_url|. @@ -33,7 +46,7 @@ class FileSystemMountPointProvider { const GURL& origin_url, FileSystemType type, bool create, - const FileSystemPathManager::GetRootPathCallback& callback) = 0; + const GetRootPathCallback& callback) = 0; // Like GetFileSystemRootPath, but synchronous, and can be called only while // running on the file thread. diff --git a/webkit/fileapi/file_system_path_manager_unittest.cc b/webkit/fileapi/file_system_mount_point_provider_unittest.cc index f99824d..9f6f135 100644 --- a/webkit/fileapi/file_system_path_manager_unittest.cc +++ b/webkit/fileapi/file_system_mount_point_provider_unittest.cc @@ -1,9 +1,7 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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 "webkit/fileapi/file_system_path_manager.h" - #include <set> #include <string> @@ -20,11 +18,18 @@ #include "base/utf_string_conversions.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" +#include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_util.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/quota/mock_special_storage_policy.h" +#if defined(OS_CHROMEOS) +#include "webkit/chromeos/fileapi/cros_mount_point_provider.h" +#endif + namespace fileapi { + namespace { // PS stands for path separator. @@ -196,21 +201,21 @@ const struct IsRestrictedNameTest { { FILE_PATH_LITERAL(".b"), false, }, }; -FilePath UTF8ToFilePath(const std::string& str) { - FilePath::StringType result; -#if defined(OS_POSIX) - result = base::SysWideToNativeMB(UTF8ToWide(str)); -#elif defined(OS_WIN) - result = UTF8ToUTF16(str); +FileSystemOptions CreateRootPathTestOptions() { + std::vector<std::string> additional_allowed_schemes; + additional_allowed_schemes.push_back("file"); +#if defined(OS_CHROMEOS) + additional_allowed_schemes.push_back("chrome-extension"); #endif - return FilePath(result); + return FileSystemOptions(FileSystemOptions::PROFILE_MODE_NORMAL, + additional_allowed_schemes); } } // namespace -class FileSystemPathManagerTest : public testing::Test { +class FileSystemMountPointProviderTest : public testing::Test { public: - FileSystemPathManagerTest() + FileSystemMountPointProviderTest() : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } @@ -219,25 +224,28 @@ class FileSystemPathManagerTest : public testing::Test { root_path_callback_status_ = false; root_path_.clear(); file_system_name_.clear(); + special_storage_policy_ = new quota::MockSpecialStoragePolicy; } protected: - FileSystemPathManager* NewPathManager( - bool incognito, - bool allow_file_access) { - FileSystemPathManager* manager = new FileSystemPathManager( + void SetupNewContext(const FileSystemOptions& options) { + file_system_context_ = new FileSystemContext( + base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), + special_storage_policy_, + NULL, data_dir_.path(), - scoped_refptr<quota::SpecialStoragePolicy>( - new quota::MockSpecialStoragePolicy), - incognito, - allow_file_access); + options); #if defined(OS_CHROMEOS) fileapi::ExternalFileSystemMountPointProvider* ext_provider = - manager->external_provider(); + file_system_context_->external_provider(); ext_provider->AddMountPoint(FilePath("/tmp/testing")); #endif - return manager; + } + + FileSystemMountPointProvider* provider(FileSystemType type) { + DCHECK(file_system_context_); + return file_system_context_->GetMountPointProvider(type); } void OnGetRootPath(bool success, @@ -248,14 +256,13 @@ class FileSystemPathManagerTest : public testing::Test { file_system_name_ = name; } - bool GetRootPath(FileSystemPathManager* manager, - const GURL& origin_url, + bool GetRootPath(const GURL& origin_url, fileapi::FileSystemType type, bool create, FilePath* root_path) { - manager->ValidateFileSystemRootAndGetURL( + provider(type)->ValidateFileSystemRootAndGetURL( origin_url, type, create, - base::Bind(&FileSystemPathManagerTest::OnGetRootPath, + base::Bind(&FileSystemMountPointProviderTest::OnGetRootPath, weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); if (root_path) @@ -269,27 +276,30 @@ class FileSystemPathManagerTest : public testing::Test { SandboxMountPointProvider::kNewFileSystemDirectory); } FilePath external_file_system_path() { - return UTF8ToFilePath(std::string(fileapi::kExternalDir)); + return FilePath::FromUTF8Unsafe(fileapi::kExternalDir); } FilePath external_file_path_root() { - return UTF8ToFilePath(std::string("/tmp")); + return FilePath::FromUTF8Unsafe("/tmp"); } private: ScopedTempDir data_dir_; - base::WeakPtrFactory<FileSystemPathManagerTest> weak_factory_; + base::WeakPtrFactory<FileSystemMountPointProviderTest> weak_factory_; bool root_path_callback_status_; FilePath root_path_; std::string file_system_name_; - DISALLOW_COPY_AND_ASSIGN(FileSystemPathManagerTest); + scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; + scoped_refptr<FileSystemContext> file_system_context_; + + DISALLOW_COPY_AND_ASSIGN(FileSystemMountPointProviderTest); }; -TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { +TEST_F(FileSystemMountPointProviderTest, GetRootPathCreateAndExamine) { std::vector<FilePath> returned_root_path( ARRAYSIZE_UNSAFE(kRootPathTestCases)); - scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); + SetupNewContext(CreateRootPathTestOptions()); // Create a new root directory. for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { @@ -297,8 +307,7 @@ TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { << kRootPathTestCases[i].expected_path); FilePath root_path; - EXPECT_TRUE(GetRootPath(manager.get(), - GURL(kRootPathTestCases[i].origin_url), + EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), kRootPathTestCases[i].type, true /* create */, &root_path)); @@ -324,8 +333,7 @@ TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { << kRootPathTestCases[i].expected_path); FilePath root_path; - EXPECT_TRUE(GetRootPath(manager.get(), - GURL(kRootPathTestCases[i].origin_url), + EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), kRootPathTestCases[i].type, false /* create */, &root_path)); ASSERT_TRUE(returned_root_path.size() > i); @@ -333,75 +341,70 @@ TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { } } -TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamineWithNewManager) { +TEST_F(FileSystemMountPointProviderTest, + GetRootPathCreateAndExamineWithNewProvider) { std::vector<FilePath> returned_root_path( ARRAYSIZE_UNSAFE(kRootPathTestCases)); - scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); + SetupNewContext(CreateAllowFileAccessOptions()); GURL origin_url("http://foo.com:1/"); FilePath root_path1; - EXPECT_TRUE(GetRootPath(manager.get(), origin_url, + EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary, true, &root_path1)); - manager.reset(NewPathManager(false, false)); + SetupNewContext(CreateDisallowFileAccessOptions()); FilePath root_path2; - EXPECT_TRUE(GetRootPath(manager.get(), origin_url, + EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary, false, &root_path2)); EXPECT_EQ(root_path1.value(), root_path2.value()); } -TEST_F(FileSystemPathManagerTest, GetRootPathGetWithoutCreate) { - scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); +TEST_F(FileSystemMountPointProviderTest, GetRootPathGetWithoutCreate) { + SetupNewContext(CreateDisallowFileAccessOptions()); // Try to get a root directory without creating. for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " << kRootPathTestCases[i].expected_path); - EXPECT_FALSE(GetRootPath(manager.get(), - GURL(kRootPathTestCases[i].origin_url), + EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), kRootPathTestCases[i].type, false /* create */, NULL)); } } -TEST_F(FileSystemPathManagerTest, GetRootPathInIncognito) { - scoped_ptr<FileSystemPathManager> manager(NewPathManager( - true /* incognito */, false)); +TEST_F(FileSystemMountPointProviderTest, GetRootPathInIncognito) { + SetupNewContext(CreateIncognitoFileSystemOptions()); // Try to get a root directory. for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " << kRootPathTestCases[i].expected_path); - EXPECT_FALSE(GetRootPath(manager.get(), - GURL(kRootPathTestCases[i].origin_url), + EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), kRootPathTestCases[i].type, true /* create */, NULL)); } } -TEST_F(FileSystemPathManagerTest, GetRootPathFileURI) { - scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); +TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURI) { + SetupNewContext(CreateDisallowFileAccessOptions()); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" << i << " " << kRootPathFileURITestCases[i].expected_path); - EXPECT_FALSE(GetRootPath(manager.get(), - GURL(kRootPathFileURITestCases[i].origin_url), + EXPECT_FALSE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), kRootPathFileURITestCases[i].type, true /* create */, NULL)); } } -TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) { - scoped_ptr<FileSystemPathManager> manager(NewPathManager( - false, true /* allow_file_access_from_files */)); +TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURIWithAllowFlag) { + SetupNewContext(CreateRootPathTestOptions()); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" << i << " " << kRootPathFileURITestCases[i].expected_path); FilePath root_path; - EXPECT_TRUE(GetRootPath(manager.get(), - GURL(kRootPathFileURITestCases[i].origin_url), + EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), kRootPathFileURITestCases[i].type, true /* create */, &root_path)); if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { @@ -415,14 +418,14 @@ TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) { } } -TEST_F(FileSystemPathManagerTest, IsRestrictedName) { - scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); +TEST_F(FileSystemMountPointProviderTest, IsRestrictedName) { + SetupNewContext(CreateDisallowFileAccessOptions()); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " << kIsRestrictedNameTestCases[i].name); FilePath name(kIsRestrictedNameTestCases[i].name); EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, - manager->IsRestrictedFileName(kFileSystemTypeTemporary, name)); + provider(kFileSystemTypeTemporary)->IsRestrictedFileName(name)); } } diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 745273b..693499a 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -12,8 +12,8 @@ #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util_proxy.h" +#include "webkit/fileapi/file_system_mount_point_provider.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_util.h" @@ -101,7 +101,14 @@ void FileSystemOperation::OpenFileSystem( // create an unpredictable directory name. Without that, we could lazily // create the root later on the first filesystem write operation, and just // return GetFileSystemRootURI() here. - file_system_context()->path_manager()->ValidateFileSystemRootAndGetURL( + FileSystemMountPointProvider* mount_point_provider = + file_system_context()->GetMountPointProvider(type); + if (!mount_point_provider) { + DidGetRootPath(false, FilePath(), std::string()); + delete this; + return; + } + mount_point_provider->ValidateFileSystemRootAndGetURL( origin_url, type, create, base::Bind(&FileSystemOperation::DidGetRootPath, base::Owned(this))); @@ -776,8 +783,9 @@ bool FileSystemOperation::VerifyFileSystemPathForWrite( dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); return false; } - if (create && file_system_context()->path_manager()->IsRestrictedFileName( - *type, virtual_path->BaseName())) { + if (create && + file_system_context()->GetMountPointProvider(*type)->IsRestrictedFileName( + virtual_path->BaseName())) { dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); return false; } @@ -794,13 +802,13 @@ bool FileSystemOperation::VerifyFileSystemPath( dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_INVALID_URL); return false; } - if (!file_system_context()->path_manager()->IsAccessAllowed( + if (!file_system_context()->GetMountPointProvider(*type)->IsAccessAllowed( *origin_url, *type, *virtual_path)) { dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY); return false; } DCHECK(file_util); - *file_util = file_system_context()->path_manager()->GetFileUtil(*type); + *file_util = file_system_context()->GetFileUtil(*type); DCHECK(*file_util); return true; diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc index fbf44b7..ad2da4f 100644 --- a/webkit/fileapi/file_system_operation_unittest.cc +++ b/webkit/fileapi/file_system_operation_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -302,7 +302,6 @@ void FileSystemOperationTest::SetUp() { base_dir, test_helper_.origin(), test_helper_.storage_type()); quota_manager_proxy_ = new MockQuotaManagerProxy(quota_manager_.get()); test_helper_.SetUp(base_dir, - false /* incognito */, false /* unlimited quota */, quota_manager_proxy_.get(), local_file_util_.get()); diff --git a/webkit/fileapi/file_system_operation_write_unittest.cc b/webkit/fileapi/file_system_operation_write_unittest.cc index 7d211c6..3bc8a2e 100644 --- a/webkit/fileapi/file_system_operation_write_unittest.cc +++ b/webkit/fileapi/file_system_operation_write_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -27,7 +27,6 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_test_helper.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/local_file_util.h" @@ -195,7 +194,6 @@ void FileSystemOperationWriteTest::SetUp() { quota_manager_ = new MockQuotaManager(base_dir, 1024); test_helper_.SetUp(base_dir, - false /* incognito */, false /* unlimited quota */, quota_manager_->proxy(), local_file_util_.get()); diff --git a/webkit/fileapi/file_system_options.cc b/webkit/fileapi/file_system_options.cc new file mode 100644 index 0000000..a3d7226 --- /dev/null +++ b/webkit/fileapi/file_system_options.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2012 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 "webkit/fileapi/file_system_options.h" + +namespace fileapi { + +FileSystemOptions::FileSystemOptions( + ProfileMode profile_mode, + const std::vector<std::string>& additional_allowed_schemes) + : profile_mode_(profile_mode), + additional_allowed_schemes_(additional_allowed_schemes) { +} + +FileSystemOptions::~FileSystemOptions() { +} + +} // namespace fileapi diff --git a/webkit/fileapi/file_system_options.h b/webkit/fileapi/file_system_options.h new file mode 100644 index 0000000..ccba7a0 --- /dev/null +++ b/webkit/fileapi/file_system_options.h @@ -0,0 +1,51 @@ +// Copyright (c) 2012 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 WEBKIT_FILEAPI_FILE_SYSTEM_OPTIONS_H_ +#define WEBKIT_FILEAPI_FILE_SYSTEM_OPTIONS_H_ + +#include <string> +#include <vector> + +namespace fileapi { + +// Provides runtime options that may change FileSystem API behavior. +// This object is copyable. +class FileSystemOptions { + public: + enum ProfileMode { + PROFILE_MODE_NORMAL = 0, + PROFILE_MODE_INCOGNITO + }; + + // |profile_mode| specifies if the profile (for this filesystem) + // is running in incognito mode (PROFILE_MODE_INCOGNITO) or no + // (PROFILE_MODE_NORMAL). + // |additional_allowed_schemes| specifies schemes that are allowed + // to access FileSystem API in addition to "http" and "https". + FileSystemOptions( + ProfileMode profile_mode, + const std::vector<std::string>& additional_allowed_schemes); + + ~FileSystemOptions(); + + // Returns true if it is running in the incognito mode. + bool is_incognito() const { return profile_mode_ == PROFILE_MODE_INCOGNITO; } + + // Returns the schemes that must be allowed to access FileSystem API + // in addition to standard "http" and "https". + // (e.g. If the --allow-file-access-from-files option is given in chrome + // "file" scheme will also need to be allowed). + const std::vector<std::string>& additional_allowed_schemes() const { + return additional_allowed_schemes_; + } + + private: + const ProfileMode profile_mode_; + const std::vector<std::string> additional_allowed_schemes_; +}; + +} // namespace fileapi + +#endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPTIONS_H_ diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc deleted file mode 100644 index a6eb20f..0000000 --- a/webkit/fileapi/file_system_path_manager.cc +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2011 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 "webkit/fileapi/file_system_path_manager.h" - -#include "base/rand_util.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" -#include "base/message_loop_proxy.h" -#include "base/stringprintf.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "googleurl/src/gurl.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h" -#include "webkit/fileapi/file_system_util.h" -#include "webkit/fileapi/sandbox_mount_point_provider.h" -#include "webkit/glue/webkit_glue.h" - -#if defined(OS_CHROMEOS) -#include "webkit/chromeos/fileapi/cros_mount_point_provider.h" -#endif - -// We use some of WebKit types for conversions between origin identifiers -// and origin URLs. -using WebKit::WebFileSystem; - -using base::PlatformFileError; - -static const char kChromeScheme[] = "chrome"; -static const char kExtensionScheme[] = "chrome-extension"; - -namespace fileapi { - -FileSystemPathManager::FileSystemPathManager( - scoped_refptr<base::MessageLoopProxy> file_message_loop, - const FilePath& profile_path, - scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, - bool is_incognito, - bool allow_file_access_from_files) - : is_incognito_(is_incognito), - allow_file_access_from_files_(allow_file_access_from_files), - sandbox_provider_( - new SandboxMountPointProvider( - ALLOW_THIS_IN_INITIALIZER_LIST(this), - file_message_loop, - profile_path)) { -#if defined(OS_CHROMEOS) - external_provider_.reset( - new chromeos::CrosMountPointProvider(special_storage_policy)); -#endif -} - -FileSystemPathManager::~FileSystemPathManager() {} - -void FileSystemPathManager::ValidateFileSystemRootAndGetURL( - const GURL& origin_url, fileapi::FileSystemType type, bool create, - const GetRootPathCallback& callback) { - FileSystemMountPointProvider* mount_point_provider = - GetMountPointProvider(type); - if (!mount_point_provider) { - callback.Run(false, FilePath(), std::string()); - return; - } - mount_point_provider->ValidateFileSystemRootAndGetURL( - origin_url, type, create, callback); -} - -FilePath FileSystemPathManager::ValidateFileSystemRootAndGetPathOnFileThread( - const GURL& origin_url, FileSystemType type, const FilePath& virtual_path, - bool create) { - FileSystemMountPointProvider* mount_point_provider = - GetMountPointProvider(type); - if (!mount_point_provider) - return FilePath(); - return mount_point_provider->ValidateFileSystemRootAndGetPathOnFileThread( - origin_url, type, virtual_path, create); -} - -bool FileSystemPathManager::IsAllowedScheme(const GURL& url) const { - // Basically we only accept http or https. We allow file:// URLs - // only if --allow-file-access-from-files flag is given. - return url.SchemeIs("http") || url.SchemeIs("https") || - url.SchemeIs(kExtensionScheme) || url.SchemeIs(kChromeScheme) || - (url.SchemeIsFile() && allow_file_access_from_files_); -} - -// static -std::string FileSystemPathManager::GetFileSystemTypeString( - fileapi::FileSystemType type) { - if (type == fileapi::kFileSystemTypeTemporary) - return fileapi::kTemporaryName; - else if (type == fileapi::kFileSystemTypePersistent) - return fileapi::kPersistentName; - else if (type == fileapi::kFileSystemTypeExternal) - return fileapi::kExternalName; - return std::string(); -} - -// Checks if a given |name| contains any restricted names/chars in it. -bool FileSystemPathManager::IsRestrictedFileName( - FileSystemType type, const FilePath& filename) { - FileSystemMountPointProvider* mount_point_provider = - GetMountPointProvider(type); - if (!mount_point_provider) - return true; - return mount_point_provider->IsRestrictedFileName(filename); -} - -// Checks if an origin has access to a particular filesystem type. -bool FileSystemPathManager::IsAccessAllowed( - const GURL& origin, FileSystemType type, const FilePath& virtual_path) { - FileSystemMountPointProvider* mount_point_provider = - GetMountPointProvider(type); - DCHECK(mount_point_provider); - return mount_point_provider->IsAccessAllowed(origin, type, virtual_path); -} - -FileSystemFileUtil* FileSystemPathManager::GetFileUtil( - FileSystemType type) const { - FileSystemMountPointProvider* mount_point_provider = - GetMountPointProvider(type); - DCHECK(mount_point_provider); - return mount_point_provider->GetFileUtil(); -} - -FileSystemMountPointProvider* FileSystemPathManager::GetMountPointProvider( - FileSystemType type) const { - switch (type) { - case kFileSystemTypeTemporary: - case kFileSystemTypePersistent: - return sandbox_provider(); - case kFileSystemTypeExternal: - return external_provider(); - case kFileSystemTypeUnknown: - default: - NOTREACHED(); - return NULL; - } -} - -} // namespace fileapi - -COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ - int(fileapi::kFileSystemTypeTemporary), mismatching_enums); -COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ - int(fileapi::kFileSystemTypePersistent), mismatching_enums); -COMPILE_ASSERT(int(WebFileSystem::TypeExternal) == \ - int(fileapi::kFileSystemTypeExternal), mismatching_enums); diff --git a/webkit/fileapi/file_system_path_manager.h b/webkit/fileapi/file_system_path_manager.h deleted file mode 100644 index 1a7b937..0000000 --- a/webkit/fileapi/file_system_path_manager.h +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2011 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 WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ -#define WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ -#pragma once - -#include "base/callback.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "webkit/fileapi/file_system_types.h" -#include "webkit/quota/special_storage_policy.h" - -class GURL; - -namespace base { -class MessageLoopProxy; -} - -namespace fileapi { - -class ExternalFileSystemMountPointProvider; -class FileSystemFileUtil; -class FileSystemMountPointProvider; -class SandboxMountPointProvider; - -class FileSystemPathManager { - public: - FileSystemPathManager( - scoped_refptr<base::MessageLoopProxy> file_message_loop, - const FilePath& profile_path, - scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, - bool is_incognito, - bool allow_file_access_from_files); - virtual ~FileSystemPathManager(); - - // Callback for GetFileSystemRootPath. - // If the request is accepted and the root filesystem for the origin exists - // the callback is called with success=true and valid root_path and name. - // If the request is accepted, |create| is specified for - // GetFileSystemRootPath, and the root directory does not exist, it creates - // a new one and calls back with success=true if the creation has succeeded. - typedef base::Callback<void(bool /* success */, - const FilePath& /* root_path */, - const std::string& /* name */)> - GetRootPathCallback; - - // Retrieves the root path for the given |origin_url| and |type|, and - // calls the given |callback| with the root path and name. - // If |create| is true this also creates the directory if it doesn't exist. - virtual void ValidateFileSystemRootAndGetURL( - const GURL& origin_url, - FileSystemType type, - bool create, - const FileSystemPathManager::GetRootPathCallback& callback); - - // Like GetFileSystemRootPath, but synchronous, and can be called only while - // running on the file thread. - virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( - const GURL& origin_url, - FileSystemType type, - const FilePath& virtual_path, - bool create); - - // Returns true if the given |url|'s scheme is allowed to access - // filesystem. - bool IsAllowedScheme(const GURL& url) const; - - // Returns the string representation of the given filesystem |type|. - // Returns an empty string if the |type| is invalid. - static std::string GetFileSystemTypeString(FileSystemType type); - - // Checks if a given |name| contains any restricted names/chars in it. - bool IsRestrictedFileName(FileSystemType type, - const FilePath& filename); - - // Checks if an origin has access to a particular filesystem type and - // file element represented by |virtual_path|. - bool IsAccessAllowed(const GURL& origin, FileSystemType type, - const FilePath& virtual_path); - - // Returns the appropriate FileUtil instance for the given |type|. - // This may return NULL if it is given an invalid or unsupported filesystem - // type. - FileSystemFileUtil* GetFileUtil(FileSystemType type) const; - - // Returns a FileSystemMountPointProvider instance for sandboxed filesystem - // types (e.g. TEMPORARY or PERSISTENT). - SandboxMountPointProvider* sandbox_provider() const { - return sandbox_provider_.get(); - } - - // Returns a FileSystemMountPointProvider instance for external filesystem - // type, which is used only by chromeos for now. - ExternalFileSystemMountPointProvider* external_provider() const { - return external_provider_.get(); - } - - bool is_incognito() const { - return is_incognito_; - } - - private: - // Returns the mount point provider instance for the given |type|. - // This may return NULL if it is given an invalid or unsupported filesystem - // type. - FileSystemMountPointProvider* GetMountPointProvider( - FileSystemType type) const; - - const bool is_incognito_; - const bool allow_file_access_from_files_; - scoped_ptr<SandboxMountPointProvider> sandbox_provider_; - scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; - - DISALLOW_COPY_AND_ASSIGN(FileSystemPathManager); -}; - -} // namespace fileapi - -#endif // WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ diff --git a/webkit/fileapi/file_system_quota_client.cc b/webkit/fileapi/file_system_quota_client.cc index 662f1ff..e1fdb52 100644 --- a/webkit/fileapi/file_system_quota_client.cc +++ b/webkit/fileapi/file_system_quota_client.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -16,7 +16,6 @@ #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/fileapi/file_system_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" diff --git a/webkit/fileapi/file_system_quota_client.h b/webkit/fileapi/file_system_quota_client.h index 35c0b79..7127387 100644 --- a/webkit/fileapi/file_system_quota_client.h +++ b/webkit/fileapi/file_system_quota_client.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -14,7 +14,6 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/memory/scoped_ptr.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/quota/quota_client.h" diff --git a/webkit/fileapi/file_system_quota_client_unittest.cc b/webkit/fileapi/file_system_quota_client_unittest.cc index 39e5314..df0e345 100644 --- a/webkit/fileapi/file_system_quota_client_unittest.cc +++ b/webkit/fileapi/file_system_quota_client_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -17,9 +17,10 @@ #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/obfuscated_file_util.h" -#include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/fileapi/quota_file_util.h" +#include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/quota/quota_types.h" namespace fileapi { @@ -33,13 +34,6 @@ const char kDummyURL3[] = "http://www.bleh"; const quota::StorageType kTemporary = quota::kStorageTypeTemporary; const quota::StorageType kPersistent = quota::kStorageTypePersistent; -class MockFileSystemPathManager : public FileSystemPathManager { - public: - explicit MockFileSystemPathManager(const FilePath& filesystem_path) - : FileSystemPathManager(base::MessageLoopProxy::current(), - filesystem_path, NULL, false, true) {} -}; - } // namespace class FileSystemQuotaClientTest : public testing::Test { @@ -57,8 +51,8 @@ class FileSystemQuotaClientTest : public testing::Test { base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), NULL, NULL, - FilePath(), false /* is_incognito */, true /* allow_file_access */, - new MockFileSystemPathManager(data_dir_.path())); + data_dir_.path(), + CreateDisallowFileAccessOptions()); } struct TestFile { @@ -129,7 +123,7 @@ class FileSystemQuotaClientTest : public testing::Test { quota::StorageType type) { // Note: this test assumes sandbox_provider impl is used for // temporary and persistent filesystem. - return file_system_context_->path_manager()->sandbox_provider()-> + return file_system_context_->sandbox_provider()-> GetBaseDirectoryForOriginAndType( GURL(origin_url), QuotaStorageTypeToFileSystemType(type), true); } @@ -150,7 +144,7 @@ class FileSystemQuotaClientTest : public testing::Test { bool CreateFileSystemDirectory(const FilePath& path, const std::string& origin_url, quota::StorageType type) { - FileSystemFileUtil* file_util = file_system_context_->path_manager()-> + FileSystemFileUtil* file_util = file_system_context_-> GetFileUtil(QuotaStorageTypeToFileSystemType(type)); scoped_ptr<FileSystemOperationContext> context( @@ -170,7 +164,7 @@ class FileSystemQuotaClientTest : public testing::Test { if (path.empty()) return false; - FileSystemFileUtil* file_util = file_system_context_->path_manager()-> + FileSystemFileUtil* file_util = file_system_context_-> sandbox_provider()->GetFileUtil(); scoped_ptr<FileSystemOperationContext> context( diff --git a/webkit/fileapi/file_system_quota_unittest.cc b/webkit/fileapi/file_system_quota_unittest.cc index 14a729b..4c1d259 100644 --- a/webkit/fileapi/file_system_quota_unittest.cc +++ b/webkit/fileapi/file_system_quota_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -203,7 +203,6 @@ void FileSystemQuotaTest::SetUp() { NULL); test_helper_.SetUp(filesystem_dir_path, - false /* incognito */, false /* unlimited quota */, quota_manager_->proxy(), local_file_util_.get()); diff --git a/webkit/fileapi/file_system_test_helper.cc b/webkit/fileapi/file_system_test_helper.cc index 9f68043..d542d10 100644 --- a/webkit/fileapi/file_system_test_helper.cc +++ b/webkit/fileapi/file_system_test_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,6 +13,7 @@ #include "webkit/fileapi/file_system_operation_context.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/quota/mock_special_storage_policy.h" @@ -34,35 +35,32 @@ FileSystemTestOriginHelper::~FileSystemTestOriginHelper() { void FileSystemTestOriginHelper::SetUp( const FilePath& base_dir, FileSystemFileUtil* file_util) { - SetUp(base_dir, false, false, NULL, file_util); + SetUp(base_dir, false, NULL, file_util); } void FileSystemTestOriginHelper::SetUp( FileSystemContext* file_system_context, FileSystemFileUtil* file_util) { - DCHECK(file_system_context->path_manager()); - DCHECK(file_system_context->path_manager()->sandbox_provider()); + DCHECK(file_system_context->sandbox_provider()); file_util_ = file_util; file_system_context_ = file_system_context; if (!file_util_) - file_util_ = file_system_context->path_manager()->sandbox_provider()-> - GetFileUtil(); + file_util_ = file_system_context->sandbox_provider()->GetFileUtil(); DCHECK(file_util_); // Prepare the origin's root directory. - file_system_context_->path_manager()-> + file_system_context_->GetMountPointProvider(type_)-> ValidateFileSystemRootAndGetPathOnFileThread( origin_, type_, FilePath(), true /* create */); // Initialize the usage cache file. - FilePath usage_cache_path = file_system_context_->path_manager() - ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); + FilePath usage_cache_path = file_system_context_-> + sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); } void FileSystemTestOriginHelper::SetUp( const FilePath& base_dir, - bool incognito_mode, bool unlimited_quota, quota::QuotaManagerProxy* quota_manager_proxy, FileSystemFileUtil* file_util) { @@ -77,22 +75,19 @@ void FileSystemTestOriginHelper::SetUp( special_storage_policy, quota_manager_proxy, base_dir, - incognito_mode, - true /* allow_file_access_from_files */, - NULL); + CreateAllowFileAccessOptions()); - DCHECK(file_system_context_->path_manager()); - DCHECK(file_system_context_->path_manager()->sandbox_provider()); + DCHECK(file_system_context_->sandbox_provider()); // Prepare the origin's root directory. - file_system_context_->path_manager()-> + file_system_context_->GetMountPointProvider(type_)-> ValidateFileSystemRootAndGetPathOnFileThread( origin_, type_, FilePath(), true /* create */); // Initialize the usage cache file. This code assumes that we're either using // OFSFU or we've mocked it out in the sandbox provider. - FilePath usage_cache_path = file_system_context_->path_manager() - ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); + FilePath usage_cache_path = file_system_context_-> + sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); } @@ -102,7 +97,7 @@ void FileSystemTestOriginHelper::TearDown() { } FilePath FileSystemTestOriginHelper::GetOriginRootPath() const { - return file_system_context_->path_manager()-> + return file_system_context_->GetMountPointProvider(type_)-> ValidateFileSystemRootAndGetPathOnFileThread( origin_, type_, FilePath(), false); } @@ -126,8 +121,8 @@ GURL FileSystemTestOriginHelper::GetURLForPath(const FilePath& path) const { } FilePath FileSystemTestOriginHelper::GetUsageCachePath() const { - return file_system_context_->path_manager() - ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); + return file_system_context_-> + sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); } int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const { diff --git a/webkit/fileapi/file_system_test_helper.h b/webkit/fileapi/file_system_test_helper.h index 0db1a07..e70ae28 100644 --- a/webkit/fileapi/file_system_test_helper.h +++ b/webkit/fileapi/file_system_test_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -46,7 +46,6 @@ class FileSystemTestOriginHelper { void SetUp(FileSystemContext* file_system_context, FileSystemFileUtil* file_util); void SetUp(const FilePath& base_dir, - bool incognito_mode, bool unlimited_quota, quota::QuotaManagerProxy* quota_manager_proxy, FileSystemFileUtil* file_util); diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index 55379f9..ad4664c 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -24,7 +24,6 @@ #include "net/url_request/url_request.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_operation.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_util.h" using net::URLRequest; diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc index 10f4d0c..0e96ec3 100644 --- a/webkit/fileapi/file_system_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_url_request_job_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -37,7 +37,7 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/quota/mock_special_storage_policy.h" @@ -83,12 +83,10 @@ class FileSystemURLRequestJobTest : public testing::Test { base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), special_storage_policy_, NULL, - FilePath(), false /* is_incognito */, true /* allow_file_access */, - new FileSystemPathManager( - base::MessageLoopProxy::current(), - temp_dir_.path(), NULL, false, false)); + temp_dir_.path(), + CreateDisallowFileAccessOptions()); - file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( + file_system_context_->sandbox_provider()->ValidateFileSystemRootAndGetURL( GURL("http://remote/"), kFileSystemTypeTemporary, true, // create base::Bind(&FileSystemURLRequestJobTest::OnGetRootPath, weak_factory_.GetWeakPtr())); @@ -144,7 +142,7 @@ class FileSystemURLRequestJobTest : public testing::Test { void CreateDirectory(const base::StringPiece& dir_name) { FilePath path = FilePath().AppendASCII(dir_name); - FileSystemFileUtil* file_util = file_system_context_->path_manager()-> + FileSystemFileUtil* file_util = file_system_context_-> sandbox_provider()->GetFileUtil(); FileSystemOperationContext context(file_system_context_, file_util); context.set_src_origin_url(GURL("http://remote")); @@ -161,7 +159,7 @@ class FileSystemURLRequestJobTest : public testing::Test { void WriteFile(const base::StringPiece& file_name, const char* buf, int buf_size) { FilePath path = FilePath().AppendASCII(file_name); - FileSystemFileUtil* file_util = file_system_context_->path_manager()-> + FileSystemFileUtil* file_util = file_system_context_-> sandbox_provider()->GetFileUtil(); FileSystemOperationContext context(file_system_context_, file_util); context.set_src_origin_url(GURL("http://remote")); diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc index 42300db..b6dfe12 100644 --- a/webkit/fileapi/file_system_util.cc +++ b/webkit/fileapi/file_system_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -162,4 +162,18 @@ GURL GetOriginURLFromIdentifier(const std::string& origin_identifier) { return origin_url; } +std::string GetFileSystemTypeString(FileSystemType type) { + switch (type) { + case kFileSystemTypeTemporary: + return fileapi::kTemporaryName; + case kFileSystemTypePersistent: + return fileapi::kPersistentName; + case kFileSystemTypeExternal: + return fileapi::kExternalName; + case kFileSystemTypeUnknown: + default: + return std::string(); + } +} + } // namespace fileapi diff --git a/webkit/fileapi/file_system_util.h b/webkit/fileapi/file_system_util.h index 25fa947..00dfd6c 100644 --- a/webkit/fileapi/file_system_util.h +++ b/webkit/fileapi/file_system_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -56,6 +56,10 @@ quota::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type); std::string GetOriginIdentifierFromURL(const GURL& url); GURL GetOriginURLFromIdentifier(const std::string& origin_identifier); +// Returns the string representation of the given filesystem |type|. +// Returns an empty string if the |type| is invalid. +std::string GetFileSystemTypeString(FileSystemType type); + } // namespace fileapi #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc index 4bd1fc3..e0f1c03 100644 --- a/webkit/fileapi/file_writer_delegate.cc +++ b/webkit/fileapi/file_writer_delegate.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,7 +13,6 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/quota_file_util.h" diff --git a/webkit/fileapi/file_writer_delegate_unittest.cc b/webkit/fileapi/file_writer_delegate_unittest.cc index d89a319..82f9956 100644 --- a/webkit/fileapi/file_writer_delegate_unittest.cc +++ b/webkit/fileapi/file_writer_delegate_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // @@ -26,7 +26,6 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_test_helper.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_writer_delegate.h" diff --git a/webkit/fileapi/local_file_util.cc b/webkit/fileapi/local_file_util.cc index 26ebc3b..0b498f0 100644 --- a/webkit/fileapi/local_file_util.cc +++ b/webkit/fileapi/local_file_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,8 +7,8 @@ #include "base/file_util_proxy.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_context.h" +#include "webkit/fileapi/file_system_mount_point_provider.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_util.h" @@ -292,7 +292,7 @@ FilePath LocalFileUtil::GetLocalPath( const GURL& origin_url, FileSystemType type, const FilePath& virtual_path) { - FilePath root = context->file_system_context()->path_manager()-> + FilePath root = context->file_system_context()->GetMountPointProvider(type)-> ValidateFileSystemRootAndGetPathOnFileThread(origin_url, type, virtual_path, false); if (root.empty()) diff --git a/webkit/fileapi/local_file_util_unittest.cc b/webkit/fileapi/local_file_util_unittest.cc index f8ae2c2..e1a138e 100644 --- a/webkit/fileapi/local_file_util_unittest.cc +++ b/webkit/fileapi/local_file_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -14,7 +14,6 @@ #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_test_helper.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/local_file_util.h" diff --git a/webkit/fileapi/mock_file_system_options.cc b/webkit/fileapi/mock_file_system_options.cc new file mode 100644 index 0000000..760562f --- /dev/null +++ b/webkit/fileapi/mock_file_system_options.cc @@ -0,0 +1,27 @@ +// Copyright (c) 2012 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 "webkit/fileapi/mock_file_system_options.h" + +namespace fileapi { + +FileSystemOptions CreateIncognitoFileSystemOptions() { + return FileSystemOptions(FileSystemOptions::PROFILE_MODE_INCOGNITO, + std::vector<std::string>()); +}; + +FileSystemOptions CreateAllowFileAccessOptions() { + std::vector<std::string> additional_allowed_schemes; + additional_allowed_schemes.push_back("file"); + return FileSystemOptions(FileSystemOptions::PROFILE_MODE_NORMAL, + additional_allowed_schemes); +}; + +FileSystemOptions CreateDisallowFileAccessOptions() { + std::vector<std::string> additional_allowed_schemes; + return FileSystemOptions(FileSystemOptions::PROFILE_MODE_NORMAL, + additional_allowed_schemes); +}; + +} // namespace fileapi diff --git a/webkit/fileapi/mock_file_system_options.h b/webkit/fileapi/mock_file_system_options.h new file mode 100644 index 0000000..e6cd729 --- /dev/null +++ b/webkit/fileapi/mock_file_system_options.h @@ -0,0 +1,26 @@ +// Copyright (c) 2012 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 WEBKIT_FILEAPI_MOCK_FILE_SYSTEM_OPTIONS_H_ +#define WEBKIT_FILEAPI_MOCK_FILE_SYSTEM_OPTIONS_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "webkit/fileapi/file_system_options.h" + +namespace fileapi { + +// Returns Filesystem options for incognito mode. +FileSystemOptions CreateIncognitoFileSystemOptions(); + +// Returns Filesystem options that allow file access. +FileSystemOptions CreateAllowFileAccessOptions(); + +// Returns Filesystem options that disallow file access. +FileSystemOptions CreateDisallowFileAccessOptions(); + +} // namespace fileapi + +#endif // WEBKIT_FILEAPI_MOCK_FILE_SYSTEM_OPTIONS_H_ diff --git a/webkit/fileapi/obfuscated_file_util.cc b/webkit/fileapi/obfuscated_file_util.cc index 2b44d4f..dc6a2c1 100644 --- a/webkit/fileapi/obfuscated_file_util.cc +++ b/webkit/fileapi/obfuscated_file_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -19,7 +19,6 @@ #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" @@ -993,8 +992,7 @@ ObfuscatedFileUtil::CreateOriginEnumerator() { bool ObfuscatedFileUtil::DestroyDirectoryDatabase( const GURL& origin, FileSystemType type) { - std::string type_string = - FileSystemPathManager::GetFileSystemTypeString(type); + std::string type_string = GetFileSystemTypeString(type); if (type_string.empty()) { LOG(WARNING) << "Unknown filesystem type requested:" << type; return true; @@ -1185,8 +1183,7 @@ FilePath ObfuscatedFileUtil::LocalPathToDataPath( // Still doesn't answer the quota issue, though. FileSystemDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase( const GURL& origin, FileSystemType type, bool create) { - std::string type_string = - FileSystemPathManager::GetFileSystemTypeString(type); + std::string type_string = GetFileSystemTypeString(type); if (type_string.empty()) { LOG(WARNING) << "Unknown filesystem type requested:" << type; return NULL; diff --git a/webkit/fileapi/obfuscated_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_util_unittest.cc index af46597..9d7b380 100644 --- a/webkit/fileapi/obfuscated_file_util_unittest.cc +++ b/webkit/fileapi/obfuscated_file_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -17,9 +17,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_test_helper.h" #include "webkit/fileapi/file_system_usage_cache.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/fileapi/obfuscated_file_util.h" #include "webkit/quota/mock_special_storage_policy.h" #include "webkit/quota/quota_manager.h" @@ -142,12 +142,15 @@ class ObfuscatedFileUtilTest : public testing::Test { void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); + scoped_refptr<quota::SpecialStoragePolicy> storage_policy = + new quota::MockSpecialStoragePolicy(); + quota_manager_ = new quota::QuotaManager( false /* is_incognito */, data_dir_.path(), base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), - NULL /* special storage policy */); + storage_policy); // Every time we create a new helper, it creates another context, which // creates another path manager, another sandbox_mount_point_provider, and @@ -155,20 +158,23 @@ class ObfuscatedFileUtilTest : public testing::Test { file_system_context_ = new FileSystemContext( base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), - new quota::MockSpecialStoragePolicy(), + storage_policy, quota_manager_->proxy(), data_dir_.path(), - false /* incognito */, - true /* allow_file_access_from_files */, - NULL /* path_manager */); + CreateAllowFileAccessOptions()); obfuscated_file_util_ = static_cast<ObfuscatedFileUtil*>( - file_system_context_->path_manager()->GetFileUtil(type_)); + file_system_context_->GetFileUtil(type_)); test_helper_.SetUp(file_system_context_.get(), obfuscated_file_util_.get()); } + void TearDown() { + quota_manager_ = NULL; + test_helper_.TearDown(); + } + FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) { FileSystemOperationContext* context; if (helper) diff --git a/webkit/fileapi/quota_file_util.cc b/webkit/fileapi/quota_file_util.cc index 6ccb578..7593b63 100644 --- a/webkit/fileapi/quota_file_util.cc +++ b/webkit/fileapi/quota_file_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,7 +8,6 @@ #include "base/logging.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/native_file_util.h" #include "webkit/quota/quota_manager.h" diff --git a/webkit/fileapi/quota_file_util_unittest.cc b/webkit/fileapi/quota_file_util_unittest.cc index c33c2a85..6b90cdd 100644 --- a/webkit/fileapi/quota_file_util_unittest.cc +++ b/webkit/fileapi/quota_file_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,7 +11,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_test_helper.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_usage_cache.h" diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index e022c05..95edc81 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -17,7 +17,7 @@ #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/file_system_options.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" @@ -30,10 +30,13 @@ using quota::QuotaManagerProxy; namespace { -static const FilePath::CharType kOldFileSystemUniqueNamePrefix[] = +const char kChromeScheme[] = "chrome"; +const char kExtensionScheme[] = "chrome-extension"; + +const FilePath::CharType kOldFileSystemUniqueNamePrefix[] = FILE_PATH_LITERAL("chrome-"); -static const int kOldFileSystemUniqueLength = 16; -static const unsigned kOldFileSystemUniqueDirectoryNameLength = +const size_t kOldFileSystemUniqueLength = 16; +const size_t kOldFileSystemUniqueDirectoryNameLength = kOldFileSystemUniqueLength + arraysize(kOldFileSystemUniqueNamePrefix) - 1; const char kOpenFileSystem[] = "FileSystem.OpenFileSystem"; @@ -47,30 +50,21 @@ enum FileSystemError { // Restricted names. // http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions -static const char* const kRestrictedNames[] = { - ".", "..", +const FilePath::CharType* const kRestrictedNames[] = { + FILE_PATH_LITERAL("."), FILE_PATH_LITERAL(".."), }; // Restricted chars. -static const FilePath::CharType kRestrictedChars[] = { - '/', '\\', +const FilePath::CharType kRestrictedChars[] = { + FILE_PATH_LITERAL('/'), FILE_PATH_LITERAL('\\'), }; -inline std::string FilePathStringToASCII( - const FilePath::StringType& path_string) { -#if defined(OS_WIN) - return WideToASCII(path_string); -#elif defined(OS_POSIX) - return path_string; -#endif -} - FilePath::StringType OldCreateUniqueDirectoryName(const GURL& origin_url) { // This can be anything but need to be unpredictable. static const FilePath::CharType letters[] = FILE_PATH_LITERAL( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); FilePath::StringType unique(kOldFileSystemUniqueNamePrefix); - for (int i = 0; i < kOldFileSystemUniqueLength; ++i) + for (size_t i = 0; i < kOldFileSystemUniqueLength; ++i) unique += letters[base::RandInt(0, arraysize(letters) - 2)]; return unique; } @@ -135,14 +129,13 @@ class OldSandboxOriginEnumerator if (current_.empty()) return GURL(); return fileapi::GetOriginURLFromIdentifier( - FilePathStringToASCII(current_.BaseName().value())); + current_.BaseName().MaybeAsASCII()); } virtual bool HasFileSystemType(fileapi::FileSystemType type) const OVERRIDE { if (current_.empty()) return false; - std::string directory = - fileapi::FileSystemPathManager::GetFileSystemTypeString(type); + std::string directory = GetFileSystemTypeString(type); DCHECK(!directory.empty()); return file_util::DirectoryExists(current_.AppendASCII(directory)); } @@ -164,8 +157,7 @@ FilePath OldGetBaseDirectoryForOrigin( FilePath OldGetBaseDirectoryForOriginAndType( const FilePath& old_base_path, const GURL& origin_url, fileapi::FileSystemType type) { - std::string type_string = - fileapi::FileSystemPathManager::GetFileSystemTypeString(type); + std::string type_string = GetFileSystemTypeString(type); if (type_string.empty()) { NOTREACHED(); return FilePath(); @@ -288,7 +280,7 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemType type, ObfuscatedFileUtil* file_util, const FilePath& old_base_path, - const FileSystemPathManager::GetRootPathCallback& callback) + const FileSystemMountPointProvider::GetRootPathCallback& callback) : file_message_loop_(file_message_loop), origin_message_loop_proxy_( base::MessageLoopProxy::current()), @@ -337,8 +329,7 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask void DispatchCallback(const FilePath& root_path) { std::string origin_identifier = GetOriginIdentifierFromURL(origin_url_); - std::string type_string = - FileSystemPathManager::GetFileSystemTypeString(type_); + std::string type_string = GetFileSystemTypeString(type_); DCHECK(!type_string.empty()); std::string name = origin_identifier + ":" + type_string; @@ -355,17 +346,17 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemType type_; scoped_refptr<ObfuscatedFileUtil> file_util_; FilePath old_base_path_; - FileSystemPathManager::GetRootPathCallback callback_; + FileSystemMountPointProvider::GetRootPathCallback callback_; }; SandboxMountPointProvider::SandboxMountPointProvider( - FileSystemPathManager* path_manager, scoped_refptr<base::MessageLoopProxy> file_message_loop, - const FilePath& profile_path) + const FilePath& profile_path, + const FileSystemOptions& file_system_options) : FileSystemQuotaUtil(file_message_loop), - path_manager_(path_manager), file_message_loop_(file_message_loop), profile_path_(profile_path), + file_system_options_(file_system_options), sandbox_file_util_( new ObfuscatedFileUtil( profile_path.Append(kNewFileSystemDirectory), @@ -382,16 +373,17 @@ bool SandboxMountPointProvider::IsAccessAllowed(const GURL& origin_url, const FilePath& unused) { if (type != kFileSystemTypeTemporary && type != kFileSystemTypePersistent) return false; - // We essentially depend on quota to do our access controls. - return path_manager_->IsAllowedScheme(origin_url); + // We essentially depend on quota to do our access controls, so here + // we only check if the requested scheme is allowed or not. + return IsAllowedScheme(origin_url); } void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( const GURL& origin_url, fileapi::FileSystemType type, bool create, - const FileSystemPathManager::GetRootPathCallback& callback) { + const FileSystemMountPointProvider::GetRootPathCallback& callback) { FilePath origin_base_path; - if (path_manager_->is_incognito()) { + if (file_system_options_.is_incognito()) { // TODO(kinuko): return an isolated temporary directory. callback.Run(false, FilePath(), std::string()); UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, @@ -400,7 +392,7 @@ void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( return; } - if (!path_manager_->IsAllowedScheme(origin_url)) { + if (!IsAllowedScheme(origin_url)) { callback.Run(false, FilePath(), std::string()); UMA_HISTOGRAM_ENUMERATION(kOpenFileSystem, kInvalidScheme, @@ -419,11 +411,11 @@ FilePath SandboxMountPointProvider::ValidateFileSystemRootAndGetPathOnFileThread( const GURL& origin_url, FileSystemType type, const FilePath& unused, bool create) { - if (path_manager_->is_incognito()) + if (file_system_options_.is_incognito()) // TODO(kinuko): return an isolated temporary directory. return FilePath(); - if (!path_manager_->IsAllowedScheme(origin_url)) + if (!IsAllowedScheme(origin_url)) return FilePath(); MigrateIfNeeded(sandbox_file_util_, old_base_path()); @@ -437,12 +429,9 @@ bool SandboxMountPointProvider::IsRestrictedFileName(const FilePath& filename) if (filename.value().empty()) return false; - std::string filename_lower = StringToLowerASCII( - FilePathStringToASCII(filename.value())); - for (size_t i = 0; i < arraysize(kRestrictedNames); ++i) { // Exact match. - if (filename_lower == kRestrictedNames[i]) + if (filename.value() == kRestrictedNames[i]) return true; } @@ -677,4 +666,19 @@ FilePath SandboxMountPointProvider::OldCreateFileSystemRootPath( return root; } +bool SandboxMountPointProvider::IsAllowedScheme(const GURL& url) const { + // Basically we only accept http or https. We allow file:// URLs + // only if --allow-file-access-from-files flag is given. + if (url.SchemeIs("http") || url.SchemeIs("https")) + return true; + for (size_t i = 0; + i < file_system_options_.additional_allowed_schemes().size(); + ++i) { + if (url.SchemeIs( + file_system_options_.additional_allowed_schemes()[i].c_str())) + return true; + } + return false; +} + } // namespace fileapi diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 5fa76ab2..e7db7b9 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,6 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_mount_point_provider.h" +#include "webkit/fileapi/file_system_options.h" #include "webkit/fileapi/file_system_quota_util.h" namespace base { @@ -36,6 +37,8 @@ class SandboxMountPointProvider : public FileSystemMountPointProvider, public FileSystemQuotaUtil { public: + typedef FileSystemMountPointProvider::GetRootPathCallback GetRootPathCallback; + // Origin enumerator interface. // An instance of this interface is assumed to be called on the file thread. class OriginEnumerator { @@ -58,9 +61,9 @@ class SandboxMountPointProvider static const FilePath::CharType kRenamedOldFileSystemDirectory[]; SandboxMountPointProvider( - FileSystemPathManager* path_manager, scoped_refptr<base::MessageLoopProxy> file_message_loop, - const FilePath& profile_path); + const FilePath& profile_path, + const FileSystemOptions& file_system_options); virtual ~SandboxMountPointProvider(); // FileSystemMountPointProvider overrides. @@ -72,7 +75,7 @@ class SandboxMountPointProvider const GURL& origin_url, FileSystemType type, bool create, - const FileSystemPathManager::GetRootPathCallback& callback) OVERRIDE; + const GetRootPathCallback& callback) OVERRIDE; virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( const GURL& origin_url, FileSystemType type, @@ -148,20 +151,22 @@ class SandboxMountPointProvider FilePath OldCreateFileSystemRootPath( const GURL& origin_url, FileSystemType type); + // Returns true if the given |url|'s scheme is allowed to access + // filesystem. + bool IsAllowedScheme(const GURL& url) const; + class GetFileSystemRootPathTask; friend class FileSystemTestOriginHelper; friend class SandboxMountPointProviderMigrationTest; friend class SandboxMountPointProviderOriginEnumeratorTest; - // The path_manager_ isn't owned by this instance; this instance is owned by - // the path_manager_, and they have the same lifetime. - FileSystemPathManager* path_manager_; - scoped_refptr<base::MessageLoopProxy> file_message_loop_; const FilePath profile_path_; + FileSystemOptions file_system_options_; + scoped_refptr<ObfuscatedFileUtil> sandbox_file_util_; // Acccessed only on the file thread. diff --git a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc index 60ad07e..4df10321 100644 --- a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc +++ b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,42 +20,40 @@ #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/fileapi/file_system_context.h" +#include "webkit/fileapi/file_system_mount_point_provider.h" #include "webkit/fileapi/file_system_operation_context.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_util.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/quota/mock_special_storage_policy.h" namespace fileapi { -class MockFileSystemPathManager : public FileSystemPathManager { - public: - explicit MockFileSystemPathManager(const FilePath& profile_path) - : FileSystemPathManager(base::MessageLoopProxy::current(), - profile_path, NULL, false, true) {} -}; - class SandboxMountPointProviderOriginEnumeratorTest : public testing::Test { public: void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - path_manager_.reset(new MockFileSystemPathManager(data_dir_.path())); + sandbox_provider_.reset( + new SandboxMountPointProvider( + base::MessageLoopProxy::current(), + data_dir_.path(), + CreateAllowFileAccessOptions())); } SandboxMountPointProvider::OriginEnumerator* CreateEnumerator() const { - return path_manager_->sandbox_provider()->CreateOriginEnumerator(); + return sandbox_provider_->CreateOriginEnumerator(); } protected: void CreateOriginTypeDirectory(const GURL& origin, fileapi::FileSystemType type) { - FilePath target = path_manager_->sandbox_provider()-> + FilePath target = sandbox_provider_-> GetBaseDirectoryForOriginAndType(origin, type, true); ASSERT_TRUE(!target.empty()); ASSERT_TRUE(file_util::DirectoryExists(target)); } ScopedTempDir data_dir_; - scoped_ptr<FileSystemPathManager> path_manager_; + scoped_ptr<SandboxMountPointProvider> sandbox_provider_; }; TEST_F(SandboxMountPointProviderOriginEnumeratorTest, Empty) { @@ -139,8 +137,6 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - path_manager_ = new MockFileSystemPathManager(data_dir_.path()); - scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = new quota::MockSpecialStoragePolicy; special_storage_policy->SetAllUnlimited(true); @@ -150,17 +146,11 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { special_storage_policy, NULL, data_dir_.path(), - false, // incognito - true, // allow_file_access_from_files - path_manager_); - } - - FileSystemPathManager* path_manager() { - return path_manager_; + CreateAllowFileAccessOptions()); } SandboxMountPointProvider* sandbox_provider() { - return path_manager()->sandbox_provider(); + return file_system_context_->sandbox_provider(); } FileSystemFileUtil* file_util() { @@ -172,7 +162,7 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { EXPECT_FALSE(success); // We told it not to create. } - FileSystemPathManager::GetRootPathCallback GetRootPathCallback() { + FileSystemMountPointProvider::GetRootPathCallback GetRootPathCallback() { return base::Bind(&SandboxMountPointProviderMigrationTest::OnGetRootPath, weak_factory_.GetWeakPtr()); } @@ -218,7 +208,7 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { std::string URLAndTypeToSeedString(const GURL& origin_url, fileapi::FileSystemType type) { return GetOriginIdentifierFromURL(origin_url) + - FileSystemPathManager::GetFileSystemTypeString(type); + GetFileSystemTypeString(type); } void ValidateDataInNewFileSystem( @@ -357,7 +347,6 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { protected: ScopedTempDir data_dir_; - FileSystemPathManager* path_manager_; scoped_refptr<FileSystemContext> file_system_context_; base::WeakPtrFactory<SandboxMountPointProviderMigrationTest> weak_factory_; }; diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi index 141813d..be1a194 100644 --- a/webkit/fileapi/webkit_fileapi.gypi +++ b/webkit/fileapi/webkit_fileapi.gypi @@ -33,10 +33,10 @@ 'file_system_operation_context.cc', 'file_system_operation_context.h', 'file_system_operation_interface.h', + 'file_system_options.cc', + 'file_system_options.h', 'file_system_origin_database.cc', 'file_system_origin_database.h', - 'file_system_path_manager.cc', - 'file_system_path_manager.h', 'file_system_quota_client.cc', 'file_system_quota_client.h', 'file_system_quota_util.cc', diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi index 65ae3c7..ada63ea 100644 --- a/webkit/support/webkit_support.gypi +++ b/webkit/support/webkit_support.gypi @@ -118,6 +118,8 @@ '<(DEPTH)/webkit/tools/test_shell/test_shell_webblobregistry_impl.h', '<(DEPTH)/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc', '<(DEPTH)/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h', + '<(DEPTH)/webkit/fileapi/mock_file_system_options.cc', + '<(DEPTH)/webkit/fileapi/mock_file_system_options.h', 'simple_database_system.cc', 'simple_database_system.h', ], diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc index ef67a13..c6982eb 100644 --- a/webkit/tools/test_shell/simple_file_system.cc +++ b/webkit/tools/test_shell/simple_file_system.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -21,8 +21,8 @@ #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_operation.h" -#include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_types.h" +#include "webkit/fileapi/mock_file_system_options.h" #include "webkit/glue/webkit_glue.h" #include "webkit/tools/test_shell/simple_file_writer.h" @@ -128,9 +128,7 @@ SimpleFileSystem::SimpleFileSystem() { NULL /* special storage policy */, NULL /* quota manager */, file_system_dir_.path(), - false /* incognito */, - true /* allow_file_access */, - NULL); + fileapi::CreateAllowFileAccessOptions()); } else { LOG(WARNING) << "Failed to create a temp dir for the filesystem." "FileSystem feature will be disabled."; diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index dcdde2a..432033a 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -398,19 +398,21 @@ '../../database/quota_table_unittest.cc', '../../fileapi/file_system_directory_database_unittest.cc', '../../fileapi/file_system_file_util_unittest.cc', + '../../fileapi/file_system_mount_point_provider_unittest.cc', '../../fileapi/file_system_operation_unittest.cc', '../../fileapi/file_system_origin_database_unittest.cc', - '../../fileapi/file_system_path_manager_unittest.cc', '../../fileapi/file_system_quota_client_unittest.cc', '../../fileapi/file_system_quota_unittest.cc', + '../../fileapi/file_system_test_helper.cc', + '../../fileapi/file_system_test_helper.h', '../../fileapi/file_system_usage_cache_unittest.cc', '../../fileapi/file_system_util_unittest.cc', '../../fileapi/local_file_util_unittest.cc', + '../../fileapi/mock_file_system_options.cc', + '../../fileapi/mock_file_system_options.h', '../../fileapi/obfuscated_file_util_unittest.cc', '../../fileapi/quota_file_util_unittest.cc', '../../fileapi/sandbox_mount_point_provider_unittest.cc', - '../../fileapi/file_system_test_helper.cc', - '../../fileapi/file_system_test_helper.h', '../../fileapi/webfilewriter_base_unittest.cc', '../../glue/bookmarklet_unittest.cc', '../../glue/context_menu_unittest.cc', |