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_RENDERER_MANIFEST_MANIFEST_PARSER_H_ | 5 #ifndef CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ |
6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ | 6 #define CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ |
7 | 7 |
8 #include "base/strings/nullable_string16.h" | 8 #include "base/strings/nullable_string16.h" |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 NoTrim | 43 NoTrim |
44 }; | 44 }; |
45 | 45 |
46 // Helper function to parse strings present on a given |dictionary| in a given | 46 // Helper function to parse strings present on a given |dictionary| in a given |
47 // field identified by its |key|. | 47 // field identified by its |key|. |
48 // Returns the parsed string if any, a null string if the parsing failed. | 48 // Returns the parsed string if any, a null string if the parsing failed. |
49 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, | 49 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, |
50 const std::string& key, | 50 const std::string& key, |
51 TrimType trim); | 51 TrimType trim); |
52 | 52 |
53 // Helper function to parse booleans present on a given |dictionary| in a | |
54 // given field identified by its |key|. | |
55 // Returns the parsed boolean if any, or |default_value| is parsing failed. | |
mlamouri (slow - plz ping)
2014/12/01 21:05:09
nit: s/is parsing failed/if parsing failed/.
Peter Beverloo
2014/12/03 15:01:59
Done.
| |
56 bool ParseBoolean(const base::DictionaryValue& dictionary, | |
57 const std::string& key, | |
58 bool default_value); | |
59 | |
53 // Helper function to parse URLs present on a given |dictionary| in a given | 60 // Helper function to parse URLs present on a given |dictionary| in a given |
54 // field identified by its |key|. The URL is first parsed as a string then | 61 // field identified by its |key|. The URL is first parsed as a string then |
55 // resolved using |base_url|. | 62 // resolved using |base_url|. |
56 // Returns a GURL. If the parsing failed, the GURL will not be valid. | 63 // Returns a GURL. If the parsing failed, the GURL will not be valid. |
57 GURL ParseURL(const base::DictionaryValue& dictionary, | 64 GURL ParseURL(const base::DictionaryValue& dictionary, |
58 const std::string& key, | 65 const std::string& key, |
59 const GURL& base_url); | 66 const GURL& base_url); |
60 | 67 |
61 // Parses the 'name' field of the manifest, as defined in: | 68 // Parses the 'name' field of the manifest, as defined in: |
62 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-name-member | 69 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-name-member |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 // any. An empty vector if the field was not present or empty. | 123 // any. An empty vector if the field was not present or empty. |
117 std::vector<Manifest::Icon> ParseIcons( | 124 std::vector<Manifest::Icon> ParseIcons( |
118 const base::DictionaryValue& dictionary); | 125 const base::DictionaryValue& dictionary); |
119 | 126 |
120 // Parses the 'gcm_sender_id' field of the manifest. | 127 // Parses the 'gcm_sender_id' field of the manifest. |
121 // This is a proprietary extension of the Web Manifest specification. | 128 // This is a proprietary extension of the Web Manifest specification. |
122 // Returns the parsed string if any, a null string if the parsing failed. | 129 // Returns the parsed string if any, a null string if the parsing failed. |
123 base::NullableString16 ParseGCMSenderID( | 130 base::NullableString16 ParseGCMSenderID( |
124 const base::DictionaryValue& dictionary); | 131 const base::DictionaryValue& dictionary); |
125 | 132 |
133 // Parses the 'gcm_user_visible_only' field of the manifest. | |
134 // This is a proprietary extension of the Web Manifest specification. | |
135 // Returns true iff the string could be parsed as the boolean true. | |
136 bool ParseGCMUserVisibleOnly(const base::DictionaryValue& dictionary); | |
137 | |
126 const base::StringPiece& data_; | 138 const base::StringPiece& data_; |
127 const GURL& manifest_url_; | 139 const GURL& manifest_url_; |
128 const GURL& document_url_; | 140 const GURL& document_url_; |
129 | 141 |
130 bool failed_; | 142 bool failed_; |
131 Manifest manifest_; | 143 Manifest manifest_; |
132 std::vector<std::string> errors_; | 144 std::vector<std::string> errors_; |
133 | 145 |
134 DISALLOW_COPY_AND_ASSIGN(ManifestParser); | 146 DISALLOW_COPY_AND_ASSIGN(ManifestParser); |
135 }; | 147 }; |
136 | 148 |
137 } // namespace content | 149 } // namespace content |
138 | 150 |
139 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ | 151 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ |
OLD | NEW |