OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/clipboard/clipboard_standalone_impl.h" | 5 #include "services/clipboard/clipboard_standalone_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/public/cpp/bindings/array.h" | 10 #include "mojo/public/cpp/bindings/array.h" |
11 #include "mojo/public/cpp/bindings/callback.h" | 11 #include "mojo/public/cpp/bindings/callback.h" |
12 #include "mojo/public/cpp/bindings/string.h" | 12 #include "mojo/public/cpp/bindings/string.h" |
13 | 13 |
14 using mojo::Array; | 14 using mojo::Array; |
15 using mojo::Map; | 15 using mojo::Map; |
16 using mojo::String; | 16 using mojo::String; |
17 | 17 |
18 namespace clipboard { | 18 namespace clipboard { |
19 | 19 |
20 // ClipboardData contains data copied to the Clipboard for a variety of formats. | 20 // ClipboardData contains data copied to the Clipboard for a variety of formats. |
21 // It mostly just provides APIs to cleanly access and manipulate this data. | 21 // It mostly just provides APIs to cleanly access and manipulate this data. |
22 class ClipboardStandaloneImpl::ClipboardData { | 22 class ClipboardStandaloneImpl::ClipboardData { |
23 public: | 23 public: |
24 ClipboardData() {} | 24 ClipboardData() {} |
25 ~ClipboardData() {} | 25 ~ClipboardData() {} |
26 | 26 |
27 Array<String> GetMimeTypes() const { | 27 Array<String> GetMimeTypes() const { |
28 Array<String> types(data_types_.size()); | 28 auto types = Array<String>::New(data_types_.size()); |
29 int i = 0; | 29 int i = 0; |
30 for (auto it = data_types_.cbegin(); it != data_types_.cend(); ++it, ++i) | 30 for (auto it = data_types_.cbegin(); it != data_types_.cend(); ++it, ++i) |
31 types[i] = it.GetKey(); | 31 types[i] = it.GetKey(); |
32 | 32 |
33 return types.Pass(); | 33 return types.Pass(); |
34 } | 34 } |
35 | 35 |
36 void SetData(Map<String, Array<uint8_t>> data) { data_types_ = data.Pass(); } | 36 void SetData(Map<String, Array<uint8_t>> data) { data_types_ = data.Pass(); } |
37 | 37 |
38 void GetData(const String& mime_type, Array<uint8_t>* data) const { | 38 void GetData(const String& mime_type, Array<uint8_t>* data) const { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void ClipboardStandaloneImpl::WriteClipboardData( | 89 void ClipboardStandaloneImpl::WriteClipboardData( |
90 Clipboard::Type clipboard_type, | 90 Clipboard::Type clipboard_type, |
91 Map<String, Array<uint8_t>> data) { | 91 Map<String, Array<uint8_t>> data) { |
92 const size_t ndx = static_cast<size_t>(clipboard_type); | 92 const size_t ndx = static_cast<size_t>(clipboard_type); |
93 CHECK_LT(ndx, arraysize(sequence_number_)); | 93 CHECK_LT(ndx, arraysize(sequence_number_)); |
94 sequence_number_[ndx]++; | 94 sequence_number_[ndx]++; |
95 clipboard_state_[ndx]->SetData(data.Pass()); | 95 clipboard_state_[ndx]->SetData(data.Pass()); |
96 } | 96 } |
97 | 97 |
98 } // namespace clipboard | 98 } // namespace clipboard |
OLD | NEW |