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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/public/common/drop_data.h" | 10 #include "content/public/common/drop_data.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 for (size_t i = 0; i < item_list.size(); ++i) { | 30 for (size_t i = 0; i < item_list.size(); ++i) { |
31 const WebDragData::Item& item = item_list[i]; | 31 const WebDragData::Item& item = item_list[i]; |
32 switch (item.storageType) { | 32 switch (item.storageType) { |
33 case WebDragData::Item::StorageTypeString: { | 33 case WebDragData::Item::StorageTypeString: { |
34 base::string16 str_type(item.stringType); | 34 base::string16 str_type(item.stringType); |
35 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeText)) { | 35 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeText)) { |
36 result.text = base::NullableString16(item.stringData, false); | 36 result.text = base::NullableString16(item.stringData, false); |
37 break; | 37 break; |
38 } | 38 } |
39 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeURIList)) { | 39 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeURIList)) { |
40 result.url = blink::WebStringToGURL(item.stringData); | 40 // The url in WebDragData received could be empty at DragEnter time, |
dcheng
2016/06/15 12:00:39
Let's do this this when we convert DropData::Metad
hush (inactive)
2016/06/15 18:02:59
Done.
| |
41 // because the URL is not available at DragEnter. We need to convert | |
42 // to a dummy URL instead of an empty URL, because the latter means | |
43 // "no URL is in DropData". | |
44 if (item.stringData.isEmpty()) { | |
45 result.url = GURL("about:dragdrop-placeholder"); | |
46 } else { | |
47 result.url = blink::WebStringToGURL(item.stringData); | |
48 } | |
41 result.url_title = item.title; | 49 result.url_title = item.title; |
42 break; | 50 break; |
43 } | 51 } |
44 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeDownloadURL)) { | 52 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeDownloadURL)) { |
45 result.download_metadata = item.stringData; | 53 result.download_metadata = item.stringData; |
46 break; | 54 break; |
47 } | 55 } |
48 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeHTML)) { | 56 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeHTML)) { |
49 result.html = base::NullableString16(item.stringData, false); | 57 result.html = base::NullableString16(item.stringData, false); |
50 result.html_base_url = item.baseURL; | 58 result.html_base_url = item.baseURL; |
(...skipping 21 matching lines...) Expand all Loading... | |
72 result.file_system_files.push_back(info); | 80 result.file_system_files.push_back(info); |
73 break; | 81 break; |
74 } | 82 } |
75 } | 83 } |
76 } | 84 } |
77 | 85 |
78 return result; | 86 return result; |
79 } | 87 } |
80 | 88 |
81 } // namespace content | 89 } // namespace content |
OLD | NEW |