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

Side by Side Diff: chrome/browser/signin/screenlock_bridge.h

Issue 446743003: Hook up new API for easy unlock to update lock screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: v Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_SIGNIN_SCREENLOCK_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 6 #define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/strings/string16.h"
16 #include "base/values.h"
13 17
14 namespace gfx { 18 namespace gfx {
15 class Image; 19 class Image;
16 } 20 }
17 21
18 class Profile; 22 class Profile;
19 23
20 // ScreenlockBridge brings together the screenLockPrivate API and underlying 24 // ScreenlockBridge brings together the screenLockPrivate API and underlying
21 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other 25 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other
22 // platforms, it delegates calls to UserManagerUI (and friends). 26 // platforms, it delegates calls to UserManagerUI (and friends).
23 class ScreenlockBridge { 27 class ScreenlockBridge {
24 public: 28 public:
25 class Observer { 29 class Observer {
26 public: 30 public:
27 // Invoked after the screen is locked. 31 // Invoked after the screen is locked.
28 virtual void OnScreenDidLock() = 0; 32 virtual void OnScreenDidLock() = 0;
29 // Invoked after the screen lock is dismissed. 33 // Invoked after the screen lock is dismissed.
30 virtual void OnScreenDidUnlock() = 0; 34 virtual void OnScreenDidUnlock() = 0;
31 protected: 35 protected:
32 virtual ~Observer() {} 36 virtual ~Observer() {}
33 }; 37 };
34 38
39 // Class containing parameters describing the custom icon that should be
40 // shown on a user's screen lock pod next to the input field.
41 class UserPodCustomIconOptions {
42 public:
43 UserPodCustomIconOptions();
44 ~UserPodCustomIconOptions();
45
46 // Converts parameters to a dictionary values that can be sent to the
47 // screenlock web UI.
48 scoped_ptr<base::DictionaryValue> ToDictionaryValue() const;
49
50 // Sets the icon as chrome://theme resource URL.
51 void SetIconAsResourceURL(const std::string& url);
52
53 // Sets the icon as a gfx::Image. The image will be converted to set of data
54 // URLs for each icon representation. Use |SetIconAsResourceURL| instead of
55 // this.
56 // TODO(tbarzic): Remove this one once easy unlock app stops using
57 // screenlockPrivate.showCustomIcon.
58 void SetIconAsImage(const gfx::Image& image);
59
60 // Sets the icon size. Has to be called if |SetIconAsResourceURL| was used
61 // to set the icon. For animated icon, this should be set to a single frame
62 // size, not the animation resource size.
63 void SetSize(size_t icon_width, size_t icon_height);
64
65 // If the icon is supposed to be animated, sets the animation parameters.
66 // If set, it expects that the resource set using |SetIcon*| methods
67 // contains horizontally arranged ordered list of animation frames.
68 // Note that the icon size set in |SetSize| should be a single frame size.
69 // |resource_width|: Total animation resource width.
70 // |frame_length_ms|: Time for which a single animation frame is shown.
71 void SetAnimation(size_t resource_width, size_t frame_length_ms);
72
73 // Sets the icon opacity. The values should be in <0, 100] interval, which
74 // will get scaled into <0, 1] interval. The default value is 100.
75 void SetOpacity(size_t opacity);
76
77 // Sets the icon tooltip. If |autoshow| is set the tooltip is automatically
78 // shown with the icon.
79 void SetTooltip(const base::string16& tooltip, bool autoshow);
80
81 private:
82 scoped_ptr<std::string> icon_resource_url_;
83 scoped_ptr<gfx::Image> icon_image_;
84
85 size_t width_;
86 size_t height_;
87
88 bool animation_set_;
89 size_t animation_resource_width_;
90 size_t animation_frame_length_ms_;
91
92 size_t opacity_;
xiyuan 2014/08/12 18:09:47 nit: document |opacity_| has range 0-100u.
tbarzic 2014/08/12 19:14:36 Done.
93
94 scoped_ptr<base::string16> tooltip_;
xiyuan 2014/08/12 18:09:47 nit: Why use scoped_ptr for |tooltip_| and |icon_r
tbarzic 2014/08/12 19:14:36 leftover from the initial cl version. Done.
95 bool autoshow_tooltip_;
96
97 DISALLOW_COPY_AND_ASSIGN(UserPodCustomIconOptions);
98 };
99
35 class LockHandler { 100 class LockHandler {
36 public: 101 public:
37 // Supported authentication types. Keep in sync with the enum in 102 // Supported authentication types. Keep in sync with the enum in
38 // user_pod_row.js. 103 // user_pod_row.js.
39 enum AuthType { 104 enum AuthType {
40 OFFLINE_PASSWORD = 0, 105 OFFLINE_PASSWORD = 0,
41 ONLINE_SIGN_IN = 1, 106 ONLINE_SIGN_IN = 1,
42 NUMERIC_PIN = 2, 107 NUMERIC_PIN = 2,
43 USER_CLICK = 3, 108 USER_CLICK = 3,
44 EXPAND_THEN_USER_CLICK = 4, 109 EXPAND_THEN_USER_CLICK = 4,
45 }; 110 };
46 111
47 // Displays |message| in a banner on the lock screen. 112 // Displays |message| in a banner on the lock screen.
48 virtual void ShowBannerMessage(const std::string& message) = 0; 113 virtual void ShowBannerMessage(const base::string16& message) = 0;
49 114
50 // Shows a custom icon in the user pod on the lock screen. 115 // Shows a custom icon in the user pod on the lock screen.
51 virtual void ShowUserPodCustomIcon(const std::string& user_email, 116 virtual void ShowUserPodCustomIcon(
52 const gfx::Image& icon) = 0; 117 const std::string& user_email,
118 const UserPodCustomIconOptions& icon) = 0;
53 119
54 // Hides the custom icon in user pod for a user. 120 // Hides the custom icon in user pod for a user.
55 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; 121 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0;
56 122
57 // (Re)enable lock screen UI. 123 // (Re)enable lock screen UI.
58 virtual void EnableInput() = 0; 124 virtual void EnableInput() = 0;
59 125
60 // Set the authentication type to be used on the lock screen. 126 // Set the authentication type to be used on the lock screen.
61 virtual void SetAuthType(const std::string& user_email, 127 virtual void SetAuthType(const std::string& user_email,
62 AuthType auth_type, 128 AuthType auth_type,
63 const std::string& auth_value) = 0; 129 const base::string16& auth_value) = 0;
64 130
65 // Returns the authentication type used for a user. 131 // Returns the authentication type used for a user.
66 virtual AuthType GetAuthType(const std::string& user_email) const = 0; 132 virtual AuthType GetAuthType(const std::string& user_email) const = 0;
67 133
68 // Unlock from easy unlock app for a user. 134 // Unlock from easy unlock app for a user.
69 virtual void Unlock(const std::string& user_email) = 0; 135 virtual void Unlock(const std::string& user_email) = 0;
70 136
71 protected: 137 protected:
72 virtual ~LockHandler() {} 138 virtual ~LockHandler() {}
73 }; 139 };
(...skipping 19 matching lines...) Expand all
93 ScreenlockBridge(); 159 ScreenlockBridge();
94 ~ScreenlockBridge(); 160 ~ScreenlockBridge();
95 161
96 LockHandler* lock_handler_; // Not owned 162 LockHandler* lock_handler_; // Not owned
97 ObserverList<Observer, true> observers_; 163 ObserverList<Observer, true> observers_;
98 164
99 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); 165 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge);
100 }; 166 };
101 167
102 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_ 168 #endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698