summaryrefslogtreecommitdiffstats
path: root/chrome/browser/file_system
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 19:40:23 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 19:40:23 +0000
commite5c621f13ac46ba5d45bf5a308edd3bd19b79a44 (patch)
tree52f9b98d511fca2ea6ae1591fb64b306bc765a10 /chrome/browser/file_system
parent420286748888437c755272ffe98fd27a16099194 (diff)
downloadchromium_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/browser/file_system')
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.cc40
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.h4
-rw-r--r--chrome/browser/file_system/file_system_host_context.cc65
-rw-r--r--chrome/browser/file_system/file_system_host_context.h51
-rw-r--r--chrome/browser/file_system/file_system_host_context_unittest.cc101
5 files changed, 5 insertions, 256 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));
- }
-}