| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "webkit/glue/webdropdata.h" | 5 #include "webkit/glue/webdropdata.h" |
| 6 | 6 |
| 7 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 7 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
| 8 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 8 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 11 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
| 12 | 12 |
| 13 using WebKit::WebData; | 13 using WebKit::WebData; |
| 14 using WebKit::WebDragData; | 14 using WebKit::WebDragData; |
| 15 using WebKit::WebString; | 15 using WebKit::WebString; |
| 16 using WebKit::WebVector; | 16 using WebKit::WebVector; |
| 17 | 17 |
| 18 WebDropData::WebDropData(int32 drag_identity) |
| 19 : identity(drag_identity) { |
| 20 } |
| 21 |
| 18 WebDropData::WebDropData(const WebDragData& drag_data) | 22 WebDropData::WebDropData(const WebDragData& drag_data) |
| 19 : identity(0), | 23 : identity(0), |
| 20 url(drag_data.url()), | 24 url(drag_data.url()), |
| 21 url_title(drag_data.urlTitle()), | 25 url_title(drag_data.urlTitle()), |
| 22 download_metadata(drag_data.downloadMetadata()), | 26 download_metadata(drag_data.downloadMetadata()), |
| 23 file_extension(drag_data.fileExtension()), | 27 file_extension(drag_data.fileExtension()), |
| 24 plain_text(drag_data.plainText()), | 28 plain_text(drag_data.plainText()), |
| 25 text_html(drag_data.htmlText()), | 29 text_html(drag_data.htmlText()), |
| 26 html_base_url(drag_data.htmlBaseURL()), | 30 html_base_url(drag_data.htmlBaseURL()), |
| 27 file_description_filename(drag_data.fileContentFileName()) { | 31 file_description_filename(drag_data.fileContentFileName()) { |
| 28 if (drag_data.hasFileNames()) { | 32 if (drag_data.hasFileNames()) { |
| 29 WebVector<WebString> fileNames; | 33 WebVector<WebString> fileNames; |
| 30 drag_data.fileNames(fileNames); | 34 drag_data.fileNames(fileNames); |
| 31 for (size_t i = 0; i < fileNames.size(); ++i) | 35 for (size_t i = 0; i < fileNames.size(); ++i) |
| 32 filenames.push_back(fileNames[i]); | 36 filenames.push_back(fileNames[i]); |
| 33 } | 37 } |
| 34 WebData contents = drag_data.fileContent(); | 38 WebData contents = drag_data.fileContent(); |
| 35 if (!contents.isEmpty()) | 39 if (!contents.isEmpty()) |
| 36 file_contents.assign(contents.data(), contents.size()); | 40 file_contents.assign(contents.data(), contents.size()); |
| 37 } | 41 } |
| 38 | 42 |
| 43 WebDropData::WebDropData() |
| 44 : identity(0) { |
| 45 } |
| 46 |
| 47 WebDropData::~WebDropData() { |
| 48 } |
| 49 |
| 39 WebDragData WebDropData::ToDragData() const { | 50 WebDragData WebDropData::ToDragData() const { |
| 40 WebDragData result; | 51 WebDragData result; |
| 41 result.initialize(); | 52 result.initialize(); |
| 42 result.setURL(url); | 53 result.setURL(url); |
| 43 result.setURLTitle(url_title); | 54 result.setURLTitle(url_title); |
| 44 result.setFileExtension(file_extension); | 55 result.setFileExtension(file_extension); |
| 45 result.setFileNames(filenames); | 56 result.setFileNames(filenames); |
| 46 result.setPlainText(plain_text); | 57 result.setPlainText(plain_text); |
| 47 result.setHTMLText(text_html); | 58 result.setHTMLText(text_html); |
| 48 result.setHTMLBaseURL(html_base_url); | 59 result.setHTMLBaseURL(html_base_url); |
| 49 result.setFileContentFileName(file_description_filename); | 60 result.setFileContentFileName(file_description_filename); |
| 50 result.setFileContent(WebData(file_contents.data(), file_contents.size())); | 61 result.setFileContent(WebData(file_contents.data(), file_contents.size())); |
| 51 return result; | 62 return result; |
| 52 } | 63 } |
| OLD | NEW |