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

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

Issue 18281002: Move WebDropData to content::DropData and split off conversion function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build error. Created 7 years, 5 months 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
« no previous file with comments | « webkit/common/webdropdata.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/common/webdropdata.h"
6
7 #include <utility>
8
9 #include "base/logging.h"
10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "third_party/WebKit/public/platform/WebData.h"
13 #include "third_party/WebKit/public/platform/WebDragData.h"
14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/WebURL.h"
16 #include "third_party/WebKit/public/platform/WebVector.h"
17 #include "ui/base/clipboard/clipboard.h"
18
19 using WebKit::WebData;
20 using WebKit::WebDragData;
21 using WebKit::WebString;
22 using WebKit::WebVector;
23
24 WebDropData::FileInfo::FileInfo() {
25 }
26
27 WebDropData::FileInfo::FileInfo(const base::string16& path,
28 const base::string16& display_name)
29 : path(path),
30 display_name(display_name) {
31 }
32
33 WebDropData::WebDropData(const WebDragData& drag_data)
34 : referrer_policy(WebKit::WebReferrerPolicyDefault) {
35 const WebVector<WebDragData::Item>& item_list = drag_data.items();
36 for (size_t i = 0; i < item_list.size(); ++i) {
37 const WebDragData::Item& item = item_list[i];
38 switch (item.storageType) {
39 case WebDragData::Item::StorageTypeString: {
40 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) {
41 text = base::NullableString16(item.stringData, false);
42 break;
43 }
44 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeURIList)) {
45 url = GURL(item.stringData);
46 url_title = item.title;
47 break;
48 }
49 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeDownloadURL)) {
50 download_metadata = item.stringData;
51 break;
52 }
53 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) {
54 html = base::NullableString16(item.stringData, false);
55 html_base_url = item.baseURL;
56 break;
57 }
58 custom_data.insert(std::make_pair(item.stringType, item.stringData));
59 break;
60 }
61 case WebDragData::Item::StorageTypeBinaryData:
62 file_contents.assign(item.binaryData.data(),
63 item.binaryData.size());
64 file_description_filename = item.title;
65 break;
66 case WebDragData::Item::StorageTypeFilename:
67 // TODO(varunjain): This only works on chromeos. Support win/mac/gtk.
68 filenames.push_back(FileInfo(item.filenameData,
69 item.displayNameData));
70 break;
71 }
72 }
73 }
74
75 WebDropData::WebDropData()
76 : referrer_policy(WebKit::WebReferrerPolicyDefault) {
77 }
78
79 WebDropData::~WebDropData() {
80 }
OLDNEW
« no previous file with comments | « webkit/common/webdropdata.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698