OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_COMMON_MANIFEST_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_MANIFEST_H_ |
6 #define CONTENT_PUBLIC_COMMON_MANIFEST_H_ | 6 #define CONTENT_PUBLIC_COMMON_MANIFEST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" | 12 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" |
13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 // The Manifest structure is an internal representation of the Manifest file | 18 // The Manifest structure is an internal representation of the Manifest file |
19 // described in the "Manifest for Web Application" document: | 19 // described in the "Manifest for Web Application" document: |
20 // http://w3c.github.io/manifest/ | 20 // http://w3c.github.io/manifest/ |
21 struct CONTENT_EXPORT Manifest { | 21 struct CONTENT_EXPORT Manifest { |
22 enum DisplayMode { | 22 enum DisplayMode { |
23 DISPLAY_MODE_UNSPECIFIED, | 23 DISPLAY_MODE_UNSPECIFIED, |
24 DISPLAY_MODE_FULLSCREEN, | 24 DISPLAY_MODE_FULLSCREEN, |
25 DISPLAY_MODE_STANDALONE, | 25 DISPLAY_MODE_STANDALONE, |
26 DISPLAY_MODE_MINIMAL_UI, | 26 DISPLAY_MODE_MINIMAL_UI, |
27 DISPLAY_MODE_BROWSER | 27 DISPLAY_MODE_BROWSER |
28 }; | 28 }; |
29 | 29 |
30 enum RelatedApplicationPlatform { | |
31 RELATED_APPLICATION_PLATFORM_UNSPECIFIED, | |
32 RELATED_APPLICATION_PLATFORM_PLAY, | |
33 }; | |
mlamouri (slow - plz ping)
2015/04/10 09:49:44
Shouldn't we have the embedder decide which platfo
benwells
2015/04/15 06:45:22
OK, makes sense. Done.
| |
34 | |
30 // Structure representing an icon as per the Manifest specification, see: | 35 // Structure representing an icon as per the Manifest specification, see: |
31 // http://w3c.github.io/manifest/#dfn-icon-object | 36 // http://w3c.github.io/manifest/#dfn-icon-object |
32 struct CONTENT_EXPORT Icon { | 37 struct CONTENT_EXPORT Icon { |
33 Icon(); | 38 Icon(); |
34 ~Icon(); | 39 ~Icon(); |
35 | 40 |
36 // MUST be a valid url. If an icon doesn't have a valid URL, it will not be | 41 // 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. | 42 // successfully parsed, thus will not be represented in the Manifest. |
38 GURL src; | 43 GURL src; |
39 | 44 |
40 // Null if the parsing failed or the field was not present. The type can be | 45 // 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. | 46 // 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 | 47 // It is up to the consumer of the object to check if the type matches a |
43 // supported type. | 48 // supported type. |
44 base::NullableString16 type; | 49 base::NullableString16 type; |
45 | 50 |
46 // Default value is 1.0 if the value is missing or invalid. | 51 // Default value is 1.0 if the value is missing or invalid. |
47 double density; | 52 double density; |
48 | 53 |
49 // Empty if the parsing failed, the field was not present or empty. | 54 // Empty if the parsing failed, the field was not present or empty. |
50 // The special value "any" is represented by gfx::Size(0, 0). | 55 // The special value "any" is represented by gfx::Size(0, 0). |
51 std::vector<gfx::Size> sizes; | 56 std::vector<gfx::Size> sizes; |
52 | 57 |
53 // Default density. Set to 1.0. | 58 // Default density. Set to 1.0. |
54 static const double kDefaultDensity; | 59 static const double kDefaultDensity; |
55 }; | 60 }; |
56 | 61 |
62 // Structure representing a related application. | |
63 struct CONTENT_EXPORT RelatedApplication { | |
64 RelatedApplication(); | |
65 ~RelatedApplication(); | |
66 | |
67 // The platform on which the application can be found. | |
68 RelatedApplicationPlatform platform; | |
69 | |
70 // URL at which the application can be found. Empty if the parsing failed or | |
71 // the field was not present. | |
72 GURL url; | |
73 | |
74 // An id which is used to represent the application on the platform. | |
75 base::NullableString16 id; | |
mlamouri (slow - plz ping)
2015/04/10 09:49:44
Could you add a comment saying that if the |id| is
benwells
2015/04/15 06:45:22
Done.
| |
76 }; | |
77 | |
57 Manifest(); | 78 Manifest(); |
58 ~Manifest(); | 79 ~Manifest(); |
59 | 80 |
60 // Returns whether this Manifest had no attribute set. A newly created | 81 // Returns whether this Manifest had no attribute set. A newly created |
61 // Manifest is always empty. | 82 // Manifest is always empty. |
62 bool IsEmpty() const; | 83 bool IsEmpty() const; |
63 | 84 |
64 // Null if the parsing failed or the field was not present. | 85 // Null if the parsing failed or the field was not present. |
65 base::NullableString16 name; | 86 base::NullableString16 name; |
66 | 87 |
67 // Null if the parsing failed or the field was not present. | 88 // Null if the parsing failed or the field was not present. |
68 base::NullableString16 short_name; | 89 base::NullableString16 short_name; |
69 | 90 |
70 // Empty if the parsing failed or the field was not present. | 91 // Empty if the parsing failed or the field was not present. |
71 GURL start_url; | 92 GURL start_url; |
72 | 93 |
73 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not | 94 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not |
74 // present. | 95 // present. |
75 DisplayMode display; | 96 DisplayMode display; |
76 | 97 |
77 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the | 98 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the |
78 // field was not present. | 99 // field was not present. |
79 blink::WebScreenOrientationLockType orientation; | 100 blink::WebScreenOrientationLockType orientation; |
80 | 101 |
81 // Empty if the parsing failed, the field was not present, empty or all the | 102 // Empty if the parsing failed, the field was not present, empty or all the |
82 // icons inside the JSON array were invalid. | 103 // icons inside the JSON array were invalid. |
83 std::vector<Icon> icons; | 104 std::vector<Icon> icons; |
84 | 105 |
106 // Empty if the parsing failed, the field was not present, empty or all the | |
107 // applications inside the array were invalid. The order of the array | |
108 // indicates the priority of the application to use. | |
109 std::vector<RelatedApplication> related_applications; | |
110 | |
111 // A boolean that is used as a hint for the user agent to say that related | |
112 // applications should be preferred over the web application. False if missing | |
113 // or there is a parsing failure. | |
114 bool prefer_related_applications; | |
115 | |
85 // This is a proprietary extension of the web Manifest, double-check that it | 116 // This is a proprietary extension of the web Manifest, double-check that it |
86 // is okay to use this entry. | 117 // is okay to use this entry. |
87 // Null if parsing failed or the field was not present. | 118 // Null if parsing failed or the field was not present. |
88 base::NullableString16 gcm_sender_id; | 119 base::NullableString16 gcm_sender_id; |
89 | 120 |
90 // This is a proprietary extension of the web Manifest, double-check that it | 121 // This is a proprietary extension of the web Manifest, double-check that it |
91 // is okay to use this entry. | 122 // is okay to use this entry. |
92 // False if parsing failed or the field was not present. | 123 // False if parsing failed or the field was not present. |
93 bool gcm_user_visible_only; | 124 bool gcm_user_visible_only; |
94 | 125 |
95 // Maximum length for all the strings inside the Manifest when it is sent over | 126 // 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 | 127 // IPC. The renderer process should truncate the strings before sending the |
97 // Manifest and the browser process must do the same when receiving it. | 128 // Manifest and the browser process must do the same when receiving it. |
98 static const size_t kMaxIPCStringLength; | 129 static const size_t kMaxIPCStringLength; |
99 }; | 130 }; |
100 | 131 |
101 } // namespace content | 132 } // namespace content |
102 | 133 |
103 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_ | 134 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_ |
OLD | NEW |