| 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_TRAY_ACTION_TRAY_ACTION_H_ |
| 6 #define ASH_TRAY_ACTION_TRAY_ACTION_H_ |
| 7 |
| 8 #include "ash/public/interfaces/tray_action.mojom.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/observer_list.h" |
| 11 #include "mojo/public/cpp/bindings/binding_set.h" |
| 12 |
| 13 namespace ash { |
| 14 |
| 15 class TrayActionObserver; |
| 16 |
| 17 // Controller that ash can use to request a predefined set of actions to be |
| 18 // performed by clients. |
| 19 // The controller provides an interface to: |
| 20 // * Send a request to the client to handle an action. |
| 21 // * Observe the state of support for an action as reported by the current ash |
| 22 // client. |
| 23 // Currently, only single action is supported - creating new note on the lock |
| 24 // screen - Chrome handles this action by launching an app (if any) that is |
| 25 // registered as a lock screen enabled action handler for the new note action. |
| 26 class TrayAction : public mojom::TrayAction { |
| 27 public: |
| 28 TrayAction(); |
| 29 ~TrayAction() override; |
| 30 |
| 31 void AddObserver(TrayActionObserver* observer); |
| 32 void RemoveObserver(TrayActionObserver* observer); |
| 33 |
| 34 void BindRequest(mojom::TrayActionRequest request); |
| 35 |
| 36 // Gets last known handler state for the lock screen note action. |
| 37 // It will return kNotSupported if an action handler has not been set using |
| 38 // |SetClient|. |
| 39 mojom::TrayActionState GetLockScreenNoteState(); |
| 40 |
| 41 // If the client is set, send it a request to handle the lock screen note |
| 42 // action. |
| 43 void RequestNewLockScreenNote(); |
| 44 |
| 45 // mojom::TrayAction: |
| 46 void SetClient(mojom::TrayActionClientPtr action_handler, |
| 47 mojom::TrayActionState lock_screen_note_state) override; |
| 48 void UpdateLockScreenNoteState(mojom::TrayActionState state) override; |
| 49 |
| 50 private: |
| 51 // Notifies the observers that state for the lock screen note action has been |
| 52 // updated. |
| 53 void NotifyLockScreenNoteStateChanged(); |
| 54 |
| 55 // Last known state for lock screen note action. |
| 56 mojom::TrayActionState lock_screen_note_state_ = |
| 57 mojom::TrayActionState::kNotSupported; |
| 58 |
| 59 base::ObserverList<TrayActionObserver> observers_; |
| 60 |
| 61 mojo::BindingSet<mojom::TrayAction> bindings_; |
| 62 |
| 63 mojom::TrayActionClientPtr tray_action_client_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(TrayAction); |
| 66 }; |
| 67 |
| 68 } // namespace ash |
| 69 |
| 70 #endif // ASH_TRAY_ACTION_TRAY_ACTION_H_ |
| OLD | NEW |