| 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/tools/test_shell/mock_webclipboard_impl.h" | 5 #include "webkit/tools/test_shell/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" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 std::vector<WebString> results; | 67 std::vector<WebString> results; |
| 68 if (!m_plainText.isEmpty()) { | 68 if (!m_plainText.isEmpty()) { |
| 69 results.push_back(WebString("text/plain")); | 69 results.push_back(WebString("text/plain")); |
| 70 } | 70 } |
| 71 if (!m_htmlText.isEmpty()) { | 71 if (!m_htmlText.isEmpty()) { |
| 72 results.push_back(WebString("text/html")); | 72 results.push_back(WebString("text/html")); |
| 73 } | 73 } |
| 74 if (!m_image.isNull()) { | 74 if (!m_image.isNull()) { |
| 75 results.push_back(WebString("image/png")); | 75 results.push_back(WebString("image/png")); |
| 76 } | 76 } |
| 77 for (std::map<string16, string16>::const_iterator it = m_customData.begin(); | 77 for (std::map<base::string16, base::string16>::const_iterator it = |
| 78 m_customData.begin(); |
| 78 it != m_customData.end(); ++it) { | 79 it != m_customData.end(); ++it) { |
| 79 CHECK(std::find(results.begin(), results.end(), it->first) == | 80 CHECK(std::find(results.begin(), results.end(), it->first) == |
| 80 results.end()); | 81 results.end()); |
| 81 results.push_back(it->first); | 82 results.push_back(it->first); |
| 82 } | 83 } |
| 83 return results; | 84 return results; |
| 84 } | 85 } |
| 85 | 86 |
| 86 WebKit::WebString MockWebClipboardImpl::readPlainText( | 87 WebKit::WebString MockWebClipboardImpl::readPlainText( |
| 87 WebKit::WebClipboard::Buffer buffer) { | 88 WebKit::WebClipboard::Buffer buffer) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 &encoded_image); | 121 &encoded_image); |
| 121 #endif | 122 #endif |
| 122 data.assign(reinterpret_cast<char*>(vector_as_array(&encoded_image)), | 123 data.assign(reinterpret_cast<char*>(vector_as_array(&encoded_image)), |
| 123 encoded_image.size()); | 124 encoded_image.size()); |
| 124 return data; | 125 return data; |
| 125 } | 126 } |
| 126 | 127 |
| 127 WebKit::WebString MockWebClipboardImpl::readCustomData( | 128 WebKit::WebString MockWebClipboardImpl::readCustomData( |
| 128 WebKit::WebClipboard::Buffer buffer, | 129 WebKit::WebClipboard::Buffer buffer, |
| 129 const WebKit::WebString& type) { | 130 const WebKit::WebString& type) { |
| 130 std::map<string16, string16>::const_iterator it = m_customData.find(type); | 131 std::map<base::string16, base::string16>::const_iterator it = |
| 132 m_customData.find(type); |
| 131 if (it != m_customData.end()) | 133 if (it != m_customData.end()) |
| 132 return it->second; | 134 return it->second; |
| 133 return WebKit::WebString(); | 135 return WebKit::WebString(); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void MockWebClipboardImpl::writeHTML( | 138 void MockWebClipboardImpl::writeHTML( |
| 137 const WebKit::WebString& htmlText, const WebKit::WebURL& url, | 139 const WebKit::WebString& htmlText, const WebKit::WebURL& url, |
| 138 const WebKit::WebString& plainText, bool writeSmartPaste) { | 140 const WebKit::WebString& plainText, bool writeSmartPaste) { |
| 139 clear(); | 141 clear(); |
| 140 | 142 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 | 200 |
| 199 void MockWebClipboardImpl::clear() { | 201 void MockWebClipboardImpl::clear() { |
| 200 m_plainText = WebString(); | 202 m_plainText = WebString(); |
| 201 m_htmlText = WebString(); | 203 m_htmlText = WebString(); |
| 202 m_image.reset(); | 204 m_image.reset(); |
| 203 m_customData.clear(); | 205 m_customData.clear(); |
| 204 m_writeSmartPaste = false; | 206 m_writeSmartPaste = false; |
| 205 } | 207 } |
| OLD | NEW |