This source file includes following definitions.
- SigninStatusFieldToString
- SigninStatusFieldToString
- TokenPrefPath
- GetTruncatedHash
#include "components/signin/core/browser/signin_internals_util.h"
#include <sstream>
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "crypto/sha2.h"
#include "google_apis/gaia/gaia_constants.h"
namespace signin_internals_util {
const char kSigninPrefPrefix[] = "google.services.signin.";
const char kTokenPrefPrefix[] = "google.services.signin.tokens.";
#define ENUM_CASE(x) case x: return (std::string(kSigninPrefPrefix) + #x)
std::string SigninStatusFieldToString(UntimedSigninStatusField field) {
switch (field) {
ENUM_CASE(USERNAME);
case UNTIMED_FIELDS_END:
NOTREACHED();
return std::string();
}
NOTREACHED();
return std::string();
}
std::string SigninStatusFieldToString(TimedSigninStatusField field) {
switch (field) {
ENUM_CASE(SIGNIN_TYPE);
ENUM_CASE(CLIENT_LOGIN_STATUS);
ENUM_CASE(OAUTH_LOGIN_STATUS);
ENUM_CASE(GET_USER_INFO_STATUS);
ENUM_CASE(UBER_TOKEN_STATUS);
ENUM_CASE(MERGE_SESSION_STATUS);
case TIMED_FIELDS_END:
NOTREACHED();
return std::string();
}
NOTREACHED();
return std::string();
}
std::string TokenPrefPath(const std::string& token_name) {
return std::string(kTokenPrefPrefix) + token_name;
}
std::string GetTruncatedHash(const std::string& str) {
if (str.empty())
return str;
const int kTruncateSize = kTruncateTokenStringLength / 2;
char hash_val[kTruncateSize];
crypto::SHA256HashString(str, &hash_val[0], kTruncateSize);
return StringToLowerASCII(base::HexEncode(&hash_val[0], kTruncateSize));
}
}