Upstream version 7.35.141.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / common / manifest.h
index 74e15f4..cbe6eb6 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>
@@ -13,6 +14,7 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string16.h"
 #include "base/values.h"
+#include "xwalk/application/browser/installer/package.h"
 #include "xwalk/application/common/install_warning.h"
 
 namespace xwalk {
@@ -38,7 +40,7 @@ class Manifest {
     TYPE_PACKAGED_APP
   };
 
-  Manifest(SourceType source_type, scoped_ptr<DictionaryValue> value);
+  Manifest(SourceType source_type, scoped_ptr<base::DictionaryValue> value);
   virtual ~Manifest();
 
   const std::string& GetApplicationID() const { return application_id_; }
@@ -69,10 +71,20 @@ class Manifest {
   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, string16* 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,
@@ -89,7 +101,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;
@@ -105,6 +130,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_;