Chromium Code Reviews| Index: ash/tray_action_handler/tray_action_handler_controller.h |
| diff --git a/ash/tray_action_handler/tray_action_handler_controller.h b/ash/tray_action_handler/tray_action_handler_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0d3f784e60ff6622ce1aa51a7dbdb853ac3a6af2 |
| --- /dev/null |
| +++ b/ash/tray_action_handler/tray_action_handler_controller.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2017 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 ASH_TRAY_ACTION_HANDLER_TRAY_ACTION_HANDLER_CONTROLLER_H_ |
| +#define ASH_TRAY_ACTION_HANDLER_TRAY_ACTION_HANDLER_CONTROLLER_H_ |
| + |
| +#include "ash/public/interfaces/tray_action_handler.mojom.h" |
| +#include "base/macros.h" |
| +#include "base/observer_list.h" |
| +#include "mojo/public/cpp/bindings/binding_set.h" |
| + |
| +namespace ash { |
| + |
| +class TrayActionHandlerObserver; |
| + |
| +// Controller that ash can use to request a predefined set of actions to be |
| +// performed by clients. |
| +// The controller provides an interface to: |
| +// * Send a request to the client to handle an action. |
| +// * Observe the state of support for an action as reported by the current ash |
| +// client. |
| +// Currently, only single action is supported - creating new note on the lock |
| +// screen. |
| +class TrayActionHandlerController : public mojom::TrayActionHandlerController { |
| + public: |
| + TrayActionHandlerController(); |
| + ~TrayActionHandlerController() override; |
| + |
| + void AddObserver(TrayActionHandlerObserver* observer); |
| + void RemoveObserver(TrayActionHandlerObserver* observer); |
| + |
| + void BindRequest(mojom::TrayActionHandlerControllerRequest request); |
| + |
| + // Gets last known handler state for the action. |
| + // It will return kNotSupported if an action handler has not been set using |
| + // |SetClient|. |
| + mojom::TrayActionHandlerState GetState(mojom::TrayActionHandlerAction action); |
| + |
| + // If an action handler is set, send it a request to handle the action. |
| + void RequestHandleAction(mojom::TrayActionHandlerAction action); |
| + |
| + // mojom::TrayActionHandlerController impl: |
|
James Cook
2017/05/03 23:31:51
super-nit: Just "mojom::TrayActionHandlerControlle
tbarzic
2017/05/04 20:58:30
Done.
|
| + void SetClient(mojom::TrayActionHandlerClientPtr action_handler) override; |
| + void UpdateActionHandlerState(mojom::TrayActionHandlerAction action, |
| + mojom::TrayActionHandlerState state) override; |
| + |
| + private: |
| + // Notifies the observers that state for the action has been updated. |
| + void NotifyActionStateChanged(mojom::TrayActionHandlerAction action); |
| + |
| + // Last known state for new_note action. |
| + mojom::TrayActionHandlerState new_note_state_ = |
| + mojom::TrayActionHandlerState::kNotSupported; |
| + |
| + base::ObserverList<TrayActionHandlerObserver> observers_; |
| + |
| + mojo::BindingSet<mojom::TrayActionHandlerController> bindings_; |
| + |
| + mojom::TrayActionHandlerClientPtr action_handler_client_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TrayActionHandlerController); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_TRAY_ACTION_HANDLER_TRAY_ACTION_HANDLER_CONTROLLER_H_ |