summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc56
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h4
-rw-r--r--chrome/common/render_messages_internal.h7
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc76
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h19
-rw-r--r--net/base/file_stream.h3
-rw-r--r--net/base/file_stream_posix.cc6
-rw-r--r--net/base/file_stream_win.cc9
-rw-r--r--webkit/glue/webfilesystem_impl.cc154
-rw-r--r--webkit/glue/webfilesystem_impl.h54
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/glue/webkitclient_impl.cc67
-rw-r--r--webkit/glue/webkitclient_impl.h14
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h25
14 files changed, 368 insertions, 128 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index b5d399d..3e26653 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -58,6 +58,7 @@
#include "chrome/common/worker_messages.h"
#include "gfx/native_widget_types.h"
#include "net/base/cookie_monster.h"
+#include "net/base/file_stream.h"
#include "net/base/keygen_handler.h"
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
@@ -537,6 +538,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime,
OnGetFileModificationTime)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile)
IPC_MESSAGE_HANDLER(ViewHostMsg_Keygen, OnKeygen)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle,
OnGetExtensionMessageBundle)
@@ -1385,6 +1387,60 @@ void ResourceMessageFilter::OnGetFileInfoOnFileThread(
NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg));
}
+void ResourceMessageFilter::OnOpenFile(const FilePath& path,
+ int mode,
+ IPC::Message* reply_msg) {
+ // Open the file only when the child process has been granted permission to
+ // upload the file.
+ // TODO(jianli): Do we need separate permission to control opening the file?
+ if (!ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) {
+ ViewHostMsg_OpenFile::WriteReplyParams(
+ reply_msg, base::kInvalidPlatformFileValue);
+ Send(reply_msg);
+ return;
+ }
+
+ // Opening the file could take a long time if it lives on a network share,
+ // so run it on the FILE thread.
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::OnOpenFileOnFileThread,
+ path, mode, reply_msg));
+}
+
+void ResourceMessageFilter::OnOpenFileOnFileThread(const FilePath& path,
+ int mode,
+ IPC::Message* reply_msg) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
+
+ base::PlatformFile file_handle = base::CreatePlatformFile(
+ path,
+ (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
+ : (base::PLATFORM_FILE_CREATE_ALWAYS |
+ base::PLATFORM_FILE_WRITE),
+ NULL);
+
+ base::PlatformFile target_file_handle;
+#if defined(OS_WIN)
+ // Duplicate the file handle so that the renderer process can access the file.
+ if (!DuplicateHandle(GetCurrentProcess(), file_handle,
+ handle(), &target_file_handle, 0, false,
+ DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
+ // file_handle is closed whether or not DuplicateHandle succeeds.
+ target_file_handle = INVALID_HANDLE_VALUE;
+ }
+#else
+ target_file_handle = file_handle;
+#endif
+
+ ViewHostMsg_OpenFile::WriteReplyParams(reply_msg, target_file_handle);
+
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg));
+}
+
void ResourceMessageFilter::OnKeygen(uint32 key_size_index,
const std::string& challenge_string,
const GURL& url,
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 4a3f544..441e8f2 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -321,6 +321,10 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnGetFileInfoOnFileThread(const FilePath& path,
IPC::Message* reply_msg,
FileInfoWriteFunc write_func);
+ void OnOpenFile(const FilePath& path, int mode,IPC::Message* reply_msg);
+ void OnOpenFileOnFileThread(const FilePath& path,
+ int mode,
+ IPC::Message* reply_msg);
void OnKeygen(uint32 key_size_index, const std::string& challenge_string,
const GURL& url, std::string* signed_public_key);
void OnGetExtensionMessageBundle(const std::string& extension_id,
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index a34991c..e5bbf5e 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -14,6 +14,7 @@
#include "base/file_path.h"
#include "base/nullable_string16.h"
+#include "base/platform_file.h"
#include "base/sync_socket.h"
#include "base/time.h"
#include "base/values.h"
@@ -2129,6 +2130,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
FilePath /* path */,
base::Time /* result */)
+ // Open the file.
+ IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_OpenFile,
+ FilePath /* path */,
+ int /* mode */,
+ base::PlatformFile /* result */)
+
// Sent by the renderer process to acknowledge receipt of a
// ViewMsg_CSSInsertRequest message and css has been inserted into the frame.
IPC_MESSAGE_ROUTED0(ViewHostMsg_OnCSSInserted)
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index e8f4214..b9c1dd6 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -25,6 +25,7 @@
#include "chrome/renderer/visitedlink_slave.h"
#include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h"
#include "googleurl/src/gurl.h"
+#include "ipc/ipc_sync_message_filter.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
@@ -60,6 +61,10 @@ WebKit::WebMimeRegistry* RendererWebKitClientImpl::mimeRegistry() {
return &mime_registry_;
}
+WebKit::WebFileSystem* RendererWebKitClientImpl::fileSystem() {
+ return &file_system_;
+}
+
WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() {
#if defined(OS_WIN) || defined(OS_LINUX)
return &sandbox_support_;
@@ -84,31 +89,15 @@ bool RendererWebKitClientImpl::sandboxEnabled() {
return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
}
-bool RendererWebKitClientImpl::getFileSize(const WebString& path,
- long long& result) {
- if (RenderThread::current()->Send(
- new ViewHostMsg_GetFileSize(webkit_glue::WebStringToFilePath(path),
- reinterpret_cast<int64*>(&result)))) {
- return result >= 0;
- }
-
- result = -1;
- return false;
-}
-
-bool RendererWebKitClientImpl::getFileModificationTime(
- const WebKit::WebString& path,
- double& result) {
- base::Time time;
- if (RenderThread::current()->Send(
- new ViewHostMsg_GetFileModificationTime(
- webkit_glue::WebStringToFilePath(path), &time))) {
- result = time.ToDoubleT();
- return true;
- }
+bool RendererWebKitClientImpl::SendSyncMessageFromAnyThread(
+ IPC::SyncMessage* msg) {
+ RenderThread* render_thread = RenderThread::current();
+ if (render_thread)
+ return render_thread->Send(msg);
- result = 0;
- return false;
+ scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter =
+ ChildThread::current()->sync_message_filter();
+ return sync_msg_filter->Send(msg);
}
unsigned long long RendererWebKitClientImpl::visitedLinkHash(
@@ -225,6 +214,45 @@ WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType(
//------------------------------------------------------------------------------
+bool RendererWebKitClientImpl::FileSystem::getFileSize(const WebString& path,
+ long long& result) {
+ if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileSize(
+ webkit_glue::WebStringToFilePath(path),
+ reinterpret_cast<int64*>(&result)))) {
+ return result >= 0;
+ }
+
+ result = -1;
+ return false;
+}
+
+bool RendererWebKitClientImpl::FileSystem::getFileModificationTime(
+ const WebString& path,
+ double& result) {
+ base::Time time;
+ if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileModificationTime(
+ webkit_glue::WebStringToFilePath(path), &time))) {
+ result = time.ToDoubleT();
+ return !time.is_null();
+ }
+
+ result = 0;
+ return false;
+}
+
+base::PlatformFile RendererWebKitClientImpl::FileSystem::openFile(
+ const WebString& path,
+ int mode) {
+ base::PlatformFile handle;
+ if (!SendSyncMessageFromAnyThread(new ViewHostMsg_OpenFile(
+ webkit_glue::WebStringToFilePath(path), mode, &handle))) {
+ handle = base::kInvalidPlatformFileValue;
+ }
+ return handle;
+}
+
+//------------------------------------------------------------------------------
+
#if defined(OS_WIN)
bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 3606eaa..7d90520 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -9,6 +9,7 @@
#include "chrome/renderer/websharedworkerrepository_impl.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webclipboard_impl.h"
+#include "webkit/glue/webfilesystem_impl.h"
#include "webkit/glue/webkitclient_impl.h"
#if defined(OS_WIN)
@@ -31,12 +32,10 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
// WebKitClient methods:
virtual WebKit::WebClipboard* clipboard();
virtual WebKit::WebMimeRegistry* mimeRegistry();
+ virtual WebKit::WebFileSystem* fileSystem();
virtual WebKit::WebSandboxSupport* sandboxSupport();
virtual WebKit::WebCookieJar* cookieJar();
virtual bool sandboxEnabled();
- virtual bool getFileSize(const WebKit::WebString& path, long long& result);
- virtual bool getFileModificationTime(const WebKit::WebString& path,
- double& result);
virtual unsigned long long visitedLinkHash(
const char* canonicalURL, size_t length);
virtual bool isLinkVisited(unsigned long long linkHash);
@@ -76,6 +75,15 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
const WebKit::WebString&);
};
+ class FileSystem : public webkit_glue::WebFileSystemImpl {
+ public:
+ virtual bool getFileSize(const WebKit::WebString& path, long long& result);
+ virtual bool getFileModificationTime(const WebKit::WebString& path,
+ double& result);
+ virtual base::PlatformFile openFile(const WebKit::WebString& path,
+ int mode);
+ };
+
#if defined(OS_WIN)
class SandboxSupport : public WebKit::WebSandboxSupport {
public:
@@ -99,8 +107,13 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
};
#endif
+ // Helper function to send synchronous message from any thread.
+ static bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg);
+
webkit_glue::WebClipboardImpl clipboard_;
+ FileSystem file_system_;
+
MimeRegistry mime_registry_;
#if defined(OS_WIN) || defined(OS_LINUX)
SandboxSupport sandbox_support_;
diff --git a/net/base/file_stream.h b/net/base/file_stream.h
index 6b7f3dc..ff9e7a6 100644
--- a/net/base/file_stream.h
+++ b/net/base/file_stream.h
@@ -34,6 +34,8 @@ class FileStream {
// |file| is valid file handle.
// |flags| is a bitfield of base::PlatformFileFlags when the file handle was
// opened.
+ // The already opened file will not be automatically closed when FileStream
+ // is destructed.
FileStream(base::PlatformFile file, int flags);
~FileStream();
@@ -128,6 +130,7 @@ class FileStream {
base::PlatformFile file_;
int open_flags_;
+ bool auto_closed_;
DISALLOW_COPY_AND_ASSIGN(FileStream);
};
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc
index a4c5b3c..65c8e2b 100644
--- a/net/base/file_stream_posix.cc
+++ b/net/base/file_stream_posix.cc
@@ -293,13 +293,15 @@ void FileStream::AsyncContext::RunAsynchronousCallback() {
FileStream::FileStream()
: file_(base::kInvalidPlatformFileValue),
- open_flags_(0) {
+ open_flags_(0),
+ auto_closed_(true) {
DCHECK(!IsOpen());
}
FileStream::FileStream(base::PlatformFile file, int flags)
: file_(file),
- open_flags_(flags) {
+ open_flags_(flags),
+ auto_closed_(false) {
// If the file handle is opened with base::PLATFORM_FILE_ASYNC, we need to
// make sure we will perform asynchronous File IO to it.
if (flags & base::PLATFORM_FILE_ASYNC) {
diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc
index cec6a9d..1ad9a34 100644
--- a/net/base/file_stream_win.cc
+++ b/net/base/file_stream_win.cc
@@ -117,12 +117,14 @@ void FileStream::AsyncContext::OnIOCompleted(
FileStream::FileStream()
: file_(INVALID_HANDLE_VALUE),
- open_flags_(0) {
+ open_flags_(0),
+ auto_closed_(true) {
}
FileStream::FileStream(base::PlatformFile file, int flags)
: file_(file),
- open_flags_(flags) {
+ open_flags_(flags),
+ auto_closed_(false) {
// If the file handle is opened with base::PLATFORM_FILE_ASYNC, we need to
// make sure we will perform asynchronous File IO to it.
if (flags & base::PLATFORM_FILE_ASYNC) {
@@ -133,7 +135,8 @@ FileStream::FileStream(base::PlatformFile file, int flags)
}
FileStream::~FileStream() {
- Close();
+ if (auto_closed_)
+ Close();
}
void FileStream::Close() {
diff --git a/webkit/glue/webfilesystem_impl.cc b/webkit/glue/webfilesystem_impl.cc
new file mode 100644
index 0000000..0573045
--- /dev/null
+++ b/webkit/glue/webfilesystem_impl.cc
@@ -0,0 +1,154 @@
+// 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 "webkit/glue/webfilesystem_impl.h"
+
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "net/base/file_stream.h"
+#include "net/base/net_util.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "webkit/glue/webkit_glue.h"
+
+using WebKit::WebString;
+
+namespace webkit_glue {
+
+WebFileSystemImpl::WebFileSystemImpl()
+ : sandbox_enabled_(true) {
+}
+
+bool WebFileSystemImpl::fileExists(const WebString& path) {
+ FilePath::StringType file_path = WebStringToFilePathString(path);
+ return file_util::PathExists(FilePath(file_path));
+}
+
+bool WebFileSystemImpl::deleteFile(const WebString& path) {
+ NOTREACHED();
+ return false;
+}
+
+bool WebFileSystemImpl::deleteEmptyDirectory(const WebString& path) {
+ NOTREACHED();
+ return false;
+}
+
+bool WebFileSystemImpl::getFileSize(const WebString& path, long long& result) {
+ if (sandbox_enabled_) {
+ NOTREACHED();
+ return false;
+ }
+ return file_util::GetFileSize(WebStringToFilePath(path),
+ reinterpret_cast<int64*>(&result));
+}
+
+bool WebFileSystemImpl::getFileModificationTime(const WebString& path,
+ double& result) {
+ if (sandbox_enabled_) {
+ NOTREACHED();
+ return false;
+ }
+ file_util::FileInfo info;
+ if (!file_util::GetFileInfo(WebStringToFilePath(path), &info))
+ return false;
+ result = info.last_modified.ToDoubleT();
+ return true;
+}
+
+WebString WebFileSystemImpl::directoryName(const WebString& path) {
+ NOTREACHED();
+ return WebString();
+}
+
+WebString WebFileSystemImpl::pathByAppendingComponent(
+ const WebString& webkit_path,
+ const WebString& webkit_component) {
+ FilePath path(WebStringToFilePathString(webkit_path));
+ FilePath component(WebStringToFilePathString(webkit_component));
+ FilePath combined_path = path.Append(component);
+ return FilePathStringToWebString(combined_path.value());
+}
+
+bool WebFileSystemImpl::makeAllDirectories(const WebString& path) {
+ DCHECK(!sandbox_enabled_);
+ FilePath::StringType file_path = WebStringToFilePathString(path);
+ return file_util::CreateDirectory(FilePath(file_path));
+}
+
+WebString WebFileSystemImpl::getAbsolutePath(const WebString& path) {
+ FilePath file_path(WebStringToFilePathString(path));
+ file_util::AbsolutePath(&file_path);
+ return FilePathStringToWebString(file_path.value());
+}
+
+bool WebFileSystemImpl::isDirectory(const WebString& path) {
+ FilePath file_path(WebStringToFilePathString(path));
+ return file_util::DirectoryExists(file_path);
+}
+
+WebKit::WebURL WebFileSystemImpl::filePathToURL(const WebString& path) {
+ return net::FilePathToFileURL(WebStringToFilePath(path));
+}
+
+base::PlatformFile WebFileSystemImpl::openFile(const WebString& path,
+ int mode) {
+ if (sandbox_enabled_) {
+ NOTREACHED();
+ return base::kInvalidPlatformFileValue;
+ }
+ return base::CreatePlatformFile(
+ WebStringToFilePath(path),
+ (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
+ : (base::PLATFORM_FILE_CREATE_ALWAYS |
+ base::PLATFORM_FILE_WRITE),
+ NULL);
+}
+
+void WebFileSystemImpl::closeFile(base::PlatformFile& handle) {
+ if (handle == base::kInvalidPlatformFileValue)
+ return;
+ if (base::ClosePlatformFile(handle))
+ handle = base::kInvalidPlatformFileValue;
+}
+
+long long WebFileSystemImpl::seekFile(base::PlatformFile handle,
+ long long offset,
+ int origin) {
+ if (handle == base::kInvalidPlatformFileValue)
+ return -1;
+ net::FileStream file_stream(handle, 0);
+ return file_stream.Seek(static_cast<net::Whence>(origin), offset);
+}
+
+bool WebFileSystemImpl::truncateFile(base::PlatformFile handle,
+ long long offset) {
+ if (handle == base::kInvalidPlatformFileValue || offset < 0)
+ return false;
+ net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE);
+ return file_stream.Truncate(offset) >= 0;
+}
+
+int WebFileSystemImpl::readFromFile(base::PlatformFile handle,
+ char* data,
+ int length) {
+ if (handle == base::kInvalidPlatformFileValue || !data || length <= 0)
+ return -1;
+ std::string buffer;
+ buffer.resize(length);
+ net::FileStream file_stream(handle, base::PLATFORM_FILE_READ);
+ return file_stream.Read(data, length, NULL);
+}
+
+int WebFileSystemImpl::writeToFile(base::PlatformFile handle,
+ const char* data,
+ int length) {
+ if (handle == base::kInvalidPlatformFileValue || !data || length <= 0)
+ return -1;
+ net::FileStream file_stream(handle, base::PLATFORM_FILE_WRITE);
+ return file_stream.Write(data, length, NULL);
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/webfilesystem_impl.h b/webkit/glue/webfilesystem_impl.h
new file mode 100644
index 0000000..875a13b
--- /dev/null
+++ b/webkit/glue/webfilesystem_impl.h
@@ -0,0 +1,54 @@
+// 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 WEBFILESYSTEM_IMPL_H_
+#define WEBFILESYSTEM_IMPL_H_
+
+#include "base/platform_file.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
+
+namespace webkit_glue {
+
+class WebFileSystemImpl : public WebKit::WebFileSystem {
+ public:
+ WebFileSystemImpl();
+ virtual ~WebFileSystemImpl() { }
+
+ // WebFileSystem methods:
+ virtual bool fileExists(const WebKit::WebString& path);
+ virtual bool deleteFile(const WebKit::WebString& path);
+ virtual bool deleteEmptyDirectory(const WebKit::WebString& path);
+ virtual bool getFileSize(const WebKit::WebString& path, long long& result);
+ virtual bool getFileModificationTime(
+ const WebKit::WebString& path,
+ double& result);
+ virtual WebKit::WebString directoryName(const WebKit::WebString& path);
+ virtual WebKit::WebString pathByAppendingComponent(
+ const WebKit::WebString& path, const WebKit::WebString& component);
+ virtual bool makeAllDirectories(const WebKit::WebString& path);
+ virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path);
+ virtual bool isDirectory(const WebKit::WebString& path);
+ virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path);
+ virtual base::PlatformFile openFile(const WebKit::WebString& path, int mode);
+ virtual void closeFile(base::PlatformFile& handle);
+ virtual long long seekFile(base::PlatformFile handle,
+ long long offset,
+ int origin);
+ virtual bool truncateFile(base::PlatformFile handle, long long offset);
+ virtual int readFromFile(base::PlatformFile handle, char* data, int length);
+ virtual int writeToFile(base::PlatformFile handle,
+ const char* data,
+ int length);
+
+ void set_sandbox_enabled(bool sandbox_enabled) {
+ sandbox_enabled_ = sandbox_enabled;
+ }
+
+ protected:
+ bool sandbox_enabled_;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBFILESYSTEM_IMPL_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 1f5e950..aec0904 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -254,6 +254,8 @@
'webdropdata.cc',
'webdropdata_win.cc',
'webdropdata.h',
+ 'webfilesystem_impl.cc',
+ 'webfilesystem_impl.h',
'webkit_glue.cc',
'webkit_glue.h',
'webkitclient_impl.cc',
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index bedae2d..a065ad8 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -12,8 +12,6 @@
#include <vector>
-#include "base/file_path.h"
-#include "base/file_util.h"
#include "base/lock.h"
#include "base/message_loop.h"
#include "base/process_util.h"
@@ -25,7 +23,6 @@
#include "base/trace_event.h"
#include "grit/webkit_resources.h"
#include "grit/webkit_strings.h"
-#include "net/base/net_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCookie.h"
#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h"
@@ -425,70 +422,6 @@ size_t WebKitClientImpl::memoryUsageMB() {
return current_mem_usage;
}
-bool WebKitClientImpl::fileExists(const WebKit::WebString& path) {
- FilePath::StringType file_path = webkit_glue::WebStringToFilePathString(path);
- return file_util::PathExists(FilePath(file_path));
-}
-
-bool WebKitClientImpl::deleteFile(const WebKit::WebString& path) {
- NOTREACHED();
- return false;
-}
-
-bool WebKitClientImpl::deleteEmptyDirectory(const WebKit::WebString& path) {
- NOTREACHED();
- return false;
-}
-
-bool WebKitClientImpl::getFileSize(const WebKit::WebString& path,
- long long& result) {
- NOTREACHED();
- return false;
-}
-
-bool WebKitClientImpl::getFileModificationTime(const WebKit::WebString& path,
- double& result) {
- NOTREACHED();
- return false;
-}
-
-WebKit::WebString WebKitClientImpl::directoryName(
- const WebKit::WebString& path) {
- NOTREACHED();
- return WebKit::WebString();
-}
-
-WebKit::WebString WebKitClientImpl::pathByAppendingComponent(
- const WebKit::WebString& webkit_path,
- const WebKit::WebString& webkit_component) {
- FilePath path(webkit_glue::WebStringToFilePathString(webkit_path));
- FilePath component(webkit_glue::WebStringToFilePathString(webkit_component));
- FilePath combined_path = path.Append(component);
- return webkit_glue::FilePathStringToWebString(combined_path.value());
-}
-
-bool WebKitClientImpl::makeAllDirectories(const WebKit::WebString& path) {
- DCHECK(!sandboxEnabled());
- FilePath::StringType file_path = webkit_glue::WebStringToFilePathString(path);
- return file_util::CreateDirectory(FilePath(file_path));
-}
-
-WebKit::WebString WebKitClientImpl::getAbsolutePath(
- const WebKit::WebString& path) {
- FilePath file_path(webkit_glue::WebStringToFilePathString(path));
- file_util::AbsolutePath(&file_path);
- return webkit_glue::FilePathStringToWebString(file_path.value());
-}
-
-bool WebKitClientImpl::isDirectory(const WebKit::WebString& path) {
- FilePath file_path(webkit_glue::WebStringToFilePathString(path));
- return file_util::DirectoryExists(file_path);
-}
-
-WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) {
- return net::FilePathToFileURL(webkit_glue::WebStringToFilePath(path));
-}
-
void WebKitClientImpl::SuspendSharedTimer() {
++shared_timer_suspended_;
}
diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h
index a6bdad5..6b8e345 100644
--- a/webkit/glue/webkitclient_impl.h
+++ b/webkit/glue/webkitclient_impl.h
@@ -23,20 +23,6 @@ class WebKitClientImpl : public WebKit::WebKitClient {
// WebKitClient methods (partial implementation):
virtual WebKit::WebThemeEngine* themeEngine();
- virtual bool fileExists(const WebKit::WebString& path);
- virtual bool deleteFile(const WebKit::WebString& path);
- virtual bool deleteEmptyDirectory(const WebKit::WebString& path);
- virtual bool getFileSize(const WebKit::WebString& path, long long& result);
- virtual bool getFileModificationTime(
- const WebKit::WebString& path,
- double& result);
- virtual WebKit::WebString directoryName(const WebKit::WebString& path);
- virtual WebKit::WebString pathByAppendingComponent(
- const WebKit::WebString& path, const WebKit::WebString& component);
- virtual bool makeAllDirectories(const WebKit::WebString& path);
- virtual WebKit::WebString getAbsolutePath(const WebKit::WebString& path);
- virtual bool isDirectory(const WebKit::WebString& path);
- virtual WebKit::WebURL filePathToURL(const WebKit::WebString& path);
virtual base::PlatformFile databaseOpenFile(
const WebKit::WebString& vfs_file_name,
int desired_flags,
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index bf0a8ad..c4e79b4 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -7,10 +7,12 @@
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "base/stats_counters.h"
#include "base/string_util.h"
#include "media/base/media.h"
+#include "net/base/file_stream.h"
#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h"
@@ -28,6 +30,7 @@
#include "webkit/extensions/v8/gears_extension.h"
#include "webkit/extensions/v8/interval_extension.h"
#include "webkit/glue/webclipboard_impl.h"
+#include "webkit/glue/webfilesystem_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h"
#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
@@ -88,6 +91,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
WebKit::WebDatabase::setObserver(&database_system_);
+ file_system_.set_sandbox_enabled(false);
+
#if defined(OS_WIN)
// Ensure we pick up the default theme engine.
SetThemeEngine(NULL);
@@ -112,6 +117,10 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
}
}
+ virtual WebKit::WebFileSystem* fileSystem() {
+ return &file_system_;
+ }
+
virtual WebKit::WebSandboxSupport* sandboxSupport() {
return NULL;
}
@@ -148,21 +157,6 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name);
}
- virtual bool getFileSize(const WebKit::WebString& path, long long& result) {
- return file_util::GetFileSize(
- webkit_glue::WebStringToFilePath(path),
- reinterpret_cast<int64*>(&result));
- }
-
- virtual bool getFileModificationTime(const WebKit::WebString& path,
- double& result) {
- file_util::FileInfo info;
- if (!file_util::GetFileInfo(webkit_glue::WebStringToFilePath(path), &info))
- return false;
- result = info.last_modified.ToDoubleT();
- return true;
- }
-
virtual unsigned long long visitedLinkHash(const char* canonicalURL,
size_t length) {
return 0;
@@ -238,6 +232,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
TestShellWebMimeRegistryImpl mime_registry_;
MockWebClipboardImpl mock_clipboard_;
webkit_glue::WebClipboardImpl real_clipboard_;
+ webkit_glue::WebFileSystemImpl file_system_;
ScopedTempDir appcache_dir_;
SimpleAppCacheSystem appcache_system_;
SimpleDatabaseSystem database_system_;