Index: chrome/browser/extensions/installed_loader.cc |
diff --git a/chrome/browser/extensions/installed_loader.cc b/chrome/browser/extensions/installed_loader.cc |
index 71fc70ef12cff1997e72f12ef75e3d519bdd9a1c..7b5e9021beb0addc7b2ba944dc5128ec2acc71f2 100644 |
--- a/chrome/browser/extensions/installed_loader.cc |
+++ b/chrome/browser/extensions/installed_loader.cc |
@@ -4,7 +4,11 @@ |
#include "chrome/browser/extensions/installed_loader.h" |
+#include "base/bind.h" |
+#include "base/callback.h" |
+#include "base/files/file_enumerator.h" |
#include "base/files/file_path.h" |
+#include "base/files/file_util.h" |
#include "base/metrics/histogram.h" |
#include "base/metrics/sparse_histogram.h" |
#include "base/strings/stringprintf.h" |
@@ -156,6 +160,46 @@ void RecordDisableReasons(int reasons) { |
} |
} |
+void RespondWithPlatformSpecificResourceArchs( |
+ const base::Callback<void(const std::set<std::string>&)>& callback, |
+ scoped_ptr<std::set<std::string> > archs) { |
+ callback.Run(*archs.get()); |
+} |
+ |
+void CollectPlatformSpecificResourceArchsOnBlockingPool( |
+ const base::FilePath& extension_path, |
+ const base::Callback<void(const std::set<std::string>&)>& callback) { |
+ scoped_ptr<std::set<std::string > > archs(new std::set<std::string>()); |
+ base::FilePath platform_specific_path = extension_path.Append( |
+ kPlatformSpecificFolder); |
+ if (base::PathExists(platform_specific_path)) { |
+ 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); |
+ } |
+ } |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&RespondWithPlatformSpecificResourceArchs, |
+ callback, |
+ base::Passed(&archs))); |
+} |
+ |
+void CollectPlatformSpecificResourceArchs(scoped_refptr<Extension> extension) { |
+ BrowserThread::PostBlockingPoolTask( |
+ FROM_HERE, |
+ base::Bind(&CollectPlatformSpecificResourceArchsOnBlockingPool, |
+ extension->path(), |
+ base::Bind(&Extension::SetPlatformSpecificResourceArchs, |
+ extension))); |
+} |
+ |
} // namespace |
InstalledLoader::InstalledLoader(ExtensionService* extension_service) |
@@ -168,7 +212,7 @@ InstalledLoader::~InstalledLoader() { |
void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { |
std::string error; |
- scoped_refptr<const Extension> extension(NULL); |
+ scoped_refptr<Extension> extension(NULL); |
if (info.extension_manifest) { |
extension = Extension::Create( |
info.extension_path, |
@@ -225,6 +269,8 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) { |
extension_prefs_->UpdateManifest(extension.get()); |
extension_service_->AddExtension(extension.get()); |
+ |
+ CollectPlatformSpecificResourceArchs(extension); |
} |
void InstalledLoader::LoadAllExtensions() { |