| Index: chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| diff --git a/chrome/browser/chromeos/lock_screen_apps/state_controller.h b/chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| index 1b043346e49e530a13a23cd1bd92b1243cf655e2..f0bf67557900b99e219484dffd43a81c7da6e527 100644
|
| --- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| +++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| @@ -5,10 +5,12 @@
|
| #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
|
| #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
|
|
|
| -#include "base/lazy_instance.h"
|
| +#include <memory>
|
| +
|
| +#include "ash/public/interfaces/tray_action.mojom.h"
|
| #include "base/observer_list.h"
|
| #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
|
| -#include "chrome/browser/chromeos/lock_screen_apps/types.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
|
|
| namespace lock_screen_apps {
|
|
|
| @@ -17,42 +19,66 @@ class StateObserver;
|
| // Manages state of lock screen action handler apps, and notifies
|
| // interested parties as the state changes.
|
| // Currently assumes single supported action - NEW_NOTE.
|
| -class StateController {
|
| +class StateController : public ash::mojom::TrayActionClient {
|
| public:
|
| + // Returns whether the StateController is enabled - it is currently guarded by
|
| + // a feature flag. If not enabled, |StateController| instance is not allowed
|
| + // to be created. |Get| will still work, but it will return nullptr.
|
| + static bool IsEnabled();
|
| +
|
| + // Returns the global StateController instance. Note that this can return
|
| + // nullptr when lock screen apps are not enabled (see |IsEnabled|).
|
| static StateController* Get();
|
|
|
| + // Note that only one StateController is allowed per process. Creating a
|
| + // StateController will set global instance ptr that can be accessed using
|
| + // |Get|. This pointer will be reset when the StateController is destroyed.
|
| + StateController();
|
| + ~StateController() override;
|
| +
|
| + // Sets the tray action that should be used by |StateController|.
|
| + // Has to be called before |Initialize|.
|
| + void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr);
|
| + void FlushTrayActionForTesting();
|
| +
|
| + // Initializes mojo bindings for the StateController - it creates binding to
|
| + // ash's tray action interface and sets this object as the interface's client.
|
| + void Initialize();
|
| +
|
| void AddObserver(StateObserver* observer);
|
| void RemoveObserver(StateObserver* observer);
|
|
|
| - // Gets current state assiciated with the action.
|
| - ActionState GetActionState(Action action) const;
|
| + // Gets current state assiciated with the lock screen note action.
|
| + ash::mojom::TrayActionState GetLockScreenNoteState() const;
|
|
|
| - // Handles an action request - if the action handler is available, this will
|
| - // show an app window for the specified action.
|
| - bool HandleAction(Action action);
|
| + // ash::mojom::TrayActionClient:
|
| + void RequestNewLockScreenNote() override;
|
|
|
| // If there are any active lock screen action handlers, moved their windows
|
| // to background, to ensure lock screen UI is visible.
|
| void MoveToBackground();
|
|
|
| - private:
|
| - friend struct base::LazyInstanceTraitsBase<StateController>;
|
| -
|
| - StateController();
|
| - ~StateController();
|
| + // Sets the current state - to be used in tests. Hopefully, when this class
|
| + // has more logic implemented, this will not be needed.
|
| + void SetLockScreenNoteStateForTesting(ash::mojom::TrayActionState state);
|
|
|
| - // Requests action state change to |state|.
|
| + private:
|
| + // Requests lock screen note action state change to |state|.
|
| // Returns whether the action state has changed.
|
| - bool UpdateActionState(Action action, ActionState state);
|
| + bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
|
|
|
| - // notifies observers that an action state changed.
|
| - void NotifyStateChanged(Action action);
|
| + // Notifies observers that the lock screen note action state changed.
|
| + void NotifyLockScreenNoteStateChanged();
|
|
|
| - // New note action state.
|
| - ActionState new_note_state_ = ActionState::kNotSupported;
|
| + // Lock screen note action state.
|
| + ash::mojom::TrayActionState lock_screen_note_state_ =
|
| + ash::mojom::TrayActionState::kNotAvailable;
|
|
|
| base::ObserverList<StateObserver> observers_;
|
|
|
| + mojo::Binding<ash::mojom::TrayActionClient> binding_;
|
| + ash::mojom::TrayActionPtr tray_action_ptr_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(StateController);
|
| };
|
|
|
|
|