1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_COMMON_MANIFEST_H_
#define CONTENT_PUBLIC_COMMON_MANIFEST_H_
#include <stddef.h>
#include <stdint.h>
#include <vector>
#include "base/optional.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string16.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebDisplayMode.h"
#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
namespace content {
// The Manifest structure is an internal representation of the Manifest file
// described in the "Manifest for Web Application" document:
// http://w3c.github.io/manifest/
struct CONTENT_EXPORT Manifest {
// Structure representing an icon as per the Manifest specification, see:
// http://w3c.github.io/manifest/#dfn-icon-object
struct CONTENT_EXPORT Icon {
enum IconPurpose {
ANY = 0,
BADGE,
ICON_PURPOSE_LAST = BADGE,
};
Icon();
Icon(const Icon& other);
~Icon();
bool operator==(const Icon& other) const;
// MUST be a valid url. If an icon doesn't have a valid URL, it will not be
// successfully parsed, thus will not be represented in the Manifest.
GURL src;
// Empty if the parsing failed or the field was not present. The type can be
// any string and doesn't have to be a valid image MIME type at this point.
// It is up to the consumer of the object to check if the type matches a
// supported type.
base::string16 type;
// Empty if the parsing failed, the field was not present or empty.
// The special value "any" is represented by gfx::Size(0, 0).
std::vector<gfx::Size> sizes;
// Empty if the field was not present or not of type "string". Defaults to
// a vector with a single value, IconPurpose::ANY, for all other parsing
// exceptions.
std::vector<IconPurpose> purpose;
};
// Structure representing how a Web Share target handles an incoming share.
struct CONTENT_EXPORT ShareTarget {
ShareTarget();
~ShareTarget();
// The URL template that contains placeholders to be replaced with shared
// data. Null if the parsing failed.
base::NullableString16 url_template;
};
// Structure representing a related application.
struct CONTENT_EXPORT RelatedApplication {
RelatedApplication();
~RelatedApplication();
// The platform on which the application can be found. This can be any
// string, and is interpreted by the consumer of the object. Empty if the
// parsing failed.
base::NullableString16 platform;
// URL at which the application can be found. One of |url| and |id| must be
// present. Empty if the parsing failed or the field was not present.
GURL url;
// An id which is used to represent the application on the platform. One of
// |url| and |id| must be present. Empty if the parsing failed or the field
// was not present.
base::NullableString16 id;
};
Manifest();
Manifest(const Manifest& other);
~Manifest();
// Returns whether this Manifest had no attribute set. A newly created
// Manifest is always empty.
bool IsEmpty() const;
// Null if the parsing failed or the field was not present.
base::NullableString16 name;
// Null if the parsing failed or the field was not present.
base::NullableString16 short_name;
// Empty if the parsing failed or the field was not present.
GURL start_url;
// Set to WebDisplayModeUndefined if the parsing failed or the field was not
// present.
blink::WebDisplayMode display;
// Set to blink::WebScreenOrientationLockDefault if the parsing failed or the
// field was not present.
blink::WebScreenOrientationLockType orientation;
// Empty if the parsing failed, the field was not present, empty or all the
// icons inside the JSON array were invalid.
std::vector<Icon> icons;
// Null if parsing failed or the field was not present.
// TODO(constantina): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/web-share-target/blob/master/docs/interface.md
// As such, this field should not be exposed to web contents.
base::Optional<ShareTarget> share_target;
// Empty if the parsing failed, the field was not present, empty or all the
// applications inside the array were invalid. The order of the array
// indicates the priority of the application to use.
std::vector<RelatedApplication> related_applications;
// A boolean that is used as a hint for the user agent to say that related
// applications should be preferred over the web application. False if missing
// or there is a parsing failure.
bool prefer_related_applications;
// This is a 64 bit integer because we need to represent an error state. The
// color itself should only be 32 bits long if the value is not
// kInvalidOrMissingColor and can be safely cast to SkColor if is valid.
// Set to kInvalidOrMissingColor if parsing failed or field is not
// present.
int64_t theme_color;
// This is a 64 bit integer because we need to represent an error state. The
// color itself should only be 32 bits long if the value is not
// kInvalidOrMissingColor and can be safely cast to SkColor if is valid.
// Set to kInvalidOrMissingColor if parsing failed or field is not
// present.
int64_t background_color;
// This is a proprietary extension of the web Manifest, double-check that it
// is okay to use this entry.
// Null if parsing failed or the field was not present.
base::NullableString16 gcm_sender_id;
// Empty if the parsing failed or the field was not present.
GURL scope;
// Maximum length for all the strings inside the Manifest when it is sent over
// IPC. The renderer process should truncate the strings before sending the
// Manifest and the browser process must do the same when receiving it.
static const size_t kMaxIPCStringLength;
// Constant representing an invalid color. Set to a value outside the
// range of a 32-bit integer.
static const int64_t kInvalidOrMissingColor;
};
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_MANIFEST_H_
|