Upstream version 6.35.131.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest.h
index ad75d8b..d484404 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>
@@ -72,6 +73,7 @@ class Manifest {
 
   PackageType GetPackageType() const { return package_type_; }
   bool IsXPKPackaged() const { return package_type_ == TYPE_XPK; }
+  bool IsWGTPackaged() const { return package_type_ == TYPE_WGT; }
 
   // These access the wrapped manifest value, returning false when the property
   // does not exist or if the manifest type can't access it.
@@ -81,8 +83,17 @@ class Manifest {
   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,
@@ -99,7 +110,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;
@@ -115,6 +139,10 @@ class Manifest {
 
   // The underlying dictionary representation of the manifest.
   scoped_ptr<base::DictionaryValue> data_;
+  scoped_ptr<base::DictionaryValue> i18n_data_;
+
+  std::string default_locale_;
+  scoped_ptr<std::list<std::string> > user_agent_locales_;
 
   Type type_;