| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/support/mock_webclipboard_impl.h" | 5 #include "webkit/support/mock_webclipboard_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "third_party/WebKit/public/platform/WebCommon.h" | 13 #include "third_party/WebKit/public/platform/WebCommon.h" |
| 14 #include "third_party/WebKit/public/platform/WebDragData.h" | 14 #include "third_party/WebKit/public/platform/WebDragData.h" |
| 15 #include "third_party/WebKit/public/platform/WebImage.h" | 15 #include "third_party/WebKit/public/platform/WebImage.h" |
| 16 #include "third_party/WebKit/public/platform/WebURL.h" | 16 #include "third_party/WebKit/public/platform/WebURL.h" |
| 17 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
| 18 #include "webkit/glue/webclipboard_impl.h" | |
| 19 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
| 19 #include "webkit/renderer/clipboard_utils.h" |
| 20 #include "webkit/support/webkit_support_gfx.h" | 20 #include "webkit/support/webkit_support_gfx.h" |
| 21 | 21 |
| 22 using WebKit::WebDragData; | 22 using WebKit::WebDragData; |
| 23 using WebKit::WebString; | 23 using WebKit::WebString; |
| 24 using WebKit::WebURL; | 24 using WebKit::WebURL; |
| 25 using WebKit::WebVector; | 25 using WebKit::WebVector; |
| 26 | 26 |
| 27 MockWebClipboardImpl::MockWebClipboardImpl() { | 27 MockWebClipboardImpl::MockWebClipboardImpl() { |
| 28 } | 28 } |
| 29 | 29 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void MockWebClipboardImpl::writePlainText(const WebKit::WebString& plain_text) { | 148 void MockWebClipboardImpl::writePlainText(const WebKit::WebString& plain_text) { |
| 149 clear(); | 149 clear(); |
| 150 | 150 |
| 151 m_plainText = plain_text; | 151 m_plainText = plain_text; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void MockWebClipboardImpl::writeURL( | 154 void MockWebClipboardImpl::writeURL( |
| 155 const WebKit::WebURL& url, const WebKit::WebString& title) { | 155 const WebKit::WebURL& url, const WebKit::WebString& title) { |
| 156 clear(); | 156 clear(); |
| 157 | 157 |
| 158 m_htmlText = WebString::fromUTF8( | 158 m_htmlText = WebString::fromUTF8(webkit_clipboard::URLToMarkup(url, title)); |
| 159 webkit_glue::WebClipboardImpl::URLToMarkup(url, title)); | |
| 160 m_plainText = url.spec().utf16(); | 159 m_plainText = url.spec().utf16(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image, | 162 void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image, |
| 164 const WebKit::WebURL& url, const WebKit::WebString& title) { | 163 const WebKit::WebURL& url, const WebKit::WebString& title) { |
| 165 if (!image.isNull()) { | 164 if (!image.isNull()) { |
| 166 clear(); | 165 clear(); |
| 167 | 166 |
| 168 m_plainText = m_htmlText; | 167 m_plainText = m_htmlText; |
| 169 m_htmlText = WebString::fromUTF8( | 168 m_htmlText = WebString::fromUTF8( |
| 170 webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title)); | 169 webkit_clipboard::URLToImageMarkup(url, title)); |
| 171 m_image = image; | 170 m_image = image; |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 | 173 |
| 175 void MockWebClipboardImpl::writeDataObject(const WebDragData& data) { | 174 void MockWebClipboardImpl::writeDataObject(const WebDragData& data) { |
| 176 clear(); | 175 clear(); |
| 177 | 176 |
| 178 const WebVector<WebDragData::Item>& itemList = data.items(); | 177 const WebVector<WebDragData::Item>& itemList = data.items(); |
| 179 for (size_t i = 0; i < itemList.size(); ++i) { | 178 for (size_t i = 0; i < itemList.size(); ++i) { |
| 180 const WebDragData::Item& item = itemList[i]; | 179 const WebDragData::Item& item = itemList[i]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 198 } | 197 } |
| 199 } | 198 } |
| 200 | 199 |
| 201 void MockWebClipboardImpl::clear() { | 200 void MockWebClipboardImpl::clear() { |
| 202 m_plainText = WebString(); | 201 m_plainText = WebString(); |
| 203 m_htmlText = WebString(); | 202 m_htmlText = WebString(); |
| 204 m_image.reset(); | 203 m_image.reset(); |
| 205 m_customData.clear(); | 204 m_customData.clear(); |
| 206 m_writeSmartPaste = false; | 205 m_writeSmartPaste = false; |
| 207 } | 206 } |
| OLD | NEW |