#include "base/file_util.h"
#include "base/files/file_enumerator.h"
#include "base/logging.h"
+#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/command_line.h"
#include "base/process/launch.h"
#include "third_party/libxml/chromium/libxml_utils.h"
#include "xwalk/application/common/application_data.h"
+#include "xwalk/application/common/application_file_util.h"
#include "xwalk/application/common/application_manifest_constants.h"
#include "xwalk/application/common/manifest_handlers/tizen_application_handler.h"
#include "xwalk/application/common/manifest_handlers/tizen_metadata_handler.h"
const std::string kServicePrefix("xwalk-service.");
const std::string kAppIdPrefix("xwalk.");
-class FileDeleter {
- public:
- FileDeleter(const base::FilePath& path, bool recursive)
- : path_(path),
- recursive_(recursive) {}
-
- ~FileDeleter() {
- if (path_.empty())
- return;
-
- base::DeleteFile(path_, recursive_);
- }
-
- void Dismiss() {
- path_.clear();
- }
-
- private:
- base::FilePath path_;
- bool recursive_;
-};
-
void WriteMetaDataElement(
XmlWriter& writer, // NOLINT
xwalk::application::TizenMetaDataInfo* info) {
return false;
std::string package_id =
- xwalk::application::GetPackageIdFromAppId(application->ID());
+ xwalk::application::AppIdToPkgId(application->ID());
base::FilePath execute_path =
app_dir.AppendASCII("bin/").AppendASCII(application->ID());
if (icon_name.empty())
xml_writer.WriteElement("icon", info::kDefaultIconName);
else
- xml_writer.WriteElement("icon", kServicePrefix + package_id + ".png");
+ xml_writer.WriteElement("icon",
+ kServicePrefix + application->ID() + ".png");
xml_writer.EndElement(); // Ends "ui-application"
xml_writer.EndElement(); // Ends "manifest" element.
: PackageInstaller(storage) {
}
+void PackageInstallerTizen::SetQuiet(bool quiet) {
+ quiet_ = quiet;
+}
+
+void PackageInstallerTizen::SetInstallationKey(const std::string& key) {
+ key_ = key;
+}
+
+std::string PackageInstallerTizen::PrepareUninstallationID(
+ const std::string& id) {
+ // this function fix pkg_id to app_id
+ // if installer was launched with pkg_id
+ if (IsValidPkgID(id)) {
+ LOG(INFO) << "The package id is given " << id << " Will find app_id...";
+ std::string appid = PkgIdToAppId(id);
+ if (!appid.empty())
+ return appid;
+ }
+ return id;
+}
+
bool PackageInstallerTizen::PlatformInstall(ApplicationData* app_data) {
std::string app_id(app_data->ID());
base::FilePath data_dir;
app_id + std::string(info::kXmlExtension));
std::string icon_name;
- if (!app_data->GetManifest()->GetString(info::kIconKey, &icon_name)) {
+ if (!app_data->GetManifest()->GetString(
+ GetIcon128Key(app_data->GetPackageType()), &icon_name))
LOG(WARNING) << "'icon' not included in manifest";
- }
+
// This will clean everything inside '<data dir>/<app id>'.
FileDeleter app_dir_cleaner(app_dir, true);
icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name);
CommandLine cmdline(kPkgHelper);
- cmdline.AppendSwitch("--install");
- cmdline.AppendArg(app_id);
- cmdline.AppendArgPath(xml_path);
- cmdline.AppendArgPath(icon);
+ cmdline.AppendSwitchASCII("--install", app_id);
+ cmdline.AppendSwitchPath("--xml", xml_path);
+ cmdline.AppendSwitchPath("--icon", icon);
+ if (quiet_)
+ cmdline.AppendSwitch("-q");
+ if (!key_.empty()) {
+ cmdline.AppendSwitchASCII("--key", key_);
+ }
int exit_code;
std::string output;
CHECK(PathService::Get(xwalk::DIR_DATA_PATH, &data_dir));
CommandLine cmdline(kPkgHelper);
- cmdline.AppendSwitch("--uninstall");
- cmdline.AppendArg(app_id);
+ cmdline.AppendSwitchASCII("--uninstall", app_id);
+ if (quiet_)
+ cmdline.AppendSwitch("-q");
+ if (!key_.empty()) {
+ cmdline.AppendSwitchASCII("--key", key_);
+ }
int exit_code;
std::string output;
app_id + ".new" + std::string(info::kXmlExtension));
std::string icon_name;
- if (!app_data->GetManifest()->GetString(info::kIconKey, &icon_name)) {
+ if (!app_data->GetManifest()->GetString(
+ GetIcon128Key(app_data->GetPackageType()), &icon_name))
LOG(WARNING) << "'icon' not included in manifest";
- }
+
// This will clean everything inside '<data dir>/<app id>' and the new XML.
FileDeleter app_dir_cleaner(app_dir, true);
FileDeleter new_xml_cleaner(new_xml_path, true);
icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name);
CommandLine cmdline(kPkgHelper);
- cmdline.AppendSwitch("--update");
- cmdline.AppendArg(app_id);
- cmdline.AppendArgPath(new_xml_path);
- cmdline.AppendArgPath(icon);
+ cmdline.AppendSwitchASCII("--update", app_id);
+ cmdline.AppendSwitchPath("--xml", new_xml_path);
+ cmdline.AppendSwitchPath("--icon", icon);
+ if (quiet_)
+ cmdline.AppendSwitch("-q");
+ if (!key_.empty()) {
+ cmdline.AppendSwitchASCII("--key", key_);
+ }
int exit_code;
std::string output;