Update To 11.40.268.0
[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   void OnTerminateIfRunning(dbus::MethodCall* method_call,
43       dbus::ExportedObject::ResponseSender response_sender);
44
45   void OnExported(const std::string& interface_name,
46                   const std::string& method_name,
47                   bool success);
48
49   void OnRemoteDebuggingEnabled(dbus::MethodCall* method_call,
50                                 dbus::ExportedObject::ResponseSender sender);
51
52   void WillDestroyApplication(Application* app) override;
53
54   dbus::ObjectPath AddObject(const std::string& app_id,
55                              const std::string& launcher_name,
56                              Application* application);
57
58   base::WeakPtrFactory<RunningApplicationsManager> weak_factory_;
59   ApplicationService* application_service_;
60   dbus::ObjectManagerAdaptor adaptor_;
61 };
62
63 }  // namespace application
64 }  // namespace xwalk
65
66 #endif  // XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATIONS_MANAGER_H_