dc94cf65dfb089feb93a13ee77a44a03da9ab197
[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/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  private:
37   PkgmgrBackendPlugin();
38
39   void SaveInfo(xwalk::application::ApplicationData* app_data,
40                 package_manager_pkg_info_t* pkg_detail_info);
41   void SaveDetailInfo(xwalk::application::ApplicationData* app_data,
42                       package_manager_pkg_detail_info_t* pkg_detail_info);
43   scoped_refptr<xwalk::application::ApplicationData> GetApplicationDataFromPkg(
44       const std::string& pkg_path);
45
46   friend struct DefaultSingletonTraits<PkgmgrBackendPlugin>;
47
48   scoped_ptr<xwalk::application::ApplicationStorage> storage_;
49
50   DISALLOW_COPY_AND_ASSIGN(PkgmgrBackendPlugin);
51 };
52
53 #endif  // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_BACKEND_PLUGIN_H_