OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 static bool IsWebBasedSigninFlowURL(const GURL& url); | 57 static bool IsWebBasedSigninFlowURL(const GURL& url); |
58 | 58 |
59 // This is used to distinguish URLs belonging to the special web signin flow | 59 // This is used to distinguish URLs belonging to the special web signin flow |
60 // running in the special signin process from other URLs on the same domain. | 60 // running in the special signin process from other URLs on the same domain. |
61 // We do not grant WebUI privilieges / bindings to this process or to URLs of | 61 // We do not grant WebUI privilieges / bindings to this process or to URLs of |
62 // this scheme; enforcement of privileges is handled separately by | 62 // this scheme; enforcement of privileges is handled separately by |
63 // OneClickSigninHelper. | 63 // OneClickSigninHelper. |
64 static const char kChromeSigninEffectiveSite[]; | 64 static const char kChromeSigninEffectiveSite[]; |
65 | 65 |
66 SigninManager(SigninClient* client, ProfileOAuth2TokenService* token_service); | 66 SigninManager(SigninClient* client, ProfileOAuth2TokenService* token_service); |
67 virtual ~SigninManager(); | 67 ~SigninManager() override; |
68 | 68 |
69 // Returns true if the username is allowed based on the policy string. | 69 // Returns true if the username is allowed based on the policy string. |
70 static bool IsUsernameAllowedByPolicy(const std::string& username, | 70 static bool IsUsernameAllowedByPolicy(const std::string& username, |
71 const std::string& policy); | 71 const std::string& policy); |
72 | 72 |
73 // Attempt to sign in this user with a refresh token. | 73 // Attempt to sign in this user with a refresh token. |
74 // If non-null, the passed |oauth_fetched_callback| callback is invoked once | 74 // If non-null, the passed |oauth_fetched_callback| callback is invoked once |
75 // signin has been completed. | 75 // signin has been completed. |
76 // The callback should invoke SignOut() or CompletePendingSignin() to either | 76 // The callback should invoke SignOut() or CompletePendingSignin() to either |
77 // continue or cancel the in-process signin. | 77 // continue or cancel the in-process signin. |
78 virtual void StartSignInWithRefreshToken( | 78 virtual void StartSignInWithRefreshToken( |
79 const std::string& refresh_token, | 79 const std::string& refresh_token, |
80 const std::string& username, | 80 const std::string& username, |
81 const std::string& password, | 81 const std::string& password, |
82 const OAuthTokenFetchedCallback& oauth_fetched_callback); | 82 const OAuthTokenFetchedCallback& oauth_fetched_callback); |
83 | 83 |
84 // Copies auth credentials from one SigninManager to this one. This is used | 84 // Copies auth credentials from one SigninManager to this one. This is used |
85 // when creating a new profile during the signin process to transfer the | 85 // when creating a new profile during the signin process to transfer the |
86 // in-progress credentials to the new profile. | 86 // in-progress credentials to the new profile. |
87 virtual void CopyCredentialsFrom(const SigninManager& source); | 87 virtual void CopyCredentialsFrom(const SigninManager& source); |
88 | 88 |
89 // Sign a user out, removing the preference, erasing all keys | 89 // Sign a user out, removing the preference, erasing all keys |
90 // associated with the user, and canceling all auth in progress. | 90 // associated with the user, and canceling all auth in progress. |
91 virtual void SignOut(signin_metrics::ProfileSignout signout_source_metric); | 91 virtual void SignOut(signin_metrics::ProfileSignout signout_source_metric); |
92 | 92 |
93 // On platforms where SigninManager is responsible for dealing with | 93 // On platforms where SigninManager is responsible for dealing with |
94 // invalid username policy updates, we need to check this during | 94 // invalid username policy updates, we need to check this during |
95 // initialization and sign the user out. | 95 // initialization and sign the user out. |
96 virtual void Initialize(PrefService* local_state) override; | 96 void Initialize(PrefService* local_state) override; |
97 virtual void Shutdown() override; | 97 void Shutdown() override; |
98 | 98 |
99 // Invoked from an OAuthTokenFetchedCallback to complete user signin. | 99 // Invoked from an OAuthTokenFetchedCallback to complete user signin. |
100 virtual void CompletePendingSignin(); | 100 virtual void CompletePendingSignin(); |
101 | 101 |
102 // Invoked from SigninManagerAndroid to indicate that the sign-in process | 102 // Invoked from SigninManagerAndroid to indicate that the sign-in process |
103 // has completed for |username|. | 103 // has completed for |username|. |
104 void OnExternalSigninCompleted(const std::string& username); | 104 void OnExternalSigninCompleted(const std::string& username); |
105 | 105 |
106 // Returns true if there's a signin in progress. | 106 // Returns true if there's a signin in progress. |
107 virtual bool AuthInProgress() const override; | 107 bool AuthInProgress() const override; |
108 | 108 |
109 virtual bool IsSigninAllowed() const override; | 109 bool IsSigninAllowed() const override; |
110 | 110 |
111 // Returns true if the passed username is allowed by policy. Virtual for | 111 // Returns true if the passed username is allowed by policy. Virtual for |
112 // mocking in tests. | 112 // mocking in tests. |
113 virtual bool IsAllowedUsername(const std::string& username) const; | 113 virtual bool IsAllowedUsername(const std::string& username) const; |
114 | 114 |
115 // If an authentication is in progress, return the username being | 115 // If an authentication is in progress, return the username being |
116 // authenticated. Returns an empty string if no auth is in progress. | 116 // authenticated. Returns an empty string if no auth is in progress. |
117 const std::string& GetUsernameForAuthInProgress() const; | 117 const std::string& GetUsernameForAuthInProgress() const; |
118 | 118 |
119 // Set the preference to turn off one-click sign-in so that it won't ever | 119 // Set the preference to turn off one-click sign-in so that it won't ever |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 scoped_ptr<MergeSessionHelper> merge_session_helper_; | 210 scoped_ptr<MergeSessionHelper> merge_session_helper_; |
211 | 211 |
212 base::WeakPtrFactory<SigninManager> weak_pointer_factory_; | 212 base::WeakPtrFactory<SigninManager> weak_pointer_factory_; |
213 | 213 |
214 DISALLOW_COPY_AND_ASSIGN(SigninManager); | 214 DISALLOW_COPY_AND_ASSIGN(SigninManager); |
215 }; | 215 }; |
216 | 216 |
217 #endif // !defined(OS_CHROMEOS) | 217 #endif // !defined(OS_CHROMEOS) |
218 | 218 |
219 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_H_ | 219 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_H_ |
OLD | NEW |