Chromium Code Reviews| Index: chrome/browser/signin/dice_response_handler.h |
| diff --git a/chrome/browser/signin/dice_response_handler.h b/chrome/browser/signin/dice_response_handler.h |
| index 00355f057cd50e86f0154960aed582e374f1bf44..f9e92780d39917bdb0b01af8f0aa53a12c66dc03 100644 |
| --- a/chrome/browser/signin/dice_response_handler.h |
| +++ b/chrome/browser/signin/dice_response_handler.h |
| @@ -7,6 +7,7 @@ |
| #include <memory> |
| #include <string> |
| +#include <vector> |
| #include "components/keyed_service/core/keyed_service.h" |
| #include "google_apis/gaia/gaia_auth_consumer.h" |
| @@ -17,12 +18,13 @@ struct DiceResponseParams; |
| class AccountTrackerService; |
| class GaiaAuthFetcher; |
| +class GoogleServiceAuthError; |
| class SigninClient; |
| class ProfileOAuth2TokenService; |
| class Profile; |
| // Processes the Dice responses from Gaia. |
| -class DiceResponseHandler : public GaiaAuthConsumer, public KeyedService { |
| +class DiceResponseHandler : public KeyedService { |
| public: |
| // Returns the DiceResponseHandler associated with this profile. |
| // May return nullptr if there is none (e.g. in incognito). |
| @@ -37,21 +39,52 @@ class DiceResponseHandler : public GaiaAuthConsumer, public KeyedService { |
| void ProcessDiceHeader(const signin::DiceResponseParams& dice_params); |
| private: |
| + // Helper class to fetch a refresh token from an authorization code. |
| + class DiceTokenFetcher : public GaiaAuthConsumer { |
| + public: |
| + DiceTokenFetcher(const std::string& gaia_id, |
| + const std::string& email, |
| + const std::string& authorization_code, |
| + SigninClient* signin_client, |
| + DiceResponseHandler* dice_response_handler); |
| + ~DiceTokenFetcher() override; |
| + |
| + const std::string& gaia_id() const { return gaia_id_; } |
| + const std::string& email() const { return email_; } |
| + |
| + private: |
| + // GaiaAuthConsumer implementation: |
| + void OnClientOAuthSuccess( |
| + const GaiaAuthConsumer::ClientOAuthResult& result) override; |
| + void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; |
| + |
| + std::string gaia_id_; |
| + std::string email_; |
| + DiceResponseHandler* dice_response_handler_; |
| + std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
|
msarda
2017/06/22 09:51:31
Add DISALLOW_COPY_AND_ASSIGN(DiceTokenFetcher);
|
| + }; |
| + |
| + // Deletes the token fetcher. |
| + void DeleteTokenFetcher(DiceTokenFetcher* token_fetcher); |
| + |
| // Process the Dice signin action. |
| void ProcessDiceSigninHeader(const std::string& gaia_id, |
| const std::string& email, |
| const std::string& authorization_code); |
| - // GaiaAuthConsumer implementation: |
| - void OnClientOAuthSuccess(const ClientOAuthResult& result) override; |
| - void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; |
| + // Called after token exchange on SIGNIN. |
|
msarda
2017/06/22 09:51:32
I do not understand what SIGNIN means here. Maybe
droger
2017/06/22 11:54:20
I meant DiceAction::SIGNIN. Clarified comment.
|
| + void OnTokenExchangeSuccess( |
| + DiceTokenFetcher* token_fetcher, |
| + const std::string& gaia_id, |
| + const std::string& email, |
| + const GaiaAuthConsumer::ClientOAuthResult& result); |
| + void OnTokenExchangeFailure(DiceTokenFetcher* token_fetcher, |
| + const GoogleServiceAuthError& error); |
| - std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
| - std::string gaia_id_; |
| - std::string email_; |
| SigninClient* signin_client_; |
| ProfileOAuth2TokenService* profile_oauth2_token_service_; |
| AccountTrackerService* account_tracker_service_; |
| + std::vector<std::unique_ptr<DiceTokenFetcher>> token_fetchers_; |
|
msarda
2017/06/22 09:51:32
Add Add DISALLOW_COPY_AND_ASSIGN( DiceResponseHand
droger
2017/06/22 11:54:20
Done.
|
| }; |
| #endif // CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_ |