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

Unified 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 side-by-side diff with in-line comments
Download patch
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
index f0bf67557900b99e219484dffd43a81c7da6e527..1b043346e49e530a13a23cd1bd92b1243cf655e2 100644
--- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h
+++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h
@@ -5,12 +5,10 @@
#ifndef CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_LOCK_SCREEN_APPS_STATE_CONTROLLER_H_
-#include <memory>
-
-#include "ash/public/interfaces/tray_action.mojom.h"
+#include "base/lazy_instance.h"
#include "base/observer_list.h"
#include "chrome/browser/chromeos/lock_screen_apps/state_observer.h"
-#include "mojo/public/cpp/bindings/binding.h"
+#include "chrome/browser/chromeos/lock_screen_apps/types.h"
namespace lock_screen_apps {
@@ -19,65 +17,41 @@
// Manages state of lock screen action handler apps, and notifies
// interested parties as the state changes.
// Currently assumes single supported action - NEW_NOTE.
-class StateController : public ash::mojom::TrayActionClient {
+class StateController {
public:
- // Returns whether the StateController is enabled - it is currently guarded by
- // a feature flag. If not enabled, |StateController| instance is not allowed
- // to be created. |Get| will still work, but it will return nullptr.
- static bool IsEnabled();
-
- // Returns the global StateController instance. Note that this can return
- // nullptr when lock screen apps are not enabled (see |IsEnabled|).
static StateController* Get();
-
- // Note that only one StateController is allowed per process. Creating a
- // StateController will set global instance ptr that can be accessed using
- // |Get|. This pointer will be reset when the StateController is destroyed.
- StateController();
- ~StateController() override;
-
- // Sets the tray action that should be used by |StateController|.
- // Has to be called before |Initialize|.
- void SetTrayActionPtrForTesting(ash::mojom::TrayActionPtr tray_action_ptr);
- void FlushTrayActionForTesting();
-
- // Initializes mojo bindings for the StateController - it creates binding to
- // ash's tray action interface and sets this object as the interface's client.
- void Initialize();
void AddObserver(StateObserver* observer);
void RemoveObserver(StateObserver* observer);
- // Gets current state assiciated with the lock screen note action.
- ash::mojom::TrayActionState GetLockScreenNoteState() const;
+ // Gets current state assiciated with the action.
+ ActionState GetActionState(Action action) const;
- // ash::mojom::TrayActionClient:
- void RequestNewLockScreenNote() override;
+ // Handles an action request - if the action handler is available, this will
+ // show an app window for the specified action.
+ bool HandleAction(Action action);
// If there are any active lock screen action handlers, moved their windows
// to background, to ensure lock screen UI is visible.
void MoveToBackground();
- // Sets the current state - to be used in tests. Hopefully, when this class
- // has more logic implemented, this will not be needed.
- void SetLockScreenNoteStateForTesting(ash::mojom::TrayActionState state);
+ private:
+ friend struct base::LazyInstanceTraitsBase<StateController>;
- private:
- // Requests lock screen note action state change to |state|.
+ StateController();
+ ~StateController();
+
+ // Requests action state change to |state|.
// Returns whether the action state has changed.
- bool UpdateLockScreenNoteState(ash::mojom::TrayActionState state);
+ bool UpdateActionState(Action action, ActionState state);
- // Notifies observers that the lock screen note action state changed.
- void NotifyLockScreenNoteStateChanged();
+ // notifies observers that an action state changed.
+ void NotifyStateChanged(Action action);
- // Lock screen note action state.
- ash::mojom::TrayActionState lock_screen_note_state_ =
- ash::mojom::TrayActionState::kNotAvailable;
+ // New note action state.
+ ActionState new_note_state_ = ActionState::kNotSupported;
base::ObserverList<StateObserver> observers_;
-
- mojo::Binding<ash::mojom::TrayActionClient> binding_;
- ash::mojom::TrayActionPtr tray_action_ptr_;
DISALLOW_COPY_AND_ASSIGN(StateController);
};
« 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