| 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/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/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); | 228 scw.WriteHTML(UTF8ToUTF16(URLToImageMarkup(url, title)), ""); |
| 229 #endif | 229 #endif |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 void WebClipboardImpl::writeDataObject(const WebDragData& data) { | 233 void WebClipboardImpl::writeDataObject(const WebDragData& data) { |
| 234 ScopedClipboardWriterGlue scw(client_); | 234 ScopedClipboardWriterGlue scw(client_); |
| 235 | 235 |
| 236 WebDropData data_object(data); | 236 WebDropData data_object(data); |
| 237 // TODO(dcheng): Properly support text/uri-list here. | 237 // TODO(dcheng): Properly support text/uri-list here. |
| 238 scw.WriteText(data_object.plain_text); | 238 if (!data_object.text.is_null()) |
| 239 scw.WriteHTML(data_object.text_html, ""); | 239 scw.WriteText(data_object.text.string()); |
| 240 if (!data_object.html.is_null()) |
| 241 scw.WriteHTML(data_object.html.string(), ""); |
| 240 // If there is no custom data, avoid calling WritePickledData. This ensures | 242 // If there is no custom data, avoid calling WritePickledData. This ensures |
| 241 // that ScopedClipboardWriterGlue's dtor remains a no-op if the page didn't | 243 // that ScopedClipboardWriterGlue's dtor remains a no-op if the page didn't |
| 242 // modify the DataTransfer object, which is important to avoid stomping on | 244 // modify the DataTransfer object, which is important to avoid stomping on |
| 243 // any clipboard contents written by extension functions such as | 245 // any clipboard contents written by extension functions such as |
| 244 // chrome.experimental.bookmarkManager.copy. | 246 // chrome.experimental.bookmarkManager.copy. |
| 245 if (!data_object.custom_data.empty()) { | 247 if (!data_object.custom_data.empty()) { |
| 246 Pickle pickle; | 248 Pickle pickle; |
| 247 ui::WriteCustomDataToPickle(data_object.custom_data, &pickle); | 249 ui::WriteCustomDataToPickle(data_object.custom_data, &pickle); |
| 248 scw.WritePickledData(pickle, ui::Clipboard::GetWebCustomDataFormatType()); | 250 scw.WritePickledData(pickle, ui::Clipboard::GetWebCustomDataFormatType()); |
| 249 } | 251 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 261 break; | 263 break; |
| 262 #endif | 264 #endif |
| 263 default: | 265 default: |
| 264 NOTREACHED(); | 266 NOTREACHED(); |
| 265 return false; | 267 return false; |
| 266 } | 268 } |
| 267 return true; | 269 return true; |
| 268 } | 270 } |
| 269 | 271 |
| 270 } // namespace webkit_glue | 272 } // namespace webkit_glue |
| OLD | NEW |