04a70b3d8f29cddb6e989145b88e1fbfb6e312ff
[platform/framework/web/crosswalk.git] / src / xwalk / application / browser / linux / running_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_RUNNING_APPLICATIONS_MANAGER_H_
6 #define XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATIONS_MANAGER_H_
7
8 #include <string>
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h"
12 #include "xwalk/application/browser/application_service.h"
13 #include "xwalk/dbus/object_manager_adaptor.h"
14
15 namespace xwalk {
16 namespace application {
17
18 class RunningApplicationObject;
19 class Application;
20
21 dbus::ObjectPath GetRunningPathForAppID(const std::string& app_id);
22
23 // Holds the D-Bus representation of the set of installed applications. This is
24 // the entry point for launching applications and listing currently running
25 // applications.
26 //
27 // The exported object implements org.freedesktop.DBus.ObjectManager, and the
28 // interface org.crosswalkproject.Installed.Manager1 (see .cc file for
29 // description).
30 class RunningApplicationsManager : public ApplicationService::Observer {
31  public:
32   RunningApplicationsManager(scoped_refptr<dbus::Bus> bus,
33                              ApplicationService* service);
34   virtual ~RunningApplicationsManager();
35
36   RunningApplicationObject* GetRunningApp(const std::string& app_id);
37
38  private:
39   // org.crosswalkproject.Running.Manager1 interface.
40   void OnLaunch(dbus::MethodCall* method_call,
41                 dbus::ExportedObject::ResponseSender response_sender);
42
43   void OnExported(const std::string& interface_name,
44                   const std::string& method_name,
45                   bool success);
46
47   void virtual WillDestroyApplication(Application* app) OVERRIDE;
48
49   dbus::ObjectPath AddObject(const std::string& app_id,
50                              const std::string& launcher_name,
51                              Application* application);
52
53   base::WeakPtrFactory<RunningApplicationsManager> weak_factory_;
54   ApplicationService* application_service_;
55   dbus::ObjectManagerAdaptor adaptor_;
56 };
57
58 }  // namespace application
59 }  // namespace xwalk
60
61 #endif  // XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATIONS_MANAGER_H_