| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 ASH_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_ |
| 6 #define ASH_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_ |
| 7 |
| 8 #include "ash/action_handler/action_handler_state_observer.h" |
| 9 #include "ash/public/interfaces/action_handler.mojom.h" |
| 10 #include "base/macros.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 // Controller that ash can use to request a predefined set of actions to be |
| 17 // performed by clients. |
| 18 // The controller provides an interface to: |
| 19 // * Send a request to the client to handle an action. |
| 20 // * Observe the state of support for an action as reported by the current ash |
| 21 // client. |
| 22 // Currently, only single action is supported - creating new note on the lock |
| 23 // screen. |
| 24 class ActionHandlerStateController |
| 25 : public mojom::ActionHandlerStateController { |
| 26 public: |
| 27 ActionHandlerStateController(); |
| 28 ~ActionHandlerStateController() override; |
| 29 |
| 30 void AddObserver(ActionHandlerStateObserver* observer); |
| 31 void RemoveObserver(ActionHandlerStateObserver* observer); |
| 32 |
| 33 void BindRequest(mojom::ActionHandlerStateControllerRequest request); |
| 34 |
| 35 // Gets last known handler state for the action. |
| 36 // It will return kNotSupported if an action handler has not been set using |
| 37 // |SetActionHandler|. |
| 38 mojom::ActionHandlerState GetState(mojom::ActionHandlerAction action); |
| 39 |
| 40 // If an action handler is set, send it a request to handle the action. |
| 41 void RequestHandleAction(mojom::ActionHandlerAction action); |
| 42 |
| 43 // mojom::ActionHandlerStateController impl: |
| 44 void SetActionHandler(mojom::ActionHandlerPtr action_handler) override; |
| 45 void UpdateActionState(mojom::ActionHandlerAction action, |
| 46 mojom::ActionHandlerState state) override; |
| 47 |
| 48 private: |
| 49 // Notifies the observers that state for the action has been updated. |
| 50 void NotifyActionStateChanged(mojom::ActionHandlerAction action); |
| 51 |
| 52 // Last known state for new_note action. |
| 53 mojom::ActionHandlerState new_note_state_ = |
| 54 mojom::ActionHandlerState::kNotSupported; |
| 55 |
| 56 base::ObserverList<ActionHandlerStateObserver> observers_; |
| 57 |
| 58 mojo::BindingSet<mojom::ActionHandlerStateController> bindings_; |
| 59 |
| 60 mojom::ActionHandlerPtr action_handler_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(ActionHandlerStateController); |
| 63 }; |
| 64 |
| 65 } // namespace ash |
| 66 |
| 67 #endif // ASH_ACTION_HANDLER_ACTION_HANDLER_STATE_CONTROLLER_H_ |
| OLD | NEW |