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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 // An interface that defines the callbacks for objects that | 10 // An interface that defines the callbacks for objects that |
(...skipping 18 matching lines...) Expand all Loading... |
29 data == b.data; | 29 data == b.data; |
30 } | 30 } |
31 | 31 |
32 std::string sid; | 32 std::string sid; |
33 std::string lsid; | 33 std::string lsid; |
34 std::string token; | 34 std::string token; |
35 // TODO(chron): Remove the data field later. Don't use it if possible. | 35 // TODO(chron): Remove the data field later. Don't use it if possible. |
36 std::string data; // Full contents of ClientLogin return. | 36 std::string data; // Full contents of ClientLogin return. |
37 }; | 37 }; |
38 | 38 |
39 enum ClientLoginErrorCode { | 39 enum GaiaAuthErrorCode { |
40 NETWORK_ERROR, | 40 NETWORK_ERROR, |
41 REQUEST_CANCELED, | 41 REQUEST_CANCELED, |
42 TWO_FACTOR, // Callers can treat this as a success. | 42 TWO_FACTOR, // Callers can treat this as a success. |
43 PERMISSION_DENIED | 43 PERMISSION_DENIED |
44 }; | 44 }; |
45 | 45 |
46 struct ClientLoginError { | 46 struct GaiaAuthError { |
47 inline bool operator==(const ClientLoginError &b) const { | 47 inline bool operator==(const GaiaAuthError &b) const { |
48 if (code != b.code) { | 48 if (code != b.code) { |
49 return false; | 49 return false; |
50 } | 50 } |
51 if (code == NETWORK_ERROR) { | 51 if (code == NETWORK_ERROR) { |
52 return network_error == b.network_error; | 52 return network_error == b.network_error; |
53 } | 53 } |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 ClientLoginErrorCode code; | 57 GaiaAuthErrorCode code; |
58 int network_error; // This field is only valid if NETWORK_ERROR occured. | 58 int network_error; // This field is only valid if NETWORK_ERROR occured. |
59 std::string data; // TODO(chron): Remove this field. Should preparse data. | 59 std::string data; // TODO(chron): Remove this field. Should preparse data. |
60 }; | 60 }; |
61 | 61 |
62 virtual ~GaiaAuthConsumer() {} | 62 virtual ~GaiaAuthConsumer() {} |
63 virtual void OnClientLoginFailure(const ClientLoginError& error) = 0; | 63 |
64 virtual void OnClientLoginSuccess(const ClientLoginResult& result) = 0; | 64 virtual void OnClientLoginSuccess(const ClientLoginResult& result) {} |
| 65 virtual void OnClientLoginFailure(const GaiaAuthError& error) {} |
| 66 |
| 67 virtual void OnIssueAuthTokenSuccess(const std::string& service, |
| 68 const std::string& auth_token) {} |
| 69 virtual void OnIssueAuthTokenFailure(const std::string& service, |
| 70 const GaiaAuthError& error) {} |
65 }; | 71 }; |
66 | 72 |
67 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ | 73 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_CONSUMER_H_ |
OLD | NEW |