summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 03:48:52 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 03:48:52 +0000
commit0de5d8609abf9961228c2a12031fc5354688345a (patch)
treee11e8fc9ac695dc41f999a62b88e95e3b6d780d8 /webkit/tools
parent66d22164c2aded1403643b52a9763f492acbbdcc (diff)
downloadchromium_src-0de5d8609abf9961228c2a12031fc5354688345a.zip
chromium_src-0de5d8609abf9961228c2a12031fc5354688345a.tar.gz
chromium_src-0de5d8609abf9961228c2a12031fc5354688345a.tar.bz2
Move clipboard-related webkit_glue embedder functions into a ClipboardClient interface.
This moves the functions into a pattern that is component-friendly. BUG=98755 TEST=Chrome, DRT, test_shell Review URL: http://codereview.chromium.org/8591030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/simple_clipboard_impl.cc72
-rw-r--r--webkit/tools/test_shell/simple_clipboard_impl.h32
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.cc3
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h2
4 files changed, 76 insertions, 33 deletions
diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc
index 2b4219f..0b137f1c 100644
--- a/webkit/tools/test_shell/simple_clipboard_impl.cc
+++ b/webkit/tools/test_shell/simple_clipboard_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/glue/webkit_glue.h"
+#include "webkit/tools/test_shell/simple_clipboard_impl.h"
#include <string>
@@ -15,62 +15,66 @@
#include "ui/base/clipboard/clipboard.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/size.h"
-#include "webkit/glue/scoped_clipboard_writer_glue.h"
+#include "webkit/glue/webkit_glue.h"
-// Clipboard glue
+namespace {
-void ScopedClipboardWriterGlue::WriteBitmapFromPixels(
- const void* pixels, const gfx::Size& size) {
- ScopedClipboardWriter::WriteBitmapFromPixels(pixels, size);
-}
+base::LazyInstance<ui::Clipboard> clipboard = LAZY_INSTANCE_INITIALIZER;
+
+} // anonymous namespace
-ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
+SimpleClipboardClient::SimpleClipboardClient() {
}
-namespace webkit_glue {
+SimpleClipboardClient::~SimpleClipboardClient() {
+}
-base::LazyInstance<ui::Clipboard> clipboard = LAZY_INSTANCE_INITIALIZER;
-ui::Clipboard* ClipboardGetClipboard() {
+ui::Clipboard* SimpleClipboardClient::GetClipboard() {
return clipboard.Pointer();
}
-uint64 ClipboardGetSequenceNumber(ui::Clipboard::Buffer buffer) {
- return ClipboardGetClipboard()->GetSequenceNumber(buffer);
+uint64 SimpleClipboardClient::GetSequenceNumber(ui::Clipboard::Buffer buffer) {
+ return GetClipboard()->GetSequenceNumber(buffer);
}
-bool ClipboardIsFormatAvailable(const ui::Clipboard::FormatType& format,
- ui::Clipboard::Buffer buffer) {
- return ClipboardGetClipboard()->IsFormatAvailable(format, buffer);
+bool SimpleClipboardClient::IsFormatAvailable(
+ const ui::Clipboard::FormatType& format,
+ ui::Clipboard::Buffer buffer) {
+ return GetClipboard()->IsFormatAvailable(format, buffer);
}
-void ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
- std::vector<string16>* types,
- bool* contains_filenames) {
- return ClipboardGetClipboard()->ReadAvailableTypes(buffer, types,
+void SimpleClipboardClient::ReadAvailableTypes(ui::Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ return GetClipboard()->ReadAvailableTypes(buffer, types,
contains_filenames);
}
-void ClipboardReadText(ui::Clipboard::Buffer buffer, string16* result) {
- ClipboardGetClipboard()->ReadText(buffer, result);
+void SimpleClipboardClient::ReadText(ui::Clipboard::Buffer buffer,
+ string16* result) {
+ GetClipboard()->ReadText(buffer, result);
}
-void ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result) {
- ClipboardGetClipboard()->ReadAsciiText(buffer, result);
+void SimpleClipboardClient::ReadAsciiText(ui::Clipboard::Buffer buffer,
+ std::string* result) {
+ GetClipboard()->ReadAsciiText(buffer, result);
}
-void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup,
- GURL* url, uint32* fragment_start,
- uint32* fragment_end) {
+void SimpleClipboardClient::ReadHTML(ui::Clipboard::Buffer buffer,
+ string16* markup,
+ GURL* url, uint32* fragment_start,
+ uint32* fragment_end) {
std::string url_str;
- ClipboardGetClipboard()->ReadHTML(buffer, markup, url ? &url_str : NULL,
- fragment_start, fragment_end);
+ GetClipboard()->ReadHTML(buffer, markup, url ? &url_str : NULL,
+ fragment_start, fragment_end);
if (url)
*url = GURL(url_str);
}
-void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data) {
- SkBitmap bitmap = ClipboardGetClipboard()->ReadImage(buffer);
+void SimpleClipboardClient::ReadImage(ui::Clipboard::Buffer buffer,
+ std::string* data) {
+ SkBitmap bitmap = GetClipboard()->ReadImage(buffer);
if (bitmap.isNull())
return;
@@ -90,4 +94,8 @@ void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data) {
}
}
-} // namespace webkit_glue
+webkit_glue::ClipboardClient::WriteContext*
+SimpleClipboardClient::CreateWriteContext() {
+ return NULL;
+}
+
diff --git a/webkit/tools/test_shell/simple_clipboard_impl.h b/webkit/tools/test_shell/simple_clipboard_impl.h
new file mode 100644
index 0000000..306e3d0
--- /dev/null
+++ b/webkit/tools/test_shell/simple_clipboard_impl.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_CLIPBOARD_IMPL_H_
+#define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_CLIPBOARD_IMPL_H_
+
+#include "webkit/glue/clipboard_client.h"
+
+class SimpleClipboardClient : public webkit_glue::ClipboardClient {
+ public:
+ SimpleClipboardClient();
+ virtual ~SimpleClipboardClient();
+
+ virtual ui::Clipboard* GetClipboard();
+ virtual uint64 GetSequenceNumber(ui::Clipboard::Buffer buffer);
+ virtual bool IsFormatAvailable(const ui::Clipboard::FormatType& format,
+ ui::Clipboard::Buffer buffer);
+ virtual void ReadAvailableTypes(ui::Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames);
+ virtual void ReadText(ui::Clipboard::Buffer buffer, string16* result);
+ virtual void ReadAsciiText(ui::Clipboard::Buffer buffer,
+ std::string* result);
+ virtual void ReadHTML(ui::Clipboard::Buffer buffer, string16* markup,
+ GURL* url, uint32* fragment_start,
+ uint32* fragment_end);
+ virtual void ReadImage(ui::Clipboard::Buffer buffer, std::string* data);
+ virtual WriteContext* CreateWriteContext();
+};
+
+#endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_CLIPBOARD_IMPL_H_
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc
index 3c28089..ca945d5 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.cc
+++ b/webkit/tools/test_shell/test_shell_webkit_init.cc
@@ -21,7 +21,8 @@
#include "webkit/tools/test_shell/test_shell_webthemeengine.h"
#endif
-TestShellWebKitInit::TestShellWebKitInit(bool layout_test_mode) {
+TestShellWebKitInit::TestShellWebKitInit(bool layout_test_mode)
+ : real_clipboard_(&clipboard_client_) {
v8::V8::SetCounterFunction(base::StatsTable::FindLocation);
WebKit::initialize(this);
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 2cf1209..4063b94 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -19,6 +19,7 @@
#include "webkit/support/simple_database_system.h"
#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
#include "webkit/tools/test_shell/simple_appcache_system.h"
+#include "webkit/tools/test_shell/simple_clipboard_impl.h"
#include "webkit/tools/test_shell/simple_file_system.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
@@ -107,6 +108,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
private:
scoped_ptr<webkit_glue::SimpleWebMimeRegistryImpl> mime_registry_;
MockWebClipboardImpl mock_clipboard_;
+ SimpleClipboardClient clipboard_client_;
webkit_glue::WebClipboardImpl real_clipboard_;
webkit_glue::WebFileUtilitiesImpl file_utilities_;
ScopedTempDir appcache_dir_;