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

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

Issue 14630003: signin: move SigninManagerBase::Signout to SigninManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
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. 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 std::string username; 60 std::string username;
61 }; 61 };
62 62
63 class SigninManagerBase : public ProfileKeyedService { 63 class SigninManagerBase : public ProfileKeyedService {
64 public: 64 public:
65 // Returns true if the cookie policy for the given profile allows cookies 65 // Returns true if the cookie policy for the given profile allows cookies
66 // for the Google signin domain. 66 // for the Google signin domain.
67 static bool AreSigninCookiesAllowed(Profile* profile); 67 static bool AreSigninCookiesAllowed(Profile* profile);
68 static bool AreSigninCookiesAllowed(CookieSettings* cookie_settings); 68 static bool AreSigninCookiesAllowed(CookieSettings* cookie_settings);
69 69
70 // Returns true if the username is allowed based on the policy string.
71 static bool IsAllowedUsername(const std::string& username,
72 const std::string& policy);
73
74 SigninManagerBase(); 70 SigninManagerBase();
75 virtual ~SigninManagerBase(); 71 virtual ~SigninManagerBase();
76 72
77 // If user was signed in, load tokens from DB if available. 73 // If user was signed in, load tokens from DB if available.
78 void Initialize(Profile* profile); 74 virtual void Initialize(Profile* profile);
79 bool IsInitialized() const; 75 bool IsInitialized() const;
80 76
81 // Returns true if the passed username is allowed by policy. Virtual for
82 // mocking in tests.
83 virtual bool IsAllowedUsername(const std::string& username) const;
84
85 // Returns true if a signin to Chrome is allowed (by policy or pref). 77 // Returns true if a signin to Chrome is allowed (by policy or pref).
86 bool IsSigninAllowed() const; 78 // TODO(tim): If the kSigninAllowed pref was non-Chrome OS-only, this
Andrew T Wilson (Slow) 2013/05/06 09:06:00 I'm confused by this comment. I believe that kSign
tim (not reviewing) 2013/05/06 17:28:57 Done. Using bug 174927.
87 79 // method wouldn't be needed, but as is we provide this method to let all
88 // Checks if signin is allowed for the profile that owns |io_data|. This must 80 // interested code query the value in one way, versus half using PrefService
89 // be invoked on the IO thread, and can be used to check if signin is enabled 81 // directly and the other half using SigninManager.
90 // on that thread. 82 virtual bool IsSigninAllowed() const;
91 static bool IsSigninAllowedOnIOThread(ProfileIOData* io_data);
92 83
93 // If a user has previously established a username and SignOut has not been 84 // If a user has previously established a username and SignOut has not been
94 // called, this will return the username. 85 // called, this will return the username.
95 // Otherwise, it will return an empty string. 86 // Otherwise, it will return an empty string.
96 const std::string& GetAuthenticatedUsername() const; 87 const std::string& GetAuthenticatedUsername() const;
97 88
98 // Sets the user name. Note: |username| should be already authenticated as 89 // Sets the user name. Note: |username| should be already authenticated as
99 // this is a sticky operation (in contrast to StartSignIn). 90 // this is a sticky operation (in contrast to StartSignIn).
100 // TODO(tim): Remove this in favor of passing username on construction by 91 // TODO(tim): Remove this in favor of passing username on construction by
101 // (by platform / depending on StartBehavior). Bug 88109. 92 // (by platform / depending on StartBehavior). Bug 88109.
102 void SetAuthenticatedUsername(const std::string& username); 93 void SetAuthenticatedUsername(const std::string& username);
103 94
104 // Sign a user out, removing the preference, erasing all keys
105 // associated with the user, and canceling all auth in progress.
106 // TODO(tim): Remove SignOut here, it belongs in the derived class.
107 // Bug 174927.
108 virtual void SignOut();
109
110 // Returns true if there's a signin in progress. 95 // Returns true if there's a signin in progress.
111 virtual bool AuthInProgress() const; 96 virtual bool AuthInProgress() const;
112 97
113 SigninGlobalError* signin_global_error() { 98 SigninGlobalError* signin_global_error() {
114 return signin_global_error_.get(); 99 return signin_global_error_.get();
115 } 100 }
116 101
117 const SigninGlobalError* signin_global_error() const { 102 const SigninGlobalError* signin_global_error() const {
118 return signin_global_error_.get(); 103 return signin_global_error_.get();
119 } 104 }
120 105
121 // ProfileKeyedService implementation. 106 // ProfileKeyedService implementation.
122 virtual void Shutdown() OVERRIDE; 107 virtual void Shutdown() OVERRIDE;
123 108
124 // Methods to register or remove SigninDiagnosticObservers 109 // Methods to register or remove SigninDiagnosticObservers
125 void AddSigninDiagnosticsObserver( 110 void AddSigninDiagnosticsObserver(
126 signin_internals_util::SigninDiagnosticsObserver* observer); 111 signin_internals_util::SigninDiagnosticsObserver* observer);
127 void RemoveSigninDiagnosticsObserver( 112 void RemoveSigninDiagnosticsObserver(
128 signin_internals_util::SigninDiagnosticsObserver* observer); 113 signin_internals_util::SigninDiagnosticsObserver* observer);
129 114
130 protected: 115 protected:
131 // Lets different platforms initialize TokenService in their own way. 116 // Lets different platforms initialize TokenService in their own way.
132 virtual void InitTokenService(); 117 virtual void InitTokenService();
133 118
119 void clear_authenticated_username();
Andrew T Wilson (Slow) 2013/05/06 09:06:00 Should document here why one would call this and n
tim (not reviewing) 2013/05/06 17:28:57 Done.
120
134 // Pointer to parent profile (protected so FakeSigninManager can access 121 // Pointer to parent profile (protected so FakeSigninManager can access
135 // it). 122 // it).
136 Profile* profile_; 123 Profile* profile_;
137 124
138 // Used to show auth errors in the wrench menu. The SigninGlobalError is 125 // Used to show auth errors in the wrench menu. The SigninGlobalError is
139 // different than most GlobalErrors in that its lifetime is controlled by 126 // different than most GlobalErrors in that its lifetime is controlled by
140 // SigninManager (so we can expose a reference for use in the wrench menu). 127 // SigninManager (so we can expose a reference for use in the wrench menu).
141 scoped_ptr<SigninGlobalError> signin_global_error_; 128 scoped_ptr<SigninGlobalError> signin_global_error_;
142 129
143 // Helper methods to notify all registered diagnostics observers with. 130 // Helper methods to notify all registered diagnostics observers with.
144 void NotifyDiagnosticsObservers( 131 void NotifyDiagnosticsObservers(
145 const signin_internals_util::UntimedSigninStatusField& field, 132 const signin_internals_util::UntimedSigninStatusField& field,
146 const std::string& value); 133 const std::string& value);
147 void NotifyDiagnosticsObservers( 134 void NotifyDiagnosticsObservers(
148 const signin_internals_util::TimedSigninStatusField& field, 135 const signin_internals_util::TimedSigninStatusField& field,
149 const std::string& value); 136 const std::string& value);
150 137
151 private: 138 private:
152 friend class FakeSigninManagerBase; 139 friend class FakeSigninManagerBase;
153 friend class FakeSigninManager; 140 friend class FakeSigninManager;
154 void OnGoogleServicesUsernamePatternChanged();
155
156 void OnSigninAllowedPrefChanged();
157
158 // Helper object to listen for changes to signin preferences stored in non-
159 // profile-specific local prefs (like kGoogleServicesUsernamePattern).
160 PrefChangeRegistrar local_state_pref_registrar_;
161
162 // Helper object to listen for changes to the signin allowed preference.
163 BooleanPrefMember signin_allowed_;
164 141
165 // Actual username after successful authentication. 142 // Actual username after successful authentication.
166 std::string authenticated_username_; 143 std::string authenticated_username_;
167 144
168 // The list of SigninDiagnosticObservers. 145 // The list of SigninDiagnosticObservers.
169 ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> 146 ObserverList<signin_internals_util::SigninDiagnosticsObserver, true>
170 signin_diagnostics_observers_; 147 signin_diagnostics_observers_;
171 148
172 base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; 149 base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_;
173 150
174 DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); 151 DISALLOW_COPY_AND_ASSIGN(SigninManagerBase);
175 }; 152 };
176 153
177 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_BASE_H_ 154 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698