Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: webkit/tools/test_shell/mock_webclipboard_impl.cc

Issue 174367: Change the ChromiumPasteboard to have a notion of an alternate clipboard... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "webkit/tools/test_shell/mock_webclipboard_impl.h" 5 #include "webkit/tools/test_shell/mock_webclipboard_impl.h"
6 6
7 #include "base/clipboard.h" 7 #include "base/clipboard.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
11 #include "webkit/api/public/WebImage.h" 11 #include "webkit/api/public/WebImage.h"
12 #include "webkit/api/public/WebURL.h" 12 #include "webkit/api/public/WebURL.h"
13 #include "webkit/glue/webclipboard_impl.h" 13 #include "webkit/glue/webclipboard_impl.h"
14 #include "webkit/glue/webkit_glue.h" 14 #include "webkit/glue/webkit_glue.h"
15 15
16 using WebKit::WebString; 16 using WebKit::WebString;
17 using WebKit::WebURL; 17 using WebKit::WebURL;
18 18
19 bool MockWebClipboardImpl::isFormatAvailable(Format format) { 19 bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
20 switch (format) { 20 switch (format) {
21 case FormatHTML: 21 case FormatHTML:
22 return !m_htmlText.isEmpty(); 22 return !m_htmlText.isEmpty();
23 23
24 case FormatSmartPaste: 24 case FormatSmartPaste:
25 return m_writeSmartPaste; 25 return m_writeSmartPaste;
26 26
27 default: 27 default:
28 NOTREACHED(); 28 NOTREACHED();
29 return false; 29 return false;
30 } 30 }
31
32 switch (buffer) {
33 case BufferStandard:
34 break;
35 case BufferSelection:
36 #if defined(OS_LINUX)
37 break;
38 #endif
39 default:
40 NOTREACHED();
41 return false;
42 }
43
31 return true; 44 return true;
32 } 45 }
33 46
34 WebKit::WebString MockWebClipboardImpl::readPlainText() { 47 WebKit::WebString MockWebClipboardImpl::readPlainText(
48 WebKit::WebClipboard::Buffer buffer) {
35 return m_plainText; 49 return m_plainText;
36 } 50 }
37 51
38 // TODO(wtc): set output argument *url. 52 // TODO(wtc): set output argument *url.
39 WebKit::WebString MockWebClipboardImpl::readHTML(WebKit::WebURL* url) { 53 WebKit::WebString MockWebClipboardImpl::readHTML(
54 WebKit::WebClipboard::Buffer buffer, WebKit::WebURL* url) {
40 return m_htmlText; 55 return m_htmlText;
41 } 56 }
42 57
43 void MockWebClipboardImpl::writeHTML( 58 void MockWebClipboardImpl::writeHTML(
44 const WebKit::WebString& htmlText, const WebKit::WebURL& url, 59 const WebKit::WebString& htmlText, const WebKit::WebURL& url,
45 const WebKit::WebString& plainText, bool writeSmartPaste) { 60 const WebKit::WebString& plainText, bool writeSmartPaste) {
46 m_htmlText = htmlText; 61 m_htmlText = htmlText;
47 m_plainText = plainText; 62 m_plainText = plainText;
48 m_writeSmartPaste = writeSmartPaste; 63 m_writeSmartPaste = writeSmartPaste;
49 } 64 }
50 65
51 void MockWebClipboardImpl::writeURL( 66 void MockWebClipboardImpl::writeURL(
52 const WebKit::WebURL& url, const WebKit::WebString& title) { 67 const WebKit::WebURL& url, const WebKit::WebString& title) {
53 m_htmlText = WebString::fromUTF8( 68 m_htmlText = WebString::fromUTF8(
54 webkit_glue::WebClipboardImpl::URLToMarkup(url, title)); 69 webkit_glue::WebClipboardImpl::URLToMarkup(url, title));
55 m_plainText = url.spec().utf16(); 70 m_plainText = url.spec().utf16();
56 m_writeSmartPaste = false; 71 m_writeSmartPaste = false;
57 } 72 }
58 73
59 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image, 74 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image,
60 const WebKit::WebURL& url, const WebKit::WebString& title) { 75 const WebKit::WebURL& url, const WebKit::WebString& title) {
61 if (!image.isNull()) { 76 if (!image.isNull()) {
62 m_htmlText = WebString::fromUTF8( 77 m_htmlText = WebString::fromUTF8(
63 webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title)); 78 webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title));
64 m_plainText = m_htmlText; 79 m_plainText = m_htmlText;
65 m_writeSmartPaste = false; 80 m_writeSmartPaste = false;
66 } 81 }
67 } 82 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/mock_webclipboard_impl.h ('k') | webkit/tools/test_shell/simple_clipboard_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698