OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ | |
6 #define COMPONENTS_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 #include <utility> | |
11 | |
12 #include "mojo/public/cpp/bindings/array.h" | |
13 #include "mojo/public/cpp/bindings/type_converter.h" | |
14 #include "third_party/WebKit/public/platform/WebVector.h" | |
15 #include "ui/mojo/geometry/geometry.mojom.h" | |
16 | |
17 namespace blink { | |
18 struct WebRect; | |
19 class WebString; | |
20 } | |
21 | |
22 namespace mojo { | |
23 class String; | |
24 | |
25 template<> | |
26 struct TypeConverter<String, blink::WebString> { | |
27 static String Convert(const blink::WebString& str); | |
28 }; | |
29 template<> | |
30 struct TypeConverter<blink::WebString, String> { | |
31 static blink::WebString Convert(const String& str); | |
32 }; | |
33 template <> | |
34 struct TypeConverter<Array<uint8_t>, blink::WebString> { | |
35 static Array<uint8_t> Convert(const blink::WebString& input); | |
36 }; | |
37 template <> | |
38 struct TypeConverter<blink::WebString, Array<uint8_t>> { | |
39 static blink::WebString Convert(const Array<uint8_t>& input); | |
40 }; | |
41 | |
42 template <> | |
43 struct TypeConverter<RectPtr, blink::WebRect> { | |
44 static RectPtr Convert(const blink::WebRect& input); | |
45 }; | |
46 | |
47 template<typename T, typename U> | |
48 struct TypeConverter<Array<T>, blink::WebVector<U> > { | |
49 static Array<T> Convert(const blink::WebVector<U>& vector) { | |
50 Array<T> array(vector.size()); | |
51 for (size_t i = 0; i < vector.size(); ++i) | |
52 array[i] = TypeConverter<T, U>::Convert(vector[i]); | |
53 return std::move(array); | |
54 } | |
55 }; | |
56 | |
57 } // namespace mojo | |
58 | |
59 #endif // COMPONENTS_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ | |
OLD | NEW |