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 10ae5b54e8129679a569d429902da5cb08a022a2..8c4a1fdb29f49c1864ab39d1c911740402eab93e 100644 |
--- a/chrome/browser/signin/dice_response_handler.h |
+++ b/chrome/browser/signin/dice_response_handler.h |
@@ -7,7 +7,9 @@ |
#include <memory> |
#include <string> |
+#include <vector> |
+#include "base/macros.h" |
#include "components/keyed_service/core/keyed_service.h" |
#include "google_apis/gaia/gaia_auth_consumer.h" |
@@ -17,12 +19,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 +40,61 @@ 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_; } |
+ const std::string& authorization_code() const { |
+ return authorization_code_; |
+ } |
+ |
+ private: |
+ // GaiaAuthConsumer implementation: |
+ void OnClientOAuthSuccess( |
+ const GaiaAuthConsumer::ClientOAuthResult& result) override; |
+ void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; |
+ |
+ std::string gaia_id_; |
+ std::string email_; |
+ std::string authorization_code_; |
+ DiceResponseHandler* dice_response_handler_; |
+ std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; |
+ |
+ 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 exchanging an OAuth 2.0 authorization code for a refresh token |
+ // after DiceAction::SIGNIN. |
+ 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* token_service_; |
AccountTrackerService* account_tracker_service_; |
+ std::vector<std::unique_ptr<DiceTokenFetcher>> token_fetchers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DiceResponseHandler); |
}; |
#endif // CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_ |