diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 19:40:23 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 19:40:23 +0000 |
commit | e5c621f13ac46ba5d45bf5a308edd3bd19b79a44 (patch) | |
tree | 52f9b98d511fca2ea6ae1591fb64b306bc765a10 /chrome | |
parent | 420286748888437c755272ffe98fd27a16099194 (diff) | |
download | chromium_src-e5c621f13ac46ba5d45bf5a308edd3bd19b79a44.zip chromium_src-e5c621f13ac46ba5d45bf5a308edd3bd19b79a44.tar.gz chromium_src-e5c621f13ac46ba5d45bf5a308edd3bd19b79a44.tar.bz2 |
Revert 57715 - Add a helper class that keeps per-profile information for FileSystem API
BUG=32277
TEST=FileSystemHostContextTest
Review URL: http://codereview.chromium.org/3028033
TBR=kinuko@chromium.org
Review URL: http://codereview.chromium.org/3243005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/file_system/file_system_dispatcher_host.cc | 40 | ||||
-rw-r--r-- | chrome/browser/file_system/file_system_dispatcher_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/file_system/file_system_host_context.cc | 65 | ||||
-rw-r--r-- | chrome/browser/file_system/file_system_host_context.h | 51 | ||||
-rw-r--r-- | chrome/browser/file_system/file_system_host_context_unittest.cc | 101 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 12 | ||||
-rw-r--r-- | chrome/browser/profile.h | 4 | ||||
-rw-r--r-- | chrome/browser/profile_impl.cc | 9 | ||||
-rw-r--r-- | chrome/browser/profile_impl.h | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_message_filter.cc | 8 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/testing_profile.h | 1 |
13 files changed, 8 insertions, 292 deletions
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc index d876808..3e23695 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.cc +++ b/chrome/browser/file_system/file_system_dispatcher_host.cc @@ -8,23 +8,19 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/file_system/file_system_host_context.h" #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" -#include "webkit/glue/webkit_glue.h" FileSystemDispatcherHost::FileSystemDispatcherHost( IPC::Message::Sender* sender, - FileSystemHostContext* file_system_host_context, HostContentSettingsMap* host_content_settings_map) : message_sender_(sender), process_handle_(0), shutdown_(false), - context_(file_system_host_context), host_content_settings_map_(host_content_settings_map) { DCHECK(message_sender_); } @@ -58,46 +54,20 @@ bool FileSystemDispatcherHost::OnMessageReceived( void FileSystemDispatcherHost::OnOpenFileSystem( const ViewHostMsg_OpenFileSystemRequest_Params& params) { + string16 name; + string16 root_path; - // TODO(kinuko): hook up ContentSettings cookies type checks. - - FilePath root_path; - std::string name; - - if (!context_->GetFileSystemRootPath(params.origin_url, - params.type, - &root_path, - &name)) { - Send(new ViewMsg_OpenFileSystemRequest_Complete( - params.routing_id, - params.request_id, - false, - string16(), - string16())); - return; - } - - // TODO(kinuko): creates the root directory and if it succeeds. + // TODO(kinuko): not implemented yet. Send(new ViewMsg_OpenFileSystemRequest_Complete( params.routing_id, params.request_id, - true, - UTF8ToUTF16(name), - webkit_glue::FilePathToWebString(root_path))); + false, + name, root_path)); } void FileSystemDispatcherHost::OnMove( int request_id, const string16& src_path, const string16& dest_path) { - if (!context_->CheckValidFileSystemPath( - webkit_glue::WebStringToFilePath(src_path)) || - !context_->CheckValidFileSystemPath( - webkit_glue::WebStringToFilePath(dest_path))) { - Send(new ViewMsg_FileSystem_Failed( - request_id, WebKit::WebFileErrorSecurity)); - return; - } - // TODO(kinuko): not implemented yet. Send(new ViewMsg_FileSystem_Failed( diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h index 0f8b63a..f756ebe 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.h +++ b/chrome/browser/file_system/file_system_dispatcher_host.h @@ -11,7 +11,6 @@ #include "base/ref_counted.h" #include "chrome/common/render_messages.h" -class FileSystemHostContext; class HostContentSettingsMap; class Receiver; class ResourceMessageFilter; @@ -20,7 +19,6 @@ class FileSystemDispatcherHost : public base::RefCountedThreadSafe<FileSystemDispatcherHost> { public: FileSystemDispatcherHost(IPC::Message::Sender* sender, - FileSystemHostContext* file_system_host_context, HostContentSettingsMap* host_content_settings_map); void Init(base::ProcessHandle process_handle); void Shutdown(); @@ -48,8 +46,6 @@ class FileSystemDispatcherHost bool shutdown_; - scoped_refptr<FileSystemHostContext> context_; - // Used to look up permissions. scoped_refptr<HostContentSettingsMap> host_content_settings_map_; }; diff --git a/chrome/browser/file_system/file_system_host_context.cc b/chrome/browser/file_system/file_system_host_context.cc deleted file mode 100644 index c14dfe1..0000000 --- a/chrome/browser/file_system/file_system_host_context.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2010 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/file_system/file_system_host_context.h" - -#include "base/file_util.h" -#include "base/logging.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/profile.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" -#include "third_party/WebKit/WebKit/chromium/public/WebCString.h" -#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" - -const FilePath::CharType FileSystemHostContext::kFileSystemDirectory[] = - FILE_PATH_LITERAL("FileSystem"); - -const char FileSystemHostContext::kPersistentName[] = "Persistent"; -const char FileSystemHostContext::kTemporaryName[] = "Temporary"; - -FileSystemHostContext::FileSystemHostContext( - const FilePath& data_path, bool is_incognito) - : base_path_(data_path.Append(kFileSystemDirectory)), - is_incognito_(is_incognito) { -} - -bool FileSystemHostContext::GetFileSystemRootPath( - const GURL& origin_url, WebKit::WebFileSystem::Type type, - FilePath* root_path, std::string* name) const { - // TODO(kinuko): should return an isolated temporary file system space. - if (is_incognito_) - return false; - std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); - switch (type) { - case WebKit::WebFileSystem::TypeTemporary: - if (root_path) - *root_path = base_path_.AppendASCII(storage_identifier) - .AppendASCII(kTemporaryName); - if (name) - *name = storage_identifier + ":" + kTemporaryName; - return true; - case WebKit::WebFileSystem::TypePersistent: - if (root_path) - *root_path = base_path_.AppendASCII(storage_identifier) - .AppendASCII(kPersistentName); - if (name) - *name = storage_identifier + ":" + kPersistentName; - return true; - } - LOG(WARNING) << "Unknown filesystem type is requested:" << type; - return false; -} - -bool FileSystemHostContext::CheckValidFileSystemPath( - const FilePath& path) const { - // Any paths that includes parent references are considered invalid. - return !path.ReferencesParent() && base_path_.IsParent(path); -} - -std::string FileSystemHostContext::GetStorageIdentifierFromURL( - const GURL& url) { - WebKit::WebSecurityOrigin web_security_origin = - WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); - return web_security_origin.databaseIdentifier().utf8(); -} diff --git a/chrome/browser/file_system/file_system_host_context.h b/chrome/browser/file_system/file_system_host_context.h deleted file mode 100644 index 592ccd6..0000000 --- a/chrome/browser/file_system/file_system_host_context.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2010 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_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_ -#define CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_ - -#include "base/file_path.h" -#include "base/ref_counted.h" -#include "base/scoped_ptr.h" -#include "googleurl/src/gurl.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" - -// This is owned by profile and shared by all the FileSystemDispatcherHost -// that shared by the same profile. -class FileSystemHostContext - : public base::RefCountedThreadSafe<FileSystemHostContext> { - public: - FileSystemHostContext(const FilePath& data_path, bool is_incognito); - const FilePath& base_path() const { return base_path_; } - bool is_incognito() const { return is_incognito_; } - - // Returns the root path and name for the file system specified by given - // |origin_url| and |type|. Returns true if the file system is available - // for the profile and |root_path| and |name| are filled successfully. - bool GetFileSystemRootPath( - const GURL& origin_url, - WebKit::WebFileSystem::Type type, - FilePath* root_path, - std::string* name) const; - - // Check if the given |path| is in the FileSystem base directory. - bool CheckValidFileSystemPath(const FilePath& path) const; - - // Returns the storage identifier string for the given |url|. - static std::string GetStorageIdentifierFromURL(const GURL& url); - - // The FileSystem directory name. - static const FilePath::CharType kFileSystemDirectory[]; - - static const char kPersistentName[]; - static const char kTemporaryName[]; - - private: - const FilePath base_path_; - const bool is_incognito_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemHostContext); -}; - -#endif // CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_ diff --git a/chrome/browser/file_system/file_system_host_context_unittest.cc b/chrome/browser/file_system/file_system_host_context_unittest.cc deleted file mode 100644 index 6bcda9d..0000000 --- a/chrome/browser/file_system/file_system_host_context_unittest.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2010 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/file_path.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/file_system/file_system_host_context.h" -#include "chrome/browser/file_system/file_system_host_context.h" -#include "googleurl/src/gurl.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" - -namespace { - -// PS stands for path separator. -#if defined(FILE_PATH_USES_WIN_SEPARATORS) -#define PS "\\" -#else -#define PS "/" -#endif - -const FilePath::CharType kTestDataPath[] = FILE_PATH_LITERAL( - "//tmp/TestingProfilePath"); - -const struct RootPathTest { - WebKit::WebFileSystem::Type type; - bool off_the_record; - const char* origin_url; - bool expect_root_path; - const char* expected_path; -} kRootPathTestCases[] = { - { WebKit::WebFileSystem::TypeTemporary, false, "http://host:1/", - true, "FileSystem" PS "http_host_1" PS "Temporary" }, - { WebKit::WebFileSystem::TypePersistent, false, "http://host:2/", - true, "FileSystem" PS "http_host_2" PS "Persistent" }, - { WebKit::WebFileSystem::TypeTemporary, true, "http://host:3/", - false, "" }, - { WebKit::WebFileSystem::TypePersistent, true, "http://host:4/", - false, "" }, -}; - -const struct CheckValidPathTest { - FilePath::StringType path; - bool expected_valid; -} kCheckValidPathTestCases[] = { - { FILE_PATH_LITERAL("//tmp/foo.txt"), false, }, - { FILE_PATH_LITERAL("//etc/hosts"), false, }, - { FILE_PATH_LITERAL("foo.txt"), true, }, - { FILE_PATH_LITERAL("a/b/c"), true, }, - // Any paths that includes parent references are considered invalid. - { FILE_PATH_LITERAL(".."), false, }, - { FILE_PATH_LITERAL("tmp/.."), false, }, - { FILE_PATH_LITERAL("a/b/../c/.."), false, }, -}; - -} // namespace - -TEST(FileSystemHostContextTest, GetRootPath) { - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { - SCOPED_TRACE(testing::Message() << "RootPath #" << i << " " - << kRootPathTestCases[i].expected_path); - - scoped_refptr<FileSystemHostContext> context( - new FileSystemHostContext(FilePath(kTestDataPath), - kRootPathTestCases[i].off_the_record)); - - FilePath root_path; - bool result = context->GetFileSystemRootPath( - GURL(kRootPathTestCases[i].origin_url), - kRootPathTestCases[i].type, - &root_path, NULL); - EXPECT_EQ(kRootPathTestCases[i].expect_root_path, result); - if (result) { - FilePath expected = FilePath(kTestDataPath).AppendASCII( - kRootPathTestCases[i].expected_path); - EXPECT_EQ(expected.value(), root_path.value()); - } - } -} - -TEST(FileSystemHostContextTest, CheckValidPath) { - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kCheckValidPathTestCases); ++i) { - SCOPED_TRACE(testing::Message() << "CheckValidPath #" << i << " " - << kCheckValidPathTestCases[i].path); - - scoped_refptr<FileSystemHostContext> context( - new FileSystemHostContext(FilePath(kTestDataPath), false)); - - FilePath root_path; - EXPECT_TRUE(context->GetFileSystemRootPath( - GURL("http://foo.com/"), WebKit::WebFileSystem::TypePersistent, - &root_path, NULL)); - FilePath path(kCheckValidPathTestCases[i].path); - if (!path.IsAbsolute()) - path = root_path.Append(path); - - EXPECT_EQ(kCheckValidPathTestCases[i].expected_valid, - context->CheckValidFileSystemPath(path)); - } -} diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 2f1641e..7b9e0fd 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -17,7 +17,6 @@ #include "chrome/browser/chrome_blob_storage_context.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/download/download_manager.h" -#include "chrome/browser/file_system/file_system_host_context.h" #include "chrome/browser/find_bar_state.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/net/chrome_url_request_context.h" @@ -315,14 +314,6 @@ class OffTheRecordProfileImpl : public Profile, return NULL; } - virtual FileSystemHostContext* GetFileSystemHostContext() { - if (!file_system_host_context_) - file_system_host_context_ = new FileSystemHostContext( - GetPath(), IsOffTheRecord()); - DCHECK(file_system_host_context_.get()); - return file_system_host_context_.get(); - } - virtual void InitThemes() { profile_->InitThemes(); } @@ -590,9 +581,6 @@ class OffTheRecordProfileImpl : public Profile, scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; - // The file_system context for this profile. - scoped_refptr<FileSystemHostContext> file_system_host_context_; - DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); }; diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index d876d8c..4dc3f5b 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -51,7 +51,6 @@ class ExtensionMessageService; class ExtensionsService; class FaviconService; class FilePath; -class FileSystemHostContext; class FindBarState; class GeolocationContentSettingsMap; class GeolocationPermissionContext; @@ -278,9 +277,6 @@ class Profile { // Returns the PersonalDataManager associated with this profile. virtual PersonalDataManager* GetPersonalDataManager() = 0; - // Returns the HTML5 FileSystemHostContext assigned to this profile. - virtual FileSystemHostContext* GetFileSystemHostContext() = 0; - // Init our themes system. virtual void InitThemes() = 0; diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index 0f8d997..650b956 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -32,7 +32,6 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/favicon_service.h" -#include "chrome/browser/file_system/file_system_host_context.h" #include "chrome/browser/find_bar_state.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" @@ -980,14 +979,6 @@ PersonalDataManager* ProfileImpl::GetPersonalDataManager() { return personal_data_manager_.get(); } -FileSystemHostContext* ProfileImpl::GetFileSystemHostContext() { - if (!file_system_host_context_.get()) - file_system_host_context_ = new FileSystemHostContext( - GetPath(), IsOffTheRecord()); - DCHECK(file_system_host_context_.get()); - return file_system_host_context_.get(); -} - void ProfileImpl::InitThemes() { if (!created_theme_provider_) { #if defined(TOOLKIT_USES_GTK) diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h index d3831cb..83815e6 100644 --- a/chrome/browser/profile_impl.h +++ b/chrome/browser/profile_impl.h @@ -59,7 +59,6 @@ class ProfileImpl : public Profile, virtual TemplateURLFetcher* GetTemplateURLFetcher(); virtual DownloadManager* GetDownloadManager(); virtual PersonalDataManager* GetPersonalDataManager(); - virtual FileSystemHostContext* GetFileSystemHostContext(); virtual void InitThemes(); virtual void SetTheme(Extension* extension); virtual void SetNativeTheme(); @@ -197,7 +196,6 @@ class ProfileImpl : public Profile, scoped_ptr<StatusTray> status_tray_; scoped_refptr<PersonalDataManager> personal_data_manager_; scoped_ptr<PinnedTabService> pinned_tab_service_; - scoped_refptr<FileSystemHostContext> file_system_host_context_; bool history_service_created_; bool favicon_service_created_; bool created_web_data_service_; diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 816d1fb..db9e6e4 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -31,7 +31,6 @@ #include "chrome/browser/download/download_file.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/file_system/file_system_dispatcher_host.h" -#include "chrome/browser/file_system/file_system_host_context.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" #include "chrome/browser/geolocation/geolocation_dispatcher_host.h" #include "chrome/browser/gpu_process_host.h" @@ -255,12 +254,11 @@ ResourceMessageFilter::ResourceMessageFilter( new SearchProviderInstallStateDispatcherHost(this, profile))), ALLOW_THIS_IN_INITIALIZER_LIST(device_orientation_dispatcher_host_( new device_orientation::DispatcherHost(this->id()))), - ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_( - new BlobDispatcherHost(profile->GetBlobStorageContext()))), ALLOW_THIS_IN_INITIALIZER_LIST(file_system_dispatcher_host_( new FileSystemDispatcherHost(this, - profile->GetFileSystemHostContext(), - profile->GetHostContentSettingsMap()))) { + profile->GetHostContentSettingsMap()))), + ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_( + new BlobDispatcherHost(profile->GetBlobStorageContext()))) { request_context_ = profile_->GetRequestContext(); DCHECK(request_context_); DCHECK(media_request_context_); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 1a1bd2d..338f9d9 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1497,8 +1497,6 @@ 'browser/file_path_watcher_win.cc', 'browser/file_system/file_system_dispatcher_host.cc', 'browser/file_system/file_system_dispatcher_host.h', - 'browser/file_system/file_system_host_context.cc', - 'browser/file_system/file_system_host_context.h', 'browser/find_bar.h', 'browser/find_bar_controller.cc', 'browser/find_bar_controller.h', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index cff0ea7..5fb20c2 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1068,7 +1068,6 @@ 'browser/extensions/user_script_listener_unittest.cc', 'browser/extensions/user_script_master_unittest.cc', 'browser/file_path_watcher_unittest.cc', - 'browser/file_system/file_system_host_context_unittest.cc', 'browser/find_backend_unittest.cc', 'browser/first_run/first_run_unittest.cc', 'browser/geolocation/fake_access_token_store.h', diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 6399692..a080bd5 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -156,7 +156,6 @@ class TestingProfile : public Profile { virtual history::TopSites* GetTopSites(); virtual DownloadManager* GetDownloadManager() { return NULL; } virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } - virtual FileSystemHostContext* GetFileSystemHostContext() { return NULL; } virtual bool HasCreatedDownloadManager() const { return false; } virtual void InitThemes(); virtual void SetTheme(Extension* extension) {} |