1 // Copyright 2017 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_SPELLCHECK_COMMON_SPELLCHECK_MOJOM_TRAITS_H_ 6 #define COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_MOJOM_TRAITS_H_ 7 8 #include "components/spellcheck/common/spellcheck.mojom-shared.h" 9 #include "components/spellcheck/common/spellcheck_result.h" 10 11 namespace mojo { 12 13 template <> 14 struct EnumTraits<spellcheck::mojom::Decoration, SpellCheckResult::Decoration> { 15 static spellcheck::mojom::Decoration ToMojom(SpellCheckResult::Decoration); 16 static bool FromMojom(spellcheck::mojom::Decoration, 17 SpellCheckResult::Decoration*); 18 }; 19 20 template <> 21 struct StructTraits<spellcheck::mojom::SpellCheckResultDataView, 22 SpellCheckResult> { 23 static SpellCheckResult::Decoration decoration( 24 const SpellCheckResult& result) { 25 return result.decoration; 26 } 27 28 static int32_t location(const SpellCheckResult& result) { 29 return result.location; 30 } 31 32 static int32_t length(const SpellCheckResult& result) { 33 return result.length; 34 } 35 36 static const std::vector<base::string16>& replacements( 37 const SpellCheckResult& result) { 38 return result.replacements; 39 } 40 41 static bool Read(spellcheck::mojom::SpellCheckResultDataView, 42 SpellCheckResult*); 43 }; 44 45 } // namespace mojo 46 47 #endif // COMPONENTS_SPELLCHECK_COMMON_SPELLCHECK_MOJOM_TRAITS_H_ 48