summaryrefslogtreecommitdiffstats
path: root/extensions/common/extension.cc
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2014-09-02 16:14:15 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-02 23:17:04 +0000
commit43ae1fb32df63bfd42c13914feb6a71f111fccb3 (patch)
tree745ae3ec372d3d572668e27d9883b016409a4b31 /extensions/common/extension.cc
parentb0b8648dc4298ee5cd46259bae0da66d04a631f9 (diff)
downloadchromium_src-43ae1fb32df63bfd42c13914feb6a71f111fccb3.zip
chromium_src-43ae1fb32df63bfd42c13914feb6a71f111fccb3.tar.gz
chromium_src-43ae1fb32df63bfd42c13914feb6a71f111fccb3.tar.bz2
Enable forced extension updates on NaCl arch mismatch
This makes extensions aware of the platforms for which they have platform-specific resources installed, if any. This also hooks up the extension update code with some additional logic to place an extension in forced-update mode if it has platform-specific resources which don't match the current NaCl architecture. BUG=409948 TEST=install an extension which uses NaCl (QuickOffice for example). Rename the _platform-specific/<your-nacl-arch> directory some something else and force an update (e.g. via chrome://extensions button). Observe that a new CRX is downloaded and installed. Review URL: https://codereview.chromium.org/516293007 Cr-Commit-Position: refs/heads/master@{#293018}
Diffstat (limited to 'extensions/common/extension.cc')
-rw-r--r--extensions/common/extension.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
index d8e798e..a671cd1 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;
}