[ServiceWorker] Implement WebServiceWorkerContextClient::openWindow().
[chromium-blink-merge.git] / chromeos / dbus / services / console_service_provider.h
blob290be23e7b076f122bd40adf60c23b47eb0880c8
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_
8 #include <string>
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"
16 namespace chromeos {
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 {
24 public:
25 class Delegate {
26 public:
27 virtual ~Delegate() {}
29 // Performs the actual work needed by the provider methods with the same
30 // names.
31 virtual void TakeDisplayOwnership() = 0;
32 virtual void ReleaseDisplayOwnership() = 0;
35 explicit ConsoleServiceProvider(scoped_ptr<Delegate> delegate);
36 ~ConsoleServiceProvider() override;
38 // CrosDBusService::ServiceProviderInterface overrides:
39 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override;
41 private:
42 // This method will get called when a external process no longer needs
43 // control of the display and Chrome can take ownership.
44 void TakeDisplayOwnership(
45 dbus::MethodCall* method_call,
46 dbus::ExportedObject::ResponseSender response_sender);
48 // This method will get called when a external process needs control of
49 // the display and needs Chrome to release ownership.
50 void ReleaseDisplayOwnership(
51 dbus::MethodCall* method_call,
52 dbus::ExportedObject::ResponseSender response_sender);
54 // This method is called when a dbus method is exported. If the export of the
55 // method is successful, |success| will be true. It will be false
56 // otherwise.
57 void OnExported(const std::string& interface_name,
58 const std::string& method_name,
59 bool success);
61 scoped_ptr<Delegate> delegate_;
62 base::WeakPtrFactory<ConsoleServiceProvider> weak_ptr_factory_;
64 DISALLOW_COPY_AND_ASSIGN(ConsoleServiceProvider);
67 } // namespace chromeos
69 #endif // CHROMEOS_DBUS_SERVICES_CONSOLE_SERVICE_PROVIDER_H_