Upstream version 10.39.233.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / tools / tizen / xwalk_backend_plugin.h
1 // Copyright (c) 2014 Samsung Electronics Co., Ltd 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_TOOLS_TIZEN_XWALK_BACKEND_PLUGIN_H_
6 #define XWALK_APPLICATION_TOOLS_TIZEN_XWALK_BACKEND_PLUGIN_H_
7
8 #include <package-manager.h>
9 #include <package-manager-types.h>
10 #include <package-manager-plugin.h>
11
12 #include <string>
13
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/singleton.h"
18 #include "xwalk/application/common/tizen/application_storage.h"
19
20 template <typename Type>
21 struct PkgmgrBackendPluginTraits : DefaultSingletonTraits<Type> {
22   static const bool kRegisterAtExit = false;
23 };
24
25 class PkgmgrBackendPlugin {
26  public:
27   static PkgmgrBackendPlugin* GetInstance();
28
29   int DetailedInfo(const std::string& pkgid,
30                    package_manager_pkg_detail_info_t* pkg_detail_info);
31   int DetailedInfoPkg(const std::string& pkg_path,
32                       package_manager_pkg_detail_info_t* pkg_detail_info);
33   int IsAppInstalled(const std::string& pkgid);
34   int AppsList(package_manager_pkg_info_t** list, int* count);
35
36   void SetLoadSet(pkg_plugin_set* set);
37
38   std::string type() const;
39
40  private:
41   PkgmgrBackendPlugin();
42
43   void SaveInfo(scoped_refptr<xwalk::application::ApplicationData> app_data,
44                 package_manager_pkg_info_t* pkg_detail_info,
45                 const std::string& force_type = std::string());
46   void SaveDetailInfo(
47       scoped_refptr<xwalk::application::ApplicationData> app_data,
48       package_manager_pkg_detail_info_t* pkg_detail_info,
49       const std::string& force_type = std::string());
50   scoped_refptr<xwalk::application::ApplicationData> GetApplicationDataFromPkg(
51       const std::string& pkg_path, base::ScopedTempDir* dir);
52
53   friend struct DefaultSingletonTraits<PkgmgrBackendPlugin>;
54
55   scoped_ptr<xwalk::application::ApplicationStorage> storage_;
56   pkg_plugin_set* set_;
57
58   DISALLOW_COPY_AND_ASSIGN(PkgmgrBackendPlugin);
59 };
60
61 #endif  // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_BACKEND_PLUGIN_H_