| 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 25 matching lines...) Expand all Loading... |
| 36 const std::vector<std::string>& errors() const; | 36 const std::vector<std::string>& errors() const; |
| 37 bool failed() const; | 37 bool failed() const; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 // Used to indicate whether to strip whitespace when parsing a string. | 40 // Used to indicate whether to strip whitespace when parsing a string. |
| 41 enum TrimType { | 41 enum TrimType { |
| 42 Trim, | 42 Trim, |
| 43 NoTrim | 43 NoTrim |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Helper function to parse booleans present on a given |dictionary| in a |
| 47 // given field identified by its |key|. |
| 48 // Returns the parsed boolean if any, or |default_value| if parsing failed. |
| 49 bool ParseBoolean(const base::DictionaryValue& dictionary, |
| 50 const std::string& key, |
| 51 bool default_value); |
| 52 |
| 46 // Helper function to parse strings present on a given |dictionary| in a given | 53 // Helper function to parse strings present on a given |dictionary| in a given |
| 47 // field identified by its |key|. | 54 // field identified by its |key|. |
| 48 // Returns the parsed string if any, a null string if the parsing failed. | 55 // Returns the parsed string if any, a null string if the parsing failed. |
| 49 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, | 56 base::NullableString16 ParseString(const base::DictionaryValue& dictionary, |
| 50 const std::string& key, | 57 const std::string& key, |
| 51 TrimType trim); | 58 TrimType trim); |
| 52 | 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|. |
| (...skipping 60 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 |