OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/aura/mus/os_exchange_data_provider_mus.h" | 5 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "mojo/common/common_type_converters.h" | |
18 #include "net/base/filename_util.h" | 17 #include "net/base/filename_util.h" |
19 #include "services/ui/public/interfaces/clipboard.mojom.h" | 18 #include "services/ui/public/interfaces/clipboard.mojom.h" |
20 #include "ui/base/dragdrop/file_info.h" | 19 #include "ui/base/dragdrop/file_info.h" |
21 #include "url/gurl.h" | 20 #include "url/gurl.h" |
22 | 21 |
23 namespace aura { | 22 namespace aura { |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 std::vector<uint8_t> FromString(const std::string& str) { | 26 std::vector<uint8_t> FromString(const std::string& str) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 mime_data_[ui::mojom::kMimeTypeURIList] = FromString(joined_data); | 123 mime_data_[ui::mojom::kMimeTypeURIList] = FromString(joined_data); |
125 } | 124 } |
126 | 125 |
127 void OSExchangeDataProviderMus::SetPickledData( | 126 void OSExchangeDataProviderMus::SetPickledData( |
128 const ui::Clipboard::FormatType& format, | 127 const ui::Clipboard::FormatType& format, |
129 const base::Pickle& pickle) { | 128 const base::Pickle& pickle) { |
130 const unsigned char* bytes = | 129 const unsigned char* bytes = |
131 reinterpret_cast<const unsigned char*>(pickle.data()); | 130 reinterpret_cast<const unsigned char*>(pickle.data()); |
132 | 131 |
133 mime_data_[format.Serialize()] = | 132 mime_data_[format.Serialize()] = |
134 mojo::Array<uint8_t>(std::vector<uint8_t>(bytes, bytes + pickle.size())); | 133 std::vector<uint8_t>(bytes, bytes + pickle.size()); |
135 } | 134 } |
136 | 135 |
137 bool OSExchangeDataProviderMus::GetString(base::string16* data) const { | 136 bool OSExchangeDataProviderMus::GetString(base::string16* data) const { |
138 auto it = mime_data_.find(ui::mojom::kMimeTypeText); | 137 auto it = mime_data_.find(ui::mojom::kMimeTypeText); |
139 if (it != mime_data_.end()) | 138 if (it != mime_data_.end()) |
140 *data = base::UTF8ToUTF16(ToString(it->second)); | 139 *data = base::UTF8ToUTF16(ToString(it->second)); |
141 return it != mime_data_.end(); | 140 return it != mime_data_.end(); |
142 } | 141 } |
143 | 142 |
144 bool OSExchangeDataProviderMus::GetURLAndTitle( | 143 bool OSExchangeDataProviderMus::GetURLAndTitle( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 GURL test_url(str); | 356 GURL test_url(str); |
358 if (!test_url.is_valid()) | 357 if (!test_url.is_valid()) |
359 return false; | 358 return false; |
360 | 359 |
361 if (url) | 360 if (url) |
362 *url = test_url; | 361 *url = test_url; |
363 return true; | 362 return true; |
364 } | 363 } |
365 | 364 |
366 } // namespace aura | 365 } // namespace aura |
OLD | NEW |