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

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

Issue 2934513003: Changes in app.window and app.runtime to support lock screen note taking (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
« no previous file with comments | « apps/launcher.cc ('k') | chrome/browser/chromeos/lock_screen_apps/state_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
13 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h" 13 #include "chrome/browser/chromeos/lock_screen_apps/app_manager.h"
14 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h" 14 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
15 #include "components/session_manager/core/session_manager_observer.h" 15 #include "components/session_manager/core/session_manager_observer.h"
16 #include "extensions/browser/app_window/app_window_registry.h"
17 #include "extensions/common/api/app_runtime.h"
16 #include "mojo/public/cpp/bindings/binding.h" 18 #include "mojo/public/cpp/bindings/binding.h"
17 19
18 class Profile; 20 class Profile;
19 21
22 namespace content {
23 class BrowserContext;
24 }
25
26 namespace extensions {
27 class AppDelegate;
28 class AppWindow;
29 class Extension;
30 }
31
20 namespace session_manager { 32 namespace session_manager {
21 class SessionManager; 33 class SessionManager;
22 } 34 }
23 35
24 namespace lock_screen_apps { 36 namespace lock_screen_apps {
25 37
26 class StateObserver; 38 class StateObserver;
27 39
28 // Manages state of lock screen action handler apps, and notifies 40 // Manages state of lock screen action handler apps, and notifies
29 // interested parties as the state changes. 41 // interested parties as the state changes.
30 // Currently assumes single supported action - NEW_NOTE. 42 // Currently assumes single supported action - NEW_NOTE.
31 class StateController : public ash::mojom::TrayActionClient, 43 class StateController : public ash::mojom::TrayActionClient,
32 public session_manager::SessionManagerObserver { 44 public session_manager::SessionManagerObserver,
45 public extensions::AppWindowRegistry::Observer {
33 public: 46 public:
34 // Returns whether the StateController is enabled - it is currently guarded by 47 // Returns whether the StateController is enabled - it is currently guarded by
35 // a feature flag. If not enabled, |StateController| instance is not allowed 48 // a feature flag. If not enabled, |StateController| instance is not allowed
36 // to be created. |Get| will still work, but it will return nullptr. 49 // to be created. |Get| will still work, but it will return nullptr.
37 static bool IsEnabled(); 50 static bool IsEnabled();
38 51
39 // Returns the global StateController instance. Note that this can return 52 // Returns the global StateController instance. Note that this can return
40 // nullptr when lock screen apps are not enabled (see |IsEnabled|). 53 // nullptr when lock screen apps are not enabled (see |IsEnabled|).
41 static StateController* Get(); 54 static StateController* Get();
42 55
(...skipping 21 matching lines...) Expand all
64 77
65 // Gets current state assiciated with the lock screen note action. 78 // Gets current state assiciated with the lock screen note action.
66 ash::mojom::TrayActionState GetLockScreenNoteState() const; 79 ash::mojom::TrayActionState GetLockScreenNoteState() const;
67 80
68 // ash::mojom::TrayActionClient: 81 // ash::mojom::TrayActionClient:
69 void RequestNewLockScreenNote() override; 82 void RequestNewLockScreenNote() override;
70 83
71 // session_manager::SessionManagerObserver: 84 // session_manager::SessionManagerObserver:
72 void OnSessionStateChanged() override; 85 void OnSessionStateChanged() override;
73 86
87 // extensions::AppWindowRegistry::Observer:
88 void OnAppWindowRemoved(extensions::AppWindow* app_window) override;
89
90 // Creates and registers an app window as action handler for the action on
91 // Chrome OS lock screen. The ownership of the returned app window is passed
92 // to the caller.
93 // If the app is not allowed to create an app window for handling the action
94 // on lock screen (e.g. if the action has not been requested), it will return
95 // nullptr.
96 extensions::AppWindow* CreateAppWindowForLockScreenAction(
97 content::BrowserContext* context,
98 const extensions::Extension* extension,
99 extensions::api::app_runtime::ActionType action,
100 std::unique_ptr<extensions::AppDelegate> app_delegate);
101
74 // If there are any active lock screen action handlers, moved their windows 102 // If there are any active lock screen action handlers, moved their windows
75 // to background, to ensure lock screen UI is visible. 103 // to background, to ensure lock screen UI is visible.
76 void MoveToBackground(); 104 void MoveToBackground();
77 105
78 // If there are any lock screen action handler in background, moves their 106 // If there are any lock screen action handler in background, moves their
79 // windows back to foreground (i.e. visible over lock screen UI). 107 // windows back to foreground (i.e. visible over lock screen UI).
80 void MoveToForeground(); 108 void MoveToForeground();
81 109
82 // Sets the current state - to be used in tests. Hopefully, when this class
83 // has more logic implemented, this will not be needed.
84 void SetLockScreenNoteStateForTesting(ash::mojom::TrayActionState state);
85
86 private: 110 private:
87 // Called when app manager reports that note taking availability has changed. 111 // Called when app manager reports that note taking availability has changed.
88 void OnNoteTakingAvailabilityChanged(); 112 void OnNoteTakingAvailabilityChanged();
89 113
114 // 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
116 // set. It changes the current state to kAvailable or kNotAvailable, depending
117 // on whether lock screen note taking action can still be handled.
118 void ResetNoteTakingWindowAndMoveToNextState(bool close_window);
119
90 // Requests lock screen note action state change to |state|. 120 // Requests lock screen note action state change to |state|.
91 // Returns whether the action state has changed. 121 // Returns whether the action state has changed.
92 bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state); 122 bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
93 123
94 // Notifies observers that the lock screen note action state changed. 124 // Notifies observers that the lock screen note action state changed.
95 void NotifyLockScreenNoteStateChanged(); 125 void NotifyLockScreenNoteStateChanged();
96 126
97 // Lock screen note action state. 127 // Lock screen note action state.
98 ash::mojom::TrayActionState lock_screen_note_state_ = 128 ash::mojom::TrayActionState lock_screen_note_state_ =
99 ash::mojom::TrayActionState::kNotAvailable; 129 ash::mojom::TrayActionState::kNotAvailable;
100 130
101 base::ObserverList<StateObserver> observers_; 131 base::ObserverList<StateObserver> observers_;
102 132
103 mojo::Binding<ash::mojom::TrayActionClient> binding_; 133 mojo::Binding<ash::mojom::TrayActionClient> binding_;
104 ash::mojom::TrayActionPtr tray_action_ptr_; 134 ash::mojom::TrayActionPtr tray_action_ptr_;
105 135
106 std::unique_ptr<AppManager> app_manager_; 136 std::unique_ptr<AppManager> app_manager_;
107 137
138 extensions::AppWindow* note_app_window_ = nullptr;
139
140 ScopedObserver<extensions::AppWindowRegistry,
141 extensions::AppWindowRegistry::Observer>
142 app_window_observer_;
108 ScopedObserver<session_manager::SessionManager, 143 ScopedObserver<session_manager::SessionManager,
109 session_manager::SessionManagerObserver> 144 session_manager::SessionManagerObserver>
110 session_observer_; 145 session_observer_;
111 146
112 DISALLOW_COPY_AND_ASSIGN(StateController); 147 DISALLOW_COPY_AND_ASSIGN(StateController);
113 }; 148 };
114 149
115 } // namespace lock_screen_apps 150 } // namespace lock_screen_apps
116 151
117 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ 152 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « apps/launcher.cc ('k') | chrome/browser/chromeos/lock_screen_apps/state_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698