Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: chrome/browser/chromeos/lock_screen_apps/state_controller.h

Issue 2902293002: Introduce lock screen app manager (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0d9d401aa158bcf3a1def3cf373436ce2df2e091..78e3938159dc1b885bf57f0c16490aaf463c09ad 100644
--- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h
+++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h
@@ -9,9 +9,18 @@
#include "ash/public/interfaces/tray_action.mojom.h"
#include "base/observer_list.h"
+#include "base/scoped_observer.h"
+#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 "mojo/public/cpp/bindings/binding.h"
+class Profile;
+
+namespace session_manager {
+class SessionManager;
+}
+
namespace lock_screen_apps {
class StateObserver;
@@ -19,7 +28,8 @@ 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 {
+class StateController : public ash::mojom::TrayActionClient,
+ public session_manager::SessionManagerObserver {
public:
// Returns whether the StateController is enabled - it is currently guarded by
// a feature flag. If not enabled, |StateController| instance is not allowed
@@ -40,10 +50,14 @@ class StateController : public ash::mojom::TrayActionClient {
// Has to be called before |Initialize|.
void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr);
void FlushTrayActionForTesting();
+ // Sets test AppManager implementation. Should be called before
+ // |SetPrimaryProfile|
+ void SetAppManagerForTesting(std::unique_ptr<AppManager> app_manager);
// 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 SetPrimaryProfile(Profile* profile);
void AddObserver(StateObserver* observer);
void RemoveObserver(StateObserver* observer);
@@ -54,6 +68,9 @@ class StateController : public ash::mojom::TrayActionClient {
// ash::mojom::TrayActionClient:
void RequestNewLockScreenNote() override;
+ // session_manager::SessionManagerObserver:
+ void OnSessionStateChanged() override;
+
// If there are any active lock screen action handlers, moved their windows
// to background, to ensure lock screen UI is visible.
void MoveToBackground();
@@ -67,6 +84,9 @@ class StateController : public ash::mojom::TrayActionClient {
void SetLockScreenNoteStateForTesting(ash::mojom::TrayActionState state);
private:
+ // Called when app manager reports that note taking availability has changed.
+ void OnNoteTakingAvailabilityChanged();
+
// Requests lock screen note action state change to |state|.
// Returns whether the action state has changed.
bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
@@ -83,6 +103,12 @@ class StateController : public ash::mojom::TrayActionClient {
mojo::Binding<ash::mojom::TrayActionClient> binding_;
ash::mojom::TrayActionPtr tray_action_ptr_;
+ std::unique_ptr<AppManager> app_manager_;
+
+ ScopedObserver<session_manager::SessionManager,
+ session_manager::SessionManagerObserver>
+ session_observer_;
+
DISALLOW_COPY_AND_ASSIGN(StateController);
};

Powered by Google App Engine
This is Rietveld 408576698