| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |
| 7 |
| 8 #include "base/lazy_instance.h" |
| 9 #include "base/observer_list.h" |
| 10 #include "chrome/browser/chromeos/lock_screen_apps/state_observer.h" |
| 11 #include "chrome/browser/chromeos/lock_screen_apps/types.h" |
| 12 |
| 13 namespace lock_screen_apps { |
| 14 |
| 15 class StateObserver; |
| 16 |
| 17 // Manages state of lock screen action handler apps, and notifies |
| 18 // interested parties as the state changes. |
| 19 // Currently assumes single supported action - NEW_NOTE. |
| 20 class StateController { |
| 21 public: |
| 22 static StateController* Get(); |
| 23 |
| 24 void AddObserver(StateObserver* observer); |
| 25 void RemoveObserver(StateObserver* observer); |
| 26 |
| 27 // Gets current state assiciated with the action. |
| 28 ActionState GetActionState(Action action) const; |
| 29 |
| 30 // Handles an action request - if the action handler is available, this will |
| 31 // show an app window for the specified action. |
| 32 bool HandleAction(Action action); |
| 33 |
| 34 // If there are any active lock screen action handlers, moved their windows |
| 35 // to background, to ensure lock screen UI is visible. |
| 36 void MoveToBackground(); |
| 37 |
| 38 private: |
| 39 friend struct base::LazyInstanceTraitsBase<StateController>; |
| 40 |
| 41 StateController(); |
| 42 ~StateController(); |
| 43 |
| 44 // Requests action state change to |state|. |
| 45 // Returns whether the action state has changed. |
| 46 bool UpdateActionState(Action action, ActionState state); |
| 47 |
| 48 // notifies observers that an action state changed. |
| 49 void NotifyStateChanged(Action action); |
| 50 |
| 51 // New note action state. |
| 52 ActionState new_note_state_ = ActionState::kNotSupported; |
| 53 |
| 54 base::ObserverList<StateObserver> observers_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(StateController); |
| 57 }; |
| 58 |
| 59 } // namespace lock_screen_apps |
| 60 |
| 61 #endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |
| OLD | NEW |