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

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

Powered by Google App Engine
This is Rietveld 408576698