fix: remove extension warning that do not have any impact (#29695)
This commit is contained in:
parent
4d89174b41
commit
fd8eb3de1b
1 changed files with 29 additions and 3 deletions
|
@ -21,7 +21,9 @@
|
||||||
#include "extensions/browser/extension_prefs.h"
|
#include "extensions/browser/extension_prefs.h"
|
||||||
#include "extensions/browser/extension_registry.h"
|
#include "extensions/browser/extension_registry.h"
|
||||||
#include "extensions/browser/pref_names.h"
|
#include "extensions/browser/pref_names.h"
|
||||||
|
#include "extensions/common/error_utils.h"
|
||||||
#include "extensions/common/file_util.h"
|
#include "extensions/common/file_util.h"
|
||||||
|
#include "extensions/common/manifest_constants.h"
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
|
||||||
|
@ -41,6 +43,15 @@ std::pair<scoped_refptr<const Extension>, std::string> LoadUnpacked(
|
||||||
return std::make_pair(nullptr, err);
|
return std::make_pair(nullptr, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove _metadata folder. Otherwise, the following warning will be thrown
|
||||||
|
// Cannot load extension with file or directory name _metadata.
|
||||||
|
// Filenames starting with "_" are reserved for use by the system.
|
||||||
|
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=377278
|
||||||
|
base::FilePath metadata_dir = extension_dir.Append(kMetadataFolder);
|
||||||
|
if (base::DirectoryExists(metadata_dir)) {
|
||||||
|
base::DeletePathRecursively(metadata_dir);
|
||||||
|
}
|
||||||
|
|
||||||
std::string load_error;
|
std::string load_error;
|
||||||
scoped_refptr<Extension> extension = file_util::LoadExtension(
|
scoped_refptr<Extension> extension = file_util::LoadExtension(
|
||||||
extension_dir, extensions::mojom::ManifestLocation::kCommandLine,
|
extension_dir, extensions::mojom::ManifestLocation::kCommandLine,
|
||||||
|
@ -55,10 +66,25 @@ std::pair<scoped_refptr<const Extension>, std::string> LoadUnpacked(
|
||||||
std::string warnings;
|
std::string warnings;
|
||||||
// Log warnings.
|
// Log warnings.
|
||||||
if (!extension->install_warnings().empty()) {
|
if (!extension->install_warnings().empty()) {
|
||||||
warnings += "Warnings loading extension at " +
|
std::string warning_prefix =
|
||||||
base::UTF16ToUTF8(extension_dir.LossyDisplayName()) + ":\n";
|
"Warnings loading extension at " +
|
||||||
|
base::UTF16ToUTF8(extension_dir.LossyDisplayName());
|
||||||
|
|
||||||
for (const auto& warning : extension->install_warnings()) {
|
for (const auto& warning : extension->install_warnings()) {
|
||||||
warnings += " " + warning.message + "\n";
|
std::string unrecognized_manifest_error = ErrorUtils::FormatErrorMessage(
|
||||||
|
manifest_errors::kUnrecognizedManifestKey, warning.key);
|
||||||
|
|
||||||
|
if (warning.message == unrecognized_manifest_error) {
|
||||||
|
// filter kUnrecognizedManifestKey error. This error does not have any
|
||||||
|
// impact e.g: Unrecognized manifest key 'minimum_chrome_version' etc.
|
||||||
|
LOG(WARNING) << warning_prefix << ": " << warning.message;
|
||||||
|
} else {
|
||||||
|
warnings += " " + warning.message + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (warnings != "") {
|
||||||
|
warnings = warning_prefix + ":\n" + warnings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue