| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "webkit/glue/clipboard_conversion.h" | 7 #include "webkit/glue/clipboard_conversion.h" |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #include "ChromiumDataObject.h" | 11 #include "ChromiumDataObject.h" |
| 12 #include "ClipboardUtilitiesChromium.h" | 12 #include "ClipboardUtilitiesChromium.h" |
| 13 #include "KURL.h" | 13 #include "KURL.h" |
| 14 #include "SharedBuffer.h" | 14 #include "SharedBuffer.h" |
| 15 #include <wtf/Vector.h> | 15 #include <wtf/Vector.h> |
| 16 | 16 |
| 17 #include "webkit/glue/glue_util.h" | 17 #include "webkit/glue/glue_util.h" |
| 18 | 18 |
| 19 namespace webkit_glue { | 19 namespace webkit_glue { |
| 20 | 20 |
| 21 WebDropData ChromiumDataObjectToWebDropData( | 21 WebDropData ChromiumDataObjectToWebDropData( |
| 22 WebCore::ChromiumDataObject* data_object) { | 22 WebCore::ChromiumDataObject* data_object) { |
| 23 WebDropData drop_data; | 23 WebDropData drop_data; |
| 24 drop_data.url = KURLToGURL(data_object->url); | 24 drop_data.url = KURLToGURL(data_object->url); |
| 25 drop_data.url_title = StringToStdWString(data_object->urlTitle); | 25 drop_data.url_title = StringToStdWString(data_object->urlTitle); |
| 26 | 26 |
| 27 drop_data.file_extension = StringToStdWString(data_object->fileExtension); |
| 28 |
| 27 for (size_t i = 0; i < data_object->filenames.size(); ++i) { | 29 for (size_t i = 0; i < data_object->filenames.size(); ++i) { |
| 28 drop_data.filenames.push_back(StringToStdWString( | 30 drop_data.filenames.push_back(StringToStdWString( |
| 29 data_object->filenames[i])); | 31 data_object->filenames[i])); |
| 30 } | 32 } |
| 31 | 33 |
| 32 drop_data.plain_text = StringToStdWString(data_object->plainText); | 34 drop_data.plain_text = StringToStdWString(data_object->plainText); |
| 33 | 35 |
| 34 drop_data.text_html = StringToStdWString(data_object->textHtml); | 36 drop_data.text_html = StringToStdWString(data_object->textHtml); |
| 35 drop_data.html_base_url = KURLToGURL(data_object->htmlBaseUrl); | 37 drop_data.html_base_url = KURLToGURL(data_object->htmlBaseUrl); |
| 36 | 38 |
| 37 drop_data.file_description_filename = StringToStdWString( | 39 drop_data.file_description_filename = StringToStdWString( |
| 38 data_object->fileContentFilename); | 40 data_object->fileContentFilename); |
| 39 if (data_object->fileContent) { | 41 if (data_object->fileContent) { |
| 40 drop_data.file_contents.assign(data_object->fileContent->data(), | 42 drop_data.file_contents.assign(data_object->fileContent->data(), |
| 41 data_object->fileContent->size()); | 43 data_object->fileContent->size()); |
| 42 } | 44 } |
| 43 | 45 |
| 44 return drop_data; | 46 return drop_data; |
| 45 } | 47 } |
| 46 | 48 |
| 47 PassRefPtr<WebCore::ChromiumDataObject> WebDropDataToChromiumDataObject( | 49 PassRefPtr<WebCore::ChromiumDataObject> WebDropDataToChromiumDataObject( |
| 48 const WebDropData& drop_data) { | 50 const WebDropData& drop_data) { |
| 49 RefPtr<WebCore::ChromiumDataObject> data_object = | 51 RefPtr<WebCore::ChromiumDataObject> data_object = |
| 50 WebCore::ChromiumDataObject::create(); | 52 WebCore::ChromiumDataObject::create(); |
| 51 data_object->url = GURLToKURL(drop_data.url); | 53 data_object->url = GURLToKURL(drop_data.url); |
| 52 data_object->urlTitle = StdWStringToString(drop_data.url_title); | 54 data_object->urlTitle = StdWStringToString(drop_data.url_title); |
| 53 | 55 |
| 56 data_object->fileExtension = StdWStringToString(drop_data.file_extension); |
| 57 |
| 54 for (size_t i = 0; i < drop_data.filenames.size(); ++i) { | 58 for (size_t i = 0; i < drop_data.filenames.size(); ++i) { |
| 55 data_object->filenames.append(StdWStringToString(drop_data.filenames[i])); | 59 data_object->filenames.append(StdWStringToString(drop_data.filenames[i])); |
| 56 } | 60 } |
| 57 | 61 |
| 58 data_object->plainText = StdWStringToString(drop_data.plain_text); | 62 data_object->plainText = StdWStringToString(drop_data.plain_text); |
| 59 | 63 |
| 60 data_object->textHtml = StdWStringToString(drop_data.text_html); | 64 data_object->textHtml = StdWStringToString(drop_data.text_html); |
| 61 data_object->htmlBaseUrl = GURLToKURL(drop_data.html_base_url); | 65 data_object->htmlBaseUrl = GURLToKURL(drop_data.html_base_url); |
| 62 | 66 |
| 63 data_object->fileContentFilename = StdWStringToString( | 67 data_object->fileContentFilename = StdWStringToString( |
| 64 drop_data.file_description_filename); | 68 drop_data.file_description_filename); |
| 65 if (!drop_data.file_contents.empty()) { | 69 if (!drop_data.file_contents.empty()) { |
| 66 data_object->fileContent = | 70 data_object->fileContent = |
| 67 WebCore::SharedBuffer::create(drop_data.file_contents.data(), | 71 WebCore::SharedBuffer::create(drop_data.file_contents.data(), |
| 68 drop_data.file_contents.size()); | 72 drop_data.file_contents.size()); |
| 69 } | 73 } |
| 70 | 74 |
| 71 return data_object; | 75 return data_object; |
| 72 } | 76 } |
| 73 | 77 |
| 74 } // namespace webkit_glue | 78 } // namespace webkit_glue |
| OLD | NEW |