| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ |
| 6 #define COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ | 6 #define COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/translate/content/common/translate.mojom.h" | 10 #include "components/translate/content/common/translate.mojom.h" |
| 11 #include "components/translate/core/common/language_detection_details.h" | 11 #include "components/translate/core/common/language_detection_details.h" |
| 12 #include "components/translate/core/common/translate_errors.h" | 12 #include "components/translate/core/common/translate_errors.h" |
| 13 #include "mojo/public/cpp/bindings/struct_traits.h" | 13 #include "mojo/public/cpp/bindings/struct_traits.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 | 16 |
| 17 template <> | 17 template <> |
| 18 struct EnumTraits<translate::mojom::TranslateError, | 18 struct EnumTraits<translate::mojom::TranslateError, |
| 19 translate::TranslateErrors::Type> { | 19 translate::TranslateErrors::Type> { |
| 20 static translate::mojom::TranslateError ToMojom( | 20 static translate::mojom::TranslateError ToMojom( |
| 21 translate::TranslateErrors::Type input); | 21 translate::TranslateErrors::Type input); |
| 22 static bool FromMojom(translate::mojom::TranslateError input, | 22 static bool FromMojom(translate::mojom::TranslateError input, |
| 23 translate::TranslateErrors::Type* output); | 23 translate::TranslateErrors::Type* output); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 template <> | 26 template <> |
| 27 struct StructTraits<translate::mojom::LanguageDetectionDetails, | 27 struct StructTraits<translate::mojom::LanguageDetectionDetailsDataView, |
| 28 translate::LanguageDetectionDetails> { | 28 translate::LanguageDetectionDetails> { |
| 29 static const base::Time& time(const translate::LanguageDetectionDetails& r) { | 29 static const base::Time& time(const translate::LanguageDetectionDetails& r) { |
| 30 return r.time; | 30 return r.time; |
| 31 } | 31 } |
| 32 | 32 |
| 33 static const GURL& url(const translate::LanguageDetectionDetails& r) { | 33 static const GURL& url(const translate::LanguageDetectionDetails& r) { |
| 34 return r.url; | 34 return r.url; |
| 35 } | 35 } |
| 36 | 36 |
| 37 static const std::string& content_language( | 37 static const std::string& content_language( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 67 return r.contents; | 67 return r.contents; |
| 68 } | 68 } |
| 69 | 69 |
| 70 static bool Read(translate::mojom::LanguageDetectionDetailsDataView data, | 70 static bool Read(translate::mojom::LanguageDetectionDetailsDataView data, |
| 71 translate::LanguageDetectionDetails* out); | 71 translate::LanguageDetectionDetails* out); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace mojo | 74 } // namespace mojo |
| 75 | 75 |
| 76 #endif // COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ | 76 #endif // COMPONENTS_TRANSLATE_CONTENT_COMMON_TRANSLATE_STRUCT_TRAITS_H_ |
| OLD | NEW |