| 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 #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 Loading... |
| 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 |
| OLD | NEW |