| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 bool LoadDirectoryListAndOpen(const PathString& login); | 99 bool LoadDirectoryListAndOpen(const PathString& login); |
| 100 | 100 |
| 101 typedef EventChannel<AuthWatcherEvent, Lock> Channel; | 101 typedef EventChannel<AuthWatcherEvent, Lock> Channel; |
| 102 | 102 |
| 103 inline Channel* channel() const { | 103 inline Channel* channel() const { |
| 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 |
| 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 |
| 112 // everywhere. |
| 109 void Authenticate(const std::string& email, const std::string& password, | 113 void Authenticate(const std::string& email, const std::string& password, |
| 110 const std::string& captcha_token, const std::string& captcha_value, | 114 const std::string& captcha_token, const std::string& captcha_value, |
| 111 bool persist_creds_to_disk); | 115 bool persist_creds_to_disk); |
| 112 | 116 |
| 113 void Authenticate(const std::string& email, const std::string& password, | 117 void Authenticate(const std::string& email, const std::string& password, |
| 114 bool persist_creds_to_disk) { | 118 bool persist_creds_to_disk) { |
| 115 Authenticate(email, password, "", "", persist_creds_to_disk); | 119 Authenticate(email, password, "", "", persist_creds_to_disk); |
| 116 } | 120 } |
| 117 | 121 |
| 118 // Use this version when you don't need the gaia authentication step because | 122 // Use this version when you don't need the gaia authentication step because |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 mail.push_back('@'); | 168 mail.push_back('@'); |
| 165 // TODO(chron): Should this be done only at the UI level? | 169 // TODO(chron): Should this be done only at the UI level? |
| 166 mail.append(DEFAULT_SIGNIN_DOMAIN); | 170 mail.append(DEFAULT_SIGNIN_DOMAIN); |
| 167 } | 171 } |
| 168 return mail; | 172 return mail; |
| 169 } | 173 } |
| 170 | 174 |
| 171 // A struct to marshal various data across to the auth_backend_thread_ on | 175 // A struct to marshal various data across to the auth_backend_thread_ on |
| 172 // Authenticate() and AuthenticateWithToken calls. | 176 // Authenticate() and AuthenticateWithToken calls. |
| 173 struct AuthRequest { | 177 struct AuthRequest { |
| 174 std::string email; | 178 std::string email; |
| 175 std::string password; | 179 std::string password; |
| 176 std::string auth_token; | 180 std::string auth_token; |
| 177 std::string captcha_token; | 181 std::string captcha_token; |
| 178 std::string captcha_value; | 182 std::string captcha_value; |
| 179 bool persist_creds_to_disk; | 183 bool persist_creds_to_disk; |
| 180 AuthWatcherEvent::AuthenticationTrigger trigger; | 184 AuthWatcherEvent::AuthenticationTrigger trigger; |
| 181 }; | 185 }; |
| 182 | 186 |
| 183 // The public interface Authenticate methods are proxies to these, which | 187 // The public interface Authenticate methods are proxies to these, which |
| 184 // can only be called from |auth_backend_thread_|. | 188 // can only be called from |auth_backend_thread_|. |
| 185 void DoAuthenticate(const AuthRequest& request); | 189 void DoAuthenticate(const AuthRequest& request); |
| 186 void DoAuthenticateWithToken(const std::string& email, | 190 void DoAuthenticateWithToken(const std::string& email, |
| 187 const std::string& auth_token); | 191 const std::string& auth_token); |
| 188 | 192 |
| 189 // The public HandleServerConnectionEvent method proxies to this method, which | 193 // The public HandleServerConnectionEvent method proxies to this method, which |
| 190 // can only be called on |auth_backend_thread_|. | 194 // can only be called on |auth_backend_thread_|. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 | 208 |
| 205 base::Thread auth_backend_thread_; | 209 base::Thread auth_backend_thread_; |
| 206 | 210 |
| 207 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; | 211 AuthWatcherEvent::AuthenticationTrigger current_attempt_trigger_; |
| 208 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); | 212 DISALLOW_COPY_AND_ASSIGN(AuthWatcher); |
| 209 }; | 213 }; |
| 210 | 214 |
| 211 } // namespace browser_sync | 215 } // namespace browser_sync |
| 212 | 216 |
| 213 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ | 217 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTH_WATCHER_H_ |
| OLD | NEW |