Chromium Code Reviews| Index: chrome/browser/chromeos/dbus/console_service_provider.h |
| diff --git a/chrome/browser/chromeos/dbus/console_service_provider.h b/chrome/browser/chromeos/dbus/console_service_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5a0a0af9b5e5c6e9d3e7d9d89b343e94f94cba87 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/dbus/console_service_provider.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ |
| + |
| +#include "base/bind.h" |
| +#include "base/observer_list.h" |
| +#include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
| +#include "dbus/exported_object.h" |
| +#include "dbus/message.h" |
| + |
| +namespace dbus { |
| +class MethodCall; |
| +class Response; |
| +} |
| + |
| +namespace chromeos { |
| + |
| +// This class provides an api for external apps to notify |
| +// chrome that it should release control of the display server. |
| +// The main client is the console application. This can |
| +// also be used by crouton to take over the display. |
| +class ConsoleServiceProvider |
| + : public CrosDBusService::ServiceProviderInterface { |
| + public: |
| + class Observer { |
| + public: |
| + virtual void OnActivateConsole(int console_id) = 0; |
|
Daniel Erat
2014/11/01 13:57:44
do you really need this observer interface? can Ac
|
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + ConsoleServiceProvider(); |
| + virtual ~ConsoleServiceProvider(); |
| + |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + bool HasObserver(Observer* observer); |
| + |
| + void Start(scoped_refptr<dbus::ExportedObject> exported_object) override; |
| + |
| + private: |
| + // This method will get called when a external process sends the dbus |
|
Daniel Erat
2014/11/01 13:57:44
nit: s/sends/calls/
|
| + // method ConsoleServiceInterface.ActivateConsole. The method receives |
|
Daniel Erat
2014/11/01 13:57:44
nit: remove "ConsoleServiceInterface." here since
|
| + // 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
|
| + // 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
|
| + // id is 0 or 1. It will relinquish control when the console_id is 2 or more |
| + // to allow other entities (such as the console) to take control of the |
| + // display. |
|
Daniel Erat
2014/11/01 13:57:44
what's the point of taking an int here and treatin
|
| + void ActivateConsole(dbus::MethodCall* method_call, |
| + dbus::ExportedObject::ResponseSender response_sender); |
| + |
| + // This method is called when a dbus method is exported. If the export of the |
| + // method is successful, |success| will be true. It will be false |
| + // otherwise. |
| + void OnExported(const std::string& interface_name, |
| + const std::string& method_name, |
| + bool success); |
| + |
| + base::WeakPtrFactory<ConsoleServiceProvider> weak_ptr_factory_; |
| + ObserverList<Observer> observers_; |
| + DISALLOW_COPY_AND_ASSIGN(ConsoleServiceProvider); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_DBUS_CONSOLE_SERVICE_PROVIDER_H_ |