Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "url/gurl.h" | |
| 12 #include "url/mojo/url_gurl_struct_traits.h" | |
| 13 | |
| 14 namespace mojo { | |
| 15 | |
| 16 template <> | |
| 17 struct StructTraits<blink::mojom::Manifest, content::Manifest> { | |
| 18 static base::NullableString16 name(const content::Manifest& m); | |
| 19 static base::NullableString16 short_name(const content::Manifest& m); | |
| 20 static base::NullableString16 gcm_sender_id(const content::Manifest& m); | |
| 21 | |
| 22 static const GURL& start_url(const content::Manifest& m) { | |
| 23 return m.start_url; | |
| 24 } | |
| 25 | |
| 26 static blink::WebDisplayMode display(const content::Manifest& m) { | |
| 27 return m.display; | |
| 28 } | |
| 29 | |
| 30 static blink::WebScreenOrientationLockType orientation( | |
| 31 const content::Manifest& m) { | |
| 32 return m.orientation; | |
| 33 } | |
| 34 | |
| 35 static int64_t theme_color(const content::Manifest& m) { | |
| 36 if (m.theme_color < std::numeric_limits<int32_t>::min() || | |
| 37 m.theme_color > std::numeric_limits<int32_t>::max()) { | |
| 38 return content::Manifest::kInvalidOrMissingColor; | |
|
dcheng
2016/06/01 23:38:42
Why do we need to do this check? From the comments
Sam McNally
2016/06/02 07:02:40
Done.
| |
| 39 } | |
| 40 return m.theme_color; | |
| 41 } | |
| 42 | |
| 43 static int64_t background_color(const content::Manifest& m) { | |
| 44 if (m.background_color < std::numeric_limits<int32_t>::min() || | |
| 45 m.background_color > std::numeric_limits<int32_t>::max()) { | |
| 46 return content::Manifest::kInvalidOrMissingColor; | |
| 47 } | |
| 48 return m.background_color; | |
| 49 } | |
| 50 | |
| 51 static const std::vector<content::Manifest::Icon>& icons( | |
| 52 const content::Manifest& m) { | |
| 53 return m.icons; | |
| 54 } | |
| 55 | |
| 56 static const std::vector<content::Manifest::RelatedApplication>& | |
| 57 related_applications(const content::Manifest& m) { | |
| 58 return m.related_applications; | |
| 59 } | |
| 60 | |
| 61 static bool prefer_related_applications(const content::Manifest& m) { | |
| 62 return m.prefer_related_applications; | |
| 63 } | |
| 64 | |
| 65 static bool Read(blink::mojom::ManifestDataView data, content::Manifest* out); | |
| 66 }; | |
| 67 | |
| 68 template <> | |
| 69 struct StructTraits<blink::mojom::ManifestIcon, content::Manifest::Icon> { | |
| 70 static const GURL& src(const content::Manifest::Icon& m) { return m.src; } | |
| 71 | |
| 72 static base::NullableString16 type(const content::Manifest::Icon& m); | |
| 73 static mojo::Array<mojo::SizePtr> sizes(const content::Manifest::Icon& m); | |
| 74 | |
| 75 static bool Read(blink::mojom::ManifestIconDataView data, | |
| 76 content::Manifest::Icon* out); | |
| 77 }; | |
| 78 | |
| 79 template <> | |
| 80 struct StructTraits<blink::mojom::RelatedApplication, | |
| 81 content::Manifest::RelatedApplication> { | |
| 82 static base::NullableString16 platform( | |
| 83 const content::Manifest::RelatedApplication& m); | |
| 84 | |
| 85 static const GURL& url(const content::Manifest::RelatedApplication& m) { | |
| 86 return m.url; | |
| 87 } | |
| 88 | |
| 89 static base::NullableString16 id( | |
| 90 const content::Manifest::RelatedApplication& m); | |
| 91 | |
| 92 static bool Read(blink::mojom::RelatedApplicationDataView data, | |
| 93 content::Manifest::RelatedApplication* out); | |
| 94 }; | |
| 95 | |
| 96 } // namespace mojo | |
| 97 | |
| 98 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_ | |
| OLD | NEW |