summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/base/clipboard/clipboard.cc38
-rw-r--r--ui/base/clipboard/clipboard.h19
-rw-r--r--ui/base/clipboard/clipboard_unittest.cc263
-rw-r--r--ui/views/controls/message_box_view.cc6
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc5
-rw-r--r--ui/views/controls/textfield/native_textfield_views_unittest.cc7
-rw-r--r--ui/views/controls/textfield/native_textfield_win.cc9
-rw-r--r--ui/views/controls/textfield/textfield_views_model.cc7
-rw-r--r--ui/views/controls/textfield/textfield_views_model_unittest.cc3
-rw-r--r--ui/views/test/test_views_delegate.cc9
-rw-r--r--ui/views/test/test_views_delegate.h2
-rw-r--r--ui/views/view_unittest.cc16
-rw-r--r--ui/views/views_delegate.h7
13 files changed, 187 insertions, 204 deletions
diff --git a/ui/base/clipboard/clipboard.cc b/ui/base/clipboard/clipboard.cc
index d20d854..b793f6e 100644
--- a/ui/base/clipboard/clipboard.cc
+++ b/ui/base/clipboard/clipboard.cc
@@ -4,8 +4,10 @@
#include "ui/base/clipboard/clipboard.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "ui/gfx/size.h"
namespace ui {
@@ -72,6 +74,15 @@ bool ValidateAndMapSharedBitmap(const Clipboard::ObjectMapParams& params,
return true;
}
+// Mapping from threads to clipboard objects.
+typedef std::map<base::PlatformThreadId, Clipboard*> ClipboardMap;
+static base::LazyInstance<ClipboardMap> g_clipboard_map =
+ LAZY_INSTANCE_INITIALIZER;
+
+// Mutex that controls access to |g_clipboard_map|.
+static base::LazyInstance<base::Lock>::Leaky
+ g_clipboard_map_lock = LAZY_INSTANCE_INITIALIZER;
+
} // namespace
const char Clipboard::kMimeTypeText[] = "text/plain";
@@ -81,6 +92,33 @@ const char Clipboard::kMimeTypeHTML[] = "text/html";
const char Clipboard::kMimeTypeRTF[] = "text/rtf";
const char Clipboard::kMimeTypePNG[] = "image/png";
+// static
+Clipboard* Clipboard::GetForCurrentThread() {
+ base::AutoLock lock(g_clipboard_map_lock.Get());
+
+ base::PlatformThreadId id = base::PlatformThread::CurrentId();
+ ClipboardMap* clipboard_map = g_clipboard_map.Pointer();
+ ClipboardMap::iterator it = clipboard_map->find(id);
+ if (it != clipboard_map->end())
+ return it->second;
+
+ Clipboard* clipboard = new ui::Clipboard;
+ clipboard_map->insert(std::make_pair(id, clipboard));
+ return clipboard;
+}
+
+void Clipboard::DestroyClipboardForCurrentThread() {
+ base::AutoLock lock(g_clipboard_map_lock.Get());
+
+ ClipboardMap* clipboard_map = g_clipboard_map.Pointer();
+ base::PlatformThreadId id = base::PlatformThread::CurrentId();
+ ClipboardMap::iterator it = clipboard_map->find(id);
+ if (it != clipboard_map->end()) {
+ delete it->second;
+ clipboard_map->erase(it);
+ }
+}
+
void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
// All types apart from CBF_WEBKIT need at least 1 non-empty param.
if (type != CBF_WEBKIT && (params.empty() || params[0].empty()))
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
index b98cfc4..82cdb91 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -46,6 +46,7 @@ class NSString;
#endif
namespace ui {
+class ClipboardTest;
class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
public:
@@ -182,8 +183,18 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
return static_cast<Buffer>(buffer);
}
- Clipboard();
- ~Clipboard();
+ // Returns the clipboard object for the current thread.
+ //
+ // Most implementations will have at most one clipboard which will live on
+ // the main UI thread, but Windows has tricky semantics where there have to
+ // be two clipboards: one that lives on the UI thread and one that lives on
+ // the IO thread.
+ static Clipboard* GetForCurrentThread();
+
+ // Destroys the clipboard for the current thread. Usually, this will clean up
+ // all clipboards, except on Windows. (Previous code leaks the IO thread
+ // clipboard, so it shouldn't be a problem.)
+ static void DestroyClipboardForCurrentThread();
// Write a bunch of objects to the system clipboard. Copies are made of the
// contents of |objects|. On Windows they are copied to the system clipboard.
@@ -284,6 +295,10 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
private:
FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest);
FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest);
+ friend class ClipboardTest;
+
+ Clipboard();
+ ~Clipboard();
void DispatchObject(ObjectType type, const ObjectMapParams& params);
diff --git a/ui/base/clipboard/clipboard_unittest.cc b/ui/base/clipboard/clipboard_unittest.cc
index 1b7eb4c..1653313 100644
--- a/ui/base/clipboard/clipboard_unittest.cc
+++ b/ui/base/clipboard/clipboard_unittest.cc
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -19,7 +20,6 @@
#include "ui/gfx/size.h"
#if defined(OS_WIN)
-#include "base/message_loop.h"
#include "ui/base/clipboard/clipboard_util_win.h"
#endif
@@ -29,21 +29,14 @@
namespace ui {
-#if defined(OS_WIN)
class ClipboardTest : public PlatformTest {
protected:
- virtual void SetUp() {
- message_loop_.reset(new MessageLoopForUI());
- }
- virtual void TearDown() {
- }
+ Clipboard& clipboard() { return clipboard_; }
private:
- scoped_ptr<MessageLoop> message_loop_;
+ MessageLoopForUI message_loop_;
+ Clipboard clipboard_;
};
-#elif defined(OS_POSIX)
-typedef PlatformTest ClipboardTest;
-#endif // defined(OS_WIN)
namespace {
@@ -55,61 +48,55 @@ bool MarkupMatches(const string16& expected_markup,
} // namespace
TEST_F(ClipboardTest, ClearTest) {
- Clipboard clipboard;
-
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteText(ASCIIToUTF16("clear me"));
}
- clipboard.Clear(Clipboard::BUFFER_STANDARD);
+ clipboard().Clear(Clipboard::BUFFER_STANDARD);
- EXPECT_FALSE(clipboard.IsFormatAvailable(
+ EXPECT_FALSE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
- EXPECT_FALSE(clipboard.IsFormatAvailable(
+ EXPECT_FALSE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextFormatType(), Clipboard::BUFFER_STANDARD));
}
TEST_F(ClipboardTest, TextTest) {
- Clipboard clipboard;
-
string16 text(ASCIIToUTF16("This is a string16!#$")), text_result;
std::string ascii_text;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteText(text);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
- Clipboard::BUFFER_STANDARD));
- clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result);
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ clipboard().ReadText(Clipboard::BUFFER_STANDARD, &text_result);
EXPECT_EQ(text, text_result);
- clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
+ clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
EXPECT_EQ(UTF16ToUTF8(text), ascii_text);
}
TEST_F(ClipboardTest, HTMLTest) {
- Clipboard clipboard;
-
string16 markup(ASCIIToUTF16("<string>Hi!</string>")), markup_result;
std::string url("http://www.example.com/"), url_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteHTML(markup, url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
&ignored, &ignored);
EXPECT_PRED2(MarkupMatches, markup, markup_result);
#if defined(OS_WIN)
@@ -120,84 +107,79 @@ TEST_F(ClipboardTest, HTMLTest) {
}
TEST_F(ClipboardTest, RTFTest) {
- Clipboard clipboard;
-
std::string rtf =
"{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\n"
"This is some {\\b bold} text.\\par\n"
"}";
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteRTF(rtf);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetRtfFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetRtfFormatType(),
+ Clipboard::BUFFER_STANDARD));
std::string result;
- clipboard.ReadRTF(Clipboard::BUFFER_STANDARD, &result);
+ clipboard().ReadRTF(Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(rtf, result);
}
#if defined(TOOLKIT_GTK)
TEST_F(ClipboardTest, MultipleBufferTest) {
- Clipboard clipboard;
-
string16 text(ASCIIToUTF16("Standard")), text_result;
string16 markup(ASCIIToUTF16("<string>Selection</string>")), markup_result;
std::string url("http://www.example.com/"), url_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteText(text);
}
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_SELECTION);
clipboard_writer.WriteHTML(markup, url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
- Clipboard::BUFFER_STANDARD));
- EXPECT_FALSE(clipboard.IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
- Clipboard::BUFFER_SELECTION));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ EXPECT_FALSE(clipboard().IsFormatAvailable(
+ Clipboard::GetPlainTextFormatType(),
+ Clipboard::BUFFER_SELECTION));
- EXPECT_FALSE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_SELECTION));
+ EXPECT_FALSE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_SELECTION));
- clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result);
+ clipboard().ReadText(Clipboard::BUFFER_STANDARD, &text_result);
EXPECT_EQ(text, text_result);
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_SELECTION, &markup_result, &url_result,
- &ignored, &ignored);
+ clipboard().ReadHTML(Clipboard::BUFFER_SELECTION, &markup_result, &url_result,
+ &ignored, &ignored);
EXPECT_PRED2(MarkupMatches, markup, markup_result);
}
#endif
TEST_F(ClipboardTest, TrickyHTMLTest) {
- Clipboard clipboard;
-
string16 markup(ASCIIToUTF16("<em>Bye!<!--EndFragment --></em>")),
markup_result;
std::string url, url_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteHTML(markup, url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
- &ignored, &ignored);
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
+ &ignored, &ignored);
EXPECT_PRED2(MarkupMatches, markup, markup_result);
#if defined(OS_WIN)
// TODO(playmobil): It's not clear that non windows clipboards need to support
@@ -208,24 +190,22 @@ TEST_F(ClipboardTest, TrickyHTMLTest) {
#if defined(OS_WIN)
TEST_F(ClipboardTest, UniodeHTMLTest) {
- Clipboard clipboard;
-
string16 markup(UTF8ToUTF16("<div>A \xc3\xb8 \xe6\xb0\xb4</div>")),
markup_result;
std::string url, url_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteHTML(markup, url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
uint32 fragment_start;
uint32 fragment_end;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
- &fragment_start, &fragment_end);
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
+ &fragment_start, &fragment_end);
EXPECT_PRED2(MarkupMatches, markup, markup_result);
EXPECT_EQ(url, url_result);
// Make sure that fragment indices were adjusted when converting.
@@ -237,21 +217,20 @@ TEST_F(ClipboardTest, UniodeHTMLTest) {
#if defined(TOOLKIT_GTK)
// Regression test for crbug.com/56298 (pasting empty HTML crashes Linux).
TEST_F(ClipboardTest, EmptyHTMLTest) {
- Clipboard clipboard;
// ScopedClipboardWriter doesn't let us write empty data to the clipboard.
- clipboard.clipboard_data_ = new Clipboard::TargetMap();
+ clipboard().clipboard_data_ = new Clipboard::TargetMap();
// The 1 is so the compiler doesn't warn about allocating an empty array.
char* empty = new char[1];
- clipboard.InsertMapping("text/html", empty, 0U);
- clipboard.SetGtkClipboard(Clipboard::BUFFER_STANDARD);
+ clipboard().InsertMapping("text/html", empty, 0U);
+ clipboard().SetGtkClipboard(Clipboard::BUFFER_STANDARD);
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
string16 markup_result;
std::string url_result;
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
- &ignored, &ignored);
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
+ &ignored, &ignored);
EXPECT_PRED2(MarkupMatches, string16(), markup_result);
}
#endif
@@ -259,88 +238,82 @@ TEST_F(ClipboardTest, EmptyHTMLTest) {
// TODO(estade): Port the following test (decide what target we use for urls)
#if !defined(OS_POSIX) || defined(OS_MACOSX)
TEST_F(ClipboardTest, BookmarkTest) {
- Clipboard clipboard;
-
string16 title(ASCIIToUTF16("The Example Company")), title_result;
std::string url("http://www.example.com/"), url_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteBookmark(title, url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetUrlWFormatType(),
- Clipboard::BUFFER_STANDARD));
- clipboard.ReadBookmark(&title_result, &url_result);
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetUrlWFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ clipboard().ReadBookmark(&title_result, &url_result);
EXPECT_EQ(title, title_result);
EXPECT_EQ(url, url_result);
}
#endif // defined(OS_WIN)
TEST_F(ClipboardTest, MultiFormatTest) {
- Clipboard clipboard;
-
string16 text(ASCIIToUTF16("Hi!")), text_result;
string16 markup(ASCIIToUTF16("<strong>Hi!</string>")), markup_result;
std::string url("http://www.example.com/"), url_result;
std::string ascii_text;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteHTML(markup, url);
clipboard_writer.WriteText(text);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextFormatType(), Clipboard::BUFFER_STANDARD));
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
- &ignored, &ignored);
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &markup_result, &url_result,
+ &ignored, &ignored);
EXPECT_PRED2(MarkupMatches, markup, markup_result);
#if defined(OS_WIN)
// TODO(playmobil): It's not clear that non windows clipboards need to support
// this.
EXPECT_EQ(url, url_result);
#endif // defined(OS_WIN)
- clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result);
+ clipboard().ReadText(Clipboard::BUFFER_STANDARD, &text_result);
EXPECT_EQ(text, text_result);
- clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
+ clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
EXPECT_EQ(UTF16ToUTF8(text), ascii_text);
}
TEST_F(ClipboardTest, URLTest) {
- Clipboard clipboard;
-
string16 url(ASCIIToUTF16("http://www.google.com/"));
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteURL(url);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetPlainTextFormatType(),
+ Clipboard::BUFFER_STANDARD));
string16 text_result;
- clipboard.ReadText(Clipboard::BUFFER_STANDARD, &text_result);
+ clipboard().ReadText(Clipboard::BUFFER_STANDARD, &text_result);
EXPECT_EQ(text_result, url);
std::string ascii_text;
- clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
+ clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &ascii_text);
EXPECT_EQ(UTF16ToUTF8(url), ascii_text);
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
ascii_text.clear();
- clipboard.ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text);
+ clipboard().ReadAsciiText(Clipboard::BUFFER_SELECTION, &ascii_text);
EXPECT_EQ(UTF16ToUTF8(url), ascii_text);
#endif
}
@@ -366,7 +339,7 @@ TEST_F(ClipboardTest, SharedBitmapTest) {
shared_buf.ShareToProcess(current_process, &handle_to_share);
ASSERT_TRUE(shared_buf.Unmap());
- // Setup data for clipboard.
+ // Setup data for clipboard().
Clipboard::ObjectMapParam placeholder_param;
Clipboard::ObjectMapParam size_param;
const char* size_data = reinterpret_cast<const char*>(&fake_bitmap_size);
@@ -381,11 +354,10 @@ TEST_F(ClipboardTest, SharedBitmapTest) {
objects[Clipboard::CBF_SMBITMAP] = params;
Clipboard::ReplaceSharedMemHandle(&objects, handle_to_share, current_process);
- Clipboard clipboard;
- clipboard.WriteObjects(Clipboard::BUFFER_STANDARD, objects);
+ clipboard().WriteObjects(Clipboard::BUFFER_STANDARD, objects);
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
+ Clipboard::BUFFER_STANDARD));
}
// The following test somehow fails on GTK. The image when read back from the
@@ -393,8 +365,6 @@ TEST_F(ClipboardTest, SharedBitmapTest) {
// channels stay intact. So I am turning this on only for aura.
#if (defined(USE_AURA) && !defined(OS_WIN)) || defined(OS_ANDROID)
TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) {
- Clipboard clipboard;
-
// Test first bitmap
unsigned int fake_bitmap_1[] = {
0x46155189, 0xF6A55C8D, 0x79845674, 0xFA57BD89,
@@ -403,13 +373,13 @@ TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) {
};
gfx::Size fake_bitmap_1_size(3, 4);
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteBitmapFromPixels(fake_bitmap_1, fake_bitmap_1_size);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
- Clipboard::BUFFER_STANDARD));
- SkBitmap image_1 = clipboard.ReadImage(Clipboard::BUFFER_STANDARD);
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ SkBitmap image_1 = clipboard().ReadImage(Clipboard::BUFFER_STANDARD);
EXPECT_EQ(fake_bitmap_1_size, gfx::Size(image_1.width(), image_1.height()));
unsigned int* pixels_1 = reinterpret_cast<unsigned int*>(image_1.getPixels());
for (int i = 0; i < fake_bitmap_1_size.width(); ++i) {
@@ -431,13 +401,13 @@ TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) {
};
gfx::Size fake_bitmap_2_size(7, 2);
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteBitmapFromPixels(fake_bitmap_2, fake_bitmap_2_size);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
- Clipboard::BUFFER_STANDARD));
- SkBitmap image_2 = clipboard.ReadImage(Clipboard::BUFFER_STANDARD);
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
+ Clipboard::BUFFER_STANDARD));
+ SkBitmap image_2 = clipboard().ReadImage(Clipboard::BUFFER_STANDARD);
EXPECT_EQ(fake_bitmap_2_size, gfx::Size(image_2.width(), image_2.height()));
unsigned int* pixels_2 = reinterpret_cast<unsigned int*>(image_2.getPixels());
for (int i = 0; i < fake_bitmap_2_size.width(); ++i) {
@@ -450,7 +420,6 @@ TEST_F(ClipboardTest, MultipleBitmapReadWriteTest) {
#endif
TEST_F(ClipboardTest, DataTest) {
- Clipboard clipboard;
const ui::Clipboard::FormatType kFormat =
ui::Clipboard::GetFormatType("chromium/x-test-format");
std::string payload("test string");
@@ -458,15 +427,15 @@ TEST_F(ClipboardTest, DataTest) {
write_pickle.WriteString(payload);
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WritePickledData(write_pickle, kFormat);
}
- ASSERT_TRUE(clipboard.IsFormatAvailable(
+ ASSERT_TRUE(clipboard().IsFormatAvailable(
kFormat, Clipboard::BUFFER_STANDARD));
std::string output;
- clipboard.ReadData(kFormat, &output);
+ clipboard().ReadData(kFormat, &output);
ASSERT_FALSE(output.empty());
Pickle read_pickle(output.data(), output.size());
@@ -477,7 +446,6 @@ TEST_F(ClipboardTest, DataTest) {
}
TEST_F(ClipboardTest, MultipleDataTest) {
- Clipboard clipboard;
const ui::Clipboard::FormatType kFormat1 =
ui::Clipboard::GetFormatType("chromium/x-test-format1");
std::string payload1("test string1");
@@ -491,19 +459,19 @@ TEST_F(ClipboardTest, MultipleDataTest) {
write_pickle2.WriteString(payload2);
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WritePickledData(write_pickle1, kFormat1);
// overwrite the previous pickle for fun
clipboard_writer.WritePickledData(write_pickle2, kFormat2);
}
- ASSERT_TRUE(clipboard.IsFormatAvailable(
+ ASSERT_TRUE(clipboard().IsFormatAvailable(
kFormat2, Clipboard::BUFFER_STANDARD));
// Check string 2.
std::string output2;
- clipboard.ReadData(kFormat2, &output2);
+ clipboard().ReadData(kFormat2, &output2);
ASSERT_FALSE(output2.empty());
Pickle read_pickle2(output2.data(), output2.size());
@@ -513,19 +481,19 @@ TEST_F(ClipboardTest, MultipleDataTest) {
EXPECT_EQ(payload2, unpickled_string2);
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WritePickledData(write_pickle2, kFormat2);
// overwrite the previous pickle for fun
clipboard_writer.WritePickledData(write_pickle1, kFormat1);
}
- ASSERT_TRUE(clipboard.IsFormatAvailable(
+ ASSERT_TRUE(clipboard().IsFormatAvailable(
kFormat1, Clipboard::BUFFER_STANDARD));
// Check string 1.
std::string output1;
- clipboard.ReadData(kFormat1, &output1);
+ clipboard().ReadData(kFormat1, &output1);
ASSERT_FALSE(output1.empty());
Pickle read_pickle1(output1.data(), output1.size());
@@ -537,8 +505,6 @@ TEST_F(ClipboardTest, MultipleDataTest) {
#if defined(OS_WIN) // Windows only tests.
TEST_F(ClipboardTest, HyperlinkTest) {
- Clipboard clipboard;
-
const std::string kTitle("The Example Company");
const std::string kUrl("http://www.example.com/");
const std::string kExpectedHtml("<a href=\"http://www.example.com/\">"
@@ -547,29 +513,27 @@ TEST_F(ClipboardTest, HyperlinkTest) {
string16 html_result;
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteHyperlink(ASCIIToUTF16(kTitle), kUrl);
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetHtmlFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetHtmlFormatType(),
+ Clipboard::BUFFER_STANDARD));
uint32 ignored;
- clipboard.ReadHTML(Clipboard::BUFFER_STANDARD, &html_result, &url_result,
- &ignored, &ignored);
+ clipboard().ReadHTML(Clipboard::BUFFER_STANDARD, &html_result, &url_result,
+ &ignored, &ignored);
EXPECT_PRED2(MarkupMatches, ASCIIToUTF16(kExpectedHtml), html_result);
}
TEST_F(ClipboardTest, WebSmartPasteTest) {
- Clipboard clipboard;
-
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteWebSmartPaste();
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetWebKitSmartPasteFormatType(), Clipboard::BUFFER_STANDARD));
}
@@ -580,16 +544,14 @@ TEST_F(ClipboardTest, BitmapTest) {
0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1,
};
- Clipboard clipboard;
-
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteBitmapFromPixels(fake_bitmap, gfx::Size(3, 4));
}
- EXPECT_TRUE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_TRUE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
+ Clipboard::BUFFER_STANDARD));
}
void HtmlTestHelper(const std::string& cf_html,
@@ -637,10 +599,8 @@ TEST_F(ClipboardTest, HtmlTest) {
// Test writing all formats we have simultaneously.
TEST_F(ClipboardTest, WriteEverything) {
- Clipboard clipboard;
-
{
- ScopedClipboardWriter writer(&clipboard, Clipboard::BUFFER_STANDARD);
+ ScopedClipboardWriter writer(&clipboard(), Clipboard::BUFFER_STANDARD);
writer.WriteText(UTF8ToUTF16("foo"));
writer.WriteURL(UTF8ToUTF16("foo"));
writer.WriteHTML(UTF8ToUTF16("foo"), "bar");
@@ -664,10 +624,9 @@ TEST_F(ClipboardTest, InternalClipboardInvalidation) {
0x91E9F63A, 0xC31EA14F, 0x69AB32DF, 0x643A3FD1,
};
- // Write a bitmap in our clipboard.
- Clipboard clipboard;
+ // Write a bitmap in our clipboard().
{
- ScopedClipboardWriter clipboard_writer(&clipboard,
+ ScopedClipboardWriter clipboard_writer(&clipboard(),
Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteBitmapFromPixels(kFakeBitmap, gfx::Size(3, 4));
}
@@ -708,16 +667,16 @@ TEST_F(ClipboardTest, InternalClipboardInvalidation) {
env->NewStringUTF(new_value.c_str()));
// The bitmap that should have been available should be gone.
- EXPECT_FALSE(clipboard.IsFormatAvailable(Clipboard::GetBitmapFormatType(),
- Clipboard::BUFFER_STANDARD));
+ EXPECT_FALSE(clipboard().IsFormatAvailable(Clipboard::GetBitmapFormatType(),
+ Clipboard::BUFFER_STANDARD));
// Make sure some text is available
- EXPECT_TRUE(clipboard.IsFormatAvailable(
+ EXPECT_TRUE(clipboard().IsFormatAvailable(
Clipboard::GetPlainTextWFormatType(), Clipboard::BUFFER_STANDARD));
// Make sure the text is what we inserted while simulating the other app
std::string contents;
- clipboard.ReadAsciiText(Clipboard::BUFFER_STANDARD, &contents);
+ clipboard().ReadAsciiText(Clipboard::BUFFER_STANDARD, &contents);
EXPECT_EQ(contents, new_value);
}
#endif
diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc
index 960b316..5d5e909 100644
--- a/ui/views/controls/message_box_view.cc
+++ b/ui/views/controls/message_box_view.cc
@@ -17,7 +17,6 @@
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
-#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
@@ -140,10 +139,7 @@ bool MessageBoxView::AcceleratorPressed(const ui::Accelerator& accelerator) {
if (prompt_field_ && prompt_field_->HasFocus())
return false;
- if (!ViewsDelegate::views_delegate)
- return false;
-
- ui::Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard();
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
if (!clipboard)
return false;
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index f1cdf26..80474c9 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -37,7 +37,6 @@
#include "ui/views/controls/textfield/textfield_views_model.h"
#include "ui/views/ime/input_method.h"
#include "ui/views/metrics.h"
-#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
#include "unicode/uchar.h"
@@ -586,8 +585,8 @@ bool NativeTextfieldViews::IsCommandIdEnabled(int command_id) const {
case IDS_APP_COPY:
return model_->HasSelection() && !textfield_->IsObscured();
case IDS_APP_PASTE:
- ViewsDelegate::views_delegate->GetClipboard()
- ->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ ui::Clipboard::GetForCurrentThread()->ReadText(
+ ui::Clipboard::BUFFER_STANDARD, &result);
return editable && !result.empty();
case IDS_APP_DELETE:
return editable && model_->HasSelection();
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
index c78bbf8..392c010 100644
--- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
@@ -34,7 +34,6 @@
#include "ui/views/ime/mock_input_method.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
-#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/widget.h"
@@ -235,14 +234,14 @@ class NativeTextfieldViewsTest : public ViewsTestBase,
string16 GetClipboardText() const {
string16 text;
- views::ViewsDelegate::views_delegate->GetClipboard()->
+ ui::Clipboard::GetForCurrentThread()->
ReadText(ui::Clipboard::BUFFER_STANDARD, &text);
return text;
}
void SetClipboardText(const std::string& text) {
ui::ScopedClipboardWriter clipboard_writer(
- views::ViewsDelegate::views_delegate->GetClipboard(),
+ ui::Clipboard::GetForCurrentThread(),
ui::Clipboard::BUFFER_STANDARD);
clipboard_writer.WriteText(ASCIIToUTF16(text));
}
@@ -1103,7 +1102,7 @@ TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) {
EXPECT_STR_NE(" one two three ", str);
SendKeyEvent(ui::VKEY_C, false, true);
- views::ViewsDelegate::views_delegate->GetClipboard()->
+ ui::Clipboard::GetForCurrentThread()->
ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
EXPECT_STR_EQ(" one two three ", str);
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index c356451..d5277d9 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -33,7 +33,6 @@
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/metrics.h"
-#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
namespace views {
@@ -560,9 +559,9 @@ void NativeTextfieldWin::OnCopy() {
return;
const string16 text(GetSelectedText());
- if (!text.empty() && ViewsDelegate::views_delegate) {
+ if (!text.empty()) {
ui::ScopedClipboardWriter scw(
- ViewsDelegate::views_delegate->GetClipboard(),
+ ui::Clipboard::GetForCurrentThread(),
ui::Clipboard::BUFFER_STANDARD);
scw.WriteText(text);
}
@@ -975,10 +974,10 @@ void NativeTextfieldWin::OnNonLButtonDown(UINT keys, const CPoint& point) {
}
void NativeTextfieldWin::OnPaste() {
- if (textfield_->read_only() || !ViewsDelegate::views_delegate)
+ if (textfield_->read_only())
return;
- ui::Clipboard* clipboard = ViewsDelegate::views_delegate->GetClipboard();
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
if (!clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(),
ui::Clipboard::BUFFER_STANDARD))
return;
diff --git a/ui/views/controls/textfield/textfield_views_model.cc b/ui/views/controls/textfield/textfield_views_model.cc
index d51e417..89fe947 100644
--- a/ui/views/controls/textfield/textfield_views_model.cc
+++ b/ui/views/controls/textfield/textfield_views_model.cc
@@ -20,7 +20,6 @@
#include "ui/gfx/render_text.h"
#include "ui/gfx/text_constants.h"
#include "ui/views/controls/textfield/textfield.h"
-#include "ui/views/views_delegate.h"
namespace views {
@@ -511,7 +510,7 @@ bool TextfieldViewsModel::Redo() {
bool TextfieldViewsModel::Cut() {
if (!HasCompositionText() && HasSelection() && !render_text_->is_obscured()) {
ui::ScopedClipboardWriter(
- views::ViewsDelegate::views_delegate->GetClipboard(),
+ ui::Clipboard::GetForCurrentThread(),
ui::Clipboard::BUFFER_STANDARD).WriteText(GetSelectedText());
// A trick to let undo/redo handle cursor correctly.
// Undoing CUT moves the cursor to the end of the change rather
@@ -529,7 +528,7 @@ bool TextfieldViewsModel::Cut() {
bool TextfieldViewsModel::Copy() {
if (!HasCompositionText() && HasSelection() && !render_text_->is_obscured()) {
ui::ScopedClipboardWriter(
- views::ViewsDelegate::views_delegate->GetClipboard(),
+ ui::Clipboard::GetForCurrentThread(),
ui::Clipboard::BUFFER_STANDARD).WriteText(GetSelectedText());
return true;
}
@@ -538,7 +537,7 @@ bool TextfieldViewsModel::Copy() {
bool TextfieldViewsModel::Paste() {
string16 result;
- views::ViewsDelegate::views_delegate->GetClipboard()
+ ui::Clipboard::GetForCurrentThread()
->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
if (!result.empty()) {
InsertTextInternal(result, false);
diff --git a/ui/views/controls/textfield/textfield_views_model_unittest.cc b/ui/views/controls/textfield/textfield_views_model_unittest.cc
index 376f7d4..a94bf4d 100644
--- a/ui/views/controls/textfield/textfield_views_model_unittest.cc
+++ b/ui/views/controls/textfield/textfield_views_model_unittest.cc
@@ -18,7 +18,6 @@
#include "ui/views/controls/textfield/textfield_views_model.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
-#include "ui/views/views_delegate.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
@@ -495,7 +494,7 @@ TEST_F(TextfieldViewsModelTest, SetText) {
#endif
TEST_F(TextfieldViewsModelTest, MAYBE_Clipboard) {
ui::Clipboard* clipboard
- = views::ViewsDelegate::views_delegate->GetClipboard();
+ = ui::Clipboard::GetForCurrentThread();
string16 initial_clipboard_text = ASCIIToUTF16("initial text");
ui::ScopedClipboardWriter(
clipboard,
diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc
index 2ae2aa4..e87f18d 100644
--- a/ui/views/test/test_views_delegate.cc
+++ b/ui/views/test/test_views_delegate.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "content/public/test/web_contents_tester.h"
-#include "ui/base/clipboard/clipboard.h"
namespace views {
@@ -24,14 +23,6 @@ void TestViewsDelegate::SetUseTransparentWindows(bool transparent) {
use_transparent_windows_ = transparent;
}
-ui::Clipboard* TestViewsDelegate::GetClipboard() const {
- if (!clipboard_.get()) {
- // Note that we need a MessageLoop for the next call to work.
- clipboard_.reset(new ui::Clipboard);
- }
- return clipboard_.get();
-}
-
void TestViewsDelegate::SaveWindowPlacement(const Widget* window,
const std::string& window_name,
const gfx::Rect& bounds,
diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h
index 54ae0be..6568196 100644
--- a/ui/views/test/test_views_delegate.h
+++ b/ui/views/test/test_views_delegate.h
@@ -28,7 +28,6 @@ class TestViewsDelegate : public ViewsDelegate {
void SetUseTransparentWindows(bool transparent);
// Overridden from ViewsDelegate:
- virtual ui::Clipboard* GetClipboard() const OVERRIDE;
virtual void SaveWindowPlacement(const Widget* window,
const std::string& window_name,
const gfx::Rect& bounds,
@@ -69,7 +68,6 @@ class TestViewsDelegate : public ViewsDelegate {
content::SiteInstance* site_instance) OVERRIDE;
private:
- mutable scoped_ptr<ui::Clipboard> clipboard_;
bool use_transparent_windows_;
DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate);
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 45d83b5..5b08793 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -1168,8 +1168,6 @@ TEST_F(ViewTest, Textfield) {
const string16 kExtraText = ASCIIToUTF16("Pretty deep, Philip!");
const string16 kEmptyString;
- ui::Clipboard clipboard;
-
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 100);
@@ -1206,7 +1204,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
const string16 kReadOnlyText = ASCIIToUTF16("Read only");
const string16 kPasswordText = ASCIIToUTF16("Password! ** Secret stuff **");
- ui::Clipboard clipboard;
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
Widget* widget = new Widget;
Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
@@ -1235,7 +1233,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
::SendMessage(normal->GetTestingHandle(), WM_CUT, 0, 0);
string16 result;
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kNormalText, result);
normal->SetText(kNormalText); // Let's revert to the original content.
@@ -1243,7 +1241,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_CUT, 0, 0);
result.clear();
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
// Cut should have failed, so the clipboard content should not have changed.
EXPECT_EQ(kNormalText, result);
@@ -1251,7 +1249,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
password->SelectAll(false);
::SendMessage(password->GetTestingHandle(), WM_CUT, 0, 0);
result.clear();
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
// Cut should have failed, so the clipboard content should not have changed.
EXPECT_EQ(kNormalText, result);
@@ -1264,19 +1262,19 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kReadOnlyText, result);
normal->SelectAll(false);
::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kNormalText, result);
password->SelectAll(false);
::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
- clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
+ clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
// We don't let you copy from an obscured field, clipboard should not have
// changed.
EXPECT_EQ(kNormalText, result);
diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h
index 5fb3929..a3f8430 100644
--- a/ui/views/views_delegate.h
+++ b/ui/views/views_delegate.h
@@ -26,10 +26,6 @@ namespace gfx {
class Rect;
}
-namespace ui {
-class Clipboard;
-}
-
namespace views {
class NonClientFrameView;
@@ -54,9 +50,6 @@ class VIEWS_EXPORT ViewsDelegate {
virtual ~ViewsDelegate() {}
- // Gets the clipboard.
- virtual ui::Clipboard* GetClipboard() const = 0;
-
// Saves the position, size and "show" state for the window with the
// specified name.
virtual void SaveWindowPlacement(const Widget* widget,