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 MOJO_SERVICES_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ 6#define MOJO_SERVICES_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ 7 8#include "mojo/public/cpp/bindings/type_converter.h" 9 10#include "mojo/public/cpp/bindings/array.h" 11#include "third_party/WebKit/public/platform/WebVector.h" 12 13namespace blink { 14class WebString; 15} 16 17namespace mojo { 18class String; 19 20template<> 21struct TypeConverter<String, blink::WebString> { 22 static String Convert(const blink::WebString& str); 23}; 24template<> 25struct TypeConverter<blink::WebString, String> { 26 static blink::WebString Convert(const String& str); 27}; 28template <> 29struct TypeConverter<Array<uint8_t>, blink::WebString> { 30 static Array<uint8_t> Convert(const blink::WebString& input); 31}; 32 33template<typename T, typename U> 34struct TypeConverter<Array<T>, blink::WebVector<U> > { 35 static Array<T> Convert(const blink::WebVector<U>& vector) { 36 Array<T> array(vector.size()); 37 for (size_t i = 0; i < vector.size(); ++i) 38 array[i] = TypeConverter<T, U>::Convert(vector[i]); 39 return array.Pass(); 40 } 41}; 42 43} // namespace mojo 44 45#endif // MOJO_SERVICES_HTML_VIEWER_BLINK_BASIC_TYPE_CONVERTERS_H_ 46