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..b180adc312e4575fe6f26e6d7145462363de76be 100644 |
--- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h |
+++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h |
@@ -13,10 +13,22 @@ |
#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 AppDelegate; |
+class AppWindow; |
+class Extension; |
+} |
+ |
namespace session_manager { |
class SessionManager; |
} |
@@ -29,7 +41,8 @@ class StateObserver; |
// 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 +84,21 @@ 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. The ownership of the returned app window is passed |
+ // to the caller. |
+ // 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_; |