| 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
|
|
|