Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2450)

Unified Diff: chrome/browser/signin/dice_response_handler.h

Issue 2950073002: [Signin] Handle multiple concurrent Dice responses (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/signin/dice_response_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | chrome/browser/signin/dice_response_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698