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

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

Issue 574433004: Revert of Fix lsan failure with ManifestParserTest.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 base::TrimWhitespace(short_name, base::TRIM_ALL, &short_name); 48 base::TrimWhitespace(short_name, base::TRIM_ALL, &short_name);
49 return base::NullableString16(short_name, false); 49 return base::NullableString16(short_name, false);
50 } 50 }
51 51
52 } // anonymous namespace 52 } // anonymous namespace
53 53
54 namespace content { 54 namespace content {
55 55
56 Manifest ManifestParser::Parse(const base::StringPiece& json) { 56 Manifest ManifestParser::Parse(const base::StringPiece& json) {
57 scoped_ptr<base::Value> value = base::JSONReader::Read(json); 57 base::Value* value = base::JSONReader::Read(json);
58 if (!value) { 58 if (!value) {
59 // TODO(mlamouri): get the JSON parsing error and report it to the developer 59 // TODO(mlamouri): get the JSON parsing error and report it to the developer
60 // console. 60 // console.
61 return Manifest(); 61 return Manifest();
62 } 62 }
63 63
64 if (value->GetType() != base::Value::TYPE_DICTIONARY) { 64 if (value->GetType() != base::Value::TYPE_DICTIONARY) {
65 // TODO(mlamouri): provide a custom message to the developer console. 65 // TODO(mlamouri): provide a custom message to the developer console.
66 return Manifest(); 66 return Manifest();
67 } 67 }
68 68
69 base::DictionaryValue* dictionary = 0; 69 base::DictionaryValue* dictionary = 0;
70 value->GetAsDictionary(&dictionary); 70 value->GetAsDictionary(&dictionary);
71 if (!dictionary) { 71 if (!dictionary) {
72 // TODO(mlamouri): provide a custom message to the developer console. 72 // TODO(mlamouri): provide a custom message to the developer console.
73 return Manifest(); 73 return Manifest();
74 } 74 }
75 75
76 Manifest manifest; 76 Manifest manifest;
77 77
78 manifest.name = ParseName(*dictionary); 78 manifest.name = ParseName(*dictionary);
79 manifest.short_name = ParseShortName(*dictionary); 79 manifest.short_name = ParseShortName(*dictionary);
80 80
81 return manifest; 81 return manifest;
82 } 82 }
83 83
84 } // namespace content 84 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698