OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/glue/webclipboard_impl.h" | 5 #include "webkit/glue/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 "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 buffer_type)) { | 112 buffer_type)) { |
113 std::string text; | 113 std::string text; |
114 ClipboardReadAsciiText(buffer_type, &text); | 114 ClipboardReadAsciiText(buffer_type, &text); |
115 if (!text.empty()) | 115 if (!text.empty()) |
116 return ASCIIToUTF16(text); | 116 return ASCIIToUTF16(text); |
117 } | 117 } |
118 | 118 |
119 return WebString(); | 119 return WebString(); |
120 } | 120 } |
121 | 121 |
122 // TODO(dcheng): For backwards compatibility during the transition. | |
123 WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url) { | |
124 ui::Clipboard::Buffer buffer_type; | |
125 if (!ConvertBufferType(buffer, &buffer_type)) | |
126 return WebString(); | |
127 | |
128 string16 html_stdstr; | |
129 GURL gurl; | |
130 uint32 fragment_start = 0; | |
131 uint32 fragment_end = 0; | |
132 ClipboardReadHTML(buffer_type, &html_stdstr, &gurl, &fragment_start, | |
133 &fragment_end); | |
134 if (fragment_start != std::string::npos && fragment_end != std::string::npos) | |
135 return html_stdstr.substr(fragment_start, fragment_end - fragment_start); | |
136 return WebString(); | |
137 } | |
138 | |
139 WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url, | 122 WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url, |
140 unsigned* fragment_start, | 123 unsigned* fragment_start, |
141 unsigned* fragment_end) { | 124 unsigned* fragment_end) { |
142 ui::Clipboard::Buffer buffer_type; | 125 ui::Clipboard::Buffer buffer_type; |
143 if (!ConvertBufferType(buffer, &buffer_type)) | 126 if (!ConvertBufferType(buffer, &buffer_type)) |
144 return WebString(); | 127 return WebString(); |
145 | 128 |
146 string16 html_stdstr; | 129 string16 html_stdstr; |
147 GURL gurl; | 130 GURL gurl; |
148 ClipboardReadHTML(buffer_type, &html_stdstr, &gurl, | 131 ClipboardReadHTML(buffer_type, &html_stdstr, &gurl, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 break; | 257 break; |
275 #endif | 258 #endif |
276 default: | 259 default: |
277 NOTREACHED(); | 260 NOTREACHED(); |
278 return false; | 261 return false; |
279 } | 262 } |
280 return true; | 263 return true; |
281 } | 264 } |
282 | 265 |
283 } // namespace webkit_glue | 266 } // namespace webkit_glue |
OLD | NEW |