| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Helper function to parse strings present on a given |dictionary| in a given | 60 // Helper function to parse strings present on a given |dictionary| in a given |
| 61 // field identified by its |key|. | 61 // field identified by its |key|. |
| 62 // Returns the parsed string if any, a null string if the parsing failed. | 62 // Returns the parsed string if any, a null string if the parsing failed. |
| 63 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, | 63 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, |
| 64 const std::string& key, | 64 const std::string& key, |
| 65 TrimType trim); | 65 TrimType trim); |
| 66 | 66 |
| 67 // Helper function to parse colors present on a given |dictionary| in a given | 67 // Helper function to parse colors present on a given |dictionary| in a given |
| 68 // field identified by its |key|. | 68 // field identified by its |key|. |
| 69 // Returns the parsed color as an int64_t if any, | 69 // Returns the parsed color as Optional<SkColor>; if the parsing failed, the |
| 70 // Manifest::kInvalidOrMissingColor if the parsing failed. | 70 // Optional<> will be empty. |
| 71 int64_t ParseColor(const base::DictionaryValue& dictionary, | 71 base::Optional<SkColor> ParseColor(const base::DictionaryValue& dictionary, |
| 72 const std::string& key); | 72 const std::string& key); |
| 73 | 73 |
| 74 // Helper function to parse URLs present on a given |dictionary| in a given | 74 // Helper function to parse URLs present on a given |dictionary| in a given |
| 75 // field identified by its |key|. The URL is first parsed as a string then | 75 // field identified by its |key|. The URL is first parsed as a string then |
| 76 // resolved using |base_url|. | 76 // resolved using |base_url|. |
| 77 // Returns a GURL. If the parsing failed, the GURL will not be valid. | 77 // Returns a GURL. If the parsing failed, the GURL will not be valid. |
| 78 GURL ParseURL(const base::DictionaryValue& dictionary, | 78 GURL ParseURL(const base::DictionaryValue& dictionary, |
| 79 const std::string& key, | 79 const std::string& key, |
| 80 const GURL& base_url); | 80 const GURL& base_url); |
| 81 | 81 |
| 82 // Parses the 'name' field of the manifest, as defined in: | 82 // Parses the 'name' field of the manifest, as defined in: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const base::DictionaryValue& dictionary); | 164 const base::DictionaryValue& dictionary); |
| 165 | 165 |
| 166 // Parses the 'prefer_related_applications' field on the manifest, as defined | 166 // Parses the 'prefer_related_applications' field on the manifest, as defined |
| 167 // in: | 167 // in: |
| 168 // https://w3c.github.io/manifest/#dfn-steps-for-processing-the-prefer_related
_applications-member | 168 // https://w3c.github.io/manifest/#dfn-steps-for-processing-the-prefer_related
_applications-member |
| 169 // returns true iff the field could be parsed as the boolean true. | 169 // returns true iff the field could be parsed as the boolean true. |
| 170 bool ParsePreferRelatedApplications(const base::DictionaryValue& dictionary); | 170 bool ParsePreferRelatedApplications(const base::DictionaryValue& dictionary); |
| 171 | 171 |
| 172 // Parses the 'theme_color' field of the manifest, as defined in: | 172 // Parses the 'theme_color' field of the manifest, as defined in: |
| 173 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-theme_color-mem
ber | 173 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-theme_color-mem
ber |
| 174 // Returns the parsed theme color if any, | 174 // Returns the parsed theme color wrapped in an Optional<> if any, empty |
| 175 // Manifest::kInvalidOrMissingColor if the parsing failed. | 175 // Optional<> if the parsing failed. |
| 176 int64_t ParseThemeColor(const base::DictionaryValue& dictionary); | 176 base::Optional<SkColor> ParseThemeColor( |
| 177 const base::DictionaryValue& dictionary); |
| 177 | 178 |
| 178 // Parses the 'background_color' field of the manifest, as defined in: | 179 // Parses the 'background_color' field of the manifest, as defined in: |
| 179 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-background_colo
r-member | 180 // http://w3c.github.io/manifest/#dfn-steps-for-processing-the-background_colo
r-member |
| 180 // Returns the parsed background color if any, | 181 // Returns the parsed background color wrapped in an Optional<> if any, empty |
| 181 // Manifest::kInvalidOrMissingColor if the parsing failed. | 182 // Optional<> if the parsing failed. |
| 182 int64_t ParseBackgroundColor(const base::DictionaryValue& dictionary); | 183 base::Optional<SkColor> ParseBackgroundColor( |
| 184 const base::DictionaryValue& dictionary); |
| 183 | 185 |
| 184 // Parses the 'gcm_sender_id' field of the manifest. | 186 // Parses the 'gcm_sender_id' field of the manifest. |
| 185 // This is a proprietary extension of the Web Manifest specification. | 187 // This is a proprietary extension of the Web Manifest specification. |
| 186 // Returns the parsed string if any, a null string if the parsing failed. | 188 // Returns the parsed string if any, a null string if the parsing failed. |
| 187 base::NullableString16 ParseGCMSenderID( | 189 base::NullableString16 ParseGCMSenderID( |
| 188 const base::DictionaryValue& dictionary); | 190 const base::DictionaryValue& dictionary); |
| 189 | 191 |
| 190 void AddErrorInfo(const std::string& error_msg, | 192 void AddErrorInfo(const std::string& error_msg, |
| 191 bool critical = false, | 193 bool critical = false, |
| 192 int error_line = 0, | 194 int error_line = 0, |
| 193 int error_column = 0); | 195 int error_column = 0); |
| 194 | 196 |
| 195 const base::StringPiece& data_; | 197 const base::StringPiece& data_; |
| 196 GURL manifest_url_; | 198 GURL manifest_url_; |
| 197 GURL document_url_; | 199 GURL document_url_; |
| 198 | 200 |
| 199 bool failed_; | 201 bool failed_; |
| 200 Manifest manifest_; | 202 Manifest manifest_; |
| 201 std::vector<ManifestDebugInfo::Error> errors_; | 203 std::vector<ManifestDebugInfo::Error> errors_; |
| 202 | 204 |
| 203 DISALLOW_COPY_AND_ASSIGN(ManifestParser); | 205 DISALLOW_COPY_AND_ASSIGN(ManifestParser); |
| 204 }; | 206 }; |
| 205 | 207 |
| 206 } // namespace content | 208 } // namespace content |
| 207 | 209 |
| 208 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ | 210 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ |
| OLD | NEW |