1 // Copyright 2018 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 #include "mojo/public/cpp/base/text_direction_mojom_traits.h" 6 7 namespace mojo { 8 9 // static 10 mojo_base::mojom::TextDirection ToMojom(base::i18n::TextDirection text_direction)11EnumTraits<mojo_base::mojom::TextDirection, base::i18n::TextDirection>::ToMojom( 12 base::i18n::TextDirection text_direction) { 13 switch (text_direction) { 14 case base::i18n::UNKNOWN_DIRECTION: 15 return mojo_base::mojom::TextDirection::UNKNOWN_DIRECTION; 16 case base::i18n::RIGHT_TO_LEFT: 17 return mojo_base::mojom::TextDirection::RIGHT_TO_LEFT; 18 case base::i18n::LEFT_TO_RIGHT: 19 return mojo_base::mojom::TextDirection::LEFT_TO_RIGHT; 20 } 21 NOTREACHED(); 22 return mojo_base::mojom::TextDirection::UNKNOWN_DIRECTION; 23 } 24 25 // static 26 bool EnumTraits<mojo_base::mojom::TextDirection, base::i18n::TextDirection>:: FromMojom(mojo_base::mojom::TextDirection input,base::i18n::TextDirection * out)27 FromMojom(mojo_base::mojom::TextDirection input, 28 base::i18n::TextDirection* out) { 29 switch (input) { 30 case mojo_base::mojom::TextDirection::UNKNOWN_DIRECTION: 31 *out = base::i18n::UNKNOWN_DIRECTION; 32 return true; 33 case mojo_base::mojom::TextDirection::RIGHT_TO_LEFT: 34 *out = base::i18n::RIGHT_TO_LEFT; 35 return true; 36 case mojo_base::mojom::TextDirection::LEFT_TO_RIGHT: 37 *out = base::i18n::LEFT_TO_RIGHT; 38 return true; 39 } 40 return false; 41 } 42 43 } // namespace mojo 44