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

Side by Side Diff: blimp/client/core/session/identity_source.h

Issue 2261273002: Integrate UI with authentication flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Misc fixes/ Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 5 #ifndef BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
6 #define BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 6 #define BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13
14 #include "blimp/client/public/blimp_client_context_delegate.h" 13 #include "blimp/client/public/blimp_client_context_delegate.h"
15 #include "google_apis/gaia/identity_provider.h" 14 #include "google_apis/gaia/identity_provider.h"
16 #include "google_apis/gaia/oauth2_token_service.h" 15 #include "google_apis/gaia/oauth2_token_service.h"
17 16
18 namespace blimp { 17 namespace blimp {
19 namespace client { 18 namespace client {
20 19
21 // IdentitySource handles OAuth2 token request and forward user sign in state 20 // IdentitySource handles OAuth2 token request and forward user sign in state
22 // change to Blimp with ProfileIdentityProvider. 21 // change to Blimp with ProfileIdentityProvider.
23 class IdentitySource : public OAuth2TokenService::Consumer, 22 class IdentitySource : public OAuth2TokenService::Consumer,
24 public OAuth2TokenService::Observer, 23 public OAuth2TokenService::Observer,
25 public IdentityProvider::Observer { 24 public IdentityProvider::Observer {
26 public: 25 public:
27 typedef base::Callback<void(const std::string&)> TokenCallback; 26 typedef base::Callback<void(const std::string&)> TokenCallback;
28 27
29 explicit IdentitySource(BlimpClientContextDelegate* delegate, 28 explicit IdentitySource(BlimpClientContextDelegate* delegate,
30 const TokenCallback& callback); 29 const TokenCallback& callback);
31 ~IdentitySource() override; 30 ~IdentitySource() override;
32 31
33 // Start Blimp authentication by requesting OAuth2 token from Google. 32 // Start Blimp authentication by requesting OAuth2 token from Google.
34 // Duplicate connect calls during token fetching will be ignored. 33 // Duplicate connect calls during token fetching will be ignored.
35 void Connect(); 34 void Connect();
36 35
36 // Add sign in state observer.
37 void AddObserver(IdentityProvider::Observer* observer);
38
39 // Remove sign in state observer.
40 void RemoveObserver(IdentityProvider::Observer* observer);
41
37 // OAuth2TokenService::Consumer implementation. 42 // OAuth2TokenService::Consumer implementation.
38 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 43 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
39 const std::string& access_token, 44 const std::string& access_token,
40 const base::Time& expiration_time) override; 45 const base::Time& expiration_time) override;
41 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 46 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
42 const GoogleServiceAuthError& error) override; 47 const GoogleServiceAuthError& error) override;
43 48
44 // OAuth2TokenService::Observer implementation. 49 // OAuth2TokenService::Observer implementation.
45 void OnRefreshTokenAvailable(const std::string& account_id) override; 50 void OnRefreshTokenAvailable(const std::string& account_id) override;
46 51
(...skipping 14 matching lines...) Expand all
61 // Callback after OAuth2 token is fetched. 66 // Callback after OAuth2 token is fetched.
62 TokenCallback token_callback_; 67 TokenCallback token_callback_;
63 68
64 // If we are fetching OAuth2 token. Connect call during token fetching will 69 // If we are fetching OAuth2 token. Connect call during token fetching will
65 // be ignored. 70 // be ignored.
66 bool is_fetching_token_; 71 bool is_fetching_token_;
67 72
68 // Account id of current active user, used during token request. 73 // Account id of current active user, used during token request.
69 std::string account_id_; 74 std::string account_id_;
70 75
76 // Current retry count due to request cancellation.
77 int retry_times_;
78
71 BlimpClientContextDelegate* delegate_; 79 BlimpClientContextDelegate* delegate_;
72 80
73 DISALLOW_COPY_AND_ASSIGN(IdentitySource); 81 DISALLOW_COPY_AND_ASSIGN(IdentitySource);
74 }; 82 };
75 83
76 } // namespace client 84 } // namespace client
77 } // namespace blimp 85 } // namespace blimp
78 86
79 #endif // BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_ 87 #endif // BLIMP_CLIENT_CORE_SESSION_IDENTITY_SOURCE_H_
OLDNEW
« no previous file with comments | « blimp/client/core/blimp_client_context_impl.cc ('k') | blimp/client/core/session/identity_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698