1 // Copyright 2014 The Chromium Authors. 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.
5 #ifndef CHROMEOS_DBUS_SERVICES_CONSOLE_SERVICE_PROVIDER_H_
6 #define CHROMEOS_DBUS_SERVICES_CONSOLE_SERVICE_PROVIDER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/services/cros_dbus_service.h"
14 #include "dbus/exported_object.h"
18 // This class provides an API for external apps to notify
19 // chrome that it should release control of the display server.
20 // The main client is the console application. This can
21 // also be used by crouton to take over the display.
22 class CHROMEOS_EXPORT ConsoleServiceProvider
23 : public CrosDBusService::ServiceProviderInterface
{
27 typedef base::Callback
<void(bool)> UpdateOwnershipCallback
;
29 virtual ~Delegate() {}
31 // Performs the actual work needed by the provider methods with the same
33 virtual void TakeDisplayOwnership(
34 const UpdateOwnershipCallback
& callback
) = 0;
35 virtual void ReleaseDisplayOwnership(
36 const UpdateOwnershipCallback
& callback
) = 0;
39 explicit ConsoleServiceProvider(scoped_ptr
<Delegate
> delegate
);
40 ~ConsoleServiceProvider() override
;
42 // CrosDBusService::ServiceProviderInterface overrides:
43 void Start(scoped_refptr
<dbus::ExportedObject
> exported_object
) override
;
46 // This method will get called when a external process no longer needs
47 // control of the display and Chrome can take ownership.
48 void TakeDisplayOwnership(
49 dbus::MethodCall
* method_call
,
50 dbus::ExportedObject::ResponseSender response_sender
);
52 // This method will get called when a external process needs control of
53 // the display and needs Chrome to release ownership.
54 void ReleaseDisplayOwnership(
55 dbus::MethodCall
* method_call
,
56 dbus::ExportedObject::ResponseSender response_sender
);
58 // This method is called when a dbus method is exported. If the export of the
59 // method is successful, |success| will be true. It will be false
61 void OnExported(const std::string
& interface_name
,
62 const std::string
& method_name
,
65 scoped_ptr
<Delegate
> delegate_
;
66 base::WeakPtrFactory
<ConsoleServiceProvider
> weak_ptr_factory_
;
68 DISALLOW_COPY_AND_ASSIGN(ConsoleServiceProvider
);
71 } // namespace chromeos
73 #endif // CHROMEOS_DBUS_SERVICES_CONSOLE_SERVICE_PROVIDER_H_