Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / browser / installer / tizen / package_installer.h
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_
6 #define XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_
7
8 #include <unistd.h>
9 #include <string>
10 #include "base/files/file_path.h"
11 #include "xwalk/application/browser/application_service.h"
12
13 namespace xwalk {
14 namespace application {
15
16 class ApplicationStorage;
17
18 // Utility class to interact with Tizen package manager. For installation, it
19 // takes an app_id already installed to Crosswalk application store, generate
20 // the necessary resources (e.g. icon for home screen) and add a new entry to
21 // Tizen database. Uninstallation will remove the created resources and remove
22 // the entry from Tizen database.
23 class PackageInstaller {
24  public:
25   ~PackageInstaller();
26   static scoped_ptr<PackageInstaller> Create(
27       ApplicationService* service,
28       ApplicationStorage* storage,
29       const std::string& package_id,
30       const base::FilePath& data_dir);
31   bool Install();
32   bool Uninstall();
33
34  private:
35   PackageInstaller(
36       ApplicationService* service,
37       ApplicationStorage* storage,
38       const std::string& package_id,
39       const base::FilePath& data_dir);
40   bool Init();
41   bool GeneratePkgInfoXml();
42   bool CopyOrLinkResources();
43   bool WriteToPackageInfoDB();
44   bool ChangeOwnerRecursive(
45       const base::FilePath& path,
46       const uid_t& uid,
47       const gid_t& gid);
48
49   const ApplicationService* service_;
50   const ApplicationStorage* storage_;
51   scoped_refptr<const ApplicationData> application_;
52   std::string package_id_;
53   std::string icon_name_;
54   std::string stripped_name_;
55   base::FilePath data_dir_;
56   base::FilePath app_dir_;
57   base::FilePath xml_path_;
58   base::FilePath execute_path_;
59   base::FilePath icon_path_;
60
61   DISALLOW_COPY_AND_ASSIGN(PackageInstaller);
62 };
63
64 }  // namespace application
65 }  // namespace xwalk
66
67 #endif  // XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_