OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 | 13 |
14 namespace signin_internals_util { | 14 namespace signin_internals_util { |
15 | 15 |
16 // Preference prefixes for signin and token values. | 16 // Preference prefixes for signin and token values. |
17 extern const char kSigninPrefPrefix[]; | 17 extern const char kSigninPrefPrefix[]; |
18 extern const char kTokenPrefPrefix[]; | 18 extern const char kTokenPrefPrefix[]; |
19 | 19 |
20 // The length of strings returned by GetTruncatedHash() below. | 20 // The length of strings returned by GetTruncatedHash() below. |
21 const size_t kTruncateTokenStringLength = 6; | 21 const size_t kTruncateTokenStringLength = 6; |
22 | 22 |
23 // Helper enums to access fields from SigninStatus (declared below). | 23 // Helper enums to access fields from SigninStatus (declared below). |
24 enum { | 24 enum { |
25 SIGNIN_FIELDS_BEGIN = 0, | 25 SIGNIN_FIELDS_BEGIN = 0, |
26 UNTIMED_FIELDS_BEGIN = SIGNIN_FIELDS_BEGIN | 26 UNTIMED_FIELDS_BEGIN = SIGNIN_FIELDS_BEGIN |
27 }; | 27 }; |
28 | 28 |
29 enum UntimedSigninStatusField { | 29 enum UntimedSigninStatusField { |
30 USERNAME = UNTIMED_FIELDS_BEGIN, | 30 ACCOUNT_ID = UNTIMED_FIELDS_BEGIN, |
| 31 GAIA_ID, |
| 32 USERNAME, |
31 UNTIMED_FIELDS_END | 33 UNTIMED_FIELDS_END |
32 }; | 34 }; |
33 | 35 |
34 enum { | 36 enum { |
35 UNTIMED_FIELDS_COUNT = UNTIMED_FIELDS_END - UNTIMED_FIELDS_BEGIN, | 37 UNTIMED_FIELDS_COUNT = UNTIMED_FIELDS_END - UNTIMED_FIELDS_BEGIN, |
36 TIMED_FIELDS_BEGIN = UNTIMED_FIELDS_END | 38 TIMED_FIELDS_BEGIN = UNTIMED_FIELDS_END |
37 }; | 39 }; |
38 | 40 |
39 enum TimedSigninStatusField { | 41 enum TimedSigninStatusField { |
40 SIGNIN_TYPE = TIMED_FIELDS_BEGIN, | 42 AUTHENTICATION_RESULT_RECEIVED = TIMED_FIELDS_BEGIN, |
41 AUTHENTICATION_RESULT_RECEIVED, | |
42 REFRESH_TOKEN_RECEIVED, | 43 REFRESH_TOKEN_RECEIVED, |
43 GET_USER_INFO_STATUS, | 44 SIGNIN_STARTED, |
44 UBER_TOKEN_STATUS, | 45 SIGNIN_COMPLETED, |
45 MERGE_SESSION_STATUS, | |
46 TIMED_FIELDS_END | 46 TIMED_FIELDS_END |
47 }; | 47 }; |
48 | 48 |
49 enum { | 49 enum { |
50 TIMED_FIELDS_COUNT = TIMED_FIELDS_END - TIMED_FIELDS_BEGIN, | 50 TIMED_FIELDS_COUNT = TIMED_FIELDS_END - TIMED_FIELDS_BEGIN, |
51 SIGNIN_FIELDS_END = TIMED_FIELDS_END, | 51 SIGNIN_FIELDS_END = TIMED_FIELDS_END, |
52 SIGNIN_FIELDS_COUNT = SIGNIN_FIELDS_END - SIGNIN_FIELDS_BEGIN | 52 SIGNIN_FIELDS_COUNT = SIGNIN_FIELDS_END - SIGNIN_FIELDS_BEGIN |
53 }; | 53 }; |
54 | 54 |
55 // Returns the root preference path for the service. The path should be | 55 // Returns the root preference path for the service. The path should be |
56 // qualified with one of .value, .status or .time to get the respective | 56 // qualified with one of .value, .status or .time to get the respective |
57 // full preference path names. | 57 // full preference path names. |
58 std::string TokenPrefPath(const std::string& service_name); | 58 std::string TokenPrefPath(const std::string& service_name); |
59 | 59 |
60 // Returns the name of a SigninStatus field. | 60 // Returns the name of a SigninStatus field. |
61 std::string SigninStatusFieldToString(UntimedSigninStatusField field); | 61 std::string SigninStatusFieldToString(UntimedSigninStatusField field); |
62 std::string SigninStatusFieldToString(TimedSigninStatusField field); | 62 std::string SigninStatusFieldToString(TimedSigninStatusField field); |
63 | 63 |
64 // An Observer class for authentication and token diagnostic information. | 64 // An Observer class for authentication and token diagnostic information. |
65 class SigninDiagnosticsObserver { | 65 class SigninDiagnosticsObserver { |
66 public: | 66 public: |
67 // Credentials and signin related changes. | 67 // Credentials and signin related changes. |
68 virtual void NotifySigninValueChanged(const UntimedSigninStatusField& field, | |
69 const std::string& value) {} | |
70 virtual void NotifySigninValueChanged(const TimedSigninStatusField& field, | 68 virtual void NotifySigninValueChanged(const TimedSigninStatusField& field, |
71 const std::string& value) {} | 69 const std::string& value) {} |
72 // OAuth tokens related changes. | 70 // OAuth tokens related changes. |
73 virtual void NotifyTokenReceivedSuccess(const std::string& token_name, | 71 virtual void NotifyTokenReceivedSuccess(const std::string& token_name, |
74 const std::string& token, | 72 const std::string& token, |
75 bool update_time) {} | 73 bool update_time) {} |
76 virtual void NotifyTokenReceivedFailure(const std::string& token_name, | 74 virtual void NotifyTokenReceivedFailure(const std::string& token_name, |
77 const std::string& error) {} | 75 const std::string& error) {} |
78 virtual void NotifyClearStoredToken(const std::string& token_name) {}}; | 76 virtual void NotifyClearStoredToken(const std::string& token_name) {}}; |
79 | 77 |
80 // Gets the first 6 hex characters of the SHA256 hash of the passed in string. | 78 // Gets the first 6 hex characters of the SHA256 hash of the passed in string. |
81 // These are enough to perform equality checks across a single users tokens, | 79 // These are enough to perform equality checks across a single users tokens, |
82 // while preventing outsiders from reverse-engineering the actual token from | 80 // while preventing outsiders from reverse-engineering the actual token from |
83 // the displayed value. | 81 // the displayed value. |
84 // Note that for readability (in about:signin-internals), an empty string | 82 // Note that for readability (in about:signin-internals), an empty string |
85 // is not hashed, but simply returned as an empty string. | 83 // is not hashed, but simply returned as an empty string. |
86 std::string GetTruncatedHash(const std::string& str); | 84 std::string GetTruncatedHash(const std::string& str); |
87 | 85 |
88 } // namespace signin_internals_util | 86 } // namespace signin_internals_util |
89 | 87 |
90 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ | 88 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_INTERNALS_UTIL_H_ |
OLD | NEW |