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 "webkit/common/webdropdata.h" | 5 #include "webkit/common/webdropdata.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 WebDropData::FileInfo::FileInfo(const base::string16& path, | 27 WebDropData::FileInfo::FileInfo(const base::string16& path, |
28 const base::string16& display_name) | 28 const base::string16& display_name) |
29 : path(path), | 29 : path(path), |
30 display_name(display_name) { | 30 display_name(display_name) { |
31 } | 31 } |
32 | 32 |
33 WebDropData::WebDropData(const WebDragData& drag_data) | 33 WebDropData::WebDropData(const WebDragData& drag_data) |
34 : referrer_policy(WebKit::WebReferrerPolicyDefault), | 34 : referrer_policy(WebKit::WebReferrerPolicyDefault), |
35 text(NullableString16(true)), | 35 text(base::NullableString16(true)), |
36 html(NullableString16(true)) { | 36 html(base::NullableString16(true)) { |
37 const WebVector<WebDragData::Item>& item_list = drag_data.items(); | 37 const WebVector<WebDragData::Item>& item_list = drag_data.items(); |
38 for (size_t i = 0; i < item_list.size(); ++i) { | 38 for (size_t i = 0; i < item_list.size(); ++i) { |
39 const WebDragData::Item& item = item_list[i]; | 39 const WebDragData::Item& item = item_list[i]; |
40 switch (item.storageType) { | 40 switch (item.storageType) { |
41 case WebDragData::Item::StorageTypeString: { | 41 case WebDragData::Item::StorageTypeString: { |
42 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) { | 42 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) { |
43 text = NullableString16(item.stringData, false); | 43 text = base::NullableString16(item.stringData, false); |
44 break; | 44 break; |
45 } | 45 } |
46 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeURIList)) { | 46 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeURIList)) { |
47 url = GURL(item.stringData); | 47 url = GURL(item.stringData); |
48 url_title = item.title; | 48 url_title = item.title; |
49 break; | 49 break; |
50 } | 50 } |
51 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeDownloadURL)) { | 51 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeDownloadURL)) { |
52 download_metadata = item.stringData; | 52 download_metadata = item.stringData; |
53 break; | 53 break; |
54 } | 54 } |
55 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) { | 55 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) { |
56 html = NullableString16(item.stringData, false); | 56 html = base::NullableString16(item.stringData, false); |
57 html_base_url = item.baseURL; | 57 html_base_url = item.baseURL; |
58 break; | 58 break; |
59 } | 59 } |
60 custom_data.insert(std::make_pair(item.stringType, item.stringData)); | 60 custom_data.insert(std::make_pair(item.stringType, item.stringData)); |
61 break; | 61 break; |
62 } | 62 } |
63 case WebDragData::Item::StorageTypeBinaryData: | 63 case WebDragData::Item::StorageTypeBinaryData: |
64 file_contents.assign(item.binaryData.data(), | 64 file_contents.assign(item.binaryData.data(), |
65 item.binaryData.size()); | 65 item.binaryData.size()); |
66 file_description_filename = item.title; | 66 file_description_filename = item.title; |
67 break; | 67 break; |
68 case WebDragData::Item::StorageTypeFilename: | 68 case WebDragData::Item::StorageTypeFilename: |
69 // TODO(varunjain): This only works on chromeos. Support win/mac/gtk. | 69 // TODO(varunjain): This only works on chromeos. Support win/mac/gtk. |
70 filenames.push_back(FileInfo(item.filenameData, | 70 filenames.push_back(FileInfo(item.filenameData, |
71 item.displayNameData)); | 71 item.displayNameData)); |
72 break; | 72 break; |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 WebDropData::WebDropData() | 77 WebDropData::WebDropData() |
78 : referrer_policy(WebKit::WebReferrerPolicyDefault), | 78 : referrer_policy(WebKit::WebReferrerPolicyDefault), |
79 text(NullableString16(true)), | 79 text(base::NullableString16(true)), |
80 html(NullableString16(true)) { | 80 html(base::NullableString16(true)) { |
81 } | 81 } |
82 | 82 |
83 WebDropData::~WebDropData() { | 83 WebDropData::~WebDropData() { |
84 } | 84 } |
OLD | NEW |