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

Unified Diff: extensions/common/extension.cc

Issue 516293007: Enable forced extension updates on NaCl arch mismatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Oops - include unit test changes Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/extension.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « extensions/common/extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698