OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ | |
7 | |
8 #include "base/bind.h" | |
9 #include "base/observer_list.h" | |
10 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | |
11 #include "dbus/exported_object.h" | |
12 #include "dbus/message.h" | |
13 | |
14 namespace dbus { | |
15 class MethodCall; | |
16 class Response; | |
17 } | |
18 | |
19 namespace chromeos { | |
20 | |
21 // This class provides an api for external apps to notify | |
22 // chrome that it should release control of the display server. | |
23 // The main client is the console application. This can | |
24 // also be used by crouton to take over the display. | |
25 class ConsoleServiceProvider | |
26 : public CrosDBusService::ServiceProviderInterface { | |
27 public: | |
28 class Observer { | |
29 public: | |
30 virtual void OnActivateConsole(int console_id) = 0; | |
Daniel Erat
2014/11/01 13:57:44
do you really need this observer interface? can Ac
| |
31 | |
32 protected: | |
33 virtual ~Observer() {} | |
34 }; | |
35 | |
36 ConsoleServiceProvider(); | |
37 virtual ~ConsoleServiceProvider(); | |
38 | |
39 void AddObserver(Observer* observer); | |
40 void RemoveObserver(Observer* observer); | |
41 bool HasObserver(Observer* observer); | |
42 | |
43 void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; | |
44 | |
45 private: | |
46 // This method will get called when a external process sends the dbus | |
Daniel Erat
2014/11/01 13:57:44
nit: s/sends/calls/
| |
47 // method ConsoleServiceInterface.ActivateConsole. The method receives | |
Daniel Erat
2014/11/01 13:57:44
nit: remove "ConsoleServiceInterface." here since
| |
48 // a single integer parameter |console_id| which indicates the console id. | |
Daniel Erat
2014/11/01 13:57:44
nit: remove redundant "which indicates the console
| |
49 // Chrome will take ownership of the display service when the console | |
Daniel Erat
2014/11/01 13:57:44
nit: remove extra space between "Chrome" and "will
| |
50 // id is 0 or 1. It will relinquish control when the console_id is 2 or more | |
51 // to allow other entities (such as the console) to take control of the | |
52 // display. | |
Daniel Erat
2014/11/01 13:57:44
what's the point of taking an int here and treatin
| |
53 void ActivateConsole(dbus::MethodCall* method_call, | |
54 dbus::ExportedObject::ResponseSender response_sender); | |
55 | |
56 // This method is called when a dbus method is exported. If the export of the | |
57 // method is successful, |success| will be true. It will be false | |
58 // otherwise. | |
59 void OnExported(const std::string& interface_name, | |
60 const std::string& method_name, | |
61 bool success); | |
62 | |
63 base::WeakPtrFactory<ConsoleServiceProvider> weak_ptr_factory_; | |
64 ObserverList<Observer> observers_; | |
65 DISALLOW_COPY_AND_ASSIGN(ConsoleServiceProvider); | |
66 }; | |
67 | |
68 } // namespace chromeos | |
69 | |
70 #endif // CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ | |
OLD | NEW |