| 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. 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/prefs/public/pref_change_registrar.h" | 26 #include "base/prefs/public/pref_change_registrar.h" |
| 27 #include "base/prefs/public/pref_observer.h" |
| 27 #include "chrome/browser/profiles/profile_keyed_service.h" | 28 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 28 #include "content/public/browser/notification_observer.h" | 29 #include "content/public/browser/notification_observer.h" |
| 29 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
| 30 #include "google_apis/gaia/gaia_auth_consumer.h" | 31 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 31 #include "google_apis/gaia/google_service_auth_error.h" | 32 #include "google_apis/gaia/google_service_auth_error.h" |
| 32 | 33 |
| 33 class CookieSettings; | 34 class CookieSettings; |
| 34 class GaiaAuthFetcher; | 35 class GaiaAuthFetcher; |
| 35 class Profile; | 36 class Profile; |
| 36 class PrefService; | 37 class PrefService; |
| 37 | 38 |
| 38 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL. | 39 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL. |
| 39 // A listener might use this to make note of a username / password | 40 // A listener might use this to make note of a username / password |
| 40 // pair for encryption keys. | 41 // pair for encryption keys. |
| 41 struct GoogleServiceSigninSuccessDetails { | 42 struct GoogleServiceSigninSuccessDetails { |
| 42 GoogleServiceSigninSuccessDetails(const std::string& in_username, | 43 GoogleServiceSigninSuccessDetails(const std::string& in_username, |
| 43 const std::string& in_password) | 44 const std::string& in_password) |
| 44 : username(in_username), | 45 : username(in_username), |
| 45 password(in_password) {} | 46 password(in_password) {} |
| 46 std::string username; | 47 std::string username; |
| 47 std::string password; | 48 std::string password; |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 class SigninManager : public GaiaAuthConsumer, | 51 class SigninManager : public GaiaAuthConsumer, |
| 51 public content::NotificationObserver, | 52 public content::NotificationObserver, |
| 53 public PrefObserver, |
| 52 public ProfileKeyedService { | 54 public ProfileKeyedService { |
| 53 public: | 55 public: |
| 54 // Returns true if the cookie policy for the given profile allows cookies | 56 // Returns true if the cookie policy for the given profile allows cookies |
| 55 // for the Google signin domain. | 57 // for the Google signin domain. |
| 56 static bool AreSigninCookiesAllowed(Profile* profile); | 58 static bool AreSigninCookiesAllowed(Profile* profile); |
| 57 static bool AreSigninCookiesAllowed(CookieSettings* cookie_settings); | 59 static bool AreSigninCookiesAllowed(CookieSettings* cookie_settings); |
| 58 | 60 |
| 59 // Returns true if the username is allowed based on the policy string. | 61 // Returns true if the username is allowed based on the policy string. |
| 60 static bool IsAllowedUsername(const std::string& username, | 62 static bool IsAllowedUsername(const std::string& username, |
| 61 const std::string& policy); | 63 const std::string& policy); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const GoogleServiceAuthError& error) OVERRIDE; | 141 const GoogleServiceAuthError& error) OVERRIDE; |
| 140 virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE; | 142 virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE; |
| 141 virtual void OnGetUserInfoFailure( | 143 virtual void OnGetUserInfoFailure( |
| 142 const GoogleServiceAuthError& error) OVERRIDE; | 144 const GoogleServiceAuthError& error) OVERRIDE; |
| 143 | 145 |
| 144 // content::NotificationObserver | 146 // content::NotificationObserver |
| 145 virtual void Observe(int type, | 147 virtual void Observe(int type, |
| 146 const content::NotificationSource& source, | 148 const content::NotificationSource& source, |
| 147 const content::NotificationDetails& details) OVERRIDE; | 149 const content::NotificationDetails& details) OVERRIDE; |
| 148 | 150 |
| 151 // PrefObserver |
| 152 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 153 const std::string& pref_name) OVERRIDE; |
| 154 |
| 149 protected: | 155 protected: |
| 150 // Weak pointer to parent profile (protected so FakeSigninManager can access | 156 // Weak pointer to parent profile (protected so FakeSigninManager can access |
| 151 // it). | 157 // it). |
| 152 Profile* profile_; | 158 Profile* profile_; |
| 153 | 159 |
| 154 private: | 160 private: |
| 155 enum SigninType { | 161 enum SigninType { |
| 156 SIGNIN_TYPE_NONE, | 162 SIGNIN_TYPE_NONE, |
| 157 SIGNIN_TYPE_CLIENT_LOGIN, | 163 SIGNIN_TYPE_CLIENT_LOGIN, |
| 158 SIGNIN_TYPE_WITH_CREDENTIALS, | 164 SIGNIN_TYPE_WITH_CREDENTIALS, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 216 |
| 211 // The type of sign being performed. This value is valid only between a call | 217 // The type of sign being performed. This value is valid only between a call |
| 212 // to one of the StartSigninXXX methods and when the sign in is either | 218 // to one of the StartSigninXXX methods and when the sign in is either |
| 213 // successful or not. | 219 // successful or not. |
| 214 SigninType type_; | 220 SigninType type_; |
| 215 | 221 |
| 216 DISALLOW_COPY_AND_ASSIGN(SigninManager); | 222 DISALLOW_COPY_AND_ASSIGN(SigninManager); |
| 217 }; | 223 }; |
| 218 | 224 |
| 219 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ | 225 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ |
| OLD | NEW |