summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 01:33:34 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-18 01:33:34 +0000
commitacb94729d3aa35ec833c922ade31340229770d60 (patch)
tree7c26a239c8b9e09b78f809a308e081329625c8b2 /content
parent4874aae4718d407f7f4de1b71f0c02b9a2065474 (diff)
downloadchromium_src-acb94729d3aa35ec833c922ade31340229770d60.zip
chromium_src-acb94729d3aa35ec833c922ade31340229770d60.tar.gz
chromium_src-acb94729d3aa35ec833c922ade31340229770d60.tar.bz2
Move the renderer_web* files to content.
TBR=avi Review URL: http://codereview.chromium.org/6713024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/child_process_launcher.cc2
-rw-r--r--content/browser/zygote_main_linux.cc2
-rw-r--r--content/common/chrome_descriptors.h18
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/content_renderer.gypi26
-rw-r--r--content/renderer/indexed_db_dispatcher.cc10
-rw-r--r--content/renderer/renderer_sandbox_support_linux.cc189
-rw-r--r--content/renderer/renderer_sandbox_support_linux.h59
-rw-r--r--content/renderer/renderer_webapplicationcachehost_impl.cc58
-rw-r--r--content/renderer/renderer_webapplicationcachehost_impl.h34
-rw-r--r--content/renderer/renderer_webaudiodevice_impl.cc41
-rw-r--r--content/renderer/renderer_webaudiodevice_impl.h41
-rw-r--r--content/renderer/renderer_webcookiejar_impl.cc79
-rw-r--r--content/renderer/renderer_webcookiejar_impl.h45
-rw-r--r--content/renderer/renderer_webidbcursor_impl.cc87
-rw-r--r--content/renderer/renderer_webidbcursor_impl.h39
-rw-r--r--content/renderer/renderer_webidbdatabase_impl.cc135
-rw-r--r--content/renderer/renderer_webidbdatabase_impl.h53
-rw-r--r--content/renderer/renderer_webidbfactory_impl.cc54
-rw-r--r--content/renderer/renderer_webidbfactory_impl.h43
-rw-r--r--content/renderer/renderer_webidbindex_impl.cc104
-rw-r--r--content/renderer/renderer_webidbindex_impl.h47
-rw-r--r--content/renderer/renderer_webidbobjectstore_impl.cc171
-rw-r--r--content/renderer/renderer_webidbobjectstore_impl.h72
-rw-r--r--content/renderer/renderer_webidbtransaction_impl.cc74
-rw-r--r--content/renderer/renderer_webidbtransaction_impl.h36
-rw-r--r--content/renderer/renderer_webkitclient_impl.cc571
-rw-r--r--content/renderer/renderer_webkitclient_impl.h117
-rw-r--r--content/renderer/renderer_webstoragearea_impl.cc83
-rw-r--r--content/renderer/renderer_webstoragearea_impl.h37
-rw-r--r--content/renderer/renderer_webstoragenamespace_impl.cc52
-rw-r--r--content/renderer/renderer_webstoragenamespace_impl.h34
32 files changed, 2407 insertions, 7 deletions
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 0cf79c2f..1b65c72 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -11,9 +11,9 @@
#include "base/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
-#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/browser_thread.h"
+#include "content/common/chrome_descriptors.h"
#include "content/common/process_watcher.h"
#include "content/common/result_codes.h"
diff --git a/content/browser/zygote_main_linux.cc b/content/browser/zygote_main_linux.cc
index 0da3212..3c5db18 100644
--- a/content/browser/zygote_main_linux.cc
+++ b/content/browser/zygote_main_linux.cc
@@ -36,10 +36,10 @@
#include "base/scoped_ptr.h"
#include "base/sys_info.h"
#include "build/build_config.h"
-#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pepper_plugin_registry.h"
+#include "content/common/chrome_descriptors.h"
#include "content/common/font_config_ipc_linux.h"
#include "content/common/main_function_params.h"
#include "content/common/process_watcher.h"
diff --git a/content/common/chrome_descriptors.h b/content/common/chrome_descriptors.h
new file mode 100644
index 0000000..166467d
--- /dev/null
+++ b/content/common/chrome_descriptors.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2009 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 CONTENT_COMMON_CHROME_DESCRIPTORS_H_
+#define CONTENT_COMMON_CHROME_DESCRIPTORS_H_
+#pragma once
+
+#include "ipc/ipc_descriptors.h"
+
+// This is a list of global descriptor keys to be used with the
+// base::GlobalDescriptors object (see base/global_descriptors_posix.h)
+enum {
+ kCrashDumpSignal = kPrimaryIPCChannel + 1,
+ kSandboxIPCChannel = kPrimaryIPCChannel + 2, // http://code.google.com/p/chromium/LinuxSandboxIPC
+};
+
+#endif // CONTENT_COMMON_CHROME_DESCRIPTORS_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 93ccbcc..57299ee 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -37,6 +37,7 @@
'common/child_thread.h',
'common/chrome_application_mac.h',
'common/chrome_application_mac.mm',
+ 'common/chrome_descriptors.h',
'common/clipboard_messages.h',
'common/common_param_traits.cc',
'common/common_param_traits.h',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 7dd7849..c12c2bd9 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -71,6 +71,32 @@
'renderer/pepper_plugin_delegate_impl.h',
'renderer/plugin_channel_host.cc',
'renderer/plugin_channel_host.h',
+ 'renderer/renderer_sandbox_support_linux.cc',
+ 'renderer/renderer_sandbox_support_linux.h',
+ 'renderer/renderer_webapplicationcachehost_impl.cc',
+ 'renderer/renderer_webapplicationcachehost_impl.h',
+ 'renderer/renderer_webaudiodevice_impl.cc',
+ 'renderer/renderer_webaudiodevice_impl.h',
+ 'renderer/renderer_webcookiejar_impl.cc',
+ 'renderer/renderer_webcookiejar_impl.h',
+ 'renderer/renderer_webidbcursor_impl.cc',
+ 'renderer/renderer_webidbcursor_impl.h',
+ 'renderer/renderer_webidbdatabase_impl.cc',
+ 'renderer/renderer_webidbdatabase_impl.h',
+ 'renderer/renderer_webidbfactory_impl.cc',
+ 'renderer/renderer_webidbfactory_impl.h',
+ 'renderer/renderer_webidbindex_impl.cc',
+ 'renderer/renderer_webidbindex_impl.h',
+ 'renderer/renderer_webidbobjectstore_impl.cc',
+ 'renderer/renderer_webidbobjectstore_impl.h',
+ 'renderer/renderer_webidbtransaction_impl.cc',
+ 'renderer/renderer_webidbtransaction_impl.h',
+ 'renderer/renderer_webkitclient_impl.cc',
+ 'renderer/renderer_webkitclient_impl.h',
+ 'renderer/renderer_webstoragearea_impl.cc',
+ 'renderer/renderer_webstoragearea_impl.h',
+ 'renderer/renderer_webstoragenamespace_impl.cc',
+ 'renderer/renderer_webstoragenamespace_impl.h',
'renderer/speech_input_dispatcher.cc',
'renderer/speech_input_dispatcher.h',
'renderer/webgraphicscontext3d_command_buffer_impl.cc',
diff --git a/content/renderer/indexed_db_dispatcher.cc b/content/renderer/indexed_db_dispatcher.cc
index d62ad6f..d422015 100644
--- a/content/renderer/indexed_db_dispatcher.cc
+++ b/content/renderer/indexed_db_dispatcher.cc
@@ -6,12 +6,12 @@
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
-#include "chrome/renderer/renderer_webidbcursor_impl.h"
-#include "chrome/renderer/renderer_webidbdatabase_impl.h"
-#include "chrome/renderer/renderer_webidbindex_impl.h"
-#include "chrome/renderer/renderer_webidbobjectstore_impl.h"
-#include "chrome/renderer/renderer_webidbtransaction_impl.h"
#include "content/common/indexed_db_messages.h"
+#include "content/renderer/renderer_webidbcursor_impl.h"
+#include "content/renderer/renderer_webidbdatabase_impl.h"
+#include "content/renderer/renderer_webidbindex_impl.h"
+#include "content/renderer/renderer_webidbobjectstore_impl.h"
+#include "content/renderer/renderer_webidbtransaction_impl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h"
diff --git a/content/renderer/renderer_sandbox_support_linux.cc b/content/renderer/renderer_sandbox_support_linux.cc
new file mode 100644
index 0000000..3029bb9
--- /dev/null
+++ b/content/renderer/renderer_sandbox_support_linux.cc
@@ -0,0 +1,189 @@
+// 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 "content/renderer/renderer_sandbox_support_linux.h"
+
+#include <sys/stat.h>
+
+#include "base/eintr_wrapper.h"
+#include "base/global_descriptors_posix.h"
+#include "base/pickle.h"
+#include "base/scoped_ptr.h"
+#include "content/common/chrome_descriptors.h"
+#include "content/common/sandbox_methods_linux.h"
+#include "content/common/unix_domain_socket_posix.h"
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderStyle.h"
+
+static int GetSandboxFD() {
+ return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
+}
+
+namespace renderer_sandbox_support {
+
+std::string getFontFamilyForCharacters(const uint16_t* utf16,
+ size_t num_utf16,
+ const char* preferred_locale) {
+ Pickle request;
+ request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
+ request.WriteInt(num_utf16);
+ for (size_t i = 0; i < num_utf16; ++i)
+ request.WriteUInt32(utf16[i]);
+ request.WriteString(preferred_locale);
+
+ uint8_t buf[512];
+ const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
+ sizeof(buf), NULL, request);
+
+ std::string family_name;
+ if (n != -1) {
+ Pickle reply(reinterpret_cast<char*>(buf), n);
+ void* pickle_iter = NULL;
+ reply.ReadString(&pickle_iter, &family_name);
+ }
+
+ return family_name;
+}
+
+void getRenderStyleForStrike(const char* family, int sizeAndStyle,
+ WebKit::WebFontRenderStyle* out) {
+ Pickle request;
+ request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
+ request.WriteString(family);
+ request.WriteInt(sizeAndStyle);
+
+ uint8_t buf[512];
+ const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
+ sizeof(buf), NULL, request);
+
+ out->setDefaults();
+ if (n == -1) {
+ return;
+ }
+
+ Pickle reply(reinterpret_cast<char*>(buf), n);
+ void* pickle_iter = NULL;
+ int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
+ if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
+ reply.ReadInt(&pickle_iter, &useAutoHint) &&
+ reply.ReadInt(&pickle_iter, &useHinting) &&
+ reply.ReadInt(&pickle_iter, &hintStyle) &&
+ reply.ReadInt(&pickle_iter, &useAntiAlias) &&
+ reply.ReadInt(&pickle_iter, &useSubpixel)) {
+ out->useBitmaps = useBitmaps;
+ out->useAutoHint = useAutoHint;
+ out->useHinting = useHinting;
+ out->hintStyle = hintStyle;
+ out->useAntiAlias = useAntiAlias;
+ out->useSubpixel = useSubpixel;
+ }
+}
+
+int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) {
+ Pickle request;
+ request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT);
+ request.WriteUInt32(length);
+ uint8_t reply_buf[10];
+ int result_fd;
+ ssize_t result = UnixDomainSocket::SendRecvMsg(GetSandboxFD(),
+ reply_buf, sizeof(reply_buf),
+ &result_fd, request);
+ if (result == -1)
+ return -1;
+ return result_fd;
+}
+
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset) {
+ Pickle request;
+ request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
+ request.WriteString(face);
+ request.WriteBool(bold);
+ request.WriteBool(italic);
+ request.WriteUInt32(charset);
+ uint8_t reply_buf[64];
+ int fd = -1;
+ UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf, sizeof(reply_buf),
+ &fd, request);
+ return fd;
+}
+
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length) {
+ if (table == 0) {
+ struct stat st;
+ if (fstat(fd, &st) < 0)
+ return false;
+ size_t length = st.st_size;
+ if (!output) {
+ *output_length = length;
+ return true;
+ }
+ if (*output_length < length)
+ return false;
+ *output_length = length;
+ ssize_t n = HANDLE_EINTR(pread(fd, output, length, 0));
+ if (n != static_cast<ssize_t>(length))
+ return false;
+ return true;
+ }
+
+ unsigned num_tables;
+ uint8_t num_tables_buf[2];
+
+ ssize_t n = HANDLE_EINTR(pread(fd, &num_tables_buf, sizeof(num_tables_buf),
+ 4 /* skip the font type */));
+ if (n != sizeof(num_tables_buf))
+ return false;
+
+ num_tables = static_cast<unsigned>(num_tables_buf[0]) << 8 |
+ num_tables_buf[1];
+
+ // The size in bytes of an entry in the table directory.
+ static const unsigned kTableEntrySize = 16;
+ scoped_array<uint8_t> table_entries(
+ new uint8_t[num_tables * kTableEntrySize]);
+ n = HANDLE_EINTR(pread(fd, table_entries.get(), num_tables * kTableEntrySize,
+ 12 /* skip the SFNT header */));
+ if (n != static_cast<ssize_t>(num_tables * kTableEntrySize))
+ return false;
+
+ size_t offset;
+ size_t length = 0;
+ for (unsigned i = 0; i < num_tables; i++) {
+ const uint8_t* entry = table_entries.get() + i * kTableEntrySize;
+ if (memcmp(entry, &table, sizeof(table)) == 0) {
+ offset = static_cast<size_t>(entry[8]) << 24 |
+ static_cast<size_t>(entry[9]) << 16 |
+ static_cast<size_t>(entry[10]) << 8 |
+ static_cast<size_t>(entry[11]);
+ length = static_cast<size_t>(entry[12]) << 24 |
+ static_cast<size_t>(entry[13]) << 16 |
+ static_cast<size_t>(entry[14]) << 8 |
+ static_cast<size_t>(entry[15]);
+
+ break;
+ }
+ }
+
+ if (!length)
+ return false;
+
+ if (!output) {
+ *output_length = length;
+ return true;
+ }
+
+ if (*output_length < length)
+ return false;
+
+ *output_length = length;
+ n = HANDLE_EINTR(pread(fd, output, length, offset));
+ if (n != static_cast<ssize_t>(length))
+ return false;
+
+ return true;
+}
+
+} // namespace render_sandbox_support
diff --git a/content/renderer/renderer_sandbox_support_linux.h b/content/renderer/renderer_sandbox_support_linux.h
new file mode 100644
index 0000000..bc482bd
--- /dev/null
+++ b/content/renderer/renderer_sandbox_support_linux.h
@@ -0,0 +1,59 @@
+// 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 CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
+#define CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
+#pragma once
+
+#include <stdint.h>
+
+#include <string>
+
+namespace WebKit {
+struct WebFontRenderStyle;
+}
+
+namespace renderer_sandbox_support {
+
+// Return a font family which provides glyphs for the Unicode code points
+// specified by |utf16|
+// utf16: a native-endian UTF16 string
+// num_utf16: the number of 16-bit words in |utf16|
+// preferred_locale: preferred locale identifier for the |utf16|
+//
+// Returns: the font family or an empty string if the request could not be
+// satisfied.
+std::string getFontFamilyForCharacters(const uint16_t* utf16,
+ size_t num_utf16,
+ const char* preferred_locale);
+
+void getRenderStyleForStrike(const char* family, int sizeAndStyle,
+ WebKit::WebFontRenderStyle* out);
+
+// Returns a file descriptor for a shared memory segment.
+// The second argument is ignored because SHM segments are always
+// mappable with PROT_EXEC on Linux.
+int MakeSharedMemorySegmentViaIPC(size_t length, bool executable);
+
+// Return a read-only file descriptor to the font which best matches the given
+// properties or -1 on failure.
+// charset: specifies the language(s) that the font must cover. See
+// render_sandbox_host_linux.cc for more information.
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset);
+
+// GetFontTable loads a specified font table from an open SFNT file.
+// fd: a file descriptor to the SFNT file. The position doesn't matter.
+// table: the table in *big-endian* format, or 0 for the whole font file.
+// output: a buffer of size output_length that gets the data. can be 0, in
+// which case output_length will be set to the required size in bytes.
+// output_length: size of output, if it's not 0.
+//
+// returns: true on success.
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length);
+
+}; // namespace render_sandbox_support
+
+#endif // CONTENT_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
diff --git a/content/renderer/renderer_webapplicationcachehost_impl.cc b/content/renderer/renderer_webapplicationcachehost_impl.cc
new file mode 100644
index 0000000..b7d628b
--- /dev/null
+++ b/content/renderer/renderer_webapplicationcachehost_impl.cc
@@ -0,0 +1,58 @@
+// 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 "content/renderer/renderer_webapplicationcachehost_impl.h"
+
+#include "chrome/common/content_settings_types.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+using appcache::AppCacheBackend;
+using WebKit::WebApplicationCacheHostClient;
+using WebKit::WebConsoleMessage;
+
+RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
+ RenderView* render_view,
+ WebApplicationCacheHostClient* client,
+ AppCacheBackend* backend)
+ : WebApplicationCacheHostImpl(client, backend),
+ content_blocked_(false),
+ routing_id_(render_view->routing_id()) {
+}
+
+void RendererWebApplicationCacheHostImpl::OnLogMessage(
+ appcache::LogLevel log_level, const std::string& message) {
+ RenderView* render_view = GetRenderView();
+ if (!render_view || !render_view->webview() ||
+ !render_view->webview()->mainFrame())
+ return;
+
+ WebKit::WebFrame* frame = render_view->webview()->mainFrame();
+ frame->addMessageToConsole(WebConsoleMessage(
+ static_cast<WebConsoleMessage::Level>(log_level),
+ WebKit::WebString::fromUTF8(message.c_str())));
+}
+
+void RendererWebApplicationCacheHostImpl::OnContentBlocked(
+ const GURL& manifest_url) {
+ RenderThread::current()->Send(new ViewHostMsg_AppCacheAccessed(
+ routing_id_, manifest_url, true));
+}
+
+void RendererWebApplicationCacheHostImpl::OnCacheSelected(
+ const appcache::AppCacheInfo& info) {
+ if (!info.manifest_url.is_empty()) {
+ RenderThread::current()->Send(new ViewHostMsg_AppCacheAccessed(
+ routing_id_, info.manifest_url, false));
+ }
+ WebApplicationCacheHostImpl::OnCacheSelected(info);
+}
+
+RenderView* RendererWebApplicationCacheHostImpl::GetRenderView() {
+ return static_cast<RenderView*>
+ (RenderThread::current()->ResolveRoute(routing_id_));
+}
diff --git a/content/renderer/renderer_webapplicationcachehost_impl.h b/content/renderer/renderer_webapplicationcachehost_impl.h
new file mode 100644
index 0000000..9727315
--- /dev/null
+++ b/content/renderer/renderer_webapplicationcachehost_impl.h
@@ -0,0 +1,34 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
+#pragma once
+
+#include "webkit/appcache/web_application_cache_host_impl.h"
+
+class RenderView;
+
+class RendererWebApplicationCacheHostImpl
+ : public appcache::WebApplicationCacheHostImpl {
+ public:
+ RendererWebApplicationCacheHostImpl(
+ RenderView* render_view,
+ WebKit::WebApplicationCacheHostClient* client,
+ appcache::AppCacheBackend* backend);
+
+ // appcache::WebApplicationCacheHostImpl methods.
+ virtual void OnLogMessage(appcache::LogLevel log_level,
+ const std::string& message);
+ virtual void OnContentBlocked(const GURL& manifest_url);
+ virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
+
+ private:
+ RenderView* GetRenderView();
+
+ bool content_blocked_;
+ int routing_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
diff --git a/content/renderer/renderer_webaudiodevice_impl.cc b/content/renderer/renderer_webaudiodevice_impl.cc
new file mode 100644
index 0000000..057132a
--- /dev/null
+++ b/content/renderer/renderer_webaudiodevice_impl.cc
@@ -0,0 +1,41 @@
+// 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 "content/renderer/renderer_webaudiodevice_impl.h"
+
+using WebKit::WebAudioDevice;
+using WebKit::WebVector;
+
+RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(size_t buffer_size,
+ int channels, double sample_rate, WebAudioDevice::RenderCallback* callback)
+ : client_callback_(callback) {
+ audio_device_.reset(
+ new AudioDevice(buffer_size, channels, sample_rate, this));
+}
+
+RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() {
+ stop();
+}
+
+void RendererWebAudioDeviceImpl::start() {
+ audio_device_->Start();
+}
+
+void RendererWebAudioDeviceImpl::stop() {
+ audio_device_->Stop();
+}
+
+void RendererWebAudioDeviceImpl::Render(const std::vector<float*>& audio_data,
+ size_t number_of_frames) {
+ // Make the client callback to get rendered audio.
+ DCHECK(client_callback_);
+ if (client_callback_) {
+ // Wrap the pointers using WebVector.
+ WebVector<float*> web_audio_data(audio_data.size());
+ for (size_t i = 0; i < audio_data.size(); ++i)
+ web_audio_data[i] = audio_data[i];
+
+ client_callback_->render(web_audio_data, number_of_frames);
+ }
+}
diff --git a/content/renderer/renderer_webaudiodevice_impl.h b/content/renderer/renderer_webaudiodevice_impl.h
new file mode 100644
index 0000000..c798663
--- /dev/null
+++ b/content/renderer/renderer_webaudiodevice_impl.h
@@ -0,0 +1,41 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBAUDIODEVICE_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBAUDIODEVICE_IMPL_H_
+
+#include <vector>
+
+#include "base/scoped_ptr.h"
+#include "content/renderer/audio_device.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioDevice.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+
+class RendererWebAudioDeviceImpl : public WebKit::WebAudioDevice,
+ public AudioDevice::RenderCallback {
+ public:
+ RendererWebAudioDeviceImpl(size_t buffer_size,
+ int channels,
+ double sample_rate,
+ WebKit::WebAudioDevice::RenderCallback* callback);
+ virtual ~RendererWebAudioDeviceImpl();
+
+ // WebKit::WebAudioDevice implementation.
+ virtual void start();
+ virtual void stop();
+
+ // AudioDevice::RenderCallback implementation.
+ virtual void Render(const std::vector<float*>& audio_data,
+ size_t number_of_frames);
+
+ private:
+ scoped_ptr<AudioDevice> audio_device_;
+
+ // Weak reference to the callback into WebKit code.
+ WebKit::WebAudioDevice::RenderCallback* client_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl);
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBAUDIODEVICE_IMPL_H_
diff --git a/content/renderer/renderer_webcookiejar_impl.cc b/content/renderer/renderer_webcookiejar_impl.cc
new file mode 100644
index 0000000..4fb1a0a
--- /dev/null
+++ b/content/renderer/renderer_webcookiejar_impl.cc
@@ -0,0 +1,79 @@
+// 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 "content/renderer/renderer_webcookiejar_impl.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h"
+#include "webkit/glue/webcookie.h"
+
+using WebKit::WebCookie;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebVector;
+
+void RendererWebCookieJarImpl::setCookie(
+ const WebURL& url, const WebURL& first_party_for_cookies,
+ const WebString& value) {
+ std::string value_utf8;
+ UTF16ToUTF8(value.data(), value.length(), &value_utf8);
+ sender_->Send(new ViewHostMsg_SetCookie(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8));
+}
+
+WebString RendererWebCookieJarImpl::cookies(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ std::string value_utf8;
+ // NOTE: This may pump events (see RenderThread::Send).
+ sender_->Send(new ViewHostMsg_GetCookies(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8));
+ return WebString::fromUTF8(value_utf8);
+}
+
+WebString RendererWebCookieJarImpl::cookieRequestHeaderFieldValue(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ return cookies(url, first_party_for_cookies);
+}
+
+void RendererWebCookieJarImpl::rawCookies(
+ const WebURL& url, const WebURL& first_party_for_cookies,
+ WebVector<WebCookie>& raw_cookies) {
+ std::vector<webkit_glue::WebCookie> cookies;
+ // NOTE: This may pump events (see RenderThread::Send).
+ sender_->Send(new ViewHostMsg_GetRawCookies(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, &cookies));
+
+ WebVector<WebCookie> result(cookies.size());
+ int i = 0;
+ for (std::vector<webkit_glue::WebCookie>::iterator it = cookies.begin();
+ it != cookies.end(); ++it) {
+ result[i++] = WebCookie(WebString::fromUTF8(it->name),
+ WebString::fromUTF8(it->value),
+ WebString::fromUTF8(it->domain),
+ WebString::fromUTF8(it->path),
+ it->expires,
+ it->http_only,
+ it->secure,
+ it->session);
+ }
+ raw_cookies.swap(result);
+}
+
+void RendererWebCookieJarImpl::deleteCookie(
+ const WebURL& url, const WebString& cookie_name) {
+ std::string cookie_name_utf8;
+ UTF16ToUTF8(cookie_name.data(), cookie_name.length(), &cookie_name_utf8);
+ sender_->Send(new ViewHostMsg_DeleteCookie(url, cookie_name_utf8));
+}
+
+bool RendererWebCookieJarImpl::cookiesEnabled(
+ const WebURL& url, const WebURL& first_party_for_cookies) {
+ bool cookies_enabled;
+ // NOTE: This may pump events (see RenderThread::Send).
+ sender_->Send(new ViewHostMsg_CookiesEnabled(
+ MSG_ROUTING_NONE, url, first_party_for_cookies, &cookies_enabled));
+ return cookies_enabled;
+}
diff --git a/content/renderer/renderer_webcookiejar_impl.h b/content/renderer/renderer_webcookiejar_impl.h
new file mode 100644
index 0000000..dcd1d3f
--- /dev/null
+++ b/content/renderer/renderer_webcookiejar_impl.h
@@ -0,0 +1,45 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
+#pragma once
+
+#include "ipc/ipc_message.h"
+// TODO(darin): WebCookieJar.h is missing a WebString.h include!
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCookieJar.h"
+
+namespace IPC {
+class SyncMessage;
+}
+
+class RendererWebCookieJarImpl : public WebKit::WebCookieJar {
+ public:
+ explicit RendererWebCookieJarImpl(IPC::Message::Sender* sender)
+ : sender_(sender) {
+ }
+ virtual ~RendererWebCookieJarImpl() {}
+
+ private:
+ // WebKit::WebCookieJar methods:
+ virtual void setCookie(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
+ const WebKit::WebString& value);
+ virtual WebKit::WebString cookies(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+ virtual WebKit::WebString cookieRequestHeaderFieldValue(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+ virtual void rawCookies(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies,
+ WebKit::WebVector<WebKit::WebCookie>& cookies);
+ virtual void deleteCookie(
+ const WebKit::WebURL& url, const WebKit::WebString& cookie_name);
+ virtual bool cookiesEnabled(
+ const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
+
+ IPC::Message::Sender* sender_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
diff --git a/content/renderer/renderer_webidbcursor_impl.cc b/content/renderer/renderer_webidbcursor_impl.cc
new file mode 100644
index 0000000..1bad237
--- /dev/null
+++ b/content/renderer/renderer_webidbcursor_impl.cc
@@ -0,0 +1,87 @@
+// 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 "content/renderer/renderer_webidbcursor_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "content/common/indexed_db_messages.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+
+using WebKit::WebExceptionCode;
+using WebKit::WebIDBCallbacks;
+using WebKit::WebIDBKey;
+using WebKit::WebSerializedScriptValue;
+
+RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id)
+ : idb_cursor_id_(idb_cursor_id) {
+}
+
+RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
+ // It's not possible for there to be pending callbacks that address this
+ // object since inside WebKit, they hold a reference to the object wich owns
+ // this object. But, if that ever changed, then we'd need to invalidate
+ // any such pointers.
+ RenderThread::current()->Send(new IndexedDBHostMsg_CursorDestroyed(
+ idb_cursor_id_));
+}
+
+unsigned short RendererWebIDBCursorImpl::direction() const {
+ int direction;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_CursorDirection(idb_cursor_id_, &direction));
+ return direction;
+}
+
+WebIDBKey RendererWebIDBCursorImpl::key() const {
+ IndexedDBKey key;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_CursorKey(idb_cursor_id_, &key));
+ return key;
+}
+
+WebIDBKey RendererWebIDBCursorImpl::primaryKey() const {
+ IndexedDBKey primaryKey;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_CursorPrimaryKey(idb_cursor_id_, &primaryKey));
+ return primaryKey;
+}
+
+void RendererWebIDBCursorImpl::value(
+ WebSerializedScriptValue& webScriptValue,
+ WebIDBKey& webKey) const {
+ SerializedScriptValue scriptValue;
+ IndexedDBKey key;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_CursorValue(idb_cursor_id_, &scriptValue,
+ &key));
+ // Only one or the other type should have been "returned" to us.
+ DCHECK(scriptValue.is_null() != (key.type() == WebIDBKey::InvalidType));
+ webScriptValue = scriptValue;
+ webKey = key;
+}
+
+void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
+ WebIDBCallbacks* callbacks,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBCursorUpdate(SerializedScriptValue(value), callbacks,
+ idb_cursor_id_, &ec);
+}
+
+void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
+ WebIDBCallbacks* callbacks,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks,
+ idb_cursor_id_, &ec);
+}
+
+void RendererWebIDBCursorImpl::remove(WebIDBCallbacks* callbacks,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
+}
diff --git a/content/renderer/renderer_webidbcursor_impl.h b/content/renderer/renderer_webidbcursor_impl.h
new file mode 100644
index 0000000..147345f
--- /dev/null
+++ b/content/renderer/renderer_webidbcursor_impl.h
@@ -0,0 +1,39 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_
+
+#include "base/basictypes.h"
+#include "content/common/indexed_db_key.h"
+#include "content/common/serialized_script_value.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
+
+class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor {
+ public:
+ RendererWebIDBCursorImpl(int32 idb_cursor_id);
+ virtual ~RendererWebIDBCursorImpl();
+
+ virtual unsigned short direction() const;
+ virtual WebKit::WebIDBKey key() const;
+ virtual WebKit::WebIDBKey primaryKey() const;
+ virtual void value(WebKit::WebSerializedScriptValue&,
+ WebKit::WebIDBKey&) const;
+ virtual void update(const WebKit::WebSerializedScriptValue& value,
+ WebKit::WebIDBCallbacks* callback,
+ WebKit::WebExceptionCode& ec);
+ virtual void continueFunction(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callback,
+ WebKit::WebExceptionCode& ec);
+ virtual void remove(WebKit::WebIDBCallbacks* callback,
+ WebKit::WebExceptionCode& ec);
+
+ private:
+ int32 idb_cursor_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_
diff --git a/content/renderer/renderer_webidbdatabase_impl.cc b/content/renderer/renderer_webidbdatabase_impl.cc
new file mode 100644
index 0000000..da99ed7
--- /dev/null
+++ b/content/renderer/renderer_webidbdatabase_impl.cc
@@ -0,0 +1,135 @@
+// 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 "content/renderer/renderer_webidbdatabase_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "content/common/indexed_db_messages.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+#include "content/renderer/renderer_webidbobjectstore_impl.h"
+#include "content/renderer/renderer_webidbtransaction_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+
+using WebKit::WebDOMStringList;
+using WebKit::WebExceptionCode;
+using WebKit::WebFrame;
+using WebKit::WebIDBCallbacks;
+using WebKit::WebIDBDatabaseCallbacks;
+using WebKit::WebIDBTransaction;
+using WebKit::WebString;
+using WebKit::WebVector;
+
+RendererWebIDBDatabaseImpl::RendererWebIDBDatabaseImpl(int32 idb_database_id)
+ : idb_database_id_(idb_database_id) {
+}
+
+RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() {
+ // It's not possible for there to be pending callbacks that address this
+ // object since inside WebKit, they hold a reference to the object which owns
+ // this object. But, if that ever changed, then we'd need to invalidate
+ // any such pointers.
+ RenderThread::current()->Send(new IndexedDBHostMsg_DatabaseDestroyed(
+ idb_database_id_));
+}
+
+WebString RendererWebIDBDatabaseImpl::name() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseName(idb_database_id_, &result));
+ return result;
+}
+
+WebString RendererWebIDBDatabaseImpl::version() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseVersion(idb_database_id_, &result));
+ return result;
+}
+
+WebDOMStringList RendererWebIDBDatabaseImpl::objectStoreNames() const {
+ std::vector<string16> result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseObjectStoreNames(idb_database_id_, &result));
+ WebDOMStringList webResult;
+ for (std::vector<string16>::const_iterator it = result.begin();
+ it != result.end(); ++it) {
+ webResult.append(*it);
+ }
+ return webResult;
+}
+
+WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool auto_increment,
+ const WebKit::WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBHostMsg_DatabaseCreateObjectStore_Params params;
+ params.name = name;
+ params.key_path = key_path;
+ params.auto_increment = auto_increment;
+ params.transaction_id = IndexedDBDispatcher::TransactionId(transaction);
+ params.idb_database_id = idb_database_id_;
+
+ int object_store;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseCreateObjectStore(
+ params, &object_store, &ec));
+ if (!object_store)
+ return NULL;
+ return new RendererWebIDBObjectStoreImpl(object_store);
+}
+
+void RendererWebIDBDatabaseImpl::deleteObjectStore(
+ const WebString& name,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseDeleteObjectStore(
+ idb_database_id_, name,
+ IndexedDBDispatcher::TransactionId(transaction), &ec));
+}
+
+void RendererWebIDBDatabaseImpl::setVersion(
+ const WebString& version,
+ WebIDBCallbacks* callbacks,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBDatabaseSetVersion(
+ version, callbacks, idb_database_id_, &ec);
+}
+
+WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction(
+ const WebDOMStringList& names,
+ unsigned short mode,
+ unsigned long timeout,
+ WebExceptionCode& ec) {
+ std::vector<string16> object_stores;
+ object_stores.reserve(names.length());
+ for (unsigned int i = 0; i < names.length(); ++i)
+ object_stores.push_back(names.item(i));
+
+ int transaction_id;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_DatabaseTransaction(
+ idb_database_id_, object_stores, mode,
+ timeout, &transaction_id, &ec));
+ if (!transaction_id)
+ return NULL;
+ return new RendererWebIDBTransactionImpl(transaction_id);
+}
+
+void RendererWebIDBDatabaseImpl::close() {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBDatabaseClose(idb_database_id_);
+}
+
+void RendererWebIDBDatabaseImpl::open(WebIDBDatabaseCallbacks* callbacks) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBDatabaseOpen(callbacks, idb_database_id_);
+}
diff --git a/content/renderer/renderer_webidbdatabase_impl.h b/content/renderer/renderer_webidbdatabase_impl.h
new file mode 100644
index 0000000..d87c4b0
--- /dev/null
+++ b/content/renderer/renderer_webidbdatabase_impl.h
@@ -0,0 +1,53 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBDATABASE_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBDATABASE_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
+
+namespace WebKit {
+class WebFrame;
+class WebIDBCallbacks;
+class WebIDBDatabaseCallbacks;
+class WebString;
+class WebIDBTransaction;
+}
+
+class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
+ public:
+ explicit RendererWebIDBDatabaseImpl(int32 idb_database_id);
+ virtual ~RendererWebIDBDatabaseImpl();
+
+ // WebKit::WebIDBDatabase
+ virtual WebKit::WebString name() const;
+ virtual WebKit::WebString version() const;
+ virtual WebKit::WebDOMStringList objectStoreNames() const;
+ virtual WebKit::WebIDBObjectStore* createObjectStore(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool auto_increment,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void deleteObjectStore(
+ const WebKit::WebString& name,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void setVersion(
+ const WebKit::WebString& version, WebKit::WebIDBCallbacks* callbacks,
+ WebKit::WebExceptionCode& ec);
+ virtual WebKit::WebIDBTransaction* transaction(
+ const WebKit::WebDOMStringList& names,
+ unsigned short mode, unsigned long timeout,
+ WebKit::WebExceptionCode& ec);
+ virtual void close();
+ virtual void open(WebKit::WebIDBDatabaseCallbacks*);
+
+ private:
+ int32 idb_database_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBDATABASE_IMPL_H_
diff --git a/content/renderer/renderer_webidbfactory_impl.cc b/content/renderer/renderer_webidbfactory_impl.cc
new file mode 100644
index 0000000..a8de8e3
--- /dev/null
+++ b/content/renderer/renderer_webidbfactory_impl.cc
@@ -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.
+
+#include "content/renderer/renderer_webidbfactory_impl.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebDOMStringList;
+using WebKit::WebFrame;
+using WebKit::WebIDBCallbacks;
+using WebKit::WebIDBDatabase;
+using WebKit::WebSecurityOrigin;
+using WebKit::WebString;
+
+RendererWebIDBFactoryImpl::RendererWebIDBFactoryImpl() {
+}
+
+RendererWebIDBFactoryImpl::~RendererWebIDBFactoryImpl() {
+}
+
+void RendererWebIDBFactoryImpl::open(
+ const WebString& name,
+ WebIDBCallbacks* callbacks,
+ const WebSecurityOrigin& origin,
+ WebFrame* web_frame,
+ const WebString& data_dir,
+ unsigned long long maximum_size,
+ WebKit::WebIDBFactory::BackingStoreType) {
+ // Don't send the data_dir. We know what we want on the Browser side of
+ // things.
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBFactoryOpen(
+ name, callbacks, origin.databaseIdentifier(), web_frame, maximum_size);
+}
+
+void RendererWebIDBFactoryImpl::deleteDatabase(
+ const WebString& name,
+ WebIDBCallbacks* callbacks,
+ const WebSecurityOrigin& origin,
+ WebFrame* web_frame,
+ const WebString& data_dir) {
+ // Don't send the data_dir. We know what we want on the Browser side of
+ // things.
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBFactoryDeleteDatabase(
+ name, callbacks, origin.databaseIdentifier(), web_frame);
+}
diff --git a/content/renderer/renderer_webidbfactory_impl.h b/content/renderer/renderer_webidbfactory_impl.h
new file mode 100644
index 0000000..941dc81
--- /dev/null
+++ b/content/renderer/renderer_webidbfactory_impl.h
@@ -0,0 +1,43 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_
+#pragma once
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+
+namespace WebKit {
+class WebDOMStringList;
+class WebFrame;
+class WebIDBDatabase;
+class WebSecurityOrigin;
+class WebString;
+}
+
+class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory {
+ public:
+ RendererWebIDBFactoryImpl();
+ virtual ~RendererWebIDBFactoryImpl();
+
+ // See WebIDBFactory.h for documentation on these functions.
+ virtual void open(
+ const WebKit::WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* web_frame,
+ const WebKit::WebString& data_dir,
+ unsigned long long maximum_size,
+ WebKit::WebIDBFactory::BackingStoreType);
+ virtual void deleteDatabase(
+ const WebKit::WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* web_frame,
+ const WebKit::WebString& data_dir);
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_
diff --git a/content/renderer/renderer_webidbindex_impl.cc b/content/renderer/renderer_webidbindex_impl.cc
new file mode 100644
index 0000000..72c0e84
--- /dev/null
+++ b/content/renderer/renderer_webidbindex_impl.cc
@@ -0,0 +1,104 @@
+// 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 "content/renderer/renderer_webidbindex_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "content/common/indexed_db_messages.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+#include "content/renderer/renderer_webidbtransaction_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+
+using WebKit::WebExceptionCode;
+using WebKit::WebDOMStringList;
+using WebKit::WebString;
+using WebKit::WebVector;
+
+RendererWebIDBIndexImpl::RendererWebIDBIndexImpl(int32 idb_index_id)
+ : idb_index_id_(idb_index_id) {
+}
+
+RendererWebIDBIndexImpl::~RendererWebIDBIndexImpl() {
+ // It's not possible for there to be pending callbacks that address this
+ // object since inside WebKit, they hold a reference to the object wich owns
+ // this object. But, if that ever changed, then we'd need to invalidate
+ // any such pointers.
+ RenderThread::current()->Send(new IndexedDBHostMsg_IndexDestroyed(
+ idb_index_id_));
+}
+
+WebString RendererWebIDBIndexImpl::name() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_IndexName(idb_index_id_, &result));
+ return result;
+}
+
+WebString RendererWebIDBIndexImpl::storeName() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_IndexStoreName(idb_index_id_, &result));
+ return result;
+}
+
+WebString RendererWebIDBIndexImpl::keyPath() const {
+ NullableString16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_IndexKeyPath(idb_index_id_, &result));
+ return result;
+}
+
+bool RendererWebIDBIndexImpl::unique() const {
+ bool result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_IndexUnique(idb_index_id_, &result));
+ return result;
+}
+
+void RendererWebIDBIndexImpl::openObjectCursor(
+ const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexOpenObjectCursor(
+ range, direction, callbacks, idb_index_id_, transaction, &ec);
+}
+
+void RendererWebIDBIndexImpl::openKeyCursor(
+ const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexOpenKeyCursor(
+ range, direction, callbacks, idb_index_id_, transaction, &ec);
+}
+
+void RendererWebIDBIndexImpl::getObject(
+ const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexGetObject(
+ IndexedDBKey(key), callbacks, idb_index_id_, transaction, &ec);
+}
+
+void RendererWebIDBIndexImpl::getKey(
+ const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBIndexGetKey(
+ IndexedDBKey(key), callbacks, idb_index_id_, transaction, &ec);
+}
diff --git a/content/renderer/renderer_webidbindex_impl.h b/content/renderer/renderer_webidbindex_impl.h
new file mode 100644
index 0000000..e085122
--- /dev/null
+++ b/content/renderer/renderer_webidbindex_impl.h
@@ -0,0 +1,47 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBINDEX_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBINDEX_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h"
+
+class RendererWebIDBIndexImpl : public WebKit::WebIDBIndex {
+ public:
+ explicit RendererWebIDBIndexImpl(int32 idb_index_id);
+ virtual ~RendererWebIDBIndexImpl();
+
+ // WebKit::WebIDBIndex
+ virtual WebKit::WebString name() const;
+ virtual WebKit::WebString storeName() const;
+ virtual WebKit::WebString keyPath() const;
+ virtual bool unique() const;
+
+ virtual void openObjectCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void openKeyCursor(const WebKit::WebIDBKeyRange& range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void getObject(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void getKey(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+
+ private:
+ int32 idb_index_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBINDEX_IMPL_H_
diff --git a/content/renderer/renderer_webidbobjectstore_impl.cc b/content/renderer/renderer_webidbobjectstore_impl.cc
new file mode 100644
index 0000000..af23fe5
--- /dev/null
+++ b/content/renderer/renderer_webidbobjectstore_impl.cc
@@ -0,0 +1,171 @@
+// 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 "content/renderer/renderer_webidbobjectstore_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "content/common/indexed_db_messages.h"
+#include "content/common/serialized_script_value.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+#include "content/renderer/renderer_webidbindex_impl.h"
+#include "content/renderer/renderer_webidbtransaction_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebDOMStringList;
+using WebKit::WebExceptionCode;
+using WebKit::WebFrame;
+using WebKit::WebIDBCallbacks;
+using WebKit::WebIDBKeyRange;
+using WebKit::WebIDBIndex;
+using WebKit::WebIDBKey;
+using WebKit::WebIDBTransaction;
+using WebKit::WebSerializedScriptValue;
+using WebKit::WebString;
+
+RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl(
+ int32 idb_object_store_id)
+ : idb_object_store_id_(idb_object_store_id) {
+}
+
+RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() {
+ // It's not possible for there to be pending callbacks that address this
+ // object since inside WebKit, they hold a reference to the object wich owns
+ // this object. But, if that ever changed, then we'd need to invalidate
+ // any such pointers.
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_));
+}
+
+WebString RendererWebIDBObjectStoreImpl::name() const {
+ string16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result));
+ return result;
+}
+
+WebString RendererWebIDBObjectStoreImpl::keyPath() const {
+ NullableString16 result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result));
+ return result;
+}
+
+WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const {
+ std::vector<string16> result;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreIndexNames(
+ idb_object_store_id_, &result));
+ WebDOMStringList web_result;
+ for (std::vector<string16>::const_iterator it = result.begin();
+ it != result.end(); ++it) {
+ web_result.append(*it);
+ }
+ return web_result;
+}
+
+void RendererWebIDBObjectStoreImpl::get(
+ const WebIDBKey& key,
+ WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreGet(
+ IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
+}
+
+void RendererWebIDBObjectStoreImpl::put(
+ const WebSerializedScriptValue& value,
+ const WebIDBKey& key,
+ PutMode put_mode,
+ WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStorePut(
+ SerializedScriptValue(value), IndexedDBKey(key), put_mode, callbacks,
+ idb_object_store_id_, transaction, &ec);
+}
+
+void RendererWebIDBObjectStoreImpl::deleteFunction(
+ const WebIDBKey& key,
+ WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreDelete(
+ IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
+}
+
+void RendererWebIDBObjectStoreImpl::clear(
+ WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreClear(
+ callbacks, idb_object_store_id_, transaction, &ec);
+}
+
+WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex(
+ const WebString& name,
+ const WebString& key_path,
+ bool unique,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBHostMsg_ObjectStoreCreateIndex_Params params;
+ params.name = name;
+ params.key_path = key_path;
+ params.unique = unique;
+ params.transaction_id = IndexedDBDispatcher::TransactionId(transaction);
+ params.idb_object_store_id = idb_object_store_id_;
+
+ int32 index_id;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec));
+ if (!index_id)
+ return NULL;
+ return new RendererWebIDBIndexImpl(index_id);
+}
+
+WebIDBIndex* RendererWebIDBObjectStoreImpl::index(
+ const WebString& name,
+ WebExceptionCode& ec) {
+ int32 idb_index_id;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name,
+ &idb_index_id, &ec));
+ if (!idb_index_id)
+ return NULL;
+ return new RendererWebIDBIndexImpl(idb_index_id);
+}
+
+void RendererWebIDBObjectStoreImpl::deleteIndex(
+ const WebString& name,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_ObjectStoreDeleteIndex(
+ idb_object_store_id_, name,
+ IndexedDBDispatcher::TransactionId(transaction), &ec));
+}
+
+void RendererWebIDBObjectStoreImpl::openCursor(
+ const WebIDBKeyRange& idb_key_range,
+ unsigned short direction, WebIDBCallbacks* callbacks,
+ const WebIDBTransaction& transaction,
+ WebExceptionCode& ec) {
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RequestIDBObjectStoreOpenCursor(
+ idb_key_range, direction, callbacks, idb_object_store_id_,
+ transaction, &ec);
+}
diff --git a/content/renderer/renderer_webidbobjectstore_impl.h b/content/renderer/renderer_webidbobjectstore_impl.h
new file mode 100644
index 0000000..802ba32
--- /dev/null
+++ b/content/renderer/renderer_webidbobjectstore_impl.h
@@ -0,0 +1,72 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBOBJECTSTORE_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBOBJECTSTORE_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
+
+namespace WebKit {
+class WebFrame;
+class WebIDBCallbacks;
+class WebIDBIndex;
+class WebIDBKey;
+class WebIDBKeyRange;
+class WebString;
+}
+
+class RendererWebIDBObjectStoreImpl : public WebKit::WebIDBObjectStore {
+ public:
+ explicit RendererWebIDBObjectStoreImpl(int32 idb_object_store_id);
+ ~RendererWebIDBObjectStoreImpl();
+
+ // WebKit::WebIDBObjectStore
+ virtual WebKit::WebString name() const;
+ virtual WebKit::WebString keyPath() const;
+ virtual WebKit::WebDOMStringList indexNames() const;
+
+ virtual void get(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void put(const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebIDBKey& key,
+ PutMode put_mode,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void deleteFunction(const WebKit::WebIDBKey& key,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ virtual void clear(WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+
+ virtual WebKit::WebIDBIndex* createIndex(
+ const WebKit::WebString& name,
+ const WebKit::WebString& key_path,
+ bool unique,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ // Transfers ownership of the WebIDBIndex to the caller.
+ virtual WebKit::WebIDBIndex* index(const WebKit::WebString& name,
+ WebKit::WebExceptionCode& ec);
+ virtual void deleteIndex(const WebKit::WebString& name,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+
+ virtual void openCursor(const WebKit::WebIDBKeyRange& idb_key_range,
+ unsigned short direction,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebIDBTransaction& transaction,
+ WebKit::WebExceptionCode& ec);
+ private:
+ int32 idb_object_store_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBOBJECTSTORE_IMPL_H_
diff --git a/content/renderer/renderer_webidbtransaction_impl.cc b/content/renderer/renderer_webidbtransaction_impl.cc
new file mode 100644
index 0000000..15a08d4
--- /dev/null
+++ b/content/renderer/renderer_webidbtransaction_impl.cc
@@ -0,0 +1,74 @@
+// 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 "content/renderer/renderer_webidbtransaction_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "content/common/indexed_db_messages.h"
+#include "content/renderer/indexed_db_dispatcher.h"
+#include "content/renderer/renderer_webidbobjectstore_impl.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+using WebKit::WebIDBObjectStore;
+using WebKit::WebIDBTransactionCallbacks;
+using WebKit::WebString;
+
+RendererWebIDBTransactionImpl::RendererWebIDBTransactionImpl(
+ int32 idb_transaction_id)
+ : idb_transaction_id_(idb_transaction_id) {
+}
+
+RendererWebIDBTransactionImpl::~RendererWebIDBTransactionImpl() {
+ // It's not possible for there to be pending callbacks that address this
+ // object since inside WebKit, they hold a reference to the object wich owns
+ // this object. But, if that ever changed, then we'd need to invalidate
+ // any such pointers.
+ RenderThread::current()->Send(new IndexedDBHostMsg_TransactionDestroyed(
+ idb_transaction_id_));
+}
+
+int RendererWebIDBTransactionImpl::mode() const
+{
+ int mode;
+ RenderThread::current()->Send(new IndexedDBHostMsg_TransactionMode(
+ idb_transaction_id_, &mode));
+ return mode;
+}
+
+WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore(
+ const WebString& name,
+ WebKit::WebExceptionCode& ec)
+{
+ int object_store_id;
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_TransactionObjectStore(
+ idb_transaction_id_, name, &object_store_id, &ec));
+ if (!object_store_id)
+ return NULL;
+ return new RendererWebIDBObjectStoreImpl(object_store_id);
+}
+
+void RendererWebIDBTransactionImpl::abort()
+{
+ RenderThread::current()->Send(new IndexedDBHostMsg_TransactionAbort(
+ idb_transaction_id_));
+}
+
+void RendererWebIDBTransactionImpl::didCompleteTaskEvents()
+{
+ RenderThread::current()->Send(
+ new IndexedDBHostMsg_TransactionDidCompleteTaskEvents(
+ idb_transaction_id_));
+}
+
+void RendererWebIDBTransactionImpl::setCallbacks(
+ WebIDBTransactionCallbacks* callbacks)
+{
+ IndexedDBDispatcher* dispatcher =
+ RenderThread::current()->indexed_db_dispatcher();
+ dispatcher->RegisterWebIDBTransactionCallbacks(callbacks,
+ idb_transaction_id_);
+}
diff --git a/content/renderer/renderer_webidbtransaction_impl.h b/content/renderer/renderer_webidbtransaction_impl.h
new file mode 100644
index 0000000..c7390ee
--- /dev/null
+++ b/content/renderer/renderer_webidbtransaction_impl.h
@@ -0,0 +1,36 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
+
+namespace WebKit {
+class WebIDBObjectStore;
+class WebIDBTransactionCallbacks;
+class WebString;
+}
+
+class RendererWebIDBTransactionImpl : public WebKit::WebIDBTransaction {
+ public:
+ explicit RendererWebIDBTransactionImpl(int32 idb_transaction_id);
+ virtual ~RendererWebIDBTransactionImpl();
+
+ virtual int mode() const;
+ virtual WebKit::WebIDBObjectStore* objectStore(const WebKit::WebString& name,
+ WebKit::WebExceptionCode&);
+ virtual void abort();
+ virtual void didCompleteTaskEvents();
+ virtual void setCallbacks(WebKit::WebIDBTransactionCallbacks*);
+
+ int id() const { return idb_transaction_id_; }
+
+ private:
+ int32 idb_transaction_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_
diff --git a/content/renderer/renderer_webkitclient_impl.cc b/content/renderer/renderer_webkitclient_impl.cc
new file mode 100644
index 0000000..ae37b0d
--- /dev/null
+++ b/content/renderer/renderer_webkitclient_impl.cc
@@ -0,0 +1,571 @@
+// 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 "content/renderer/renderer_webkitclient_impl.h"
+
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/platform_file.h"
+#include "base/shared_memory.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/net/renderer_net_predictor.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+#include "chrome/renderer/visitedlink_slave.h"
+#include "content/common/database_util.h"
+#include "content/common/file_system/webfilesystem_impl.h"
+#include "content/common/file_utilities_messages.h"
+#include "content/common/mime_registry_messages.h"
+#include "content/common/webblobregistry_impl.h"
+#include "content/common/webmessageportchannel_impl.h"
+#include "content/plugin/npobject_util.h"
+#include "content/renderer/renderer_webaudiodevice_impl.h"
+#include "content/renderer/renderer_webidbfactory_impl.h"
+#include "content/renderer/renderer_webstoragenamespace_impl.h"
+#include "content/renderer/webgraphicscontext3d_command_buffer_impl.h"
+#include "content/renderer/websharedworkerrepository_impl.h"
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_sync_message_filter.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebBlobRegistry.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispatcher.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+#include "webkit/glue/simple_webmimeregistry_impl.h"
+#include "webkit/glue/webclipboard_impl.h"
+#include "webkit/glue/webfileutilities_impl.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
+
+#if defined(OS_WIN)
+#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport.h"
+#endif
+
+#if defined(OS_MACOSX)
+#include "content/common/font_descriptor_mac.h"
+#include "content/common/font_loader_mac.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h"
+#endif
+
+#if defined(OS_LINUX)
+#include <string>
+#include <map>
+
+#include "base/synchronization/lock.h"
+#include "content/renderer/renderer_sandbox_support_linux.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
+#endif
+
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
+using WebKit::WebAudioDevice;
+using WebKit::WebBlobRegistry;
+using WebKit::WebFileSystem;
+using WebKit::WebFrame;
+using WebKit::WebIDBFactory;
+using WebKit::WebIDBKey;
+using WebKit::WebIDBKeyPath;
+using WebKit::WebKitClient;
+using WebKit::WebSerializedScriptValue;
+using WebKit::WebStorageArea;
+using WebKit::WebStorageEventDispatcher;
+using WebKit::WebStorageNamespace;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebVector;
+
+//------------------------------------------------------------------------------
+
+class RendererWebKitClientImpl::MimeRegistry
+ : public webkit_glue::SimpleWebMimeRegistryImpl {
+ public:
+ virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&);
+ virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&);
+ virtual WebKit::WebString preferredExtensionForMIMEType(
+ const WebKit::WebString&);
+};
+
+class RendererWebKitClientImpl::FileUtilities
+ : public webkit_glue::WebFileUtilitiesImpl {
+ public:
+ virtual void revealFolderInOS(const WebKit::WebString& path);
+ 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);
+};
+
+class RendererWebKitClientImpl::SandboxSupport
+ : public WebKit::WebSandboxSupport {
+ public:
+#if defined(OS_WIN)
+ virtual bool ensureFontLoaded(HFONT);
+#elif defined(OS_MACOSX)
+ virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out);
+#elif defined(OS_LINUX)
+ virtual WebKit::WebString getFontFamilyForCharacters(
+ const WebKit::WebUChar* characters,
+ size_t numCharacters,
+ const char* preferred_locale);
+ virtual void getRenderStyleForStrike(
+ const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
+
+ private:
+ // WebKit likes to ask us for the correct font family to use for a set of
+ // unicode code points. It needs this information frequently so we cache it
+ // here. The key in this map is an array of 16-bit UTF16 values from WebKit.
+ // The value is a string containing the correct font family.
+ base::Lock unicode_font_families_mutex_;
+ std::map<std::string, std::string> unicode_font_families_;
+#endif
+};
+
+//------------------------------------------------------------------------------
+
+RendererWebKitClientImpl::RendererWebKitClientImpl()
+ : clipboard_(new webkit_glue::WebClipboardImpl),
+ mime_registry_(new RendererWebKitClientImpl::MimeRegistry),
+ sandbox_support_(new RendererWebKitClientImpl::SandboxSupport),
+ sudden_termination_disables_(0),
+ shared_worker_repository_(new WebSharedWorkerRepositoryImpl) {
+}
+
+RendererWebKitClientImpl::~RendererWebKitClientImpl() {
+}
+
+//------------------------------------------------------------------------------
+
+WebKit::WebClipboard* RendererWebKitClientImpl::clipboard() {
+ return clipboard_.get();
+}
+
+WebKit::WebMimeRegistry* RendererWebKitClientImpl::mimeRegistry() {
+ return mime_registry_.get();
+}
+
+WebKit::WebFileUtilities* RendererWebKitClientImpl::fileUtilities() {
+ if (!file_utilities_.get()) {
+ file_utilities_.reset(new FileUtilities);
+ file_utilities_->set_sandbox_enabled(sandboxEnabled());
+ }
+ return file_utilities_.get();
+}
+
+WebKit::WebSandboxSupport* RendererWebKitClientImpl::sandboxSupport() {
+ return sandbox_support_.get();
+}
+
+WebKit::WebCookieJar* RendererWebKitClientImpl::cookieJar() {
+ NOTREACHED() << "Use WebFrameClient::cookieJar() instead!";
+ return NULL;
+}
+
+bool RendererWebKitClientImpl::sandboxEnabled() {
+ // As explained in WebKitClient.h, this function is used to decide whether to
+ // allow file system operations to come out of WebKit or not. Even if the
+ // sandbox is disabled, there's no reason why the code should act any
+ // differently...unless we're in single process mode. In which case, we have
+ // no other choice. WebKitClient.h discourages using this switch unless
+ // absolutely necessary, so hopefully we won't end up with too many code paths
+ // being different in single-process mode.
+ return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
+}
+
+bool RendererWebKitClientImpl::SendSyncMessageFromAnyThread(
+ IPC::SyncMessage* msg) {
+ RenderThread* render_thread = RenderThread::current();
+ if (render_thread)
+ return render_thread->Send(msg);
+
+ scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter(
+ ChildThread::current()->sync_message_filter());
+ return sync_msg_filter->Send(msg);
+}
+
+unsigned long long RendererWebKitClientImpl::visitedLinkHash(
+ const char* canonical_url,
+ size_t length) {
+ return RenderThread::current()->visited_link_slave()->ComputeURLFingerprint(
+ canonical_url, length);
+}
+
+bool RendererWebKitClientImpl::isLinkVisited(unsigned long long link_hash) {
+ return RenderThread::current()->visited_link_slave()->IsVisited(link_hash);
+}
+
+WebKit::WebMessagePortChannel*
+RendererWebKitClientImpl::createMessagePortChannel() {
+ return new WebMessagePortChannelImpl();
+}
+
+void RendererWebKitClientImpl::prefetchHostName(const WebString& hostname) {
+ if (!hostname.isEmpty()) {
+ std::string hostname_utf8;
+ UTF16ToUTF8(hostname.data(), hostname.length(), &hostname_utf8);
+ DnsPrefetchCString(hostname_utf8.data(), hostname_utf8.length());
+ }
+}
+
+bool RendererWebKitClientImpl::CheckPreparsedJsCachingEnabled() const {
+ static bool checked = false;
+ static bool result = false;
+ if (!checked) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching);
+ checked = true;
+ }
+ return result;
+}
+
+void RendererWebKitClientImpl::cacheMetadata(
+ const WebKit::WebURL& url,
+ double response_time,
+ const char* data,
+ size_t size) {
+ if (!CheckPreparsedJsCachingEnabled())
+ return;
+
+ // Let the browser know we generated cacheable metadata for this resource. The
+ // browser may cache it and return it on subsequent responses to speed
+ // the processing of this resource.
+ std::vector<char> copy(data, data + size);
+ RenderThread::current()->Send(new ViewHostMsg_DidGenerateCacheableMetadata(
+ url, response_time, copy));
+}
+
+WebString RendererWebKitClientImpl::defaultLocale() {
+ // TODO(darin): Eliminate this webkit_glue call.
+ return ASCIIToUTF16(webkit_glue::GetWebKitLocale());
+}
+
+void RendererWebKitClientImpl::suddenTerminationChanged(bool enabled) {
+ if (enabled) {
+ // We should not get more enables than disables, but we want it to be a
+ // non-fatal error if it does happen.
+ DCHECK_GT(sudden_termination_disables_, 0);
+ sudden_termination_disables_ = std::max(sudden_termination_disables_ - 1,
+ 0);
+ if (sudden_termination_disables_ != 0)
+ return;
+ } else {
+ sudden_termination_disables_++;
+ if (sudden_termination_disables_ != 1)
+ return;
+ }
+
+ RenderThread* thread = RenderThread::current();
+ if (thread) // NULL in unittests.
+ thread->Send(new ViewHostMsg_SuddenTerminationChanged(enabled));
+}
+
+WebStorageNamespace* RendererWebKitClientImpl::createLocalStorageNamespace(
+ const WebString& path, unsigned quota) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
+ return WebStorageNamespace::createLocalStorageNamespace(path, quota);
+ return new RendererWebStorageNamespaceImpl(DOM_STORAGE_LOCAL);
+}
+
+void RendererWebKitClientImpl::dispatchStorageEvent(
+ const WebString& key, const WebString& old_value,
+ const WebString& new_value, const WebString& origin,
+ const WebKit::WebURL& url, bool is_local_storage) {
+ DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
+ // Inefficient, but only used in single process mode.
+ scoped_ptr<WebStorageEventDispatcher> event_dispatcher(
+ WebStorageEventDispatcher::create());
+ event_dispatcher->dispatchStorageEvent(key, old_value, new_value, origin,
+ url, is_local_storage);
+}
+
+//------------------------------------------------------------------------------
+
+WebIDBFactory* RendererWebKitClientImpl::idbFactory() {
+ if (!web_idb_factory_.get()) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
+ web_idb_factory_.reset(WebIDBFactory::create());
+ else
+ web_idb_factory_.reset(new RendererWebIDBFactoryImpl());
+ }
+ return web_idb_factory_.get();
+}
+
+void RendererWebKitClientImpl::createIDBKeysFromSerializedValuesAndKeyPath(
+ const WebVector<WebSerializedScriptValue>& values,
+ const WebString& keyPath,
+ WebVector<WebIDBKey>& keys_out) {
+ DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
+ WebVector<WebIDBKey> keys(values.size());
+ for (size_t i = 0; i < values.size(); ++i) {
+ keys[i] = WebIDBKey::createFromValueAndKeyPath(
+ values[i], WebIDBKeyPath::create(keyPath));
+ }
+ keys_out.swap(keys);
+}
+
+WebSerializedScriptValue
+RendererWebKitClientImpl::injectIDBKeyIntoSerializedValue(const WebIDBKey& key,
+ const WebSerializedScriptValue& value,
+ const WebString& keyPath) {
+ DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
+ return WebIDBKey::injectIDBKeyIntoSerializedValue(
+ key, value, WebIDBKeyPath::create(keyPath));
+}
+
+//------------------------------------------------------------------------------
+
+WebFileSystem* RendererWebKitClientImpl::fileSystem() {
+ if (!web_file_system_.get())
+ web_file_system_.reset(new WebFileSystemImpl());
+ return web_file_system_.get();
+}
+
+//------------------------------------------------------------------------------
+
+WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension(
+ const WebString& file_extension) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::mimeTypeForExtension(file_extension);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ std::string mime_type;
+ RenderThread::current()->Send(
+ new MimeRegistryMsg_GetMimeTypeFromExtension(
+ webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
+ return ASCIIToUTF16(mime_type);
+
+}
+
+WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile(
+ const WebString& file_path) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::mimeTypeFromFile(file_path);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ std::string mime_type;
+ RenderThread::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile(
+ FilePath(webkit_glue::WebStringToFilePathString(file_path)),
+ &mime_type));
+ return ASCIIToUTF16(mime_type);
+
+}
+
+WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType(
+ const WebString& mime_type) {
+ if (IsPluginProcess())
+ return SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(mime_type);
+
+ // The sandbox restricts our access to the registry, so we need to proxy
+ // these calls over to the browser process.
+ FilePath::StringType file_extension;
+ RenderThread::current()->Send(
+ new MimeRegistryMsg_GetPreferredExtensionForMimeType(
+ UTF16ToASCII(mime_type), &file_extension));
+ return webkit_glue::FilePathStringToWebString(file_extension);
+}
+
+//------------------------------------------------------------------------------
+
+bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path,
+ long long& result) {
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize(
+ webkit_glue::WebStringToFilePath(path),
+ reinterpret_cast<int64*>(&result)))) {
+ return result >= 0;
+ }
+
+ result = -1;
+ return false;
+}
+
+void RendererWebKitClientImpl::FileUtilities::revealFolderInOS(
+ const WebString& path) {
+ FilePath file_path(webkit_glue::WebStringToFilePath(path));
+ file_util::AbsolutePath(&file_path);
+ RenderThread::current()->Send(new ViewHostMsg_RevealFolderInOS(file_path));
+}
+
+bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime(
+ const WebString& path,
+ double& result) {
+ base::Time time;
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime(
+ webkit_glue::WebStringToFilePath(path), &time))) {
+ result = time.ToDoubleT();
+ return !time.is_null();
+ }
+
+ result = 0;
+ return false;
+}
+
+base::PlatformFile RendererWebKitClientImpl::FileUtilities::openFile(
+ const WebString& path,
+ int mode) {
+ IPC::PlatformFileForTransit handle = IPC::InvalidPlatformFileForTransit();
+ SendSyncMessageFromAnyThread(new FileUtilitiesMsg_OpenFile(
+ webkit_glue::WebStringToFilePath(path), mode, &handle));
+ return IPC::PlatformFileForTransitToPlatformFile(handle);
+}
+
+//------------------------------------------------------------------------------
+
+#if defined(OS_WIN)
+
+bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
+ LOGFONT logfont;
+ GetObject(font, sizeof(LOGFONT), &logfont);
+ return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont));
+}
+
+#elif defined(OS_LINUX)
+
+WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
+ const WebKit::WebUChar* characters,
+ size_t num_characters,
+ const char* preferred_locale) {
+ base::AutoLock lock(unicode_font_families_mutex_);
+ const std::string key(reinterpret_cast<const char*>(characters),
+ num_characters * sizeof(characters[0]));
+ const std::map<std::string, std::string>::const_iterator iter =
+ unicode_font_families_.find(key);
+ if (iter != unicode_font_families_.end())
+ return WebString::fromUTF8(iter->second);
+
+ const std::string family_name =
+ renderer_sandbox_support::getFontFamilyForCharacters(characters,
+ num_characters,
+ preferred_locale);
+ unicode_font_families_.insert(make_pair(key, family_name));
+ return WebString::fromUTF8(family_name);
+}
+
+void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
+ const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
+ renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out);
+}
+
+#elif defined(OS_MACOSX)
+
+bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont,
+ ATSFontContainerRef* out) {
+ DCHECK(srcFont);
+ DCHECK(out);
+
+ uint32 font_data_size;
+ FontDescriptor src_font_descriptor(srcFont);
+ base::SharedMemoryHandle font_data;
+ if (!RenderThread::current()->Send(new ViewHostMsg_LoadFont(
+ src_font_descriptor, &font_data_size, &font_data))) {
+ LOG(ERROR) << "Sending ViewHostMsg_LoadFont() IPC failed for " <<
+ src_font_descriptor.font_name;
+ *out = kATSFontContainerRefUnspecified;
+ return false;
+ }
+
+ if (font_data_size == 0 || font_data == base::SharedMemory::NULLHandle()) {
+ LOG(ERROR) << "Bad response from ViewHostMsg_LoadFont() for " <<
+ src_font_descriptor.font_name;
+ *out = kATSFontContainerRefUnspecified;
+ return false;
+ }
+
+ return FontLoader::ATSFontContainerFromBuffer(font_data, font_data_size, out);
+}
+
+#endif
+
+//------------------------------------------------------------------------------
+
+WebKitClient::FileHandle RendererWebKitClientImpl::databaseOpenFile(
+ const WebString& vfs_file_name, int desired_flags) {
+ return DatabaseUtil::databaseOpenFile(vfs_file_name, desired_flags);
+}
+
+int RendererWebKitClientImpl::databaseDeleteFile(
+ const WebString& vfs_file_name, bool sync_dir) {
+ return DatabaseUtil::databaseDeleteFile(vfs_file_name, sync_dir);
+}
+
+long RendererWebKitClientImpl::databaseGetFileAttributes(
+ const WebString& vfs_file_name) {
+ return DatabaseUtil::databaseGetFileAttributes(vfs_file_name);
+}
+
+long long RendererWebKitClientImpl::databaseGetFileSize(
+ const WebString& vfs_file_name) {
+ return DatabaseUtil::databaseGetFileSize(vfs_file_name);
+}
+
+WebKit::WebSharedWorkerRepository*
+RendererWebKitClientImpl::sharedWorkerRepository() {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableSharedWorkers)) {
+ return shared_worker_repository_.get();
+ } else {
+ return NULL;
+ }
+}
+
+WebKit::WebGraphicsContext3D*
+RendererWebKitClientImpl::createGraphicsContext3D() {
+ // The WebGraphicsContext3DInProcessImpl code path is used for
+ // layout tests (though not through this code) as well as for
+ // debugging and bringing up new ports.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
+ return new webkit::gpu::WebGraphicsContext3DInProcessImpl();
+ } else {
+#if defined(ENABLE_GPU)
+ return new WebGraphicsContext3DCommandBufferImpl();
+#else
+ return NULL;
+#endif
+ }
+}
+
+WebAudioDevice*
+RendererWebKitClientImpl::createAudioDevice(
+ size_t buffer_size,
+ unsigned channels,
+ double sample_rate,
+ WebAudioDevice::RenderCallback* callback) {
+ return new RendererWebAudioDeviceImpl(buffer_size,
+ channels,
+ sample_rate,
+ callback);
+}
+
+//------------------------------------------------------------------------------
+
+WebKit::WebString RendererWebKitClientImpl::signedPublicKeyAndChallengeString(
+ unsigned key_size_index,
+ const WebKit::WebString& challenge,
+ const WebKit::WebURL& url) {
+ std::string signed_public_key;
+ RenderThread::current()->Send(new ViewHostMsg_Keygen(
+ static_cast<uint32>(key_size_index),
+ challenge.utf8(),
+ GURL(url),
+ &signed_public_key));
+ return WebString::fromUTF8(signed_public_key);
+}
+
+//------------------------------------------------------------------------------
+
+WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() {
+ if (!blob_registry_.get())
+ blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current()));
+ return blob_registry_.get();
+}
diff --git a/content/renderer/renderer_webkitclient_impl.h b/content/renderer/renderer_webkitclient_impl.h
new file mode 100644
index 0000000..41ea45e
--- /dev/null
+++ b/content/renderer/renderer_webkitclient_impl.h
@@ -0,0 +1,117 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBKITCLIENT_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBKITCLIENT_IMPL_H_
+#pragma once
+
+#include "base/platform_file.h"
+#include "base/scoped_ptr.h"
+#include "webkit/glue/webkitclient_impl.h"
+
+class WebSharedWorkerRepositoryImpl;
+class WebFileSystemImpl;
+
+namespace IPC {
+class SyncMessage;
+}
+
+namespace webkit_glue {
+class WebClipboardImpl;
+}
+
+class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
+ public:
+ RendererWebKitClientImpl();
+ virtual ~RendererWebKitClientImpl();
+
+ // WebKitClient methods:
+ virtual WebKit::WebClipboard* clipboard();
+ virtual WebKit::WebMimeRegistry* mimeRegistry();
+ virtual WebKit::WebFileUtilities* fileUtilities();
+ virtual WebKit::WebSandboxSupport* sandboxSupport();
+ virtual WebKit::WebCookieJar* cookieJar();
+ virtual bool sandboxEnabled();
+ virtual unsigned long long visitedLinkHash(
+ const char* canonicalURL, size_t length);
+ virtual bool isLinkVisited(unsigned long long linkHash);
+ virtual WebKit::WebMessagePortChannel* createMessagePortChannel();
+ virtual void prefetchHostName(const WebKit::WebString&);
+ virtual void cacheMetadata(
+ const WebKit::WebURL&, double, const char*, size_t);
+ virtual WebKit::WebString defaultLocale();
+ virtual void suddenTerminationChanged(bool enabled);
+ virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
+ const WebKit::WebString& path, unsigned quota);
+ virtual void dispatchStorageEvent(
+ const WebKit::WebString& key, const WebKit::WebString& old_value,
+ const WebKit::WebString& new_value, const WebKit::WebString& origin,
+ const WebKit::WebURL& url, bool is_local_storage);
+
+ virtual WebKit::WebKitClient::FileHandle databaseOpenFile(
+ const WebKit::WebString& vfs_file_name, int desired_flags);
+ virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name,
+ bool sync_dir);
+ virtual long databaseGetFileAttributes(
+ const WebKit::WebString& vfs_file_name);
+ virtual long long databaseGetFileSize(
+ const WebKit::WebString& vfs_file_name);
+ virtual WebKit::WebString signedPublicKeyAndChallengeString(
+ unsigned key_size_index,
+ const WebKit::WebString& challenge,
+ const WebKit::WebURL& url);
+ virtual WebKit::WebIDBFactory* idbFactory();
+ virtual void createIDBKeysFromSerializedValuesAndKeyPath(
+ const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
+ const WebKit::WebString& keyPath,
+ WebKit::WebVector<WebKit::WebIDBKey>& keys);
+ virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath);
+ virtual WebKit::WebFileSystem* fileSystem();
+
+ virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
+ virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D();
+ virtual WebKit::WebAudioDevice* createAudioDevice(
+ size_t buffer_size, unsigned channels, double sample_rate,
+ WebKit::WebAudioDevice::RenderCallback* callback);
+
+ virtual WebKit::WebBlobRegistry* blobRegistry();
+
+ private:
+ bool CheckPreparsedJsCachingEnabled() const;
+
+ // Helper function to send synchronous message from any thread.
+ static bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg);
+
+ scoped_ptr<webkit_glue::WebClipboardImpl> clipboard_;
+
+ class FileUtilities;
+ scoped_ptr<FileUtilities> file_utilities_;
+
+ class MimeRegistry;
+ scoped_ptr<MimeRegistry> mime_registry_;
+
+ class SandboxSupport;
+ scoped_ptr<SandboxSupport> sandbox_support_;
+
+ // This counter keeps track of the number of times sudden termination is
+ // enabled or disabled. It starts at 0 (enabled) and for every disable
+ // increments by 1, for every enable decrements by 1. When it reaches 0,
+ // we tell the browser to enable fast termination.
+ int sudden_termination_disables_;
+
+ // Implementation of the WebSharedWorkerRepository APIs (provides an interface
+ // to WorkerService on the browser thread.
+ scoped_ptr<WebSharedWorkerRepositoryImpl> shared_worker_repository_;
+
+ scoped_ptr<WebKit::WebIDBFactory> web_idb_factory_;
+
+ scoped_ptr<WebFileSystemImpl> web_file_system_;
+
+ scoped_ptr<WebKit::WebBlobRegistry> blob_registry_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBKITCLIENT_IMPL_H_
diff --git a/content/renderer/renderer_webstoragearea_impl.cc b/content/renderer/renderer_webstoragearea_impl.cc
new file mode 100644
index 0000000..07d225c
--- /dev/null
+++ b/content/renderer/renderer_webstoragearea_impl.cc
@@ -0,0 +1,83 @@
+// 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 "content/renderer/renderer_webstoragearea_impl.h"
+
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+#include "content/common/dom_storage_messages.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+using WebKit::WebFrame;
+using WebKit::WebString;
+using WebKit::WebURL;
+using WebKit::WebView;
+
+RendererWebStorageAreaImpl::RendererWebStorageAreaImpl(
+ int64 namespace_id, const WebString& origin) {
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_StorageAreaId(namespace_id, origin,
+ &storage_area_id_));
+}
+
+RendererWebStorageAreaImpl::~RendererWebStorageAreaImpl() {
+}
+
+unsigned RendererWebStorageAreaImpl::length() {
+ unsigned length;
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_Length(storage_area_id_, &length));
+ return length;
+}
+
+WebString RendererWebStorageAreaImpl::key(unsigned index) {
+ NullableString16 key;
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_Key(storage_area_id_, index, &key));
+ return key;
+}
+
+WebString RendererWebStorageAreaImpl::getItem(const WebString& key) {
+ NullableString16 value;
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_GetItem(storage_area_id_, key, &value));
+ return value;
+}
+
+void RendererWebStorageAreaImpl::setItem(
+ const WebString& key, const WebString& value, const WebURL& url,
+ WebStorageArea::Result& result, WebString& old_value_webkit,
+ WebFrame* web_frame) {
+ int32 render_view_id = MSG_ROUTING_CONTROL;
+ if (web_frame) {
+ RenderView* render_view = RenderView::FromWebView(web_frame->view());
+ if (render_view)
+ render_view_id = render_view->routing_id();
+ }
+ DCHECK(render_view_id != MSG_ROUTING_CONTROL);
+
+ NullableString16 old_value;
+ IPC::SyncMessage* message =
+ new DOMStorageHostMsg_SetItem(render_view_id, storage_area_id_, key,
+ value, url, &result, &old_value);
+ // NOTE: This may pump events (see RenderThread::Send).
+ RenderThread::current()->Send(message);
+ old_value_webkit = old_value;
+}
+
+void RendererWebStorageAreaImpl::removeItem(
+ const WebString& key, const WebURL& url, WebString& old_value_webkit) {
+ NullableString16 old_value;
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_RemoveItem(storage_area_id_, key, url, &old_value));
+ old_value_webkit = old_value;
+}
+
+void RendererWebStorageAreaImpl::clear(
+ const WebURL& url, bool& cleared_something) {
+ RenderThread::current()->Send(
+ new DOMStorageHostMsg_Clear(storage_area_id_, url, &cleared_something));
+}
diff --git a/content/renderer/renderer_webstoragearea_impl.h b/content/renderer/renderer_webstoragearea_impl.h
new file mode 100644
index 0000000..dba539e
--- /dev/null
+++ b/content/renderer/renderer_webstoragearea_impl.h
@@ -0,0 +1,37 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBSTORAGEAREA_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBSTORAGEAREA_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+class RendererWebStorageAreaImpl : public WebKit::WebStorageArea {
+ public:
+ RendererWebStorageAreaImpl(int64 namespace_id,
+ const WebKit::WebString& origin);
+ virtual ~RendererWebStorageAreaImpl();
+
+ // See WebStorageArea.h for documentation on these functions.
+ virtual unsigned length();
+ virtual WebKit::WebString key(unsigned index);
+ virtual WebKit::WebString getItem(const WebKit::WebString& key);
+ virtual void setItem(
+ const WebKit::WebString& key, const WebKit::WebString& value,
+ const WebKit::WebURL& url, WebStorageArea::Result& result,
+ WebKit::WebString& old_value, WebKit::WebFrame* web_view);
+ virtual void removeItem(
+ const WebKit::WebString& key, const WebKit::WebURL& url,
+ WebKit::WebString& old_value);
+ virtual void clear(const WebKit::WebURL& url, bool& cleared_something);
+
+ private:
+ // The ID we use for all IPC.
+ int64 storage_area_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBSTORAGEAREA_IMPL_H_
diff --git a/content/renderer/renderer_webstoragenamespace_impl.cc b/content/renderer/renderer_webstoragenamespace_impl.cc
new file mode 100644
index 0000000..5edfa39
--- /dev/null
+++ b/content/renderer/renderer_webstoragenamespace_impl.cc
@@ -0,0 +1,52 @@
+// 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 "content/renderer/renderer_webstoragenamespace_impl.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "content/renderer/renderer_webstoragearea_impl.h"
+
+using WebKit::WebStorageArea;
+using WebKit::WebStorageNamespace;
+using WebKit::WebString;
+
+RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
+ DOMStorageType storage_type)
+ : storage_type_(storage_type),
+ namespace_id_(kLocalStorageNamespaceId) {
+ DCHECK(storage_type == DOM_STORAGE_LOCAL);
+}
+
+RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
+ DOMStorageType storage_type, int64 namespace_id)
+ : storage_type_(storage_type),
+ namespace_id_(namespace_id) {
+ DCHECK(storage_type == DOM_STORAGE_SESSION);
+}
+
+RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() {
+}
+
+WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea(
+ const WebString& origin) {
+ // Ideally, we'd keep a hash map of origin to these objects. Unfortunately
+ // this doesn't seem practical because there's no good way to ref-count these
+ // objects, and it'd be unclear who owned them. So, instead, we'll pay the
+ // price in terms of wasted memory.
+ return new RendererWebStorageAreaImpl(namespace_id_, origin);
+}
+
+WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() {
+ // By returning NULL, we're telling WebKit to lazily fetch it the next time
+ // session storage is used. In the WebViewClient::createView, we do the
+ // book-keeping necessary to make it a true copy-on-write despite not doing
+ // anything here, now.
+ return NULL;
+}
+
+void RendererWebStorageNamespaceImpl::close() {
+ // This is called only on LocalStorage namespaces when WebKit thinks its
+ // shutting down. This has no impact on Chromium.
+}
diff --git a/content/renderer/renderer_webstoragenamespace_impl.h b/content/renderer/renderer_webstoragenamespace_impl.h
new file mode 100644
index 0000000..7b938c8
--- /dev/null
+++ b/content/renderer/renderer_webstoragenamespace_impl.h
@@ -0,0 +1,34 @@
+// 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 CONTENT_RENDERER_RENDERER_WEBSTORAGENAMESPACE_IMPL_H_
+#define CONTENT_RENDERER_RENDERER_WEBSTORAGENAMESPACE_IMPL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "content/common/dom_storage_common.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h"
+
+class RendererWebStorageNamespaceImpl : public WebKit::WebStorageNamespace {
+ public:
+ explicit RendererWebStorageNamespaceImpl(DOMStorageType storage_type);
+ RendererWebStorageNamespaceImpl(DOMStorageType storage_type,
+ int64 namespace_id);
+
+ // See WebStorageNamespace.h for documentation on these functions.
+ virtual ~RendererWebStorageNamespaceImpl();
+ virtual WebKit::WebStorageArea* createStorageArea(
+ const WebKit::WebString& origin);
+ virtual WebKit::WebStorageNamespace* copy();
+ virtual void close();
+
+ private:
+ // Used during lazy initialization of namespace_id_.
+ const DOMStorageType storage_type_;
+
+ // Our namespace ID.
+ int64 namespace_id_;
+};
+
+#endif // CONTENT_RENDERER_RENDERER_WEBSTORAGENAMESPACE_IMPL_H_