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

Side by Side Diff: content/public/common/manifest_struct_traits.h

Issue 1913043002: Convert ManifestManager IPCs to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_
6 #define CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_
7
8 #include "content/public/common/manifest.h"
9 #include "mojo/public/cpp/bindings/string_traits_nullable_string16.h"
10 #include "third_party/WebKit/public/platform/modules/manifest/manifest.mojom.h"
11 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
12 #include "url/gurl.h"
13 #include "url/mojo/url_gurl_struct_traits.h"
14
15 namespace mojo {
16
17 template <>
18 struct StructTraits<blink::mojom::Manifest, content::Manifest> {
19 static const base::NullableString16& name(const content::Manifest& m) {
20 DCHECK(m.name.is_null() ||
21 m.name.string().size() < content::Manifest::kMaxIPCStringLength);
22 return m.name;
23 }
24
25 static const base::NullableString16& short_name(const content::Manifest& m) {
26 DCHECK(m.short_name.is_null() ||
27 m.short_name.string().size() <
28 content::Manifest::kMaxIPCStringLength);
29 return m.short_name;
30 }
31
32 static const base::NullableString16& gcm_sender_id(
33 const content::Manifest& m) {
34 DCHECK(m.gcm_sender_id.is_null() ||
35 m.gcm_sender_id.string().size() <
36 content::Manifest::kMaxIPCStringLength);
37 return m.gcm_sender_id;
38 }
39
40 static const GURL& start_url(const content::Manifest& m) {
41 return m.start_url;
42 }
43
44 static blink::WebDisplayMode display(const content::Manifest& m) {
45 return m.display;
46 }
47
48 static blink::WebScreenOrientationLockType orientation(
49 const content::Manifest& m) {
50 return m.orientation;
51 }
52
53 static int64_t theme_color(const content::Manifest& m) {
54 return m.theme_color;
55 }
56
57 static int64_t background_color(const content::Manifest& m) {
58 return m.background_color;
59 }
60
61 static const std::vector<content::Manifest::Icon>& icons(
62 const content::Manifest& m) {
63 return m.icons;
64 }
65
66 static const std::vector<content::Manifest::RelatedApplication>&
67 related_applications(const content::Manifest& m) {
68 return m.related_applications;
69 }
70
71 static bool prefer_related_applications(const content::Manifest& m) {
72 return m.prefer_related_applications;
73 }
74
75 static bool Read(blink::mojom::ManifestDataView data, content::Manifest* out);
76 };
77
78 template <>
79 struct StructTraits<blink::mojom::ManifestIcon, content::Manifest::Icon> {
80 static const GURL& src(const content::Manifest::Icon& m) { return m.src; }
81
82 static const base::NullableString16& type(const content::Manifest::Icon& m) {
83 DCHECK(m.type.is_null() ||
84 m.type.string().size() < content::Manifest::kMaxIPCStringLength);
85 return m.type;
86 }
87 static const std::vector<gfx::Size>& sizes(const content::Manifest::Icon& m) {
88 return m.sizes;
89 }
90
91 static bool Read(blink::mojom::ManifestIconDataView data,
92 content::Manifest::Icon* out);
93 };
94
95 template <>
96 struct StructTraits<blink::mojom::RelatedApplication,
97 content::Manifest::RelatedApplication> {
98 static const base::NullableString16& platform(
99 const content::Manifest::RelatedApplication& m) {
100 DCHECK(m.platform.is_null() ||
101 m.platform.string().size() < content::Manifest::kMaxIPCStringLength);
102 return m.platform;
103 }
104
105 static const GURL& url(const content::Manifest::RelatedApplication& m) {
106 return m.url;
107 }
108
109 static const base::NullableString16& id(
110 const content::Manifest::RelatedApplication& m) {
111 DCHECK(m.id.is_null() ||
112 m.id.string().size() < content::Manifest::kMaxIPCStringLength);
113 return m.id;
114 }
115
116 static bool Read(blink::mojom::RelatedApplicationDataView data,
117 content::Manifest::RelatedApplication* out);
118 };
119
120 } // namespace mojo
121
122 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698