Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7af390cde42471d31b3d1b1c5c6b5a4550289e15 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |
| + |
| +#include "base/lazy_instance.h" |
| +#include "base/observer_list.h" |
| +#include "chrome/browser/chromeos/lock_screen_apps/state_observer.h" |
| +#include "chrome/browser/chromeos/lock_screen_apps/types.h" |
| + |
| +namespace lock_screen_apps { |
| +class StateObserver; |
|
xiyuan
2017/05/02 18:12:23
nit: move this down after line 17. Prevailing styl
tbarzic
2017/05/02 18:43:37
Done.
|
| +} |
| + |
| +namespace lock_screen_apps { |
| + |
| +// Manages state of lock scree action handler apps, and notifies |
| +// interested parties as the state changes. |
| +// Currently assumes single supported action - NEW_NOTE. |
| +class StateController { |
| + public: |
| + static StateController* Get(); |
| + |
| + void AddObserver(StateObserver* observer); |
| + void RemoveObserver(StateObserver* observer); |
| + |
| + // Gets current state assiciated with the action. |
| + ActionState GetActionState(Action action) const; |
| + |
| + // Handles an action request - if the action handler is available, this will |
| + // show an app window for the specified action. |
| + void HandleAction(Action action); |
|
xiyuan
2017/05/02 18:12:23
Do we care about whether the action is handled? e.
tbarzic
2017/05/02 18:43:37
Not necessarily, but it could be useful, e.g. for
|
| + |
| + // If there are any active lock screen action handlers, moved their windows |
| + // to background, to ensure lock screen UI is visible. |
| + void MoveToBackground(); |
| + |
| + private: |
| + friend struct base::LazyInstanceTraitsBase<StateController>; |
| + |
| + StateController(); |
| + ~StateController(); |
| + |
| + // Requests action state change to |state|. |
| + // Returns whether the action state has changed. |
| + bool UpdateActionState(Action action, ActionState state); |
|
xiyuan
2017/05/02 18:12:23
How do we plan to change state with this method be
tbarzic
2017/05/02 18:43:37
Yes, I plan not to have this expose explicit updat
xiyuan
2017/05/02 19:23:03
Acknowledged.
|
| + |
| + // notifies observers that an action state changed. |
| + void NotifyStateChanged(Action action); |
| + |
| + // New note action state. |
| + ActionState new_note_state_ = ActionState::kNotSupported; |
| + |
| + base::ObserverList<StateObserver> observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(StateController); |
| +}; |
| + |
| +} // namespace lock_screen_apps |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_ |