| Index: components/signin/core/browser/dice_header_helper.cc
|
| diff --git a/components/signin/core/browser/dice_header_helper.cc b/components/signin/core/browser/dice_header_helper.cc
|
| index 3771dcf75bff770b0d2adc759e05dbc2bde843e3..ae7e4f8886cf7bd6902409883f675420e9deb26c 100644
|
| --- a/components/signin/core/browser/dice_header_helper.cc
|
| +++ b/components/signin/core/browser/dice_header_helper.cc
|
| @@ -11,6 +11,60 @@
|
|
|
| namespace signin {
|
|
|
| +namespace {
|
| +
|
| +const char kActionAttrName[] = "action";
|
| +const char kAuthUserAttrName[] = "authuser";
|
| +const char kAuthorizationCodeAttrName[] = "authorization_code";
|
| +const char kEmailAttrName[] = "email";
|
| +const char kIdAttrName[] = "id";
|
| +const char kLogoutAttrName[] = "logout";
|
| +
|
| +// Determines the Dice action that has been passed from Gaia in the header.
|
| +DiceAction GetDiceActionFromHeader(const std::string& value) {
|
| + if (value == "SIGNIN")
|
| + return DiceAction::SIGNIN;
|
| + else if (value == "SIGNOUT")
|
| + return DiceAction::SIGNOUT;
|
| + else if (value == "SINGLE_SESSION_SIGN_OUT")
|
| + return DiceAction::SINGLE_SESSION_SIGNOUT;
|
| + else
|
| + return DiceAction::NONE;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +DiceResponseParams DiceHeaderHelper::BuildDiceResponseParams(
|
| + const std::string& header_value) {
|
| + DCHECK(!header_value.empty());
|
| + DiceResponseParams params;
|
| + ResponseHeaderDictionary header_dictionary =
|
| + ParseAccountConsistencyResponseHeader(header_value);
|
| + ResponseHeaderDictionary::const_iterator it = header_dictionary.begin();
|
| + for (; it != header_dictionary.end(); ++it) {
|
| + const std::string key_name(it->first);
|
| + const std::string value(it->second);
|
| + if (key_name == kActionAttrName) {
|
| + params.user_intention = GetDiceActionFromHeader(value);
|
| + } else if (key_name == kIdAttrName) {
|
| + params.obfuscated_gaia_id = value;
|
| + } else if (key_name == kEmailAttrName) {
|
| + params.email = value;
|
| + } else if (key_name == kAuthUserAttrName) {
|
| + params.session_index = value;
|
| + } else if (key_name == kAuthorizationCodeAttrName) {
|
| + params.authorization_code = value;
|
| + } else if (key_name == kLogoutAttrName) {
|
| + params.logout_url = GURL(value);
|
| + } else {
|
| + DLOG(WARNING) << "Unexpected Gaia header attribute '" << key_name << "'.";
|
| + }
|
| + }
|
| +
|
| + return params;
|
| +}
|
| +
|
| bool DiceHeaderHelper::IsUrlEligibleForRequestHeader(const GURL& url) {
|
| if (switches::GetAccountConsistencyMethod() !=
|
| switches::AccountConsistencyMethod::kDice) {
|
|
|