OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // AuthWatcher watches authentication events and user open and close | 5 // AuthWatcher watches authentication events and user open and close |
6 // events and accordingly opens and closes shares. | 6 // events and accordingly opens and closes shares. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 8 #ifndef CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
9 #define CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 9 #define CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return channel_.get(); | 104 return channel_.get(); |
105 } | 105 } |
106 | 106 |
107 // The following 3 flavors of authentication routines are asynchronous and can | 107 // The following 3 flavors of authentication routines are asynchronous and can |
108 // be called from any thread. | 108 // be called from any thread. |
109 // If |captcha_value| is specified but |captcha_token| is not, this will | 109 // If |captcha_value| is specified but |captcha_token| is not, this will |
110 // attempt authentication using the last observed captcha token out of | 110 // attempt authentication using the last observed captcha token out of |
111 // convenience in the common case so the token doesn't have to be plumbed | 111 // convenience in the common case so the token doesn't have to be plumbed |
112 // everywhere. | 112 // everywhere. |
113 void Authenticate(const std::string& email, const std::string& password, | 113 void Authenticate(const std::string& email, const std::string& password, |
114 const std::string& captcha_token, const std::string& captcha_value, | 114 const std::string& captcha_token, const std::string& captcha_value); |
115 bool persist_creds_to_disk); | |
116 | 115 |
117 void Authenticate(const std::string& email, const std::string& password, | 116 void Authenticate(const std::string& email, const std::string& password, |
118 bool persist_creds_to_disk) { | 117 bool persist_creds_to_disk) { |
119 Authenticate(email, password, "", "", persist_creds_to_disk); | 118 Authenticate(email, password, "", ""); |
120 } | 119 } |
121 | 120 |
122 // Use this to update only the token of the current email address. | 121 // Use this to update only the token of the current email address. |
123 void RenewAuthToken(const std::string& updated_token); | 122 void RenewAuthToken(const std::string& updated_token); |
124 void DoRenewAuthToken(const std::string& updated_token); | 123 void DoRenewAuthToken(const std::string& updated_token); |
125 | 124 |
126 // Use this version when you don't need the gaia authentication step because | 125 // Use this version when you don't need the gaia authentication step because |
127 // you already have a valid LSID cookie for |gaia_email|. | 126 // you already have a valid LSID cookie for |gaia_email|. |
128 void AuthenticateWithLsid(const std::string& lsid); | 127 void AuthenticateWithLsid(const std::string& lsid); |
129 | 128 |
(...skipping 13 matching lines...) Expand all Loading... |
143 UserSettings* settings() const { return user_settings_; } | 142 UserSettings* settings() const { return user_settings_; } |
144 Status status() const { return (Status)status_; } | 143 Status status() const { return (Status)status_; } |
145 | 144 |
146 protected: | 145 protected: |
147 void ClearAuthenticationData(); | 146 void ClearAuthenticationData(); |
148 | 147 |
149 void NotifyAuthSucceeded(const std::string& email); | 148 void NotifyAuthSucceeded(const std::string& email); |
150 void HandleServerConnectionEvent(const ServerConnectionEvent& event); | 149 void HandleServerConnectionEvent(const ServerConnectionEvent& event); |
151 | 150 |
152 void SaveUserSettings(const std::string& username, | 151 void SaveUserSettings(const std::string& username, |
153 const std::string& auth_token, | 152 const std::string& auth_token); |
154 const bool save_credentials); | |
155 | 153 |
156 MessageLoop* message_loop() { return auth_backend_thread_.message_loop(); } | 154 MessageLoop* message_loop() { return auth_backend_thread_.message_loop(); } |
157 | 155 |
158 private: | 156 private: |
159 // These two helpers should only be called from the auth function. | 157 // These two helpers should only be called from the auth function. |
160 // Called when authentication with gaia succeeds, to save credential info. | 158 // Called when authentication with gaia succeeds, to save credential info. |
161 void PersistCredentials(); | 159 void PersistCredentials(); |
162 // Called when authentication with gaia fails. | 160 // Called when authentication with gaia fails. |
163 void ProcessGaiaAuthFailure(); | 161 void ProcessGaiaAuthFailure(); |
164 | 162 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 216 |
219 base::Thread auth_backend_thread_; | 217 base::Thread auth_backend_thread_; |
220 | 218 |
221 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; | 219 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; |
222 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); | 220 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); |
223 }; | 221 }; |
224 | 222 |
225 } // namespace browser_sync | 223 } // namespace browser_sync |
226 | 224 |
227 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 225 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
OLD | NEW |