| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <map> | 10 #include <map> |
| 8 #include <set> | 11 #include <set> |
| 9 #include <string> | 12 #include <string> |
| 10 #include <utility> | 13 #include <utility> |
| 11 #include <vector> | 14 #include <vector> |
| 12 | 15 |
| 13 #include "base/files/file_enumerator.h" | 16 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 16 #include "base/files/scoped_temp_dir.h" | 19 #include "base/files/scoped_temp_dir.h" |
| 17 #include "base/json/json_file_value_serializer.h" | 20 #include "base/json/json_file_value_serializer.h" |
| 18 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/macros.h" |
| 19 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/metrics/field_trial.h" | 24 #include "base/metrics/field_trial.h" |
| 21 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
| 22 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
| 25 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 26 #include "extensions/common/constants.h" | 30 #include "extensions/common/constants.h" |
| 27 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/extension_icon_set.h" | 32 #include "extensions/common/extension_icon_set.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 257 |
| 254 if (!root->IsType(base::Value::TYPE_DICTIONARY)) { | 258 if (!root->IsType(base::Value::TYPE_DICTIONARY)) { |
| 255 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID); | 259 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID); |
| 256 return NULL; | 260 return NULL; |
| 257 } | 261 } |
| 258 | 262 |
| 259 return base::DictionaryValue::From(std::move(root)); | 263 return base::DictionaryValue::From(std::move(root)); |
| 260 } | 264 } |
| 261 | 265 |
| 262 bool ValidateFilePath(const base::FilePath& path) { | 266 bool ValidateFilePath(const base::FilePath& path) { |
| 263 int64 size = 0; | 267 int64_t size = 0; |
| 264 return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0; | 268 return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0; |
| 265 } | 269 } |
| 266 | 270 |
| 267 bool ValidateExtension(const Extension* extension, | 271 bool ValidateExtension(const Extension* extension, |
| 268 std::string* error, | 272 std::string* error, |
| 269 std::vector<InstallWarning>* warnings) { | 273 std::vector<InstallWarning>* warnings) { |
| 270 // Ask registered manifest handlers to validate their paths. | 274 // Ask registered manifest handlers to validate their paths. |
| 271 if (!ManifestHandler::ValidateExtension(extension, error, warnings)) | 275 if (!ManifestHandler::ValidateExtension(extension, error, warnings)) |
| 272 return false; | 276 return false; |
| 273 | 277 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { | 615 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { |
| 612 return extension_path.Append(kMetadataFolder) | 616 return extension_path.Append(kMetadataFolder) |
| 613 .Append(kVerifiedContentsFilename); | 617 .Append(kVerifiedContentsFilename); |
| 614 } | 618 } |
| 615 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { | 619 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { |
| 616 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); | 620 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); |
| 617 } | 621 } |
| 618 | 622 |
| 619 } // namespace file_util | 623 } // namespace file_util |
| 620 } // namespace extensions | 624 } // namespace extensions |
| OLD | NEW |