| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The signin manager encapsulates some functionality tracking | 5 // The signin manager encapsulates some functionality tracking |
| 6 // which user is signed in. See SigninManagerBase for full description of | 6 // which user is signed in. See SigninManagerBase for full description of |
| 7 // responsibilities. The class defined in this file provides functionality | 7 // responsibilities. The class defined in this file provides functionality |
| 8 // required by all platforms except Chrome OS. | 8 // required by all platforms except Chrome OS. |
| 9 // | 9 // |
| 10 // When a user is signed in, a ClientLogin request is run on their behalf. | 10 // When a user is signed in, a ClientLogin request is run on their behalf. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // This is used to distinguish URLs belonging to the special web signin flow | 63 // This is used to distinguish URLs belonging to the special web signin flow |
| 64 // running in the special signin process from other URLs on the same domain. | 64 // running in the special signin process from other URLs on the same domain. |
| 65 // We do not grant WebUI privilieges / bindings to this process or to URLs of | 65 // We do not grant WebUI privilieges / bindings to this process or to URLs of |
| 66 // this scheme; enforcement of privileges is handled separately by | 66 // this scheme; enforcement of privileges is handled separately by |
| 67 // OneClickSigninHelper. | 67 // OneClickSigninHelper. |
| 68 static const char* kChromeSigninEffectiveSite; | 68 static const char* kChromeSigninEffectiveSite; |
| 69 | 69 |
| 70 SigninManager(); | 70 SigninManager(); |
| 71 virtual ~SigninManager(); | 71 virtual ~SigninManager(); |
| 72 | 72 |
| 73 // Returns true if the username is allowed based on the policy string. |
| 74 static bool IsUsernameAllowedByPolicy(const std::string& username, |
| 75 const std::string& policy); |
| 76 |
| 73 // Attempt to sign in this user with ClientLogin. If successful, set a | 77 // Attempt to sign in this user with ClientLogin. If successful, set a |
| 74 // preference indicating the signed in user and send out a notification, | 78 // preference indicating the signed in user and send out a notification, |
| 75 // then start fetching tokens for the user. | 79 // then start fetching tokens for the user. |
| 76 // This is overridden for test subclasses that don't want to issue auth | 80 // This is overridden for test subclasses that don't want to issue auth |
| 77 // requests. | 81 // requests. |
| 78 virtual void StartSignIn(const std::string& username, | 82 virtual void StartSignIn(const std::string& username, |
| 79 const std::string& password, | 83 const std::string& password, |
| 80 const std::string& login_token, | 84 const std::string& login_token, |
| 81 const std::string& login_captcha); | 85 const std::string& login_captcha); |
| 82 | 86 |
| 83 // Used when a second factor access code was required to complete a signin | 87 // Used when a second factor access code was required to complete a signin |
| 84 // attempt. | 88 // attempt. |
| 85 void ProvideSecondFactorAccessCode(const std::string& access_code); | 89 void ProvideSecondFactorAccessCode(const std::string& access_code); |
| 86 | 90 |
| 87 // Attempt to sign in this user with existing credentials from the cookie jar. | 91 // Attempt to sign in this user with existing credentials from the cookie jar. |
| 88 // |session_index| indicates which user account to use if the cookie jar | 92 // |session_index| indicates which user account to use if the cookie jar |
| 89 // contains a multi-login session. Otherwise the end result of this call is | 93 // contains a multi-login session. Otherwise the end result of this call is |
| 90 // the same as StartSignIn(). | 94 // the same as StartSignIn(). |
| 91 virtual void StartSignInWithCredentials(const std::string& session_index, | 95 virtual void StartSignInWithCredentials(const std::string& session_index, |
| 92 const std::string& username, | 96 const std::string& username, |
| 93 const std::string& password); | 97 const std::string& password); |
| 94 | 98 |
| 95 // Sign a user out, removing the preference, erasing all keys | 99 // Sign a user out, removing the preference, erasing all keys |
| 96 // associated with the user, and canceling all auth in progress. | 100 // associated with the user, and canceling all auth in progress. |
| 97 virtual void SignOut() OVERRIDE; | 101 virtual void SignOut(); |
| 102 |
| 103 // On platforms where SigninManager is responsible for dealing with |
| 104 // invalid username policy updates, we need to check this during |
| 105 // initialization and sign the user out. |
| 106 virtual void Initialize(Profile* profile) OVERRIDE; |
| 98 | 107 |
| 99 // Returns true if there's a signin in progress. | 108 // Returns true if there's a signin in progress. |
| 100 virtual bool AuthInProgress() const OVERRIDE; | 109 virtual bool AuthInProgress() const OVERRIDE; |
| 101 | 110 |
| 111 virtual bool IsSigninAllowed() const OVERRIDE; |
| 112 |
| 113 // Returns true if the passed username is allowed by policy. Virtual for |
| 114 // mocking in tests. |
| 115 virtual bool IsAllowedUsername(const std::string& username) const; |
| 116 |
| 102 // If an authentication is in progress, return the username being | 117 // If an authentication is in progress, return the username being |
| 103 // authenticated. Returns an empty string if no auth is in progress. | 118 // authenticated. Returns an empty string if no auth is in progress. |
| 104 const std::string& GetUsernameForAuthInProgress() const; | 119 const std::string& GetUsernameForAuthInProgress() const; |
| 105 | 120 |
| 106 // Handles errors if a required user info key is not returned from the | 121 // Handles errors if a required user info key is not returned from the |
| 107 // GetUserInfo call. | 122 // GetUserInfo call. |
| 108 void OnGetUserInfoKeyNotFound(const std::string& key); | 123 void OnGetUserInfoKeyNotFound(const std::string& key); |
| 109 | 124 |
| 110 // Set the profile preference to turn off one-click sign-in so that it won't | 125 // Set the profile preference to turn off one-click sign-in so that it won't |
| 111 // ever show it again in this profile (even if the user tries a new account). | 126 // ever show it again in this profile (even if the user tries a new account). |
| (...skipping 22 matching lines...) Expand all Loading... |
| 134 | 149 |
| 135 | 150 |
| 136 // Tells the SigninManager whether to prohibit signout for this profile. | 151 // Tells the SigninManager whether to prohibit signout for this profile. |
| 137 // If |prohibit_signout| is true, then signout will be prohibited. | 152 // If |prohibit_signout| is true, then signout will be prohibited. |
| 138 void ProhibitSignout(bool prohibit_signout); | 153 void ProhibitSignout(bool prohibit_signout); |
| 139 | 154 |
| 140 // If true, signout is prohibited for this profile (calls to SignOut() are | 155 // If true, signout is prohibited for this profile (calls to SignOut() are |
| 141 // ignored). | 156 // ignored). |
| 142 bool IsSignoutProhibited() const; | 157 bool IsSignoutProhibited() const; |
| 143 | 158 |
| 159 // Checks if signin is allowed for the profile that owns |io_data|. This must |
| 160 // be invoked on the IO thread, and can be used to check if signin is enabled |
| 161 // on that thread. |
| 162 static bool IsSigninAllowedOnIOThread(ProfileIOData* io_data); |
| 163 |
| 144 // Allows the SigninManager to track the privileged signin process | 164 // Allows the SigninManager to track the privileged signin process |
| 145 // identified by |process_id| so that we can later ask (via IsSigninProcess) | 165 // identified by |process_id| so that we can later ask (via IsSigninProcess) |
| 146 // if it is safe to sign the user in from the current context (see | 166 // if it is safe to sign the user in from the current context (see |
| 147 // OneClickSigninHelper). All of this tracking state is reset once the | 167 // OneClickSigninHelper). All of this tracking state is reset once the |
| 148 // renderer process terminates. | 168 // renderer process terminates. |
| 149 void SetSigninProcess(int process_id); | 169 void SetSigninProcess(int process_id); |
| 150 bool IsSigninProcess(int process_id) const; | 170 bool IsSigninProcess(int process_id) const; |
| 151 bool HasSigninProcess() const; | 171 bool HasSigninProcess() const; |
| 152 | 172 |
| 153 protected: | 173 protected: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 Profile::CreateStatus status); | 247 Profile::CreateStatus status); |
| 228 | 248 |
| 229 // Cancels the in-progress signin for this profile. | 249 // Cancels the in-progress signin for this profile. |
| 230 void CancelSignin(); | 250 void CancelSignin(); |
| 231 | 251 |
| 232 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 252 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 233 | 253 |
| 234 // Invoked once policy has been loaded to complete user signin. | 254 // Invoked once policy has been loaded to complete user signin. |
| 235 void CompleteSigninAfterPolicyLoad(); | 255 void CompleteSigninAfterPolicyLoad(); |
| 236 | 256 |
| 257 void OnSigninAllowedPrefChanged(); |
| 258 void OnGoogleServicesUsernamePatternChanged(); |
| 259 |
| 237 // ClientLogin identity. | 260 // ClientLogin identity. |
| 238 std::string possibly_invalid_username_; | 261 std::string possibly_invalid_username_; |
| 239 std::string password_; // This is kept empty whenever possible. | 262 std::string password_; // This is kept empty whenever possible. |
| 240 bool had_two_factor_error_; | 263 bool had_two_factor_error_; |
| 241 | 264 |
| 242 void CleanupNotificationRegistration(); | 265 void CleanupNotificationRegistration(); |
| 243 | 266 |
| 244 // Result of the last client login, kept pending the lookup of the | 267 // Result of the last client login, kept pending the lookup of the |
| 245 // canonical email. | 268 // canonical email. |
| 246 ClientLoginResult last_result_; | 269 ClientLoginResult last_result_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 272 // See SetSigninProcess. Tracks the currently active signin process | 295 // See SetSigninProcess. Tracks the currently active signin process |
| 273 // by ID, if there is one. | 296 // by ID, if there is one. |
| 274 int signin_process_id_; | 297 int signin_process_id_; |
| 275 | 298 |
| 276 #if defined(ENABLE_CONFIGURATION_POLICY) | 299 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 277 // CloudPolicyClient reference we keep while determining whether to create | 300 // CloudPolicyClient reference we keep while determining whether to create |
| 278 // a new profile for an enterprise user or not. | 301 // a new profile for an enterprise user or not. |
| 279 scoped_ptr<policy::CloudPolicyClient> policy_client_; | 302 scoped_ptr<policy::CloudPolicyClient> policy_client_; |
| 280 #endif | 303 #endif |
| 281 | 304 |
| 305 // Helper object to listen for changes to signin preferences stored in non- |
| 306 // profile-specific local prefs (like kGoogleServicesUsernamePattern). |
| 307 PrefChangeRegistrar local_state_pref_registrar_; |
| 308 |
| 309 // Helper object to listen for changes to the signin allowed preference. |
| 310 BooleanPrefMember signin_allowed_; |
| 311 |
| 282 DISALLOW_COPY_AND_ASSIGN(SigninManager); | 312 DISALLOW_COPY_AND_ASSIGN(SigninManager); |
| 283 }; | 313 }; |
| 284 | 314 |
| 285 #endif // !defined(OS_CHROMEOS) | 315 #endif // !defined(OS_CHROMEOS) |
| 286 | 316 |
| 287 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ | 317 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ |
| OLD | NEW |