Chromium Code Reviews| 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> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 namespace file_util { | 49 namespace file_util { |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 enum SafeInstallationFlag { | 52 enum SafeInstallationFlag { |
| 53 DEFAULT, // Default case, controlled by a field trial. | 53 DEFAULT, // Default case, controlled by a field trial. |
| 54 DISABLED, // Safe installation is disabled. | 54 DISABLED, // Safe installation is disabled. |
| 55 ENABLED, // Safe installation is enabled. | 55 ENABLED, // Safe installation is enabled. |
| 56 }; | 56 }; |
| 57 SafeInstallationFlag g_use_safe_installation = DEFAULT; | 57 SafeInstallationFlag g_use_safe_installation = DEFAULT; |
| 58 | 58 |
| 59 // Returns true if the given file path exists and is not zero-length. | |
| 60 bool ValidateFilePath(const base::FilePath& path) { | |
| 61 int64 size = 0; | |
|
Lei Zhang
2015/12/29 19:48:39
avi@ got rid of base/basictypes.h, see chromium-de
| |
| 62 if (!base::PathExists(path) || !base::GetFileSize(path, &size) || size == 0) { | |
| 63 return false; | |
| 64 } | |
| 65 | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 // Returns true if the extension installation should flush all files and the | 59 // Returns true if the extension installation should flush all files and the |
| 70 // directory. | 60 // directory. |
| 71 bool UseSafeInstallation() { | 61 bool UseSafeInstallation() { |
| 72 if (g_use_safe_installation == DEFAULT) { | 62 if (g_use_safe_installation == DEFAULT) { |
| 73 const char kFieldTrialName[] = "ExtensionUseSafeInstallation"; | 63 const char kFieldTrialName[] = "ExtensionUseSafeInstallation"; |
| 74 const char kEnable[] = "Enable"; | 64 const char kEnable[] = "Enable"; |
| 75 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable; | 65 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable; |
| 76 } | 66 } |
| 77 | 67 |
| 78 return g_use_safe_installation == ENABLED; | 68 return g_use_safe_installation == ENABLED; |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { | 615 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { |
| 626 return extension_path.Append(kMetadataFolder) | 616 return extension_path.Append(kMetadataFolder) |
| 627 .Append(kVerifiedContentsFilename); | 617 .Append(kVerifiedContentsFilename); |
| 628 } | 618 } |
| 629 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { | 619 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { |
| 630 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); | 620 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); |
| 631 } | 621 } |
| 632 | 622 |
| 633 } // namespace file_util | 623 } // namespace file_util |
| 634 } // namespace extensions | 624 } // namespace extensions |
| OLD | NEW |