Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest.h
index 8f14c28..c129f8c 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef XWALK_APPLICATION_COMMON_MANIFEST_H_
 #define XWALK_APPLICATION_COMMON_MANIFEST_H_
 
+#include <list>
 #include <map>
 #include <string>
 #include <set>
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string16.h"
 #include "base/values.h"
-#include "xwalk/application/common/install_warning.h"
+#include "xwalk/application/common/installer/package.h"
 
 namespace xwalk {
 namespace application {
 
-struct InstallWarning;
-
 // Wraps the DictionaryValue form of application's manifest. Enforces access to
 // properties of the manifest using ManifestFeatureProvider.
 class Manifest {
@@ -38,14 +37,8 @@ class Manifest {
     TYPE_PACKAGED_APP
   };
 
-  enum PackageType {
-    TYPE_WGT = 0,
-    TYPE_XPK
-  };
-
-
   Manifest(SourceType source_type, scoped_ptr<base::DictionaryValue> value);
-  virtual ~Manifest();
+  ~Manifest();
 
   const std::string& GetApplicationID() const { return application_id_; }
   void SetApplicationID(const std::string& id) { application_id_ = id; }
@@ -55,14 +48,7 @@ class Manifest {
   // Returns false and |error| will be non-empty if the manifest is malformed.
   // |warnings| will be populated if there are keys in the manifest that cannot
   // be specified by the application type.
-  bool ValidateManifest(std::string* error,
-                        std::vector<InstallWarning>* warnings) const;
-
-  // The version of this application's manifest. We increase the manifest
-  // version when making breaking changes to the application system. If the
-  // manifest contains no explicit manifest version, this returns the current
-  // system default.
-  int GetManifestVersion() const;
+  bool ValidateManifest(std::string* error) const;
 
   // Returns the manifest type.
   Type GetType() const { return type_; }
@@ -70,18 +56,25 @@ class Manifest {
   bool IsPackaged() const { return type_ == TYPE_PACKAGED_APP; }
   bool IsHosted() const { return type_ == TYPE_HOSTED_APP; }
 
-  PackageType GetPackageType() const { return package_type_; }
-  bool IsXPKPackaged() const { return package_type_ == TYPE_XPK; }
-
   // These access the wrapped manifest value, returning false when the property
   // does not exist or if the manifest type can't access it.
   bool HasKey(const std::string& key) const;
   bool HasPath(const std::string& path) const;
   bool Get(const std::string& path, const base::Value** out_value) const;
+  bool Get(const std::string& path, base::Value** out_value) const;
   bool GetBoolean(const std::string& path, bool* out_value) const;
   bool GetInteger(const std::string& path, int* out_value) const;
+
+  // If the path is supported by i18n, we can get a locale string from
+  // this two GetString function. The following is locale priority:
+  // Application locale (locale get from system).                 | high
+  // Default locale (defaultlocale attribute of widget element)
+  // Unlocalized (the element without xml:lang attribute)
+  // Auto ("en-us"(tizen is "en-gb") will be considered as a default)
+  // First (the worst case we get the first element)              | low
   bool GetString(const std::string& path, std::string* out_value) const;
   bool GetString(const std::string& path, base::string16* out_value) const;
+
   bool GetDictionary(const std::string& path,
                      const base::DictionaryValue** out_value) const;
   bool GetList(const std::string& path,
@@ -98,7 +91,20 @@ class Manifest {
   // Note: only use this when you KNOW you don't need the validation.
   const base::DictionaryValue* value() const { return data_.get(); }
 
+  const std::string& default_locale() const {
+    return default_locale_;
+  }
+
+  // Update user agent locale when system locale is changed.
+  void SetSystemLocale(const std::string& locale);
+
  private:
+  void ParseWGTI18n();
+  void ParseWGTI18nEachPath(const std::string& path);
+  bool ParseWGTI18nEachElement(base::Value* value,
+                               const std::string& path,
+                               const std::string& locale = "");
+
   // Returns true if the application can specify the given |path|.
   bool CanAccessPath(const std::string& path) const;
   bool CanAccessKey(const std::string& key) const;
@@ -109,15 +115,22 @@ class Manifest {
   // key, or as a hash of the path in the case of unpacked applications.
   std::string application_id_;
 
+#if defined(OS_TIZEN)
+  // Unique package id for tizen platform
+  std::string package_id_;
+#endif
+
   // The source the application was loaded from.
   SourceType source_type_;
 
   // The underlying dictionary representation of the manifest.
   scoped_ptr<base::DictionaryValue> data_;
+  scoped_ptr<base::DictionaryValue> i18n_data_;
 
-  Type type_;
+  std::string default_locale_;
+  scoped_ptr<std::list<std::string> > user_agent_locales_;
 
-  PackageType package_type_;
+  Type type_;
 
   DISALLOW_COPY_AND_ASSIGN(Manifest);
 };