| Index: ash/action_handler/action_handler_state_controller.h
|
| diff --git a/ash/action_handler/action_handler_state_controller.h b/ash/action_handler/action_handler_state_controller.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dd7a3712ac9f7e986f06aa7ee31b49d3976bb5c8
|
| --- /dev/null
|
| +++ b/ash/action_handler/action_handler_state_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_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_
|
| +#define ASH_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_
|
| +
|
| +#include "ash/action_handler/action_handler_state_observer.h"
|
| +#include "ash/public/interfaces/action_handler.mojom.h"
|
| +#include "base/macros.h"
|
| +#include "base/observer_list.h"
|
| +#include "mojo/public/cpp/bindings/binding_set.h"
|
| +
|
| +namespace ash {
|
| +
|
| +// 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 ActionHandlerStateController
|
| + : public mojom::ActionHandlerStateController {
|
| + public:
|
| + ActionHandlerStateController();
|
| + ~ActionHandlerStateController() override;
|
| +
|
| + void AddObserver(ActionHandlerStateObserver* observer);
|
| + void RemoveObserver(ActionHandlerStateObserver* observer);
|
| +
|
| + void BindRequest(mojom::ActionHandlerStateControllerRequest request);
|
| +
|
| + // Gets last known handler state for the action.
|
| + // It will return kNotSupported if an action handler has not been set using
|
| + // |SetActionHandler|.
|
| + mojom::ActionHandlerState GetState(mojom::ActionHandlerAction action);
|
| +
|
| + // If an action handler is set, send it a request to handle the action.
|
| + void RequestHandleAction(mojom::ActionHandlerAction action);
|
| +
|
| + // mojom::ActionHandlerStateController impl:
|
| + void SetActionHandler(mojom::ActionHandlerPtr action_handler) override;
|
| + void UpdateActionState(mojom::ActionHandlerAction action,
|
| + mojom::ActionHandlerState state) override;
|
| +
|
| + private:
|
| + // Notifies the observers that state for the action has been updated.
|
| + void NotifyActionStateChanged(mojom::ActionHandlerAction action);
|
| +
|
| + // Last known state for new_note action.
|
| + mojom::ActionHandlerState new_note_state_ =
|
| + mojom::ActionHandlerState::kNotSupported;
|
| +
|
| + base::ObserverList<ActionHandlerStateObserver> observers_;
|
| +
|
| + mojo::BindingSet<mojom::ActionHandlerStateController> bindings_;
|
| +
|
| + mojom::ActionHandlerPtr action_handler_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ActionHandlerStateController);
|
| +};
|
| +
|
| +} // namespace ash
|
| +
|
| +#endif // ASH_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_
|
|
|