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

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

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits and rebase to ToT. Created 7 years, 9 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
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/signin/signin_manager.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) 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. When a user is signed in, a ClientLogin 6 // which user is signed in. When a user is signed in, a ClientLogin
7 // request is run on their behalf. Auth tokens are fetched from Google 7 // request is run on their behalf. Auth tokens are fetched from Google
8 // and the results are stored in the TokenService. 8 // and the results are stored in the TokenService.
9 // 9 //
10 // **NOTE** on semantics of SigninManager: 10 // **NOTE** on semantics of SigninManager:
11 // 11 //
12 // Once a signin is successful, the username becomes "established" and will not 12 // Once a signin is successful, the username becomes "established" and will not
13 // be cleared until a SignOut operation is performed (persists across 13 // be cleared until a SignOut operation is performed (persists across
14 // restarts). Until that happens, the signin manager can still be used to 14 // restarts). Until that happens, the signin manager can still be used to
15 // refresh credentials, but changing the username is not permitted. 15 // refresh credentials, but changing the username is not permitted.
16 16
17 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 17 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
18 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 18 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
19 19
20 #include <string> 20 #include <string>
21 21
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/gtest_prod_util.h" 23 #include "base/gtest_prod_util.h"
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
26 #include "base/observer_list.h" 26 #include "base/observer_list.h"
27 #include "base/prefs/public/pref_change_registrar.h" 27 #include "base/prefs/public/pref_change_registrar.h"
28 #include "base/prefs/public/pref_member.h"
28 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/profiles/profile_keyed_service.h" 30 #include "chrome/browser/profiles/profile_keyed_service.h"
30 #include "chrome/browser/signin/signin_internals_util.h" 31 #include "chrome/browser/signin/signin_internals_util.h"
31 #include "chrome/browser/signin/ubertoken_fetcher.h" 32 #include "chrome/browser/signin/ubertoken_fetcher.h"
32 #include "content/public/browser/notification_observer.h" 33 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h" 34 #include "content/public/browser/notification_registrar.h"
34 #include "google_apis/gaia/gaia_auth_consumer.h" 35 #include "google_apis/gaia/gaia_auth_consumer.h"
35 #include "google_apis/gaia/google_service_auth_error.h" 36 #include "google_apis/gaia/google_service_auth_error.h"
36 #include "net/cookies/canonical_cookie.h" 37 #include "net/cookies/canonical_cookie.h"
37 38
38 class CookieSettings; 39 class CookieSettings;
39 class GaiaAuthFetcher; 40 class GaiaAuthFetcher;
41 class ProfileIOData;
40 class PrefService; 42 class PrefService;
41 class SigninGlobalError; 43 class SigninGlobalError;
42 44
43 namespace policy { 45 namespace policy {
44 class CloudPolicyClient; 46 class CloudPolicyClient;
45 } 47 }
46 48
47 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL. 49 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL.
48 // A listener might use this to make note of a username / password 50 // A listener might use this to make note of a username / password
49 // pair for encryption keys. 51 // pair for encryption keys.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual ~SigninManager(); 89 virtual ~SigninManager();
88 90
89 // If user was signed in, load tokens from DB if available. 91 // If user was signed in, load tokens from DB if available.
90 void Initialize(Profile* profile); 92 void Initialize(Profile* profile);
91 bool IsInitialized() const; 93 bool IsInitialized() const;
92 94
93 // Returns true if the passed username is allowed by policy. Virtual for 95 // Returns true if the passed username is allowed by policy. Virtual for
94 // mocking in tests. 96 // mocking in tests.
95 virtual bool IsAllowedUsername(const std::string& username) const; 97 virtual bool IsAllowedUsername(const std::string& username) const;
96 98
99 // Returns true if a signin to Chrome is allowed (by policy or pref).
100 bool IsSigninAllowed() const;
101
102 // Checks if signin is allowed for the profile that owns |io_data|. This must
103 // be invoked on the IO thread, and can be used to check if signin is enabled
104 // on that thread.
105 static bool IsSigninAllowedOnIOThread(ProfileIOData* io_data);
106
97 // If a user has previously established a username and SignOut has not been 107 // If a user has previously established a username and SignOut has not been
98 // called, this will return the username. 108 // called, this will return the username.
99 // Otherwise, it will return an empty string. 109 // Otherwise, it will return an empty string.
100 const std::string& GetAuthenticatedUsername() const; 110 const std::string& GetAuthenticatedUsername() const;
101 111
102 // Sets the user name. Note: |username| should be already authenticated as 112 // Sets the user name. Note: |username| should be already authenticated as
103 // this is a sticky operation (in contrast to StartSignIn). 113 // this is a sticky operation (in contrast to StartSignIn).
104 // TODO(tim): Remove this in favor of passing username on construction by 114 // TODO(tim): Remove this in favor of passing username on construction by
105 // (by platform / depending on StartBehavior). Bug 88109. 115 // (by platform / depending on StartBehavior). Bug 88109.
106 void SetAuthenticatedUsername(const std::string& username); 116 void SetAuthenticatedUsername(const std::string& username);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 290
281 // ClientLogin identity. 291 // ClientLogin identity.
282 std::string possibly_invalid_username_; 292 std::string possibly_invalid_username_;
283 std::string password_; // This is kept empty whenever possible. 293 std::string password_; // This is kept empty whenever possible.
284 bool had_two_factor_error_; 294 bool had_two_factor_error_;
285 295
286 void CleanupNotificationRegistration(); 296 void CleanupNotificationRegistration();
287 297
288 void OnGoogleServicesUsernamePatternChanged(); 298 void OnGoogleServicesUsernamePatternChanged();
289 299
300 void OnSigninAllowedPrefChanged();
301
290 // Helper methods to notify all registered diagnostics observers with. 302 // Helper methods to notify all registered diagnostics observers with.
291 void NotifyDiagnosticsObservers( 303 void NotifyDiagnosticsObservers(
292 const signin_internals_util::UntimedSigninStatusField& field, 304 const signin_internals_util::UntimedSigninStatusField& field,
293 const std::string& value); 305 const std::string& value);
294 void NotifyDiagnosticsObservers( 306 void NotifyDiagnosticsObservers(
295 const signin_internals_util::TimedSigninStatusField& field, 307 const signin_internals_util::TimedSigninStatusField& field,
296 const std::string& value); 308 const std::string& value);
297 309
298 // Result of the last client login, kept pending the lookup of the 310 // Result of the last client login, kept pending the lookup of the
299 // canonical email. 311 // canonical email.
300 ClientLoginResult last_result_; 312 ClientLoginResult last_result_;
301 313
302 // Actual client login handler. 314 // Actual client login handler.
303 scoped_ptr<GaiaAuthFetcher> client_login_; 315 scoped_ptr<GaiaAuthFetcher> client_login_;
304 316
305 // Registrar for notifications from the TokenService. 317 // Registrar for notifications from the TokenService.
306 content::NotificationRegistrar registrar_; 318 content::NotificationRegistrar registrar_;
307 319
308 // UbertokenFetcher to login to user to the web property. 320 // UbertokenFetcher to login to user to the web property.
309 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_; 321 scoped_ptr<UbertokenFetcher> ubertoken_fetcher_;
310 322
311 // Helper object to listen for changes to signin preferences stored in non- 323 // Helper object to listen for changes to signin preferences stored in non-
312 // profile-specific local prefs (like kGoogleServicesUsernamePattern). 324 // profile-specific local prefs (like kGoogleServicesUsernamePattern).
313 PrefChangeRegistrar local_state_pref_registrar_; 325 PrefChangeRegistrar local_state_pref_registrar_;
314 326
327 // Helper object to listen for changes to the signin allowed preference.
328 BooleanPrefMember signin_allowed_;
329
315 // Actual username after successful authentication. 330 // Actual username after successful authentication.
316 std::string authenticated_username_; 331 std::string authenticated_username_;
317 332
318 // The type of sign being performed. This value is valid only between a call 333 // The type of sign being performed. This value is valid only between a call
319 // to one of the StartSigninXXX methods and when the sign in is either 334 // to one of the StartSigninXXX methods and when the sign in is either
320 // successful or not. 335 // successful or not.
321 SigninType type_; 336 SigninType type_;
322 337
323 // Temporarily saves the oauth2 refresh and access tokens when signing in 338 // Temporarily saves the oauth2 refresh and access tokens when signing in
324 // with credentials. These will be passed to TokenService so that it does 339 // with credentials. These will be passed to TokenService so that it does
(...skipping 10 matching lines...) Expand all
335 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS) 350 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS)
336 // CloudPolicyClient reference we keep while determining whether to create 351 // CloudPolicyClient reference we keep while determining whether to create
337 // a new profile for an enterprise user or not. 352 // a new profile for an enterprise user or not.
338 scoped_ptr<policy::CloudPolicyClient> policy_client_; 353 scoped_ptr<policy::CloudPolicyClient> policy_client_;
339 #endif 354 #endif
340 355
341 DISALLOW_COPY_AND_ASSIGN(SigninManager); 356 DISALLOW_COPY_AND_ASSIGN(SigninManager);
342 }; 357 };
343 358
344 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 359 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/signin/signin_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698