1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_
7 #define XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_
10 #include "base/memory/ref_counted.h"
12 #include "ipc/ipc_channel_handle.h"
13 #include "xwalk/application/browser/application.h"
14 #include "xwalk/dbus/object_manager_adaptor.h"
21 namespace application {
23 // Represents the running application inside D-Bus hierarchy of
24 // RunningApplicationsManager.
26 // Watches for the D-Bus presence of the launcher, when it disappears (e.g. the
27 // launcher was ended by a task manager) will terminate the corresponding
28 // application in Crosswalk.
29 class RunningApplicationObject : public dbus::ManagedObject {
31 RunningApplicationObject(scoped_refptr<dbus::Bus> bus,
32 const std::string& app_id,
33 const std::string& launcher_name,
34 Application* application);
36 virtual ~RunningApplicationObject();
38 void ExtensionProcessCreated(const IPC::ChannelHandle& handle);
41 void TerminateApplication();
43 void OnExported(const std::string& interface_name,
44 const std::string& method_name,
47 void OnTerminate(dbus::MethodCall* method_call,
48 dbus::ExportedObject::ResponseSender response_sender);
50 void OnGetExtensionProcessChannel(
51 dbus::MethodCall* method_call,
52 dbus::ExportedObject::ResponseSender response_sender);
55 void OnHide(dbus::MethodCall* method_call,
56 dbus::ExportedObject::ResponseSender response_sender);
58 void OnSuspend(dbus::MethodCall* method_call,
59 dbus::ExportedObject::ResponseSender response_sender);
61 void OnResume(dbus::MethodCall* method_call,
62 dbus::ExportedObject::ResponseSender response_sender);
64 void OnRemoveAllCookies(dbus::MethodCall* method_call,
65 dbus::ExportedObject::ResponseSender response_sender);
67 void SetUserAgentStringOnIOThread(const std::string& user_agent_string);
68 void OnSetUserAgentString(dbus::MethodCall* method_call,
69 dbus::ExportedObject::ResponseSender response_sender);
72 void ListenForOwnerChange();
73 void UnlistenForOwnerChange();
74 void OnNameOwnerChanged(const std::string& service_owner);
76 void OnLauncherDisappeared();
78 void SendChannel(dbus::MethodCall* method_call,
79 dbus::ExportedObject::ResponseSender response_sender);
81 scoped_refptr<dbus::Bus> bus_;
82 std::string launcher_name_;
83 dbus::Bus::GetServiceOwnerCallback owner_change_callback_;
84 Application* application_;
86 IPC::ChannelHandle ep_bp_channel_;
89 } // namespace application
92 #endif // XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_