Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: extensions/common/file_util.cc

Issue 1554583002: Revert of Change extension icon load errors to warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge issues Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/file_util.h ('k') | extensions/common/file_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_t size = 0;
62 return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0;
63 }
64
59 // Returns true if the extension installation should flush all files and the 65 // Returns true if the extension installation should flush all files and the
60 // directory. 66 // directory.
61 bool UseSafeInstallation() { 67 bool UseSafeInstallation() {
62 if (g_use_safe_installation == DEFAULT) { 68 if (g_use_safe_installation == DEFAULT) {
63 const char kFieldTrialName[] = "ExtensionUseSafeInstallation"; 69 const char kFieldTrialName[] = "ExtensionUseSafeInstallation";
64 const char kEnable[] = "Enable"; 70 const char kEnable[] = "Enable";
65 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable; 71 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable;
66 } 72 }
67 73
68 return g_use_safe_installation == ENABLED; 74 return g_use_safe_installation == ENABLED;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 262 }
257 263
258 if (!root->IsType(base::Value::TYPE_DICTIONARY)) { 264 if (!root->IsType(base::Value::TYPE_DICTIONARY)) {
259 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID); 265 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID);
260 return NULL; 266 return NULL;
261 } 267 }
262 268
263 return base::DictionaryValue::From(std::move(root)); 269 return base::DictionaryValue::From(std::move(root));
264 } 270 }
265 271
266 bool ValidateFilePath(const base::FilePath& path) {
267 int64_t size = 0;
268 return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0;
269 }
270
271 bool ValidateExtension(const Extension* extension, 272 bool ValidateExtension(const Extension* extension,
272 std::string* error, 273 std::string* error,
273 std::vector<InstallWarning>* warnings) { 274 std::vector<InstallWarning>* warnings) {
274 // Ask registered manifest handlers to validate their paths. 275 // Ask registered manifest handlers to validate their paths.
275 if (!ManifestHandler::ValidateExtension(extension, error, warnings)) 276 if (!ManifestHandler::ValidateExtension(extension, error, warnings))
276 return false; 277 return false;
277 278
278 // Check children of extension root to see if any of them start with _ and is 279 // Check children of extension root to see if any of them start with _ and is
279 // not on the reserved list. We only warn, and do not block the loading of the 280 // not on the reserved list. We only warn, and do not block the loading of the
280 // extension. 281 // extension.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { 616 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) {
616 return extension_path.Append(kMetadataFolder) 617 return extension_path.Append(kMetadataFolder)
617 .Append(kVerifiedContentsFilename); 618 .Append(kVerifiedContentsFilename);
618 } 619 }
619 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { 620 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) {
620 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); 621 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename);
621 } 622 }
622 623
623 } // namespace file_util 624 } // namespace file_util
624 } // namespace extensions 625 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/file_util.h ('k') | extensions/common/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698