Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: components/translate/content/public/cpp/translate_struct_traits.h

Issue 2143383002: [Translate] Migrate IPCs to Mojo interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Ken and Anand Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_TRANSLATE_CONTENT_PUBLIC_INTERFACES_TRANSLATE_STRUCT_TRAITS_H _
6 #define COMPONENTS_TRANSLATE_CONTENT_PUBLIC_INTERFACES_TRANSLATE_STRUCT_TRAITS_H _
7
8 #include "base/strings/string16.h"
9 #include "base/time/time.h"
10 #include "components/translate/content/public/interfaces/translate.mojom.h"
11 #include "components/translate/core/common/language_detection_details.h"
12 #include "components/translate/core/common/translate_errors.h"
13 #include "mojo/public/cpp/bindings/struct_traits.h"
14
15 namespace mojo {
16
17 template <>
18 struct EnumTraits<translate::mojom::TranslateError,
Ken Rockot(use gerrit already) 2016/07/29 17:21:17 It would be nice if we could just move the enum de
leonhsl(Using Gerrit) 2016/07/30 08:45:07 Yeah agree, lots of code need to be changed, I'd l
19 translate::TranslateErrors::Type> {
20 static translate::mojom::TranslateError ToMojom(
21 translate::TranslateErrors::Type input);
22 static bool FromMojom(translate::mojom::TranslateError input,
23 translate::TranslateErrors::Type* output);
24 };
25
26 template <>
27 struct StructTraits<translate::mojom::LanguageDetectionDetails,
28 translate::LanguageDetectionDetails> {
29 static const base::Time& time(const translate::LanguageDetectionDetails& r) {
30 return r.time;
31 }
32
33 static const GURL& url(const translate::LanguageDetectionDetails& r) {
34 return r.url;
35 }
36
37 static const std::string& content_language(
38 const translate::LanguageDetectionDetails& r) {
39 return r.content_language;
40 }
41
42 static const std::string& cld_language(
43 const translate::LanguageDetectionDetails& r) {
44 return r.cld_language;
45 }
46
47 static bool is_cld_reliable(const translate::LanguageDetectionDetails& r) {
48 return r.is_cld_reliable;
49 }
50
51 static bool has_notranslate(const translate::LanguageDetectionDetails& r) {
52 return r.has_notranslate;
53 }
54
55 static const std::string& html_root_language(
56 const translate::LanguageDetectionDetails& r) {
57 return r.html_root_language;
58 }
59
60 static const std::string& adopted_language(
61 const translate::LanguageDetectionDetails& r) {
62 return r.adopted_language;
63 }
64
65 static const base::string16& contents(
66 const translate::LanguageDetectionDetails& r) {
67 return r.contents;
68 }
69
70 static bool Read(translate::mojom::LanguageDetectionDetailsDataView data,
71 translate::LanguageDetectionDetails* out);
72 };
73
74 } // namespace mojo
75
76 #endif // COMPONENTS_TRANSLATE_CONTENT_PUBLIC_INTERFACES_TRANSLATE_STRUCT_TRAIT S_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698