Temporarily re-enabling SizeAfterPrefChange test with traces (this time for Linux...
[chromium-blink-merge.git] / chrome / browser / signin / screenlock_bridge.h
blob6e82317f305ad435430c7e8367e52c666483c0cb
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
8 #include <string>
10 #include "base/lazy_instance.h"
11 #include "base/macros.h"
12 #include "base/observer_list.h"
14 namespace gfx {
15 class Image;
18 class Profile;
20 // ScreenlockBridge brings together the screenLockPrivate API and underlying
21 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other
22 // platforms, it delegates calls to UserManagerUI (and friends).
23 class ScreenlockBridge {
24 public:
25 class Observer {
26 public:
27 // Invoked after the screen is locked.
28 virtual void OnScreenDidLock() = 0;
29 // Invoked after the screen lock is dismissed.
30 virtual void OnScreenDidUnlock() = 0;
31 protected:
32 virtual ~Observer() {}
35 class LockHandler {
36 public:
37 // Supported authentication types. Keep in sync with the enum in
38 // user_pod_row.js.
39 enum AuthType {
40 OFFLINE_PASSWORD = 0,
41 ONLINE_SIGN_IN = 1,
42 NUMERIC_PIN = 2,
43 USER_CLICK = 3,
46 // Displays |message| in a banner on the lock screen.
47 virtual void ShowBannerMessage(const std::string& message) = 0;
49 // Shows a custom icon in the user pod on the lock screen.
50 virtual void ShowUserPodCustomIcon(const std::string& user_email,
51 const gfx::Image& icon) = 0;
53 // Hides the custom icon in user pod for a user.
54 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0;
56 // (Re)enable lock screen UI.
57 virtual void EnableInput() = 0;
59 // Set the authentication type to be used on the lock screen.
60 virtual void SetAuthType(const std::string& user_email,
61 AuthType auth_type,
62 const std::string& auth_value) = 0;
64 // Returns the authentication type used for a user.
65 virtual AuthType GetAuthType(const std::string& user_email) const = 0;
67 // Unlock from easy unlock app for a user.
68 virtual void Unlock(const std::string& user_email) = 0;
70 protected:
71 virtual ~LockHandler() {}
74 static ScreenlockBridge* Get();
75 static std::string GetAuthenticatedUserEmail(Profile* profile);
77 void SetLockHandler(LockHandler* lock_handler);
79 bool IsLocked() const;
80 void Lock(Profile* profile);
81 void Unlock(Profile* profile);
83 void AddObserver(Observer* observer);
84 void RemoveObserver(Observer* observer);
86 LockHandler* lock_handler() { return lock_handler_; }
88 private:
89 friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>;
90 friend struct base::DefaultDeleter<ScreenlockBridge>;
92 ScreenlockBridge();
93 ~ScreenlockBridge();
95 LockHandler* lock_handler_; // Not owned
96 ObserverList<Observer, true> observers_;
98 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge);
101 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_