Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_CLIENT_CORE_AUTHENTICATOR_H_ | |
| 6 #define BLIMP_CLIENT_CORE_AUTHENTICATOR_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 #include "google_apis/gaia/identity_provider.h" | |
| 11 #include "google_apis/gaia/oauth2_token_service.h" | |
| 12 | |
| 13 namespace blimp { | |
| 14 namespace client { | |
| 15 | |
| 16 // Authenticator handles OAuth2 token request and forward user sign in state | |
|
nyquist
2016/08/10 16:48:56
Could we come up with a different name than 'Authe
xingliu
2016/08/10 21:03:14
Renamed to IdentitySource, also Authenticator is p
| |
| 17 // change to Blimp with ProfileIdentityProvider. | |
| 18 class Authenticator : public OAuth2TokenService::Consumer, | |
|
nyquist
2016/08/10 01:20:33
I think we want this to live in //blimp/client/cor
xingliu
2016/08/10 21:03:14
Done.
| |
| 19 public OAuth2TokenService::Observer, | |
| 20 public IdentityProvider::Observer { | |
| 21 public: | |
| 22 explicit Authenticator( | |
| 23 std::unique_ptr<IdentityProvider> identity_provider); | |
| 24 | |
| 25 ~Authenticator() override; | |
| 26 | |
| 27 // Start Blimp authentication by requesting OAuth2 token from google. | |
|
nyquist
2016/08/10 01:20:33
Capitalize Google here and below.
xingliu
2016/08/10 21:03:14
Done.
| |
| 28 void Connect(); | |
| 29 | |
| 30 // OAuth2TokenService::Consumer implementation. | |
| 31 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 32 const std::string& access_token, | |
| 33 const base::Time& expiration_time) override; | |
| 34 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 35 const GoogleServiceAuthError& error) override; | |
| 36 | |
| 37 // OAuth2TokenService::Observer implementation. | |
| 38 void OnRefreshTokenAvailable(const std::string& account_id) override; | |
| 39 | |
| 40 // IdentityProvider::Observer implementation. | |
| 41 void OnActiveAccountLogin() override; | |
| 42 void OnActiveAccountLogout() override; | |
| 43 | |
| 44 private: | |
| 45 // Fetch OAuth token. | |
| 46 void FetchAuthToken(); | |
| 47 | |
| 48 // Provide OAuth2 token service and listen to google account sign in state. | |
| 49 std::unique_ptr<IdentityProvider> identity_provider_; | |
|
nyquist
2016/08/10 01:20:33
#include <memory>
xingliu
2016/08/10 21:03:14
Done.
| |
| 50 | |
| 51 // OAuth2 token request. This class should take ownership of the request. | |
|
nyquist
2016/08/10 01:20:33
std::unique_ptr implies ownership. Maybe instead f
xingliu
2016/08/10 21:03:14
I'll change the comment.
Yes, it's the actual req
| |
| 52 std::unique_ptr<OAuth2TokenService::Request> token_request_; | |
| 53 | |
| 54 // Account id of current active user, used during token request. | |
| 55 std::string account_id_; | |
|
nyquist
2016/08/10 01:20:33
#include <string>
xingliu
2016/08/10 21:03:14
Done.
| |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(Authenticator); | |
| 58 }; | |
| 59 | |
| 60 } // namespace client | |
| 61 } // namespace blimp | |
| 62 | |
| 63 #endif // BLIMP_CLIENT_CORE_AUTHENTICATOR_H_ | |
| OLD | NEW |