| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/file_util.h" | 5 #include "extensions/common/file_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 base::DictionaryValue* LoadManifest( | 161 base::DictionaryValue* LoadManifest( |
| 162 const base::FilePath& extension_path, | 162 const base::FilePath& extension_path, |
| 163 const base::FilePath::CharType* manifest_filename, | 163 const base::FilePath::CharType* manifest_filename, |
| 164 std::string* error) { | 164 std::string* error) { |
| 165 base::FilePath manifest_path = extension_path.Append(manifest_filename); | 165 base::FilePath manifest_path = extension_path.Append(manifest_filename); |
| 166 if (!base::PathExists(manifest_path)) { | 166 if (!base::PathExists(manifest_path)) { |
| 167 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); | 167 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); |
| 168 return NULL; | 168 return NULL; |
| 169 } | 169 } |
| 170 | 170 |
| 171 JSONFileValueSerializer serializer(manifest_path); | 171 JSONFileValueDeserializer deserializer(manifest_path); |
| 172 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, error)); | 172 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, error)); |
| 173 if (!root.get()) { | 173 if (!root.get()) { |
| 174 if (error->empty()) { | 174 if (error->empty()) { |
| 175 // If |error| is empty, than the file could not be read. | 175 // If |error| is empty, than the file could not be read. |
| 176 // It would be cleaner to have the JSON reader give a specific error | 176 // It would be cleaner to have the JSON reader give a specific error |
| 177 // in this case, but other code tests for a file error with | 177 // in this case, but other code tests for a file error with |
| 178 // error->empty(). For now, be consistent. | 178 // error->empty(). For now, be consistent. |
| 179 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); | 179 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); |
| 180 } else { | 180 } else { |
| 181 *error = base::StringPrintf( | 181 *error = base::StringPrintf( |
| 182 "%s %s", manifest_errors::kManifestParseError, error->c_str()); | 182 "%s %s", manifest_errors::kManifestParseError, error->c_str()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { | 447 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { |
| 448 return extension_path.Append(kMetadataFolder) | 448 return extension_path.Append(kMetadataFolder) |
| 449 .Append(kVerifiedContentsFilename); | 449 .Append(kVerifiedContentsFilename); |
| 450 } | 450 } |
| 451 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { | 451 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { |
| 452 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); | 452 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace file_util | 455 } // namespace file_util |
| 456 } // namespace extensions | 456 } // namespace extensions |
| OLD | NEW |