Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / common / manifest.h
blobd221c8ca1cf8f11dc3ce8ed709dfaa91d69862ca
1 // Copyright 2014 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.
5 #ifndef CONTENT_PUBLIC_COMMON_MANIFEST_H_
6 #define CONTENT_PUBLIC_COMMON_MANIFEST_H_
8 #include <vector>
10 #include "base/strings/nullable_string16.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "url/gurl.h"
16 namespace content {
18 // The Manifest structure is an internal representation of the Manifest file
19 // described in the "Manifest for Web Application" document:
20 // http://w3c.github.io/manifest/
21 struct CONTENT_EXPORT Manifest {
22 enum DisplayMode {
23 DISPLAY_MODE_UNSPECIFIED,
24 DISPLAY_MODE_FULLSCREEN,
25 DISPLAY_MODE_STANDALONE,
26 DISPLAY_MODE_MINIMAL_UI,
27 DISPLAY_MODE_BROWSER
30 // Structure representing an icon as per the Manifest specification, see:
31 // http://w3c.github.io/manifest/#dfn-icon-object
32 struct CONTENT_EXPORT Icon {
33 Icon();
34 ~Icon();
36 // MUST be a valid url. If an icon doesn't have a valid URL, it will not be
37 // successfully parsed, thus will not be represented in the Manifest.
38 GURL src;
40 // Null if the parsing failed or the field was not present. The type can be
41 // any string and doesn't have to be a valid image MIME type at this point.
42 // It is up to the consumer of the object to check if the type matches a
43 // supported type.
44 base::NullableString16 type;
46 // Default value is 1.0 if the value is missing or invalid.
47 double density;
49 // Empty if the parsing failed, the field was not present or empty.
50 // The special value "any" is represented by gfx::Size(0, 0).
51 std::vector<gfx::Size> sizes;
53 // Default density. Set to 1.0.
54 static const double kDefaultDensity;
57 Manifest();
58 ~Manifest();
60 // Returns whether this Manifest had no attribute set. A newly created
61 // Manifest is always empty.
62 bool IsEmpty() const;
64 // Null if the parsing failed or the field was not present.
65 base::NullableString16 name;
67 // Null if the parsing failed or the field was not present.
68 base::NullableString16 short_name;
70 // Empty if the parsing failed or the field was not present.
71 GURL start_url;
73 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not
74 // present.
75 DisplayMode display;
77 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the
78 // field was not present.
79 blink::WebScreenOrientationLockType orientation;
81 // Empty if the parsing failed, the field was not present, empty or all the
82 // icons inside the JSON array were invalid.
83 std::vector<Icon> icons;
85 // This is a proprietary extension of the web Manifest, double-check that it
86 // is okay to use this entry.
87 // Null if parsing failed or the field was not present.
88 base::NullableString16 gcm_sender_id;
90 // This is a proprietary extension of the web Manifest, double-check that it
91 // is okay to use this entry.
92 // False if parsing failed or the field was not present.
93 bool gcm_user_visible_only;
95 // Maximum length for all the strings inside the Manifest when it is sent over
96 // IPC. The renderer process should truncate the strings before sending the
97 // Manifest and the browser process must do the same when receiving it.
98 static const size_t kMaxIPCStringLength;
101 } // namespace content
103 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_