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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 std::vector<InstallWarning> warnings; | 148 std::vector<InstallWarning> warnings; |
149 if (!ValidateExtension(extension.get(), error, &warnings)) | 149 if (!ValidateExtension(extension.get(), error, &warnings)) |
150 return NULL; | 150 return NULL; |
151 extension->AddInstallWarnings(warnings); | 151 extension->AddInstallWarnings(warnings); |
152 | 152 |
153 return extension; | 153 return extension; |
154 } | 154 } |
155 | 155 |
156 base::DictionaryValue* LoadManifest(const base::FilePath& extension_path, | 156 base::DictionaryValue* LoadManifest(const base::FilePath& extension_path, |
157 std::string* error) { | 157 std::string* error) { |
158 base::FilePath manifest_path = extension_path.Append(kManifestFilename); | 158 return LoadManifest(extension_path, kManifestFilename, error); |
| 159 } |
| 160 |
| 161 base::DictionaryValue* LoadManifest( |
| 162 const base::FilePath& extension_path, |
| 163 const base::FilePath::CharType* manifest_filename, |
| 164 std::string* error) { |
| 165 base::FilePath manifest_path = extension_path.Append(manifest_filename); |
159 if (!base::PathExists(manifest_path)) { | 166 if (!base::PathExists(manifest_path)) { |
160 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); | 167 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); |
161 return NULL; | 168 return NULL; |
162 } | 169 } |
163 | 170 |
164 JSONFileValueSerializer serializer(manifest_path); | 171 JSONFileValueSerializer serializer(manifest_path); |
165 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, error)); | 172 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, error)); |
166 if (!root.get()) { | 173 if (!root.get()) { |
167 if (error->empty()) { | 174 if (error->empty()) { |
168 // If |error| is empty, than the file could not be read. | 175 // If |error| is empty, than the file could not be read. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { | 447 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { |
441 return extension_path.Append(kMetadataFolder) | 448 return extension_path.Append(kMetadataFolder) |
442 .Append(kVerifiedContentsFilename); | 449 .Append(kVerifiedContentsFilename); |
443 } | 450 } |
444 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { | 451 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { |
445 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); | 452 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); |
446 } | 453 } |
447 | 454 |
448 } // namespace file_util | 455 } // namespace file_util |
449 } // namespace extensions | 456 } // namespace extensions |
OLD | NEW |