| Index: extensions/common/extension.cc
|
| diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
|
| index d8e798e516e2795c50f670fd27a6b26e4a1ed6e9..a671cd12ca2d65b809517ec059787b9d27a0711e 100644
|
| --- a/extensions/common/extension.cc
|
| +++ b/extensions/common/extension.cc
|
| @@ -4,10 +4,14 @@
|
|
|
| #include "extensions/common/extension.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "base/base64.h"
|
| #include "base/basictypes.h"
|
| #include "base/command_line.h"
|
| +#include "base/files/file_enumerator.h"
|
| #include "base/files/file_path.h"
|
| +#include "base/files/file_util.h"
|
| #include "base/i18n/rtl.h"
|
| #include "base/logging.h"
|
| #include "base/memory/singleton.h"
|
| @@ -65,6 +69,26 @@ bool ContainsReservedCharacters(const base::FilePath& path) {
|
| return !net::IsSafePortableRelativePath(path);
|
| }
|
|
|
| +void CollectPlatformSpecificResourceArchs(const base::FilePath& extension_path,
|
| + std::set<std::string>* archs) {
|
| + archs->clear();
|
| + base::FilePath platform_specific_path = extension_path.Append(
|
| + kPlatformSpecificFolder);
|
| + if (!base::PathExists(platform_specific_path)) {
|
| + return;
|
| + }
|
| +
|
| + base::FileEnumerator all_archs(platform_specific_path,
|
| + false,
|
| + base::FileEnumerator::DIRECTORIES);
|
| + base::FilePath arch;
|
| + while (!(arch = all_archs.Next()).empty()) {
|
| + std::string arch_name = arch.BaseName().AsUTF8Unsafe();
|
| + std::replace(arch_name.begin(), arch_name.end(), '_', '-');
|
| + archs->insert(arch_name);
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| const int Extension::kInitFromValueFlagBits = 13;
|
| @@ -435,6 +459,15 @@ void Extension::AddWebExtentPattern(const URLPattern& pattern) {
|
| extent_.AddPattern(pattern);
|
| }
|
|
|
| +bool Extension::HasPlatformSpecificResources() const {
|
| + return !platform_specific_resource_archs_.empty();
|
| +}
|
| +
|
| +bool Extension::HasResourcesForPlatform(const std::string& arch) const {
|
| + return platform_specific_resource_archs_.find(arch) !=
|
| + platform_specific_resource_archs_.end();
|
| +}
|
| +
|
| // static
|
| bool Extension::InitExtensionID(extensions::Manifest* manifest,
|
| const base::FilePath& path,
|
| @@ -536,6 +569,9 @@ bool Extension::InitFromValue(int flags, base::string16* error) {
|
|
|
| permissions_data_.reset(new PermissionsData(this));
|
|
|
| + CollectPlatformSpecificResourceArchs(path_,
|
| + &platform_specific_resource_archs_);
|
| +
|
| return true;
|
| }
|
|
|
|
|