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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/public/common/manifest_struct_traits.h
diff --git a/content/public/common/manifest_struct_traits.h b/content/public/common/manifest_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..14d4855ddd557fc90c5428febd43fdb259a9766f
--- /dev/null
+++ b/content/public/common/manifest_struct_traits.h
@@ -0,0 +1,122 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_
+#define CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_
+
+#include "content/public/common/manifest.h"
+#include "mojo/public/cpp/bindings/string_traits_nullable_string16.h"
+#include "third_party/WebKit/public/platform/modules/manifest/manifest.mojom.h"
+#include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
+#include "url/gurl.h"
+#include "url/mojo/url_gurl_struct_traits.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<blink::mojom::Manifest, content::Manifest> {
+ static const base::NullableString16& name(const content::Manifest& m) {
+ DCHECK(m.name.is_null() ||
+ m.name.string().size() < content::Manifest::kMaxIPCStringLength);
+ return m.name;
+ }
+
+ static const base::NullableString16& short_name(const content::Manifest& m) {
+ DCHECK(m.short_name.is_null() ||
+ m.short_name.string().size() <
+ content::Manifest::kMaxIPCStringLength);
+ return m.short_name;
+ }
+
+ static const base::NullableString16& gcm_sender_id(
+ const content::Manifest& m) {
+ DCHECK(m.gcm_sender_id.is_null() ||
+ m.gcm_sender_id.string().size() <
+ content::Manifest::kMaxIPCStringLength);
+ return m.gcm_sender_id;
+ }
+
+ static const GURL& start_url(const content::Manifest& m) {
+ return m.start_url;
+ }
+
+ static blink::WebDisplayMode display(const content::Manifest& m) {
+ return m.display;
+ }
+
+ static blink::WebScreenOrientationLockType orientation(
+ const content::Manifest& m) {
+ return m.orientation;
+ }
+
+ static int64_t theme_color(const content::Manifest& m) {
+ return m.theme_color;
+ }
+
+ static int64_t background_color(const content::Manifest& m) {
+ return m.background_color;
+ }
+
+ static const std::vector<content::Manifest::Icon>& icons(
+ const content::Manifest& m) {
+ return m.icons;
+ }
+
+ static const std::vector<content::Manifest::RelatedApplication>&
+ related_applications(const content::Manifest& m) {
+ return m.related_applications;
+ }
+
+ static bool prefer_related_applications(const content::Manifest& m) {
+ return m.prefer_related_applications;
+ }
+
+ static bool Read(blink::mojom::ManifestDataView data, content::Manifest* out);
+};
+
+template <>
+struct StructTraits<blink::mojom::ManifestIcon, content::Manifest::Icon> {
+ static const GURL& src(const content::Manifest::Icon& m) { return m.src; }
+
+ static const base::NullableString16& type(const content::Manifest::Icon& m) {
+ DCHECK(m.type.is_null() ||
+ m.type.string().size() < content::Manifest::kMaxIPCStringLength);
+ return m.type;
+ }
+ static const std::vector<gfx::Size>& sizes(const content::Manifest::Icon& m) {
+ return m.sizes;
+ }
+
+ static bool Read(blink::mojom::ManifestIconDataView data,
+ content::Manifest::Icon* out);
+};
+
+template <>
+struct StructTraits<blink::mojom::RelatedApplication,
+ content::Manifest::RelatedApplication> {
+ static const base::NullableString16& platform(
+ const content::Manifest::RelatedApplication& m) {
+ DCHECK(m.platform.is_null() ||
+ m.platform.string().size() < content::Manifest::kMaxIPCStringLength);
+ return m.platform;
+ }
+
+ static const GURL& url(const content::Manifest::RelatedApplication& m) {
+ return m.url;
+ }
+
+ static const base::NullableString16& id(
+ const content::Manifest::RelatedApplication& m) {
+ DCHECK(m.id.is_null() ||
+ m.id.string().size() < content::Manifest::kMaxIPCStringLength);
+ return m.id;
+ }
+
+ static bool Read(blink::mojom::RelatedApplicationDataView data,
+ content::Manifest::RelatedApplication* out);
+};
+
+} // namespace mojo
+
+#endif // CONTENT_PUBLIC_COMMON_MANIFEST_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698