Enable WebAudio support on Android/x86.
[chromium-blink-merge.git] / content / renderer / drop_data_builder.cc
blobf9e5c420d3ccdee07ac37950b23ae7006c7544a5
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.
5 #include "content/renderer/drop_data_builder.h"
7 #include "base/strings/string_util.h"
8 #include "content/public/common/drop_data.h"
9 #include "third_party/WebKit/public/platform/WebDragData.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/platform/WebVector.h"
12 #include "ui/base/clipboard/clipboard.h"
14 using blink::WebDragData;
15 using blink::WebVector;
17 namespace content {
19 //static
20 DropData DropDataBuilder::Build(const WebDragData& drag_data) {
21 DropData result;
22 result.referrer_policy = blink::WebReferrerPolicyDefault;
24 const WebVector<WebDragData::Item>& item_list = drag_data.items();
25 for (size_t i = 0; i < item_list.size(); ++i) {
26 const WebDragData::Item& item = item_list[i];
27 switch (item.storageType) {
28 case WebDragData::Item::StorageTypeString: {
29 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) {
30 result.text = base::NullableString16(item.stringData, false);
31 break;
33 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeURIList)) {
34 result.url = GURL(item.stringData);
35 result.url_title = item.title;
36 break;
38 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeDownloadURL)) {
39 result.download_metadata = item.stringData;
40 break;
42 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) {
43 result.html = base::NullableString16(item.stringData, false);
44 result.html_base_url = item.baseURL;
45 break;
47 result.custom_data.insert(
48 std::make_pair(item.stringType, item.stringData));
49 break;
51 case WebDragData::Item::StorageTypeBinaryData:
52 result.file_contents.assign(item.binaryData.data(),
53 item.binaryData.size());
54 result.file_description_filename = item.title;
55 break;
56 case WebDragData::Item::StorageTypeFilename:
57 // TODO(varunjain): This only works on chromeos. Support win/mac/gtk.
58 result.filenames.push_back(
59 DropData::FileInfo(item.filenameData, item.displayNameData));
60 break;
64 return result;
67 } // namespace content