// static
scoped_refptr<ApplicationData> ApplicationData::Create(
- const base::FilePath& path,
- Manifest::SourceType source_type,
- const base::DictionaryValue& manifest_data,
- const std::string& explicit_id,
+ const base::FilePath& path, const std::string& explicit_id,
+ SourceType source_type, scoped_ptr<Manifest> manifest,
std::string* error_message) {
DCHECK(error_message);
base::string16 error;
- scoped_ptr<xwalk::application::Manifest> manifest(
- new xwalk::application::Manifest(source_type,
- scoped_ptr<base::DictionaryValue>(manifest_data.DeepCopy())));
-
- std::vector<InstallWarning> install_warnings;
- if (!manifest->ValidateManifest(error_message, &install_warnings)) {
+ if (!manifest->ValidateManifest(error_message))
return NULL;
- }
-
- scoped_refptr<ApplicationData> application = new ApplicationData(path,
- manifest.Pass());
- application->install_warnings_.swap(install_warnings);
- if (!application->Init(explicit_id, &error)) {
+ scoped_refptr<ApplicationData> app_data =
+ new ApplicationData(path, source_type, manifest.Pass());
+ if (!app_data->Init(explicit_id, &error)) {
*error_message = base::UTF16ToUTF8(error);
return NULL;
}
- return application;
-}
+ ManifestHandlerRegistry* registry =
+ ManifestHandlerRegistry::GetInstance(app_data->manifest_type());
-// static
-scoped_refptr<ApplicationData> ApplicationData::Create(
- const GURL& url,
- std::string* error_message) {
- const std::string& url_spec = url.spec();
- DCHECK(!url_spec.empty());
- const std::string& app_id = GenerateId(url_spec);
-
- base::DictionaryValue manifest;
- // FIXME: define permissions!
- manifest.SetString(application_manifest_keys::kStartURLKey, url_spec);
- // FIXME: Why use URL as name?
- manifest.SetString(application_manifest_keys::kNameKey, url_spec);
- manifest.SetString(application_manifest_keys::kXWalkVersionKey, "0");
- scoped_refptr<ApplicationData> application_data =
- ApplicationData::Create(base::FilePath(), Manifest::COMMAND_LINE,
- manifest, app_id, error_message);
-
- return application_data;
+ if (!registry->ValidateAppManifest(app_data, error_message))
+ return NULL;
+
+ return app_data;
}
// static
GURL ApplicationData::GetBaseURLFromApplicationId(
const std::string& application_id) {
- return GURL(std::string(xwalk::application::kApplicationScheme) +
- url::kStandardSchemeSeparator + application_id + "/");
+ return GURL(std::string(kApplicationScheme) +
+ url::kStandardSchemeSeparator + application_id + "/");
}
ApplicationData::ManifestData* ApplicationData::GetManifestData(
manifest_data_[key] = linked_ptr<ManifestData>(data);
}
-Manifest::SourceType ApplicationData::GetSourceType() const {
- return manifest_->GetSourceType();
-}
-
-const std::string& ApplicationData::ID() const {
- return manifest_->GetApplicationID();
+#if defined(OS_TIZEN)
+std::string ApplicationData::GetPackageID() const {
+ return AppIdToPkgId(application_id_);
}
+#endif
const std::string ApplicationData::VersionString() const {
if (!version_->components().empty())
return "";
}
-bool ApplicationData::IsPlatformApp() const {
- return manifest_->IsPackaged();
-}
-
bool ApplicationData::IsHostedApp() const {
- return GetManifest()->IsHosted();
+ bool hosted = source_type_ == EXTERNAL_URL;
+#if defined(OS_TIZEN)
+ if (manifest_->HasPath(widget_keys::kContentNamespace)) {
+ std::string ns;
+ if (manifest_->GetString(widget_keys::kContentNamespace, &ns) &&
+ ns == kTizenNamespacePrefix)
+ hosted = true;
+ }
+#endif
+ return hosted;
}
ApplicationData::ApplicationData(const base::FilePath& path,
- scoped_ptr<xwalk::application::Manifest> manifest)
+ SourceType source_type, scoped_ptr<Manifest> manifest)
: manifest_version_(0),
+ path_(path),
manifest_(manifest.release()),
- finished_parsing_manifest_(false) {
- DCHECK(path.empty() || path.IsAbsolute());
- path_ = path;
- if (manifest_->HasPath(widget_keys::kWidgetKey))
- package_type_ = Package::WGT;
- else
- package_type_ = Package::XPK;
+ finished_parsing_manifest_(false),
+ source_type_(source_type) {
+ DCHECK(path_.empty() || path_.IsAbsolute());
}
ApplicationData::~ApplicationData() {
// static
GURL ApplicationData::GetResourceURL(const GURL& application_url,
const std::string& relative_path) {
- DCHECK(application_url.SchemeIs(xwalk::application::kApplicationScheme));
+ DCHECK(application_url.SchemeIs(kApplicationScheme));
DCHECK_EQ("/", application_url.path());
std::string path = relative_path;
return ret_val;
}
-Manifest::Type ApplicationData::GetType() const {
- return manifest_->GetType();
-}
-
bool ApplicationData::Init(const std::string& explicit_id,
base::string16* error) {
DCHECK(error);
ManifestHandlerRegistry* registry =
- ManifestHandlerRegistry::GetInstance(GetPackageType());
+ ManifestHandlerRegistry::GetInstance(manifest_type());
if (!registry->ParseAppManifest(this, error))
return false;
base::string16* error) {
std::string application_id;
#if defined(OS_TIZEN)
- if (GetPackageType() == Package::WGT) {
+ if (manifest_type() == Manifest::TYPE_WIDGET) {
const TizenApplicationInfo* tizen_app_info =
static_cast<TizenApplicationInfo*>(GetManifestData(
widget_keys::kTizenApplicationKey));
}
if (!application_id.empty()) {
- manifest_->SetApplicationID(application_id);
+ application_id_ = application_id;
return true;
}
#endif
if (!explicit_id.empty()) {
- manifest_->SetApplicationID(explicit_id);
+ application_id_ = explicit_id;
return true;
}
NOTREACHED() << "Could not create ID from path.";
return false;
}
- manifest_->SetApplicationID(application_id);
+ application_id_ = application_id;
return true;
}
bool ApplicationData::LoadName(base::string16* error) {
DCHECK(error);
base::string16 localized_name;
- std::string name_key(GetNameKey(GetPackageType()));
+ std::string name_key(GetNameKey(manifest_type()));
if (!manifest_->GetString(name_key, &localized_name) &&
- package_type_ == Package::XPK) {
+ manifest_type() == Manifest::TYPE_MANIFEST) {
*error = base::ASCIIToUTF16(errors::kInvalidName);
return false;
}
version_.reset(new base::Version());
- if (package_type_ == Package::WGT) {
+ if (manifest_type() == Manifest::TYPE_WIDGET) {
bool ok = manifest_->GetString(widget_keys::kVersionKey, &version_str);
if (!ok) {
*error = base::ASCIIToUTF16(errors::kInvalidVersion);
- return false;
+ return true;
}
version_.reset(new base::Version(version_str));
bool ApplicationData::LoadDescription(base::string16* error) {
DCHECK(error);
// FIXME: Better to assert on use from Widget.
- if (package_type_ != Package::XPK)
+ if (manifest_type() != Manifest::TYPE_MANIFEST)
return true; // No error.
bool hasDeprecatedKey = manifest_->HasKey(keys::kDeprecatedDescriptionKey);
bool ApplicationData::HasCSPDefined() const {
#if defined(OS_TIZEN)
- return manifest_->HasPath(GetCSPKey(package_type_)) ||
+ return manifest_->HasPath(GetCSPKey(manifest_type())) ||
manifest_->HasPath(widget_keys::kCSPReportOnlyKey) ||
manifest_->HasPath(widget_keys::kAllowNavigationKey);
#else
- return manifest_->HasPath(GetCSPKey(package_type_));
+ return manifest_->HasPath(GetCSPKey(manifest_type()));
#endif
}