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/Source/WebKit/chromium/public/WebData.h" | 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | 11 #include "third_party/WebKit/Source/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 | |
22 WebDropData::WebDropData(const WebDragData& drag_data) | 18 WebDropData::WebDropData(const WebDragData& drag_data) |
23 : identity(0), | 19 : url(drag_data.url()), |
24 url(drag_data.url()), | |
25 url_title(drag_data.urlTitle()), | 20 url_title(drag_data.urlTitle()), |
26 download_metadata(drag_data.downloadMetadata()), | 21 download_metadata(drag_data.downloadMetadata()), |
27 file_extension(drag_data.fileExtension()), | 22 file_extension(drag_data.fileExtension()), |
28 plain_text(drag_data.plainText()), | 23 plain_text(drag_data.plainText()), |
29 text_html(drag_data.htmlText()), | 24 text_html(drag_data.htmlText()), |
30 html_base_url(drag_data.htmlBaseURL()), | 25 html_base_url(drag_data.htmlBaseURL()), |
31 file_description_filename(drag_data.fileContentFilename()) { | 26 file_description_filename(drag_data.fileContentFilename()) { |
32 if (drag_data.containsFilenames()) { | 27 if (drag_data.containsFilenames()) { |
33 WebVector<WebString> filenames_copy; | 28 WebVector<WebString> filenames_copy; |
34 drag_data.filenames(filenames_copy); | 29 drag_data.filenames(filenames_copy); |
35 for (size_t i = 0; i < filenames_copy.size(); ++i) | 30 for (size_t i = 0; i < filenames_copy.size(); ++i) |
36 filenames.push_back(filenames_copy[i]); | 31 filenames.push_back(filenames_copy[i]); |
37 } | 32 } |
38 WebData contents = drag_data.fileContent(); | 33 WebData contents = drag_data.fileContent(); |
39 if (!contents.isEmpty()) | 34 if (!contents.isEmpty()) |
40 file_contents.assign(contents.data(), contents.size()); | 35 file_contents.assign(contents.data(), contents.size()); |
41 } | 36 } |
42 | 37 |
43 WebDropData::WebDropData() | 38 WebDropData::WebDropData() { |
44 : identity(0) { | |
45 } | 39 } |
46 | 40 |
47 WebDropData::~WebDropData() { | 41 WebDropData::~WebDropData() { |
48 } | 42 } |
49 | 43 |
50 WebDragData WebDropData::ToDragData() const { | 44 WebDragData WebDropData::ToDragData() const { |
51 WebDragData result; | 45 WebDragData result; |
52 result.initialize(); | 46 result.initialize(); |
53 result.setURL(url); | 47 result.setURL(url); |
54 result.setURLTitle(url_title); | 48 result.setURLTitle(url_title); |
55 result.setFileExtension(file_extension); | 49 result.setFileExtension(file_extension); |
56 result.setFilenames(filenames); | 50 result.setFilenames(filenames); |
57 result.setPlainText(plain_text); | 51 result.setPlainText(plain_text); |
58 result.setHTMLText(text_html); | 52 result.setHTMLText(text_html); |
59 result.setHTMLBaseURL(html_base_url); | 53 result.setHTMLBaseURL(html_base_url); |
60 result.setFileContentFilename(file_description_filename); | 54 result.setFileContentFilename(file_description_filename); |
61 result.setFileContent(WebData(file_contents.data(), file_contents.size())); | 55 result.setFileContent(WebData(file_contents.data(), file_contents.size())); |
62 return result; | 56 return result; |
63 } | 57 } |
OLD | NEW |