| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ | 5 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ |
| 6 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ | 6 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 class GoogleServiceAuthError; | 11 class GoogleServiceAuthError; |
| 12 | 12 |
| 13 // An interface that defines the callbacks for objects that | 13 // An interface that defines the callbacks for objects that |
| 14 // GaiaAuthFetcher can return data to. | 14 // GaiaAuthFetcher can return data to. |
| 15 class GaiaAuthConsumer { | 15 class GaiaAuthConsumer { |
| 16 public: | 16 public: |
| 17 struct ClientLoginResult { | 17 struct ClientLoginResult { |
| 18 inline ClientLoginResult() {} | 18 inline ClientLoginResult() : two_factor(false) {} |
| 19 inline ClientLoginResult(const std::string& new_sid, | 19 inline ClientLoginResult(const std::string& new_sid, |
| 20 const std::string& new_lsid, | 20 const std::string& new_lsid, |
| 21 const std::string& new_token, | 21 const std::string& new_token, |
| 22 const std::string& new_data) | 22 const std::string& new_data) |
| 23 : sid(new_sid), | 23 : sid(new_sid), |
| 24 lsid(new_lsid), | 24 lsid(new_lsid), |
| 25 token(new_token), | 25 token(new_token), |
| 26 data(new_data) {} | 26 data(new_data), |
| 27 two_factor(false) {} |
| 27 | 28 |
| 28 inline bool operator==(const ClientLoginResult &b) const { | 29 inline bool operator==(const ClientLoginResult &b) const { |
| 29 return sid == b.sid && | 30 return sid == b.sid && |
| 30 lsid == b.lsid && | 31 lsid == b.lsid && |
| 31 token == b.token && | 32 token == b.token && |
| 32 data == b.data; | 33 data == b.data && |
| 34 two_factor == b.two_factor; |
| 33 } | 35 } |
| 34 | 36 |
| 35 std::string sid; | 37 std::string sid; |
| 36 std::string lsid; | 38 std::string lsid; |
| 37 std::string token; | 39 std::string token; |
| 38 // TODO(chron): Remove the data field later. Don't use it if possible. | 40 // TODO(chron): Remove the data field later. Don't use it if possible. |
| 39 std::string data; // Full contents of ClientLogin return. | 41 std::string data; // Full contents of ClientLogin return. |
| 42 bool two_factor; // set to true if there was a TWO_FACTOR "failure". |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 virtual ~GaiaAuthConsumer() {} | 45 virtual ~GaiaAuthConsumer() {} |
| 43 | 46 |
| 44 virtual void OnClientLoginSuccess(const ClientLoginResult& result) {} | 47 virtual void OnClientLoginSuccess(const ClientLoginResult& result) {} |
| 45 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error) {} | 48 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error) {} |
| 46 | 49 |
| 47 virtual void OnIssueAuthTokenSuccess(const std::string& service, | 50 virtual void OnIssueAuthTokenSuccess(const std::string& service, |
| 48 const std::string& auth_token) {} | 51 const std::string& auth_token) {} |
| 49 virtual void OnIssueAuthTokenFailure(const std::string& service, | 52 virtual void OnIssueAuthTokenFailure(const std::string& service, |
| 50 const GoogleServiceAuthError& error) {} | 53 const GoogleServiceAuthError& error) {} |
| 51 | 54 |
| 52 virtual void OnGetUserInfoSuccess(const std::string& key, | 55 virtual void OnGetUserInfoSuccess(const std::string& key, |
| 53 const std::string& value) {} | 56 const std::string& value) {} |
| 54 virtual void OnGetUserInfoKeyNotFound(const std::string& key) {} | 57 virtual void OnGetUserInfoKeyNotFound(const std::string& key) {} |
| 55 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) {} | 58 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) {} |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ | 61 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ |
| OLD | NEW |