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

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

Issue 2870473002: Revert of Introduce ash mojo interface for lock screen action handlers (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 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 "base/lazy_instance.h"
9
10 #include "ash/public/interfaces/tray_action.mojom.h"
11 #include "base/observer_list.h" 9 #include "base/observer_list.h"
12 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h" 10 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
13 #include "mojo/public/cpp/bindings/binding.h" 11 #include "chrome/browser/chromeos/lock_screen_apps/types.h"
14 12
15 namespace lock_screen_apps { 13 namespace lock_screen_apps {
16 14
17 class StateObserver; 15 class StateObserver;
18 16
19 // Manages state of lock screen action handler apps, and notifies 17 // Manages state of lock screen action handler apps, and notifies
20 // interested parties as the state changes. 18 // interested parties as the state changes.
21 // Currently assumes single supported action - NEW_NOTE. 19 // Currently assumes single supported action - NEW_NOTE.
22 class StateController : public ash::mojom::TrayActionClient { 20 class StateController {
23 public: 21 public:
24 // Returns whether the StateController is enabled - it is currently guarded by
25 // a feature flag. If not enabled, |StateController| instance is not allowed
26 // to be created. |Get| will still work, but it will return nullptr.
27 static bool IsEnabled();
28
29 // Returns the global StateController instance. Note that this can return
30 // nullptr when lock screen apps are not enabled (see |IsEnabled|).
31 static StateController* Get(); 22 static StateController* Get();
32 23
33 // Note that only one StateController is allowed per process. Creating a
34 // StateController will set global instance ptr that can be accessed using
35 // |Get|. This pointer will be reset when the StateController is destroyed.
36 StateController();
37 ~StateController() override;
38
39 // Sets the tray action that should be used by |StateController|.
40 // Has to be called before |Initialize|.
41 void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr);
42 void FlushTrayActionForTesting();
43
44 // Initializes mojo bindings for the StateController - it creates binding to
45 // ash's tray action interface and sets this object as the interface's client.
46 void Initialize();
47
48 void AddObserver(StateObserver* observer); 24 void AddObserver(StateObserver* observer);
49 void RemoveObserver(StateObserver* observer); 25 void RemoveObserver(StateObserver* observer);
50 26
51 // Gets current state assiciated with the lock screen note action. 27 // Gets current state assiciated with the action.
52 ash::mojom::TrayActionState GetLockScreenNoteState() const; 28 ActionState GetActionState(Action action) const;
53 29
54 // ash::mojom::TrayActionClient: 30 // Handles an action request - if the action handler is available, this will
55 void RequestNewLockScreenNote() override; 31 // show an app window for the specified action.
32 bool HandleAction(Action action);
56 33
57 // If there are any active lock screen action handlers, moved their windows 34 // If there are any active lock screen action handlers, moved their windows
58 // to background, to ensure lock screen UI is visible. 35 // to background, to ensure lock screen UI is visible.
59 void MoveToBackground(); 36 void MoveToBackground();
60 37
61 // Sets the current state - to be used in tests. Hopefully, when this class 38 private:
62 // has more logic implemented, this will not be needed. 39 friend struct base::LazyInstanceTraitsBase<StateController>;
63 void SetLockScreenNoteStateForTesting(ash::mojom::TrayActionState state);
64 40
65 private: 41 StateController();
66 // Requests lock screen note action state change to |state|. 42 ~StateController();
43
44 // Requests action state change to |state|.
67 // Returns whether the action state has changed. 45 // Returns whether the action state has changed.
68 bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state); 46 bool UpdateActionState(Action action, ActionState state);
69 47
70 // Notifies observers that the lock screen note action state changed. 48 // notifies observers that an action state changed.
71 void NotifyLockScreenNoteStateChanged(); 49 void NotifyStateChanged(Action action);
72 50
73 // Lock screen note action state. 51 // New note action state.
74 ash::mojom::TrayActionState lock_screen_note_state_ = 52 ActionState new_note_state_ = ActionState::kNotSupported;
75 ash::mojom::TrayActionState::kNotAvailable;
76 53
77 base::ObserverList<StateObserver> observers_; 54 base::ObserverList<StateObserver> observers_;
78 55
79 mojo::Binding<ash::mojom::TrayActionClient> binding_;
80 ash::mojom::TrayActionPtr tray_action_ptr_;
81
82 DISALLOW_COPY_AND_ASSIGN(StateController); 56 DISALLOW_COPY_AND_ASSIGN(StateController);
83 }; 57 };
84 58
85 } // namespace lock_screen_apps 59 } // namespace lock_screen_apps
86 60
87 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ 61 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.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