| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Use this class to authenticate users with Gaia and access cookies sent | 5 // Use this class to authenticate users with Gaia and access cookies sent |
| 6 // by the Gaia servers. This class cannot be used on its own becaue it relies | 6 // by the Gaia servers. This class cannot be used on its own becaue it relies |
| 7 // on a subclass to provide the virtual Post and GetBackoffDelaySeconds methods. | 7 // on a subclass to provide the virtual Post and GetBackoffDelaySeconds methods. |
| 8 // | 8 // |
| 9 // Sample usage: | 9 // Sample usage: |
| 10 // class ActualGaiaAuthenticator : public gaia::GaiaAuthenticator { | 10 // class ActualGaiaAuthenticator : public gaia::GaiaAuthenticator { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const std::string& captcha_value); | 173 const std::string& captcha_value); |
| 174 | 174 |
| 175 // The real Authenticate implementations. | 175 // The real Authenticate implementations. |
| 176 bool AuthenticateImpl(const AuthParams& params); | 176 bool AuthenticateImpl(const AuthParams& params); |
| 177 bool AuthenticateImpl(const AuthParams& params, AuthResults* results); | 177 bool AuthenticateImpl(const AuthParams& params, AuthResults* results); |
| 178 | 178 |
| 179 // virtual for testing purposes. | 179 // virtual for testing purposes. |
| 180 virtual bool PerformGaiaRequest(const AuthParams& params, | 180 virtual bool PerformGaiaRequest(const AuthParams& params, |
| 181 AuthResults* results); | 181 AuthResults* results); |
| 182 virtual bool Post(const GURL& url, const std::string& post_body, | 182 virtual bool Post(const GURL& url, const std::string& post_body, |
| 183 unsigned long* response_code, std::string* response_body) { | 183 unsigned long* response_code, std::string* response_body); |
| 184 return false; | |
| 185 } | |
| 186 | 184 |
| 187 // Caller should fill in results->LSID before calling. Result in | 185 // Caller should fill in results->LSID before calling. Result in |
| 188 // results->primary_email. | 186 // results->primary_email. |
| 189 virtual bool LookupEmail(AuthResults* results); | 187 virtual bool LookupEmail(AuthResults* results); |
| 190 | 188 |
| 191 // Subclasses must override to provide a backoff delay. It is virtual instead | 189 // Subclasses must override to provide a backoff delay. It is virtual instead |
| 192 // of pure virtual for testing purposes. | 190 // of pure virtual for testing purposes. |
| 193 // TODO(sanjeevr): This should be made pure virtual. But this class is | 191 // TODO(sanjeevr): This should be made pure virtual. But this class is |
| 194 // currently directly being used in sync/engine/authenticator.cc, which is | 192 // currently directly being used in sync/engine/authenticator.cc, which is |
| 195 // wrong. | 193 // wrong. |
| 196 virtual int GetBackoffDelaySeconds(int current_backoff_delay) { | 194 virtual int GetBackoffDelaySeconds(int current_backoff_delay); |
| 197 NOTREACHED(); | |
| 198 return current_backoff_delay; | |
| 199 } | |
| 200 | 195 |
| 201 public: | 196 public: |
| 202 // Retrieve email. | 197 // Retrieve email. |
| 203 inline std::string email() const { | 198 inline std::string email() const { |
| 204 DCHECK_EQ(MessageLoop::current(), message_loop_); | 199 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 205 return auth_results_.email; | 200 return auth_results_.email; |
| 206 } | 201 } |
| 207 | 202 |
| 208 // Retrieve password. | 203 // Retrieve password. |
| 209 inline std::string password() const { | 204 inline std::string password() const { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 #endif // defined(OS_WIN) | 294 #endif // defined(OS_WIN) |
| 300 int early_auth_attempt_count_; | 295 int early_auth_attempt_count_; |
| 301 | 296 |
| 302 // The message loop all our methods are invoked on. | 297 // The message loop all our methods are invoked on. |
| 303 const MessageLoop* message_loop_; | 298 const MessageLoop* message_loop_; |
| 304 }; | 299 }; |
| 305 | 300 |
| 306 } // namespace gaia | 301 } // namespace gaia |
| 307 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR_H_ | 302 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR_H_ |
| 308 | 303 |
| OLD | NEW |