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

Unified Diff: content/renderer/manifest/manifest_parser.cc

Issue 1932623003: DevTools: Introduce Page.getManifest remote debugging protocol method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: browser test updated Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/manifest/manifest_parser.h ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/manifest/manifest_parser.cc
diff --git a/content/renderer/manifest/manifest_parser.cc b/content/renderer/manifest/manifest_parser.cc
index 40d4d3311004f334c47ebb315459bb413943b7a3..1222a556c488067e97dcb90af6d6679f373bbfa8 100644
--- a/content/renderer/manifest/manifest_parser.cc
+++ b/content/renderer/manifest/manifest_parser.cc
@@ -84,12 +84,6 @@ std::vector<gfx::Size> ParseIconSizesHTML(const base::string16& sizes_str16) {
return sizes;
}
-const std::string& GetErrorPrefix() {
- CR_DEFINE_STATIC_LOCAL(std::string, error_prefix,
- ("Manifest parsing error: "));
- return error_prefix;
-}
-
} // anonymous namespace
@@ -114,7 +108,7 @@ void ManifestParser::Parse() {
&error_column);
if (!value) {
- AddErrorInfo(GetErrorPrefix() + error_msg, error_line, error_column);
+ AddErrorInfo(error_msg, true, error_line, error_column);
ManifestUmaUtil::ParseFailed();
failed_ = true;
return;
@@ -122,8 +116,7 @@ void ManifestParser::Parse() {
base::DictionaryValue* dictionary = nullptr;
if (!value->GetAsDictionary(&dictionary)) {
- AddErrorInfo(GetErrorPrefix() +
- "root element must be a valid JSON object.");
+ AddErrorInfo("root element must be a valid JSON object.", true);
ManifestUmaUtil::ParseFailed();
failed_ = true;
return;
@@ -150,9 +143,10 @@ const Manifest& ManifestParser::manifest() const {
return manifest_;
}
-const std::vector<std::unique_ptr<ManifestParser::ErrorInfo>>&
-ManifestParser::errors() const {
- return errors_;
+void ManifestParser::TakeErrors(
+ std::vector<ManifestDebugInfo::Error>* errors) {
+ errors->clear();
+ errors->swap(errors_);
}
bool ManifestParser::failed() const {
@@ -167,7 +161,7 @@ bool ManifestParser::ParseBoolean(const base::DictionaryValue& dictionary,
bool value;
if (!dictionary.GetBoolean(key, &value)) {
- AddErrorInfo(GetErrorPrefix() + "property '" + key + "' ignored, type " +
+ AddErrorInfo("property '" + key + "' ignored, type " +
"boolean expected.");
return default_value;
}
@@ -184,7 +178,7 @@ base::NullableString16 ManifestParser::ParseString(
base::string16 value;
if (!dictionary.GetString(key, &value)) {
- AddErrorInfo(GetErrorPrefix() + "property '" + key + "' ignored, type " +
+ AddErrorInfo("property '" + key + "' ignored, type " +
"string expected.");
return base::NullableString16();
}
@@ -203,7 +197,7 @@ int64_t ManifestParser::ParseColor(
blink::WebColor color;
if (!blink::WebCSSParser::parseColor(&color, parsed_color.string())) {
- AddErrorInfo(GetErrorPrefix() + "property '" + key + "' ignored, '" +
+ AddErrorInfo("property '" + key + "' ignored, '" +
base::UTF16ToUTF8(parsed_color.string()) + "' is not a " +
"valid color.");
return Manifest::kInvalidOrMissingColor;
@@ -243,7 +237,7 @@ GURL ManifestParser::ParseStartURL(const base::DictionaryValue& dictionary) {
return GURL();
if (start_url.GetOrigin() != document_url_.GetOrigin()) {
- AddErrorInfo(GetErrorPrefix() + "property 'start_url' ignored, should be " +
+ AddErrorInfo("property 'start_url' ignored, should be "
"same origin as document.");
return GURL();
}
@@ -266,7 +260,7 @@ blink::WebDisplayMode ManifestParser::ParseDisplay(
else if (base::LowerCaseEqualsASCII(display.string(), "browser"))
return blink::WebDisplayModeBrowser;
else {
- AddErrorInfo(GetErrorPrefix() + "unknown 'display' value ignored.");
+ AddErrorInfo("unknown 'display' value ignored.");
return blink::WebDisplayModeUndefined;
}
}
@@ -300,7 +294,7 @@ blink::WebScreenOrientationLockType ManifestParser::ParseOrientation(
"portrait-secondary"))
return blink::WebScreenOrientationLockPortraitSecondary;
else {
- AddErrorInfo(GetErrorPrefix() + "unknown 'orientation' value ignored.");
+ AddErrorInfo("unknown 'orientation' value ignored.");
return blink::WebScreenOrientationLockDefault;
}
}
@@ -323,7 +317,7 @@ std::vector<gfx::Size> ManifestParser::ParseIconSizes(
std::vector<gfx::Size> sizes = ParseIconSizesHTML(sizes_str.string());
if (sizes.empty()) {
- AddErrorInfo(GetErrorPrefix() + "found icon with no valid size.");
+ AddErrorInfo("found icon with no valid size.");
}
return sizes;
}
@@ -336,8 +330,7 @@ std::vector<Manifest::Icon> ManifestParser::ParseIcons(
const base::ListValue* icons_list = nullptr;
if (!dictionary.GetList("icons", &icons_list)) {
- AddErrorInfo(GetErrorPrefix() +
- "property 'icons' ignored, type array expected.");
+ AddErrorInfo("property 'icons' ignored, type array expected.");
return icons;
}
@@ -384,9 +377,8 @@ ManifestParser::ParseRelatedApplications(
const base::ListValue* applications_list = nullptr;
if (!dictionary.GetList("related_applications", &applications_list)) {
- AddErrorInfo(
- GetErrorPrefix() +
- "property 'related_applications' ignored, type array expected.");
+ AddErrorInfo("property 'related_applications' ignored,"
+ " type array expected.");
return applications;
}
@@ -400,9 +392,8 @@ ManifestParser::ParseRelatedApplications(
ParseRelatedApplicationPlatform(*application_dictionary);
// "If platform is undefined, move onto the next item if any are left."
if (application.platform.is_null()) {
- AddErrorInfo(
- GetErrorPrefix() +
- "'platform' is a required field, related application ignored.");
+ AddErrorInfo("'platform' is a required field, related application"
+ " ignored.");
continue;
}
@@ -411,9 +402,8 @@ ManifestParser::ParseRelatedApplications(
// "If both id and url are undefined, move onto the next item if any are
// left."
if (application.url.is_empty() && application.id.is_null()) {
- AddErrorInfo(
- GetErrorPrefix() +
- "one of 'url' or 'id' is required, related application ignored.");
+ AddErrorInfo("one of 'url' or 'id' is required, related application"
+ " ignored.");
continue;
}
@@ -444,9 +434,10 @@ base::NullableString16 ManifestParser::ParseGCMSenderID(
}
void ManifestParser::AddErrorInfo(const std::string& error_msg,
+ bool critical,
int error_line,
int error_column) {
- errors_.push_back(
- base::WrapUnique(new ErrorInfo(error_msg, error_line, error_column)));
+ errors_.push_back({error_msg, critical, error_line, error_column});
}
+
} // namespace content
« no previous file with comments | « content/renderer/manifest/manifest_parser.h ('k') | content/renderer/manifest/manifest_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698