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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/signin/dice_response_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_
6 #define CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_ 6 #define CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
12 #include "base/macros.h"
11 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
12 #include "google_apis/gaia/gaia_auth_consumer.h" 14 #include "google_apis/gaia/gaia_auth_consumer.h"
13 15
14 namespace signin { 16 namespace signin {
15 struct DiceResponseParams; 17 struct DiceResponseParams;
16 } 18 }
17 19
18 class AccountTrackerService; 20 class AccountTrackerService;
19 class GaiaAuthFetcher; 21 class GaiaAuthFetcher;
22 class GoogleServiceAuthError;
20 class SigninClient; 23 class SigninClient;
21 class ProfileOAuth2TokenService; 24 class ProfileOAuth2TokenService;
22 class Profile; 25 class Profile;
23 26
24 // Processes the Dice responses from Gaia. 27 // Processes the Dice responses from Gaia.
25 class DiceResponseHandler : public GaiaAuthConsumer, public KeyedService { 28 class DiceResponseHandler : public KeyedService {
26 public: 29 public:
27 // Returns the DiceResponseHandler associated with this profile. 30 // Returns the DiceResponseHandler associated with this profile.
28 // May return nullptr if there is none (e.g. in incognito). 31 // May return nullptr if there is none (e.g. in incognito).
29 static DiceResponseHandler* GetForProfile(Profile* profile); 32 static DiceResponseHandler* GetForProfile(Profile* profile);
30 33
31 DiceResponseHandler(SigninClient* signin_client, 34 DiceResponseHandler(SigninClient* signin_client,
32 ProfileOAuth2TokenService* profile_oauth2_token_service, 35 ProfileOAuth2TokenService* profile_oauth2_token_service,
33 AccountTrackerService* account_tracker_service); 36 AccountTrackerService* account_tracker_service);
34 ~DiceResponseHandler() override; 37 ~DiceResponseHandler() override;
35 38
36 // Must be called when receiving a Dice response header. 39 // Must be called when receiving a Dice response header.
37 void ProcessDiceHeader(const signin::DiceResponseParams& dice_params); 40 void ProcessDiceHeader(const signin::DiceResponseParams& dice_params);
38 41
39 private: 42 private:
43 // Helper class to fetch a refresh token from an authorization code.
44 class DiceTokenFetcher : public GaiaAuthConsumer {
45 public:
46 DiceTokenFetcher(const std::string& gaia_id,
47 const std::string& email,
48 const std::string& authorization_code,
49 SigninClient* signin_client,
50 DiceResponseHandler* dice_response_handler);
51 ~DiceTokenFetcher() override;
52
53 const std::string& gaia_id() const { return gaia_id_; }
54 const std::string& email() const { return email_; }
55 const std::string& authorization_code() const {
56 return authorization_code_;
57 }
58
59 private:
60 // GaiaAuthConsumer implementation:
61 void OnClientOAuthSuccess(
62 const GaiaAuthConsumer::ClientOAuthResult& result) override;
63 void OnClientOAuthFailure(const GoogleServiceAuthError& error) override;
64
65 std::string gaia_id_;
66 std::string email_;
67 std::string authorization_code_;
68 DiceResponseHandler* dice_response_handler_;
69 std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
70
71 DISALLOW_COPY_AND_ASSIGN(DiceTokenFetcher);
72 };
73
74 // Deletes the token fetcher.
75 void DeleteTokenFetcher(DiceTokenFetcher* token_fetcher);
76
40 // Process the Dice signin action. 77 // Process the Dice signin action.
41 void ProcessDiceSigninHeader(const std::string& gaia_id, 78 void ProcessDiceSigninHeader(const std::string& gaia_id,
42 const std::string& email, 79 const std::string& email,
43 const std::string& authorization_code); 80 const std::string& authorization_code);
44 81
45 // GaiaAuthConsumer implementation: 82 // Called after exchanging an OAuth 2.0 authorization code for a refresh token
46 void OnClientOAuthSuccess(const ClientOAuthResult& result) override; 83 // after DiceAction::SIGNIN.
47 void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; 84 void OnTokenExchangeSuccess(
85 DiceTokenFetcher* token_fetcher,
86 const std::string& gaia_id,
87 const std::string& email,
88 const GaiaAuthConsumer::ClientOAuthResult& result);
89 void OnTokenExchangeFailure(DiceTokenFetcher* token_fetcher,
90 const GoogleServiceAuthError& error);
48 91
49 std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
50 std::string gaia_id_;
51 std::string email_;
52 SigninClient* signin_client_; 92 SigninClient* signin_client_;
53 ProfileOAuth2TokenService* token_service_; 93 ProfileOAuth2TokenService* token_service_;
54 AccountTrackerService* account_tracker_service_; 94 AccountTrackerService* account_tracker_service_;
95 std::vector<std::unique_ptr<DiceTokenFetcher>> token_fetchers_;
96
97 DISALLOW_COPY_AND_ASSIGN(DiceResponseHandler);
55 }; 98 };
56 99
57 #endif // CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_ 100 #endif // CHROME_BROWSER_SIGNIN_DICE_RESPONSE_HANDLER_H_
OLDNEW
« 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