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

Side by Side Diff: chrome/browser/chromeos/login/login_performer.h

Issue 3583013: [cros] Add blocking UI on offline: OK, online auth: fail case. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix for review comments Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "chrome/browser/chromeos/login/authenticator.h" 13 #include "chrome/browser/chromeos/login/authenticator.h"
14 #include "chrome/browser/chromeos/login/login_status_consumer.h" 14 #include "chrome/browser/chromeos/login/login_status_consumer.h"
15 #include "chrome/browser/chromeos/login/signed_settings_helper.h" 15 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
16 #include "chrome/common/net/gaia/google_service_auth_error.h" 16 #include "chrome/common/net/gaia/google_service_auth_error.h"
17 #include "chrome/common/notification_observer.h"
18 #include "chrome/common/notification_registrar.h"
17 19
18 namespace chromeos { 20 namespace chromeos {
19 21
20 // This class encapsulates sign in operations. 22 // This class encapsulates sign in operations.
21 // Sign in is performed in a way that offline login is executed first. 23 // Sign in is performed in a way that offline auth is executed first.
22 // Once it's successful user homedir is mounted, UI is launched. 24 // Once offline auth is OK - user homedir is mounted, UI is launched.
23 // If concurrent online login operation would fail that means: 25 // At this point LoginPerformer |delegate_| is destroyed and it releases
24 // - User password has changed. Ask user for the new password. 26 // LP instance ownership. LP waits for online login result.
25 // - User password has changed & CAPTCHA input is required. 27 // If auth is succeeded, cookie fetcher is executed, LP instance deletes itself.
26 // If |delegate_| is not NULL it will handle 28 //
27 // password changed and CAPTCHA dialogs. 29 // If online login operation fails that means:
30 // (1) User password has changed. Ask user for the new password.
31 // (2) User password has changed and/or CAPTCHA input is required.
32 // (3) User account is deleted/disabled/not signed up.
33 // (4) Timeout/service unavailable/connection failed.
34 //
35 // Actions:
36 // (1)-(3): Request screen lock.
37 // (1) Ask for new user password.
38 // (2) Ask for new user password and/or CAPTCHA.
39 // (3) Display error message and allow "Sign Out" as the only action.
40 // (4) Delete LP instance since offline auth was OK.
41 //
42 // If |delegate_| is not NULL it will handle error messages,
43 // CAPTCHA dialog, password input.
28 // If |delegate_| is NULL that does mean that LoginPerformer instance 44 // If |delegate_| is NULL that does mean that LoginPerformer instance
29 // is waiting for online login operation. 45 // is waiting for successful online login or blocked on online login failure.
30 // In case of failure use ScreenLock and ask for a new password. 46 // In case of failure password/captcha
47 // input & error messages display is dedicated to ScreenLocker instance.
48 //
49 // 2 things make LoginPerfrormer instance exist longer:
50 // 1. ScreenLock active (pending correct new password input)
51 // 2. Pending online auth request.
31 class LoginPerformer : public LoginStatusConsumer, 52 class LoginPerformer : public LoginStatusConsumer,
32 public SignedSettingsHelper::Callback { 53 public SignedSettingsHelper::Callback,
54 public NotificationObserver {
33 public: 55 public:
34 // Delegate class to get notifications from the LoginPerformer. 56 // Delegate class to get notifications from the LoginPerformer.
35 class Delegate : public LoginStatusConsumer { 57 class Delegate : public LoginStatusConsumer {
36 public: 58 public:
37 virtual ~Delegate() {} 59 virtual ~Delegate() {}
38 virtual void WhiteListCheckFailed(const std::string& email) = 0; 60 virtual void WhiteListCheckFailed(const std::string& email) = 0;
39 }; 61 };
40 62
41 explicit LoginPerformer(Delegate* delegate); 63 explicit LoginPerformer(Delegate* delegate);
64 ~LoginPerformer();
oshima 2010/11/29 20:10:10 virtual (just a style nit)
Nikita (slow) 2010/12/01 12:42:57 Done.
65
66 // Returns the default instance if it has been created.
67 // This instance is owned by delegate_ till it's destroyed.
68 // When LP instance lives by itself it's used by ScreenLocker instance.
69 static LoginPerformer* default_performer() {
70 return default_performer_;
71 }
42 72
43 // LoginStatusConsumer implementation: 73 // LoginStatusConsumer implementation:
44 virtual void OnLoginFailure(const LoginFailure& error); 74 virtual void OnLoginFailure(const LoginFailure& error);
45 virtual void OnLoginSuccess( 75 virtual void OnLoginSuccess(
46 const std::string& username, 76 const std::string& username,
47 const std::string& password, 77 const std::string& password,
48 const GaiaAuthConsumer::ClientLoginResult& credentials, 78 const GaiaAuthConsumer::ClientLoginResult& credentials,
49 bool pending_requests); 79 bool pending_requests);
50 virtual void OnOffTheRecordLoginSuccess(); 80 virtual void OnOffTheRecordLoginSuccess();
51 virtual void OnPasswordChangeDetected( 81 virtual void OnPasswordChangeDetected(
52 const GaiaAuthConsumer::ClientLoginResult& credentials); 82 const GaiaAuthConsumer::ClientLoginResult& credentials);
53 83
54 // SignedSettingsHelper::Callback 84 // SignedSettingsHelper::Callback implementation:
55 virtual void OnCheckWhiteListCompleted(bool success, 85 virtual void OnCheckWhiteListCompleted(bool success,
56 const std::string& email); 86 const std::string& email);
57 87
88 // NotificationObserver implementation:
89 virtual void Observe(NotificationType type,
90 const NotificationSource& source,
91 const NotificationDetails& details);
92
58 // Performs login with the |username| and |password| specified. 93 // Performs login with the |username| and |password| specified.
59 void Login(const std::string& username, const std::string& password); 94 void Login(const std::string& username, const std::string& password);
60 95
61 // Performs actions to prepare Guest mode login. 96 // Performs actions to prepare Guest mode login.
62 void LoginOffTheRecord(); 97 void LoginOffTheRecord();
63 98
64 // Migrates cryptohome using |old_password| specified. 99 // Migrates cryptohome using |old_password| specified.
65 void RecoverEncryptedData(const std::string& old_password); 100 void RecoverEncryptedData(const std::string& old_password);
66 101
67 // Reinitializes cryptohome with the new password. 102 // Reinitializes cryptohome with the new password.
68 void ResyncEncryptedData(); 103 void ResyncEncryptedData();
69 104
70 // Returns latest auth error. 105 // Returns latest auth error.
71 const GoogleServiceAuthError& error() const { 106 const GoogleServiceAuthError& error() const {
72 return last_login_failure_.error(); 107 return last_login_failure_.error();
73 } 108 }
74 109
75 // True if last login operation has timed out. 110 // True if last login operation has timed out.
76 bool login_timed_out() { 111 bool login_timed_out() {
77 return last_login_failure_.reason() == LoginFailure::LOGIN_TIMED_OUT; 112 return last_login_failure_.reason() == LoginFailure::LOGIN_TIMED_OUT;
78 } 113 }
79 114
80 void set_captcha(const std::string& captcha) { captcha_ = captcha; } 115 void set_captcha(const std::string& captcha) { captcha_ = captcha; }
81 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 116 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
82 117
83 private: 118 private:
119 // Requests screen lock and subscribes to screen lock notifications.
120 void RequestScreenLock();
121
122 // Requests screen unlock.
123 void RequestScreenUnlock();
124
125 // Resolves initial LoginFailure::NETWORK_AUTH_FAILED error i.e.
126 // when screen is not locked yet.
127 void ResolveInitialNetworkAuthFailure();
128
129 // Resolves LoginFailure when screen is locked.
130 void ResolveLockLoginFailure();
131
132 // Resolves LoginFailure::NETWORK_AUTH_FAILED error when screen is locked.
133 // Uses ScreenLocker to show error message based on |last_login_failure_|.
134 void ResolveLockNetworkAuthFailure();
135
136 // Resolve ScreenLock changed state.
137 void ResolveScreenLocked();
138 void ResolveScreenUnlocked();
139
84 // Starts authentication. 140 // Starts authentication.
85 void StartAuthentication(); 141 void StartAuthentication();
86 142
143 // Default performer. Will be used by ScreenLocker.
144 static LoginPerformer* default_performer_;
145
87 // Used for logging in. 146 // Used for logging in.
88 scoped_refptr<Authenticator> authenticator_; 147 scoped_refptr<Authenticator> authenticator_;
89 148
90 // Represents last login failure that was encountered when communicating to 149 // Represents last login failure that was encountered when communicating to
91 // sign-in server. LoginFailure.None() by default. 150 // sign-in server. LoginFailure.None() by default.
92 LoginFailure last_login_failure_; 151 LoginFailure last_login_failure_;
93 152
94 // String entered by the user as an answer to a CAPTCHA challenge. 153 // String entered by the user as an answer to a CAPTCHA challenge.
95 std::string captcha_; 154 std::string captcha_;
96 155
97 // Token representing the specific CAPTCHA challenge. 156 // Token representing the specific CAPTCHA challenge.
98 std::string captcha_token_; 157 std::string captcha_token_;
99 158
100 // Cached credentials data when password change is detected. 159 // Cached credentials data when password change is detected.
101 GaiaAuthConsumer::ClientLoginResult cached_credentials_; 160 GaiaAuthConsumer::ClientLoginResult cached_credentials_;
102 161
103 // Username and password for the current login attempt. 162 // Username and password for the current login attempt.
104 std::string username_; 163 std::string username_;
105 std::string password_; 164 std::string password_;
106 165
107 // Notifications receiver. 166 // Notifications receiver.
108 Delegate* delegate_; 167 Delegate* delegate_;
109 168
169 // True if password change has been detected.
170 // Once correct password is entered homedir migration is executed.
171 bool password_changed_;
172
173 NotificationRegistrar registrar_;
174
110 DISALLOW_COPY_AND_ASSIGN(LoginPerformer); 175 DISALLOW_COPY_AND_ASSIGN(LoginPerformer);
111 }; 176 };
112 177
113 } // namespace chromeos 178 } // namespace chromeos
114 179
115 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_ 180 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_PERFORMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698