Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / updater / extension_updater.cc
index 3cd89a2..c3f5cb4 100644 (file)
@@ -8,7 +8,6 @@
 #include <set>
 
 #include "base/bind.h"
-#include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/metrics/histogram.h"
@@ -23,7 +22,6 @@
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/pending_extension_manager.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
 #include "components/omaha_query_params/omaha_query_params.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_details.h"
@@ -37,6 +35,7 @@
 #include "extensions/common/extension.h"
 #include "extensions/common/extension_set.h"
 #include "extensions/common/manifest.h"
+#include "extensions/common/manifest_constants.h"
 
 using base::RandDouble;
 using base::RandInt;
@@ -119,15 +118,29 @@ void DetermineForcedUpdatesOnBlockingPool(
         extensions::kPlatformSpecificFolder);
     if (base::PathExists(platform_specific_path)) {
       bool force = true;
-      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(), '_', '-');
-        if (arch_name == OmahaQueryParams::GetNaclArch())
-          force = false;
+      const base::ListValue* platforms;
+      if (extension->manifest()->GetList(extensions::manifest_keys::kPlatforms,
+                                         &platforms)) {
+        for (size_t i = 0; i < platforms->GetSize(); ++i) {
+          const base::DictionaryValue* p;
+          if (platforms->GetDictionary(i, &p)) {
+            std::string nacl_arch;
+            if (p->GetString(extensions::manifest_keys::kNaClArch,
+                             &nacl_arch) &&
+                nacl_arch == OmahaQueryParams::GetNaclArch()) {
+              std::string subpath;
+              if (p->GetString(extensions::manifest_keys::kSubPackagePath,
+                               &subpath)) {
+                // _platform_specific is part of the sub_package_path entry.
+                base::FilePath platform_specific_subpath =
+                    extension->path().AppendASCII(subpath);
+                if (base::PathExists(platform_specific_subpath)) {
+                  force = false;
+                }
+              }
+            }
+          }
+        }
       }
 
       if (force)
@@ -214,7 +227,6 @@ ExtensionUpdater::ExtensionUpdater(
     ExtensionCache* cache,
     const ExtensionDownloader::Factory& downloader_factory)
     : alive_(false),
-      weak_ptr_factory_(this),
       service_(service),
       downloader_factory_(downloader_factory),
       frequency_seconds_(frequency_seconds),
@@ -225,7 +237,8 @@ ExtensionUpdater::ExtensionUpdater(
       next_request_id_(0),
       extension_registry_observer_(this),
       crx_install_is_running_(false),
-      extension_cache_(cache) {
+      extension_cache_(cache),
+      weak_ptr_factory_(this) {
   DCHECK_GE(frequency_seconds_, 5);
   DCHECK_LE(frequency_seconds_, kMaxUpdateFrequencySeconds);
 #if defined(NDEBUG)
@@ -381,6 +394,11 @@ bool ExtensionUpdater::WillCheckSoon() const {
   return will_check_soon_;
 }
 
+void ExtensionUpdater::SetExtensionCacheForTesting(
+    ExtensionCache* extension_cache) {
+  extension_cache_ = extension_cache;
+}
+
 void ExtensionUpdater::DoCheckSoon() {
   DCHECK(will_check_soon_);
   CheckNow(default_params_);
@@ -595,6 +613,8 @@ bool ExtensionUpdater::GetPingDataForExtension(
   ping_data->rollcall_days = CalculatePingDays(
       extension_prefs_->LastPingDay(id));
   ping_data->is_enabled = service_->IsExtensionEnabled(id);
+  if (!ping_data->is_enabled)
+    ping_data->disable_reasons = extension_prefs_->GetDisableReasons(id);
   ping_data->active_days =
       CalculateActivePingDays(extension_prefs_->LastActivePingDay(id),
                               extension_prefs_->GetActiveBit(id));