Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: webkit/glue/webdropdata.cc

Issue 8775025: Add glue for supporting custom MIME types in DataTransfer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <utility>
8
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
12 14
13 using WebKit::WebData; 15 using WebKit::WebData;
14 using WebKit::WebDragData; 16 using WebKit::WebDragData;
15 using WebKit::WebString; 17 using WebKit::WebString;
16 using WebKit::WebVector; 18 using WebKit::WebVector;
17 19
18 WebDropData::WebDropData(const WebDragData& drag_data) 20 WebDropData::WebDropData(const WebDragData& drag_data)
19 : url(drag_data.url()), 21 : url(drag_data.url()),
20 url_title(drag_data.urlTitle()), 22 url_title(drag_data.urlTitle()),
21 download_metadata(drag_data.downloadMetadata()), 23 download_metadata(drag_data.downloadMetadata()),
22 file_extension(drag_data.fileExtension()), 24 file_extension(drag_data.fileExtension()),
23 plain_text(drag_data.plainText()), 25 plain_text(drag_data.plainText()),
24 text_html(drag_data.htmlText()), 26 text_html(drag_data.htmlText()),
25 html_base_url(drag_data.htmlBaseURL()), 27 html_base_url(drag_data.htmlBaseURL()),
26 file_description_filename(drag_data.fileContentFilename()) { 28 file_description_filename(drag_data.fileContentFilename()) {
27 if (drag_data.containsFilenames()) { 29 if (drag_data.containsFilenames()) {
28 WebVector<WebString> filenames_copy; 30 WebVector<WebString> filenames_copy;
29 drag_data.filenames(filenames_copy); 31 drag_data.filenames(filenames_copy);
30 for (size_t i = 0; i < filenames_copy.size(); ++i) 32 for (size_t i = 0; i < filenames_copy.size(); ++i)
31 filenames.push_back(filenames_copy[i]); 33 filenames.push_back(filenames_copy[i]);
32 } 34 }
33 WebData contents = drag_data.fileContent(); 35 WebData contents = drag_data.fileContent();
34 if (!contents.isEmpty()) 36 if (!contents.isEmpty())
35 file_contents.assign(contents.data(), contents.size()); 37 file_contents.assign(contents.data(), contents.size());
38 WebVector<WebDragData::CustomData> custom_data_copy = drag_data.customData();
39 for (size_t i = 0; i < custom_data_copy.size(); ++i)
tony 2011/12/02 00:13:29 Nit: The for loop should use {} since the body is
dcheng 2011/12/02 00:29:17 Done.
40 custom_data.insert(std::make_pair(custom_data_copy[i].m_type,
41 custom_data_copy[i].m_data));
36 } 42 }
37 43
38 WebDropData::WebDropData() { 44 WebDropData::WebDropData() {
39 } 45 }
40 46
41 WebDropData::~WebDropData() { 47 WebDropData::~WebDropData() {
42 } 48 }
43 49
44 WebDragData WebDropData::ToDragData() const { 50 WebDragData WebDropData::ToDragData() const {
45 WebDragData result; 51 WebDragData result;
46 result.initialize(); 52 result.initialize();
47 result.setURL(url); 53 result.setURL(url);
48 result.setURLTitle(url_title); 54 result.setURLTitle(url_title);
49 result.setFileExtension(file_extension); 55 result.setFileExtension(file_extension);
50 result.setFilenames(filenames); 56 result.setFilenames(filenames);
51 result.setPlainText(plain_text); 57 result.setPlainText(plain_text);
52 result.setHTMLText(text_html); 58 result.setHTMLText(text_html);
53 result.setHTMLBaseURL(html_base_url); 59 result.setHTMLBaseURL(html_base_url);
54 result.setFileContentFilename(file_description_filename); 60 result.setFileContentFilename(file_description_filename);
55 result.setFileContent(WebData(file_contents.data(), file_contents.size())); 61 result.setFileContent(WebData(file_contents.data(), file_contents.size()));
62 WebVector<WebDragData::CustomData> custom_data_vector(custom_data.size());
63 size_t i = 0;
64 for (std::map<string16, string16>::const_iterator it = custom_data.begin();
65 it != custom_data.end();
66 ++it) {
67 WebDragData::CustomData data = {it->first, it->second};
68 custom_data_vector[i++] = data;
tony 2011/12/02 00:13:29 Nit: I think it's a bit easier to read with i as p
dcheng 2011/12/02 00:29:17 Done.
69 }
56 return result; 70 return result;
57 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698