Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/renderer/manifest/manifest_parser.h

Issue 1932623003: DevTools: Introduce Page.getManifest remote debugging protocol method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/nullable_string16.h" 13 #include "base/strings/nullable_string16.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/common/manifest.h" 16 #include "content/public/common/manifest.h"
17 #include "content/renderer/manifest/manifest_debug_info.h"
17 18
18 class GURL; 19 class GURL;
19 20
20 namespace base { 21 namespace base {
21 class DictionaryValue; 22 class DictionaryValue;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 26
26 // ManifestParser handles the logic of parsing the Web Manifest from a string. 27 // ManifestParser handles the logic of parsing the Web Manifest from a string.
27 // It implements: 28 // It implements:
28 // http://w3c.github.io/manifest/#dfn-steps-for-processing-a-manifest 29 // http://w3c.github.io/manifest/#dfn-steps-for-processing-a-manifest
29 class CONTENT_EXPORT ManifestParser { 30 class CONTENT_EXPORT ManifestParser {
30 public: 31 public:
31 class ErrorInfo {
32 public:
33 ErrorInfo(const std::string& error_msg, int error_line, int error_column)
34 : error_msg(error_msg),
35 error_line(error_line),
36 error_column(error_column) {}
37 const std::string error_msg;
38 const int error_line;
39 const int error_column;
40 };
41 ManifestParser(const base::StringPiece& data, 32 ManifestParser(const base::StringPiece& data,
42 const GURL& manifest_url, 33 const GURL& manifest_url,
43 const GURL& document_url); 34 const GURL& document_url);
44 ~ManifestParser(); 35 ~ManifestParser();
45 36
46 // Parse the Manifest from a string using following: 37 // Parse the Manifest from a string using following:
47 // http://w3c.github.io/manifest/#dfn-steps-for-processing-a-manifest 38 // http://w3c.github.io/manifest/#dfn-steps-for-processing-a-manifest
48 void Parse(); 39 void Parse();
49 40
50 const Manifest& manifest() const; 41 const Manifest& manifest() const;
51 const std::vector<std::unique_ptr<ErrorInfo>>& errors() const;
52 bool failed() const; 42 bool failed() const;
53 43
44 void TakeErrors(std::vector<ManifestDebugInfo::Error>* errors);
45
54 private: 46 private:
55 // Used to indicate whether to strip whitespace when parsing a string. 47 // Used to indicate whether to strip whitespace when parsing a string.
56 enum TrimType { 48 enum TrimType {
57 Trim, 49 Trim,
58 NoTrim 50 NoTrim
59 }; 51 };
60 52
61 // Helper function to parse booleans present on a given |dictionary| in a 53 // Helper function to parse booleans present on a given |dictionary| in a
62 // given field identified by its |key|. 54 // given field identified by its |key|.
63 // Returns the parsed boolean if any, or |default_value| if parsing failed. 55 // Returns the parsed boolean if any, or |default_value| if parsing failed.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void AddErrorInfo(const std::string& error_msg, 184 void AddErrorInfo(const std::string& error_msg,
193 int error_line = 0, 185 int error_line = 0,
194 int error_column = 0); 186 int error_column = 0);
195 187
196 const base::StringPiece& data_; 188 const base::StringPiece& data_;
197 GURL manifest_url_; 189 GURL manifest_url_;
198 GURL document_url_; 190 GURL document_url_;
199 191
200 bool failed_; 192 bool failed_;
201 Manifest manifest_; 193 Manifest manifest_;
202 std::vector<std::unique_ptr<ErrorInfo>> errors_; 194 std::vector<ManifestDebugInfo::Error> errors_;
203 195
204 DISALLOW_COPY_AND_ASSIGN(ManifestParser); 196 DISALLOW_COPY_AND_ASSIGN(ManifestParser);
205 }; 197 };
206 198
207 } // namespace content 199 } // namespace content
208 200
209 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_ 201 #endif // CONTENT_RENDERER_MANIFEST_MANIFEST_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698