[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / public / common / manifest.h
blob8305884aaf2e9382e59377d2572ed73d52ab55cb
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/WebDisplayMode.h"
13 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h"
14 #include "ui/gfx/geometry/size.h"
15 #include "url/gurl.h"
17 namespace content {
19 // The Manifest structure is an internal representation of the Manifest file
20 // described in the "Manifest for Web Application" document:
21 // http://w3c.github.io/manifest/
22 struct CONTENT_EXPORT Manifest {
23 // Structure representing an icon as per the Manifest specification, see:
24 // http://w3c.github.io/manifest/#dfn-icon-object
25 struct CONTENT_EXPORT Icon {
26 Icon();
27 ~Icon();
29 // MUST be a valid url. If an icon doesn't have a valid URL, it will not be
30 // successfully parsed, thus will not be represented in the Manifest.
31 GURL src;
33 // Null if the parsing failed or the field was not present. The type can be
34 // any string and doesn't have to be a valid image MIME type at this point.
35 // It is up to the consumer of the object to check if the type matches a
36 // supported type.
37 base::NullableString16 type;
39 // Default value is 1.0 if the value is missing or invalid.
40 double density;
42 // Empty if the parsing failed, the field was not present or empty.
43 // The special value "any" is represented by gfx::Size(0, 0).
44 std::vector<gfx::Size> sizes;
46 // Default density. Set to 1.0.
47 static const double kDefaultDensity;
50 // Structure representing a related application.
51 struct CONTENT_EXPORT RelatedApplication {
52 RelatedApplication();
53 ~RelatedApplication();
55 // The platform on which the application can be found. This can be any
56 // string, and is interpreted by the consumer of the object. Empty if the
57 // parsing failed.
58 base::NullableString16 platform;
60 // URL at which the application can be found. One of |url| and |id| must be
61 // present. Empty if the parsing failed or the field was not present.
62 GURL url;
64 // An id which is used to represent the application on the platform. One of
65 // |url| and |id| must be present. Empty if the parsing failed or the field
66 // was not present.
67 base::NullableString16 id;
70 Manifest();
71 ~Manifest();
73 // Returns whether this Manifest had no attribute set. A newly created
74 // Manifest is always empty.
75 bool IsEmpty() const;
77 // Null if the parsing failed or the field was not present.
78 base::NullableString16 name;
80 // Null if the parsing failed or the field was not present.
81 base::NullableString16 short_name;
83 // Empty if the parsing failed or the field was not present.
84 GURL start_url;
86 // Set to WebDisplayModeUndefined if the parsing failed or the field was not
87 // present.
88 blink::WebDisplayMode display;
90 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the
91 // field was not present.
92 blink::WebScreenOrientationLockType orientation;
94 // Empty if the parsing failed, the field was not present, empty or all the
95 // icons inside the JSON array were invalid.
96 std::vector<Icon> icons;
98 // Empty if the parsing failed, the field was not present, empty or all the
99 // applications inside the array were invalid. The order of the array
100 // indicates the priority of the application to use.
101 std::vector<RelatedApplication> related_applications;
103 // A boolean that is used as a hint for the user agent to say that related
104 // applications should be preferred over the web application. False if missing
105 // or there is a parsing failure.
106 bool prefer_related_applications;
108 // This is a 64 bit integer because we need to represent an error state. The
109 // color itself should only be 32 bits long if the value is not
110 // kInvalidOrMissingColor and can be safely cast to SkColor if is valid.
111 // Set to kInvalidOrMissingColor if parsing failed or field is not
112 // present.
113 int64_t theme_color;
115 // This is a 64 bit integer because we need to represent an error state. The
116 // color itself should only be 32 bits long if the value is not
117 // kInvalidOrMissingColor and can be safely cast to SkColor if is valid.
118 // Set to kInvalidOrMissingColor if parsing failed or field is not
119 // present.
120 int64_t background_color;
122 // This is a proprietary extension of the web Manifest, double-check that it
123 // is okay to use this entry.
124 // Null if parsing failed or the field was not present.
125 base::NullableString16 gcm_sender_id;
127 // Maximum length for all the strings inside the Manifest when it is sent over
128 // IPC. The renderer process should truncate the strings before sending the
129 // Manifest and the browser process must do the same when receiving it.
130 static const size_t kMaxIPCStringLength;
132 // Constant representing an invalid color. Set to a value outside the
133 // range of a 32-bit integer.
134 static const int64_t kInvalidOrMissingColor;
137 } // namespace content
139 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_