#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/browser/installer/package.h"
#include "xwalk/application/common/install_warning.h"
namespace xwalk {
TYPE_PACKAGED_APP
};
- enum PackageType {
- TYPE_WGT = 0,
- TYPE_XPK
- };
-
-
Manifest(SourceType source_type, scoped_ptr<base::DictionaryValue> value);
virtual ~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,
// 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;
// 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);
};