Chromium Code Reviews| 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. | 6 // which user is signed in. |
| 7 // | 7 // |
| 8 // **NOTE** on semantics of SigninManager: | 8 // **NOTE** on semantics of SigninManager: |
| 9 // | 9 // |
| 10 // Once a signin is successful, the username becomes "established" and will not | 10 // Once a signin is successful, the username becomes "established" and will not |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 // TODO(tim): kSigninAllowed is defined for all platforms in pref_names.h. | 71 // TODO(tim): kSigninAllowed is defined for all platforms in pref_names.h. |
| 72 // If kSigninAllowed pref was non-Chrome OS-only, this method wouldn't be | 72 // If kSigninAllowed pref was non-Chrome OS-only, this method wouldn't be |
| 73 // needed, but as is we provide this method to let all interested code | 73 // needed, but as is we provide this method to let all interested code |
| 74 // code query the value in one way, versus half using PrefService directly | 74 // code query the value in one way, versus half using PrefService directly |
| 75 // and the other half using SigninManager. | 75 // and the other half using SigninManager. |
| 76 virtual bool IsSigninAllowed() const; | 76 virtual bool IsSigninAllowed() const; |
| 77 | 77 |
| 78 // If a user has previously signed in (and has not signed out), this returns | 78 // If a user has previously signed in (and has not signed out), this returns |
| 79 // the normalized email address of the account. Otherwise, it returns an empty | 79 // the normalized email address of the account. Otherwise, it returns an empty |
| 80 // string. | 80 // string. |
| 81 const std::string& GetAuthenticatedUsername() const; | 81 std::string GetAuthenticatedUsername() const; |
|
msarda
2014/10/02 08:48:06
I think this should still return const std::string
Roger Tawa OOO till Jul 10th
2014/10/02 20:31:18
Done.
| |
| 82 | 82 |
| 83 // If a user has previously signed in (and has not signed out), this returns | 83 // If a user has previously signed in (and has not signed out), this returns |
| 84 // the account id. Otherwise, it returns an empty string. This id can be used | 84 // the account id. Otherwise, it returns an empty string. This id can be used |
| 85 // to uniquely identify an account, so for example can be used as a key to | 85 // to uniquely identify an account, so for example can be used as a key to |
| 86 // map accounts to data. | 86 // map accounts to data. |
| 87 // | 87 // |
| 88 // TODO(rogerta): eventually the account id should be an obfuscated gaia id. | 88 // TODO(rogerta): eventually the account id should be an obfuscated gaia id. |
| 89 // For now though, this function returns the same value as | 89 // For now though, this function returns the same value as |
| 90 // GetAuthenticatedUsername() since lots of code assumes the unique id for an | 90 // GetAuthenticatedUsername() since lots of code assumes the unique id for an |
| 91 // account is the username. For code that needs a unique id to represent the | 91 // account is the username. For code that needs a unique id to represent the |
| 92 // connected account, call this method. Example: the AccountInfoMap type | 92 // connected account, call this method. Example: the AccountInfoMap type |
| 93 // in MutableProfileOAuth2TokenService. For code that needs to know the | 93 // in MutableProfileOAuth2TokenService. For code that needs to know the |
| 94 // normalized email address of the connected account, use | 94 // normalized email address of the connected account, use |
| 95 // GetAuthenticatedUsername(). Example: to show the string "Signed in as XXX" | 95 // GetAuthenticatedUsername(). Example: to show the string "Signed in as XXX" |
| 96 // in the hotdog menu. | 96 // in the hotdog menu. |
| 97 const std::string& GetAuthenticatedAccountId() const; | 97 std::string GetAuthenticatedAccountId() const; |
|
msarda
2014/10/02 08:48:06
I think this should still return const std::string
Roger Tawa OOO till Jul 10th
2014/10/02 20:31:17
Done.
| |
| 98 | 98 |
| 99 // Sets the user name. Note: |username| should be already authenticated as | 99 // Sets the user name. Note: |username| should be already authenticated as |
| 100 // this is a sticky operation (in contrast to StartSignIn). | 100 // this is a sticky operation (in contrast to StartSignIn). |
| 101 // TODO(tim): Remove this in favor of passing username on construction by | 101 // TODO(tim): Remove this in favor of passing username on construction by |
| 102 // (by platform / depending on StartBehavior). Bug 88109. | 102 // (by platform / depending on StartBehavior). Bug 88109. |
| 103 void SetAuthenticatedUsername(const std::string& username); | 103 void SetAuthenticatedUsername(const std::string& username); |
| 104 | 104 |
| 105 // Returns true if there is an authenticated user. | 105 // Returns true if there is an authenticated user. |
| 106 bool IsAuthenticated() const; | 106 bool IsAuthenticated() const; |
| 107 | 107 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 118 // Methods to register or remove SigninDiagnosticObservers. | 118 // Methods to register or remove SigninDiagnosticObservers. |
| 119 void AddSigninDiagnosticsObserver( | 119 void AddSigninDiagnosticsObserver( |
| 120 signin_internals_util::SigninDiagnosticsObserver* observer); | 120 signin_internals_util::SigninDiagnosticsObserver* observer); |
| 121 void RemoveSigninDiagnosticsObserver( | 121 void RemoveSigninDiagnosticsObserver( |
| 122 signin_internals_util::SigninDiagnosticsObserver* observer); | 122 signin_internals_util::SigninDiagnosticsObserver* observer); |
| 123 | 123 |
| 124 protected: | 124 protected: |
| 125 // Used by subclass to clear authenticated_username_ instead of using | 125 // Used by subclass to clear authenticated_username_ instead of using |
| 126 // SetAuthenticatedUsername, which enforces special preconditions due | 126 // SetAuthenticatedUsername, which enforces special preconditions due |
| 127 // to the fact that it is part of the public API and called by clients. | 127 // to the fact that it is part of the public API and called by clients. |
| 128 void clear_authenticated_username(); | 128 void ClearAuthenticatedUsername(); |
| 129 | 129 |
| 130 // List of observers to notify on signin events. | 130 // List of observers to notify on signin events. |
| 131 // Makes sure list is empty on destruction. | 131 // Makes sure list is empty on destruction. |
| 132 ObserverList<Observer, true> observer_list_; | 132 ObserverList<Observer, true> observer_list_; |
| 133 | 133 |
| 134 // Helper methods to notify all registered diagnostics observers with. | 134 // Helper methods to notify all registered diagnostics observers with. |
| 135 void NotifyDiagnosticsObservers( | 135 void NotifyDiagnosticsObservers( |
| 136 const signin_internals_util::UntimedSigninStatusField& field, | 136 const signin_internals_util::UntimedSigninStatusField& field, |
| 137 const std::string& value); | 137 const std::string& value); |
| 138 void NotifyDiagnosticsObservers( | 138 void NotifyDiagnosticsObservers( |
| 139 const signin_internals_util::TimedSigninStatusField& field, | 139 const signin_internals_util::TimedSigninStatusField& field, |
| 140 const std::string& value); | 140 const std::string& value); |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 friend class FakeSigninManagerBase; | 143 friend class FakeSigninManagerBase; |
| 144 friend class FakeSigninManager; | 144 friend class FakeSigninManager; |
| 145 | 145 |
| 146 SigninClient* client_; | 146 SigninClient* client_; |
| 147 bool initialized_; | 147 bool initialized_; |
| 148 | 148 |
| 149 // Actual username after successful authentication. | 149 // Actual username and account_id after successful authentication. |
| 150 std::string authenticated_username_; | 150 std::string authenticated_username_; |
| 151 std::string authenticated_account_id_; | |
| 151 | 152 |
| 152 // The list of SigninDiagnosticObservers. | 153 // The list of SigninDiagnosticObservers. |
| 153 ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> | 154 ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> |
| 154 signin_diagnostics_observers_; | 155 signin_diagnostics_observers_; |
| 155 | 156 |
| 156 base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; | 157 base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; |
| 157 | 158 |
| 158 DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); | 159 DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_BASE_H_ | 162 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_BASE_H_ |
| OLD | NEW |