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

Side by Side Diff: chrome/browser/chromeos/lock_screen_apps/state_controller.h

Issue 2945023002: Introduce profile for lock screen apps (Closed)
Patch Set: . Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/public/interfaces/tray_action.mojom.h" 10 #include "ash/public/interfaces/tray_action.mojom.h"
11 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h" 12 #include "base/observer_list.h"
12 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
13 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h" 14 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h"
14 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h" 15 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
16 #include "chrome/browser/profiles/profile.h"
15 #include "components/session_manager/core/session_manager_observer.h" 17 #include "components/session_manager/core/session_manager_observer.h"
16 #include "extensions/browser/app_window/app_window_registry.h" 18 #include "extensions/browser/app_window/app_window_registry.h"
17 #include "extensions/common/api/app_runtime.h" 19 #include "extensions/common/api/app_runtime.h"
18 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
19 21
20 class Profile;
21
22 namespace content { 22 namespace content {
23 class BrowserContext; 23 class BrowserContext;
24 } 24 }
25 25
26 namespace extensions { 26 namespace extensions {
27 class AppDelegate; 27 class AppDelegate;
28 class AppWindow; 28 class AppWindow;
29 class Extension; 29 class Extension;
30 } 30 } // namespace extensions
31 31
32 namespace session_manager { 32 namespace session_manager {
33 class SessionManager; 33 class SessionManager;
34 } 34 }
35 35
36 namespace lock_screen_apps { 36 namespace lock_screen_apps {
37 37
38 class StateObserver; 38 class StateObserver;
39 39
40 // Manages state of lock screen action handler apps, and notifies 40 // Manages state of lock screen action handler apps, and notifies
(...skipping 15 matching lines...) Expand all
56 // Note that only one StateController is allowed per process. Creating a 56 // Note that only one StateController is allowed per process. Creating a
57 // StateController will set global instance ptr that can be accessed using 57 // StateController will set global instance ptr that can be accessed using
58 // |Get|. This pointer will be reset when the StateController is destroyed. 58 // |Get|. This pointer will be reset when the StateController is destroyed.
59 StateController(); 59 StateController();
60 ~StateController() override; 60 ~StateController() override;
61 61
62 // Sets the tray action that should be used by |StateController|. 62 // Sets the tray action that should be used by |StateController|.
63 // Has to be called before |Initialize|. 63 // Has to be called before |Initialize|.
64 void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr); 64 void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr);
65 void FlushTrayActionForTesting(); 65 void FlushTrayActionForTesting();
66 // Sets the callback that will be run when the state controller is fully
67 // initialized and ready for action.
68 void SetReadyCallbackForTesting(const base::Closure& ready_callback);
66 // Sets test AppManager implementation. Should be called before 69 // Sets test AppManager implementation. Should be called before
67 // |SetPrimaryProfile| 70 // |SetPrimaryProfile|
68 void SetAppManagerForTesting(std::unique_ptr<AppManager> app_manager); 71 void SetAppManagerForTesting(std::unique_ptr<AppManager> app_manager);
69 72
70 // Initializes mojo bindings for the StateController - it creates binding to 73 // Initializes mojo bindings for the StateController - it creates binding to
71 // ash's tray action interface and sets this object as the interface's client. 74 // ash's tray action interface and sets this object as the interface's client.
72 void Initialize(); 75 void Initialize();
73 void SetPrimaryProfile(Profile* profile); 76 void SetPrimaryProfile(Profile* profile);
74 77
75 void AddObserver(StateObserver* observer); 78 void AddObserver(StateObserver* observer);
(...skipping 25 matching lines...) Expand all
101 104
102 // If there are any active lock screen action handlers, moved their windows 105 // If there are any active lock screen action handlers, moved their windows
103 // to background, to ensure lock screen UI is visible. 106 // to background, to ensure lock screen UI is visible.
104 void MoveToBackground(); 107 void MoveToBackground();
105 108
106 // If there are any lock screen action handler in background, moves their 109 // If there are any lock screen action handler in background, moves their
107 // windows back to foreground (i.e. visible over lock screen UI). 110 // windows back to foreground (i.e. visible over lock screen UI).
108 void MoveToForeground(); 111 void MoveToForeground();
109 112
110 private: 113 private:
114 // Called when profiles needed to run lock screen apps are ready - i.e. when
115 // primary user profiles was set using |SetPrimaryProfile| and the profile in
xiyuan 2017/06/22 20:15:25 nit: primary user profiles -> the primary user p
tbarzic 2017/06/22 20:51:15 Done.
116 // which app lock screen windows will be run creation is done.
117 // |status| - The lock screen profile creation status.
118 void OnProfilesReady(Profile* primary_profile,
119 Profile* lock_screen_profile,
120 Profile::CreateStatus status);
121
111 // Called when app manager reports that note taking availability has changed. 122 // Called when app manager reports that note taking availability has changed.
112 void OnNoteTakingAvailabilityChanged(); 123 void OnNoteTakingAvailabilityChanged();
113 124
114 // If there is an app window registered as a handler for note taking action 125 // If there is an app window registered as a handler for note taking action
115 // on lock screen, unregisters the window, and closes is if |close_window| is 126 // on lock screen, unregisters the window, and closes is if |close_window| is
116 // set. It changes the current state to kAvailable or kNotAvailable, depending 127 // set. It changes the current state to kAvailable or kNotAvailable, depending
117 // on whether lock screen note taking action can still be handled. 128 // on whether lock screen note taking action can still be handled.
118 void ResetNoteTakingWindowAndMoveToNextState(bool close_window); 129 void ResetNoteTakingWindowAndMoveToNextState(bool close_window);
119 130
120 // Requests lock screen note action state change to |state|. 131 // Requests lock screen note action state change to |state|.
121 // Returns whether the action state has changed. 132 // Returns whether the action state has changed.
122 bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state); 133 bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
123 134
124 // Notifies observers that the lock screen note action state changed. 135 // Notifies observers that the lock screen note action state changed.
125 void NotifyLockScreenNoteStateChanged(); 136 void NotifyLockScreenNoteStateChanged();
126 137
127 // Lock screen note action state. 138 // Lock screen note action state.
128 ash::mojom::TrayActionState lock_screen_note_state_ = 139 ash::mojom::TrayActionState lock_screen_note_state_ =
129 ash::mojom::TrayActionState::kNotAvailable; 140 ash::mojom::TrayActionState::kNotAvailable;
130 141
131 base::ObserverList<StateObserver> observers_; 142 base::ObserverList<StateObserver> observers_;
132 143
133 mojo::Binding<ash::mojom::TrayActionClient> binding_; 144 mojo::Binding<ash::mojom::TrayActionClient> binding_;
134 ash::mojom::TrayActionPtr tray_action_ptr_; 145 ash::mojom::TrayActionPtr tray_action_ptr_;
135 146
147 Profile* lock_screen_profile_ = nullptr;
148
136 std::unique_ptr<AppManager> app_manager_; 149 std::unique_ptr<AppManager> app_manager_;
137 150
138 extensions::AppWindow* note_app_window_ = nullptr; 151 extensions::AppWindow* note_app_window_ = nullptr;
139 152
140 ScopedObserver<extensions::AppWindowRegistry, 153 ScopedObserver<extensions::AppWindowRegistry,
141 extensions::AppWindowRegistry::Observer> 154 extensions::AppWindowRegistry::Observer>
142 app_window_observer_; 155 app_window_observer_;
143 ScopedObserver<session_manager::SessionManager, 156 ScopedObserver<session_manager::SessionManager,
144 session_manager::SessionManagerObserver> 157 session_manager::SessionManagerObserver>
145 session_observer_; 158 session_observer_;
146 159
160 // If set, this callback will be run when the state controller is fully
161 // initialized. It can be used to throttle tests until state controller
162 // is ready for action - i.e. until the state controller starts reacting
163 // to session / app manager changes.
164 base::Closure ready_callback_;
165
166 base::WeakPtrFactory<StateController> weak_ptr_factory_;
167
147 DISALLOW_COPY_AND_ASSIGN(StateController); 168 DISALLOW_COPY_AND_ASSIGN(StateController);
148 }; 169 };
149 170
150 } // namespace lock_screen_apps 171 } // namespace lock_screen_apps
151 172
152 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ 173 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698