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> | |
9 | |
8 #include "base/strings/nullable_string16.h" | 10 #include "base/strings/nullable_string16.h" |
9 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
10 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" | 12 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" |
11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
12 | 14 |
13 namespace content { | 15 namespace content { |
14 | 16 |
15 // The Manifest structure is an internal representation of the Manifest file | 17 // The Manifest structure is an internal representation of the Manifest file |
16 // described in the "Manifest for Web Application" document: | 18 // described in the "Manifest for Web Application" document: |
17 // http://w3c.github.io/manifest/ | 19 // http://w3c.github.io/manifest/ |
18 struct CONTENT_EXPORT Manifest { | 20 struct CONTENT_EXPORT Manifest { |
19 enum DisplayMode { | 21 enum DisplayMode { |
20 DISPLAY_MODE_UNSPECIFIED, | 22 DISPLAY_MODE_UNSPECIFIED, |
21 DISPLAY_MODE_FULLSCREEN, | 23 DISPLAY_MODE_FULLSCREEN, |
22 DISPLAY_MODE_STANDALONE, | 24 DISPLAY_MODE_STANDALONE, |
23 DISPLAY_MODE_MINIMAL_UI, | 25 DISPLAY_MODE_MINIMAL_UI, |
24 DISPLAY_MODE_BROWSER | 26 DISPLAY_MODE_BROWSER |
25 }; | 27 }; |
26 | 28 |
29 // Structure representing an icon as per the Manifest specification, see: | |
30 // http://w3c.github.io/manifest/#dfn-icon-object | |
31 struct Icon { | |
32 Icon(); | |
33 ~Icon(); | |
34 | |
35 // MUST be a valid url. If an icon doesn't have a valid URL, it will not be | |
36 // successfully parsed, thus will not be represented in the Manifest. | |
37 GURL src; | |
38 | |
39 // Null if the parsing failed or the field was not present. The type can be | |
40 // any string and doesn't have to be a valid image MIME type at this point. | |
41 // It is up to the consumer of the object to check if the type matches a | |
42 // supported type. | |
43 base::NullableString16 type; | |
palmer
2014/09/22 20:35:43
Ultimately, I'd expect the interface to "harden",
mlamouri (slow - plz ping)
2014/09/22 21:09:31
It's NullableString16 because the type might not b
| |
44 | |
45 // Default value is 1.0 if the value is missing or invalid. | |
46 double density; | |
47 | |
48 // Default density. Set to 1.0. | |
49 static const double kDefaultDensity; | |
50 }; | |
51 | |
27 Manifest(); | 52 Manifest(); |
28 ~Manifest(); | 53 ~Manifest(); |
29 | 54 |
30 // Returns whether this Manifest had no attribute set. A newly created | 55 // Returns whether this Manifest had no attribute set. A newly created |
31 // Manifest is always empty. | 56 // Manifest is always empty. |
32 bool IsEmpty() const; | 57 bool IsEmpty() const; |
33 | 58 |
34 // Null if the parsing failed or the field was not present. | 59 // Null if the parsing failed or the field was not present. |
35 base::NullableString16 name; | 60 base::NullableString16 name; |
36 | 61 |
37 // Null if the parsing failed or the field was not present. | 62 // Null if the parsing failed or the field was not present. |
38 base::NullableString16 short_name; | 63 base::NullableString16 short_name; |
39 | 64 |
40 // Empty if the parsing failed or the field was not present. | 65 // Empty if the parsing failed or the field was not present. |
41 GURL start_url; | 66 GURL start_url; |
42 | 67 |
43 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not | 68 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not |
44 // present. | 69 // present. |
45 DisplayMode display; | 70 DisplayMode display; |
46 | 71 |
47 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the | 72 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the |
48 // field was not present. | 73 // field was not present. |
49 blink::WebScreenOrientationLockType orientation; | 74 blink::WebScreenOrientationLockType orientation; |
50 | 75 |
76 // Empty if the parsing failed, the field was not present, empty or all the | |
77 // icons inside the JSON array were invalid. | |
78 std::vector<Icon> icons; | |
79 | |
51 // Maximum length for all the strings inside the Manifest when it is sent over | 80 // Maximum length for all the strings inside the Manifest when it is sent over |
52 // IPC. The renderer process should truncate the strings before sending the | 81 // IPC. The renderer process should truncate the strings before sending the |
53 // Manifest and the browser process must do the same when receiving it. | 82 // Manifest and the browser process must do the same when receiving it. |
54 static const size_t kMaxIPCStringLength; | 83 static const size_t kMaxIPCStringLength; |
55 }; | 84 }; |
56 | 85 |
57 } // namespace content | 86 } // namespace content |
58 | 87 |
59 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_ | 88 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_ |
OLD | NEW |