Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / extensions / common / manifest_handlers / background_info.cc
index a5583d7..230eba1 100644 (file)
@@ -5,12 +5,11 @@
 #include "extensions/common/manifest_handlers/background_info.h"
 
 #include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
 #include "base/lazy_instance.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
-#include "content/public/common/content_switches.h"
 #include "extensions/common/constants.h"
 #include "extensions/common/error_utils.h"
 #include "extensions/common/file_util.h"
@@ -70,12 +69,6 @@ const std::vector<std::string>& BackgroundInfo::GetBackgroundScripts(
 }
 
 // static
-const std::string& BackgroundInfo::GetServiceWorkerScript(
-    const Extension* extension) {
-  return GetBackgroundInfo(extension).service_worker_script_;
-}
-
-// static
 bool BackgroundInfo::HasBackgroundPage(const Extension* extension) {
   return GetBackgroundInfo(extension).has_background_page();
 }
@@ -97,11 +90,6 @@ bool BackgroundInfo::HasGeneratedBackgroundPage(const Extension* extension) {
 }
 
 // static
-bool BackgroundInfo::HasServiceWorker(const Extension* extension) {
-  return GetBackgroundInfo(extension).has_service_worker();
-}
-
-// static
 bool BackgroundInfo::AllowJSAccess(const Extension* extension) {
   return GetBackgroundInfo(extension).allow_js_access_;
 }
@@ -109,12 +97,7 @@ bool BackgroundInfo::AllowJSAccess(const Extension* extension) {
 bool BackgroundInfo::Parse(const Extension* extension, base::string16* error) {
   const std::string& bg_scripts_key = extension->is_platform_app() ?
       keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts;
-  const std::string& sw_scripts_key =
-      extension->is_platform_app()
-          ? keys::kPlatformAppServiceWorkerScript
-          : "";  // TODO(scheib): Support extensions crbug.com/346885
-  if (!LoadServiceWorkerScript(extension, sw_scripts_key, error) ||
-      !LoadBackgroundScripts(extension, bg_scripts_key, error) ||
+  if (!LoadBackgroundScripts(extension, bg_scripts_key, error) ||
       !LoadBackgroundPage(extension, error) ||
       !LoadBackgroundPersistent(extension, error) ||
       !LoadAllowJSAccess(extension, error)) {
@@ -122,8 +105,7 @@ bool BackgroundInfo::Parse(const Extension* extension, base::string16* error) {
   }
 
   int background_solution_sum = (background_url_.is_valid() ? 1 : 0) +
-                                (!background_scripts_.empty() ? 1 : 0) +
-                                (has_service_worker() ? 1 : 0);
+                                (!background_scripts_.empty() ? 1 : 0);
   if (background_solution_sum > 1) {
     *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination);
     return false;
@@ -132,27 +114,6 @@ bool BackgroundInfo::Parse(const Extension* extension, base::string16* error) {
   return true;
 }
 
-bool BackgroundInfo::LoadServiceWorkerScript(const Extension* extension,
-                                             const std::string& key,
-                                             base::string16* error) {
-  const base::Value* service_worker_script_value = NULL;
-  if (!extension->manifest()->Get(key, &service_worker_script_value))
-    return true;
-
-  if (!CommandLine::ForCurrentProcess()->HasSwitch(
-          ::switches::kEnableExperimentalWebPlatformFeatures)) {
-    *error = ASCIIToUTF16(errors::kServiceWorkerRequiresFlag);
-    return false;
-  }
-
-  CHECK(service_worker_script_value);
-  if (!service_worker_script_value->GetAsString(&service_worker_script_)) {
-    *error = ASCIIToUTF16(errors::kInvalidServiceWorkerScript);
-    return false;
-  }
-  return true;
-}
-
 bool BackgroundInfo::LoadBackgroundScripts(const Extension* extension,
                                            const std::string& key,
                                            base::string16* error) {
@@ -289,9 +250,8 @@ bool BackgroundManifestHandler::Parse(Extension* extension,
   if (!info->Parse(extension, error))
     return false;
 
-  // Platform apps must have background pages or service workers.
-  if (extension->is_platform_app() && !info->has_background_page() &&
-      !info->has_service_worker()) {
+  // Platform apps must have background pages.
+  if (extension->is_platform_app() && !info->has_background_page()) {
     *error = ASCIIToUTF16(errors::kBackgroundRequiredForPlatformApps);
     return false;
   }
@@ -348,14 +308,11 @@ bool BackgroundManifestHandler::AlwaysParseForType(Manifest::Type type) const {
 }
 
 const std::vector<std::string> BackgroundManifestHandler::Keys() const {
-  static const char* keys[] = {keys::kBackgroundAllowJsAccess,
-                               keys::kBackgroundPage,
-                               keys::kBackgroundPageLegacy,
-                               keys::kBackgroundPersistent,
-                               keys::kBackgroundScripts,
-                               keys::kPlatformAppBackgroundPage,
-                               keys::kPlatformAppBackgroundScripts,
-                               keys::kPlatformAppServiceWorkerScript};
+  static const char* keys[] = {
+      keys::kBackgroundAllowJsAccess,     keys::kBackgroundPage,
+      keys::kBackgroundPageLegacy,        keys::kBackgroundPersistent,
+      keys::kBackgroundScripts,           keys::kPlatformAppBackgroundPage,
+      keys::kPlatformAppBackgroundScripts};
   return std::vector<std::string>(keys, keys + arraysize(keys));
 }