Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / xwalk / application / browser / linux / installed_applications_manager.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_LINUX_INSTALLED_APPLICATIONS_MANAGER_H_
6 #define XWALK_APPLICATION_BROWSER_LINUX_INSTALLED_APPLICATIONS_MANAGER_H_
7
8 #include <string>
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "xwalk/application/browser/application_service.h"
12 #include "xwalk/dbus/object_manager_adaptor.h"
13
14 namespace xwalk {
15 namespace application {
16
17 class InstalledApplicationObject;
18
19 // Holds the D-Bus representation of the set of installed applications. This is
20 // the entry point for listing, installing and uninstalling applications via
21 // D-Bus.
22 //
23 // The exported object implements org.freedesktop.DBus.ObjectManager, and the
24 // interface org.crosswalkproject.Installed.Manager1 (see .cc file for
25 // description).
26 class InstalledApplicationsManager : public ApplicationService::Observer {
27  public:
28   InstalledApplicationsManager(scoped_refptr<dbus::Bus> bus,
29                                ApplicationService* service,
30                                ApplicationStorage* app_storage);
31   virtual ~InstalledApplicationsManager();
32
33  private:
34   // ApplicationService::Observer implementation.
35   void virtual OnApplicationInstalled(const std::string& app_id) OVERRIDE;
36   void virtual OnApplicationUninstalled(const std::string& app_id) OVERRIDE;
37   void virtual OnApplicationUpdated(const std::string& app_id) OVERRIDE;
38   void virtual OnApplicationNameChanged(const std::string& app_id,
39                                         const std::string& app_name) OVERRIDE;
40
41   void AddInitialObjects();
42   void AddObject(scoped_refptr<const ApplicationData> app);
43
44   void OnInstall(
45       dbus::MethodCall* method_call,
46       dbus::ExportedObject::ResponseSender response_sender);
47   void OnUninstall(
48       InstalledApplicationObject* installed_app_object,
49       dbus::MethodCall* method_call,
50       dbus::ExportedObject::ResponseSender response_sender);
51
52   void OnExported(const std::string& interface_name,
53                   const std::string& method_name,
54                   bool success);
55
56   base::WeakPtrFactory<InstalledApplicationsManager> weak_factory_;
57   ApplicationService* application_service_;
58   ApplicationStorage* app_storage_;
59   dbus::ObjectManagerAdaptor adaptor_;
60 };
61
62 }  // namespace application
63 }  // namespace xwalk
64
65 #endif  // XWALK_APPLICATION_BROWSER_LINUX_INSTALLED_APPLICATIONS_MANAGER_H_