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

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

Issue 1537473003: Change extension icon load errors to warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ultimate weirdness Created 5 years 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
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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 namespace file_util { 45 namespace file_util {
46 namespace { 46 namespace {
47 47
48 enum SafeInstallationFlag { 48 enum SafeInstallationFlag {
49 DEFAULT, // Default case, controlled by a field trial. 49 DEFAULT, // Default case, controlled by a field trial.
50 DISABLED, // Safe installation is disabled. 50 DISABLED, // Safe installation is disabled.
51 ENABLED, // Safe installation is enabled. 51 ENABLED, // Safe installation is enabled.
52 }; 52 };
53 SafeInstallationFlag g_use_safe_installation = DEFAULT; 53 SafeInstallationFlag g_use_safe_installation = DEFAULT;
54 54
55 // Returns true if the given file path exists and is not zero-length.
56 bool ValidateFilePath(const base::FilePath& path) {
57 int64 size = 0;
58 if (!base::PathExists(path) ||
59 !base::GetFileSize(path, &size) ||
60 size == 0) {
61 return false;
62 }
63
64 return true;
65 }
66
67 // Returns true if the extension installation should flush all files and the 55 // Returns true if the extension installation should flush all files and the
68 // directory. 56 // directory.
69 bool UseSafeInstallation() { 57 bool UseSafeInstallation() {
70 if (g_use_safe_installation == DEFAULT) { 58 if (g_use_safe_installation == DEFAULT) {
71 const char kFieldTrialName[] = "ExtensionUseSafeInstallation"; 59 const char kFieldTrialName[] = "ExtensionUseSafeInstallation";
72 const char kEnable[] = "Enable"; 60 const char kEnable[] = "Enable";
73 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable; 61 return base::FieldTrialList::FindFullName(kFieldTrialName) == kEnable;
74 } 62 }
75 63
76 return g_use_safe_installation == ENABLED; 64 return g_use_safe_installation == ENABLED;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 252 }
265 253
266 if (!root->IsType(base::Value::TYPE_DICTIONARY)) { 254 if (!root->IsType(base::Value::TYPE_DICTIONARY)) {
267 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID); 255 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID);
268 return NULL; 256 return NULL;
269 } 257 }
270 258
271 return base::DictionaryValue::From(std::move(root)); 259 return base::DictionaryValue::From(std::move(root));
272 } 260 }
273 261
262 bool ValidateFilePath(const base::FilePath& path) {
263 int64 size = 0;
264 return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0;
265 }
266
274 bool ValidateExtension(const Extension* extension, 267 bool ValidateExtension(const Extension* extension,
275 std::string* error, 268 std::string* error,
276 std::vector<InstallWarning>* warnings) { 269 std::vector<InstallWarning>* warnings) {
277 // Ask registered manifest handlers to validate their paths. 270 // Ask registered manifest handlers to validate their paths.
278 if (!ManifestHandler::ValidateExtension(extension, error, warnings)) 271 if (!ManifestHandler::ValidateExtension(extension, error, warnings))
279 return false; 272 return false;
280 273
281 // Check children of extension root to see if any of them start with _ and is 274 // Check children of extension root to see if any of them start with _ and is
282 // not on the reserved list. We only warn, and do not block the loading of the 275 // not on the reserved list. We only warn, and do not block the loading of the
283 // extension. 276 // extension.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { 611 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) {
619 return extension_path.Append(kMetadataFolder) 612 return extension_path.Append(kMetadataFolder)
620 .Append(kVerifiedContentsFilename); 613 .Append(kVerifiedContentsFilename);
621 } 614 }
622 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { 615 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) {
623 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); 616 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename);
624 } 617 }
625 618
626 } // namespace file_util 619 } // namespace file_util
627 } // namespace extensions 620 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698