| 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/child/url_conversion.h" |
| 10 #include "content/public/common/drop_data.h" | 11 #include "content/public/common/drop_data.h" |
| 11 #include "third_party/WebKit/public/platform/WebDragData.h" | 12 #include "third_party/WebKit/public/platform/WebDragData.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 #include "ui/base/clipboard/clipboard.h" | 15 #include "ui/base/clipboard/clipboard.h" |
| 15 | 16 |
| 16 using blink::WebDragData; | 17 using blink::WebDragData; |
| 17 using blink::WebVector; | 18 using blink::WebVector; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 DropData DropDataBuilder::Build(const WebDragData& drag_data) { | 23 DropData DropDataBuilder::Build(const WebDragData& drag_data) { |
| 23 DropData result; | 24 DropData result; |
| 24 result.referrer_policy = blink::WebReferrerPolicyDefault; | 25 result.referrer_policy = blink::WebReferrerPolicyDefault; |
| 25 | 26 |
| 26 const WebVector<WebDragData::Item>& item_list = drag_data.items(); | 27 const WebVector<WebDragData::Item>& item_list = drag_data.items(); |
| 27 for (size_t i = 0; i < item_list.size(); ++i) { | 28 for (size_t i = 0; i < item_list.size(); ++i) { |
| 28 const WebDragData::Item& item = item_list[i]; | 29 const WebDragData::Item& item = item_list[i]; |
| 29 switch (item.storageType) { | 30 switch (item.storageType) { |
| 30 case WebDragData::Item::StorageTypeString: { | 31 case WebDragData::Item::StorageTypeString: { |
| 31 base::string16 str_type(item.stringType); | 32 base::string16 str_type(item.stringType); |
| 32 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeText)) { | 33 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeText)) { |
| 33 result.text = base::NullableString16(item.stringData, false); | 34 result.text = base::NullableString16(item.stringData, false); |
| 34 break; | 35 break; |
| 35 } | 36 } |
| 36 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeURIList)) { | 37 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeURIList)) { |
| 37 result.url = GURL(item.stringData); | 38 result.url = WebStringToGURL(item.stringData); |
| 38 result.url_title = item.title; | 39 result.url_title = item.title; |
| 39 break; | 40 break; |
| 40 } | 41 } |
| 41 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeDownloadURL)) { | 42 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeDownloadURL)) { |
| 42 result.download_metadata = item.stringData; | 43 result.download_metadata = item.stringData; |
| 43 break; | 44 break; |
| 44 } | 45 } |
| 45 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeHTML)) { | 46 if (base::EqualsASCII(str_type, ui::Clipboard::kMimeTypeHTML)) { |
| 46 result.html = base::NullableString16(item.stringData, false); | 47 result.html = base::NullableString16(item.stringData, false); |
| 47 result.html_base_url = item.baseURL; | 48 result.html_base_url = item.baseURL; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 result.file_system_files.push_back(info); | 70 result.file_system_files.push_back(info); |
| 70 break; | 71 break; |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 | 75 |
| 75 return result; | 76 return result; |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace content | 79 } // namespace content |
| OLD | NEW |