| 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 78e3938159dc1b885bf57f0c16490aaf463c09ad..eadde1bba57f364e68d8f2096dfe21c40a6f4bee 100644
|
| --- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| +++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h
|
| @@ -13,23 +13,37 @@
|
| #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h"
|
| #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
|
| #include "components/session_manager/core/session_manager_observer.h"
|
| +#include "extensions/browser/app_window/app_window_registry.h"
|
| +#include "extensions/common/api/app_runtime.h"
|
| #include "mojo/public/cpp/bindings/binding.h"
|
|
|
| class Profile;
|
|
|
| +namespace content {
|
| +class BrowserContext;
|
| +}
|
| +
|
| +namespace extensions {
|
| +class AppWindow;
|
| +class AppDelegate;
|
| +class Extension;
|
| +}
|
| +
|
| namespace session_manager {
|
| class SessionManager;
|
| }
|
|
|
| namespace lock_screen_apps {
|
|
|
| +class AppManager;
|
| 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 : public ash::mojom::TrayActionClient,
|
| - public session_manager::SessionManagerObserver {
|
| + public session_manager::SessionManagerObserver,
|
| + public extensions::AppWindowRegistry::Observer {
|
| public:
|
| // Returns whether the StateController is enabled - it is currently guarded by
|
| // a feature flag. If not enabled, |StateController| instance is not allowed
|
| @@ -71,6 +85,20 @@ class StateController : public ash::mojom::TrayActionClient,
|
| // session_manager::SessionManagerObserver:
|
| void OnSessionStateChanged() override;
|
|
|
| + // extensions::AppWindowRegistry::Observer:
|
| + void OnAppWindowRemoved(extensions::AppWindow* app_window) override;
|
| +
|
| + // Creates and registers an app window as action handler for the action on
|
| + // Chrome OS lock screen.
|
| + // If the app is not allowed to create an app window for handling the action
|
| + // on lock screen (e.g. if the action has not been requested), it will return
|
| + // nullptr.
|
| + extensions::AppWindow* CreateAppWindowForLockScreenAction(
|
| + content::BrowserContext* context,
|
| + const extensions::Extension* extension,
|
| + extensions::api::app_runtime::ActionType action,
|
| + std::unique_ptr<extensions::AppDelegate> app_delegate);
|
| +
|
| // If there are any active lock screen action handlers, moved their windows
|
| // to background, to ensure lock screen UI is visible.
|
| void MoveToBackground();
|
| @@ -79,14 +107,16 @@ class StateController : public ash::mojom::TrayActionClient,
|
| // windows back to foreground (i.e. visible over lock screen UI).
|
| void MoveToForeground();
|
|
|
| - // 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);
|
| -
|
| private:
|
| // Called when app manager reports that note taking availability has changed.
|
| void OnNoteTakingAvailabilityChanged();
|
|
|
| + // If there is an app window registered as a handler for note taking action
|
| + // on lock screen, unregisters the window, and closes is if |close_window| is
|
| + // set. It changes the current state to kAvailable or kNotAvailable, depending
|
| + // on whether lock screen note taking action can still be handled.
|
| + void ResetNoteTakingWindowAndMoveToNextState(bool close_window);
|
| +
|
| // Requests lock screen note action state change to |state|.
|
| // Returns whether the action state has changed.
|
| bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
|
| @@ -105,6 +135,11 @@ class StateController : public ash::mojom::TrayActionClient,
|
|
|
| std::unique_ptr<AppManager> app_manager_;
|
|
|
| + extensions::AppWindow* note_app_window_ = nullptr;
|
| +
|
| + ScopedObserver<extensions::AppWindowRegistry,
|
| + extensions::AppWindowRegistry::Observer>
|
| + app_window_observer_;
|
| ScopedObserver<session_manager::SessionManager,
|
| session_manager::SessionManagerObserver>
|
| session_observer_;
|
|
|