OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
12 #include "webkit/glue/webclipboard_impl.h" | 12 #include "webkit/glue/webclipboard_impl.h" |
13 #include "webkit/glue/webkit_glue.h" | 13 #include "webkit/glue/webkit_glue.h" |
14 | 14 |
15 using WebKit::WebString; | 15 using WebKit::WebString; |
16 using WebKit::WebURL; | 16 using WebKit::WebURL; |
| 17 using WebKit::WebVector; |
17 | 18 |
18 bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { | 19 bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { |
19 switch (format) { | 20 switch (format) { |
20 case FormatHTML: | 21 case FormatHTML: |
21 return !m_htmlText.isEmpty(); | 22 return !m_htmlText.isEmpty(); |
22 | 23 |
23 case FormatSmartPaste: | 24 case FormatSmartPaste: |
24 return m_writeSmartPaste; | 25 return m_writeSmartPaste; |
25 | 26 |
26 default: | 27 default: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 79 |
79 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image, | 80 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image, |
80 const WebKit::WebURL& url, const WebKit::WebString& title) { | 81 const WebKit::WebURL& url, const WebKit::WebString& title) { |
81 if (!image.isNull()) { | 82 if (!image.isNull()) { |
82 m_htmlText = WebString::fromUTF8( | 83 m_htmlText = WebString::fromUTF8( |
83 webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title)); | 84 webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title)); |
84 m_plainText = m_htmlText; | 85 m_plainText = m_htmlText; |
85 m_writeSmartPaste = false; | 86 m_writeSmartPaste = false; |
86 } | 87 } |
87 } | 88 } |
| 89 |
| 90 WebVector<WebString> MockWebClipboardImpl::readAvailableTypes( |
| 91 Buffer buffer, bool* containsFilenames) { |
| 92 *containsFilenames = false; |
| 93 std::vector<WebString> results; |
| 94 if (!m_plainText.isEmpty()) { |
| 95 results.push_back(WebString("Text")); |
| 96 results.push_back(WebString("text/plain")); |
| 97 } |
| 98 if (!m_htmlText.isEmpty()) { |
| 99 results.push_back(WebString("text/html")); |
| 100 } |
| 101 return results; |
| 102 } |
OLD | NEW |