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. 4 5 #ifndef CONTENT_PUBLIC_COMMON_MANIFEST_H_ 6 #define CONTENT_PUBLIC_COMMON_MANIFEST_H_ 7 8 #include <vector> 9 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" 15 16 namespace content { 17 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 28 }; 29 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(); 35 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; 39 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; 45 46 // Default value is 1.0 if the value is missing or invalid. 47 double density; 48 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; 52 53 // Default density. Set to 1.0. 54 static const double kDefaultDensity; 55 }; 56 57 Manifest(); 58 ~Manifest(); 59 60 // Returns whether this Manifest had no attribute set. A newly created 61 // Manifest is always empty. 62 bool IsEmpty() const; 63 64 // Null if the parsing failed or the field was not present. 65 base::NullableString16 name; 66 67 // Null if the parsing failed or the field was not present. 68 base::NullableString16 short_name; 69 70 // Empty if the parsing failed or the field was not present. 71 GURL start_url; 72 73 // Set to DISPLAY_MODE_UNSPECIFIED if the parsing failed or the field was not 74 // present. 75 DisplayMode display; 76 77 // Set to blink::WebScreenOrientationLockDefault if the parsing failed or the 78 // field was not present. 79 blink::WebScreenOrientationLockType orientation; 80 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; 84 85 // Maximum length for all the strings inside the Manifest when it is sent over 86 // IPC. The renderer process should truncate the strings before sending the 87 // Manifest and the browser process must do the same when receiving it. 88 static const size_t kMaxIPCStringLength; 89 }; 90 91 } // namespace content 92 93 #endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_ 94