OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "content/renderer/drop_data_builder.h" | 5 #include "content/renderer/drop_data_builder.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/public/common/drop_data.h" | 8 #include "content/public/common/drop_data.h" |
9 #include "third_party/WebKit/public/platform/WebDragData.h" | 9 #include "third_party/WebKit/public/platform/WebDragData.h" |
10 #include "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
11 #include "third_party/WebKit/public/platform/WebVector.h" | 11 #include "third_party/WebKit/public/platform/WebVector.h" |
12 #include "ui/base/clipboard/clipboard.h" | 12 #include "ui/base/clipboard/clipboard.h" |
13 | 13 |
14 using blink::WebDragData; | 14 using blink::WebDragData; |
15 using blink::WebVector; | 15 using blink::WebVector; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 //static | 19 //static |
20 DropData DropDataBuilder::Build(const WebDragData& drag_data) { | 20 DropData DropDataBuilder::Build(const WebDragData& drag_data) { |
21 DropData result; | 21 DropData result; |
22 result.referrer_policy = blink::WebReferrerPolicyDefault; | 22 result.referrer_policy = blink::WebReferrerPolicyDefault; |
23 | 23 |
24 const WebVector<WebDragData::Item>& item_list = drag_data.items(); | 24 const WebVector<WebDragData::Item>& item_list = drag_data.items(); |
25 for (size_t i = 0; i < item_list.size(); ++i) { | 25 for (size_t i = 0; i < item_list.size(); ++i) { |
26 const WebDragData::Item& item = item_list[i]; | 26 const WebDragData::Item& item = item_list[i]; |
27 switch (item.storageType) { | 27 switch (item.storageType) { |
28 case WebDragData::Item::StorageTypeString: { | 28 case WebDragData::Item::StorageTypeString: { |
29 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) { | 29 if (base::EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) { |
30 result.text = base::NullableString16(item.stringData, false); | 30 result.text = base::NullableString16(item.stringData, false); |
31 break; | 31 break; |
32 } | 32 } |
33 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeURIList)) { | 33 if (base::EqualsASCII(item.stringType, |
| 34 ui::Clipboard::kMimeTypeURIList)) { |
34 result.url = GURL(item.stringData); | 35 result.url = GURL(item.stringData); |
35 result.url_title = item.title; | 36 result.url_title = item.title; |
36 break; | 37 break; |
37 } | 38 } |
38 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeDownloadURL)) { | 39 if (base::EqualsASCII(item.stringType, |
| 40 ui::Clipboard::kMimeTypeDownloadURL)) { |
39 result.download_metadata = item.stringData; | 41 result.download_metadata = item.stringData; |
40 break; | 42 break; |
41 } | 43 } |
42 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) { | 44 if (base::EqualsASCII(item.stringType, |
| 45 ui::Clipboard::kMimeTypeHTML)) { |
43 result.html = base::NullableString16(item.stringData, false); | 46 result.html = base::NullableString16(item.stringData, false); |
44 result.html_base_url = item.baseURL; | 47 result.html_base_url = item.baseURL; |
45 break; | 48 break; |
46 } | 49 } |
47 result.custom_data.insert( | 50 result.custom_data.insert( |
48 std::make_pair(item.stringType, item.stringData)); | 51 std::make_pair(item.stringType, item.stringData)); |
49 break; | 52 break; |
50 } | 53 } |
51 case WebDragData::Item::StorageTypeBinaryData: | 54 case WebDragData::Item::StorageTypeBinaryData: |
52 result.file_contents.assign(item.binaryData.data(), | 55 result.file_contents.assign(item.binaryData.data(), |
(...skipping 13 matching lines...) Expand all Loading... |
66 result.file_system_files.push_back(info); | 69 result.file_system_files.push_back(info); |
67 break; | 70 break; |
68 } | 71 } |
69 } | 72 } |
70 } | 73 } |
71 | 74 |
72 return result; | 75 return result; |
73 } | 76 } |
74 | 77 |
75 } // namespace content | 78 } // namespace content |
OLD | NEW |