Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ | |
| 6 #define CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/time/time.h" | |
| 13 #include "base/timer/timer.h" | |
| 14 #include "google_apis/gaia/oauth2_token_service.h" | |
| 15 #include "net/base/backoff_entry.h" | |
| 16 #include "net/base/network_change_notifier.h" | |
| 17 | |
| 18 class Profile; | |
| 19 class SigninManager; | |
| 20 | |
| 21 // ForceSigninVerifier will verify profile's auth token when profile is loaded | |
| 22 // into memory by the first time via gaia server. It will retry on any transient | |
| 23 // error. | |
| 24 class ForceSigninVerifier | |
| 25 : public OAuth2TokenService::Consumer, | |
| 26 public net::NetworkChangeNotifier::NetworkChangeObserver { | |
| 27 public: | |
| 28 explicit ForceSigninVerifier(Profile* profile); | |
| 29 ~ForceSigninVerifier(); | |
| 30 | |
| 31 // OAuth2TokenService::Consumer implementation | |
| 32 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 33 const std::string& access_token, | |
| 34 const base::Time& expiration_time) override; | |
| 35 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 36 const GoogleServiceAuthError& error) override; | |
| 37 | |
| 38 // net::NetworkChangeNotifier::NetworkChangeObserver | |
| 39 void OnNetworkChanged( | |
| 40 net::NetworkChangeNotifier::ConnectionType type) override; | |
| 41 | |
| 42 // Cancel any pending or ongoing verification. | |
| 43 void Cancel(); | |
| 44 | |
| 45 protected: | |
| 46 // Sent the token verification request. The request will be sent only if | |
|
Roger Tawa OOO till Jul 10th
2017/04/10 15:15:20
nit: Sent -> Send
zmin
2017/04/10 22:27:49
Done.
| |
| 47 // - The token has never been verified before. | |
| 48 // - There is no on going verification. | |
| 49 // - There is network connection. | |
| 50 // - The profile has signed in. | |
| 51 // | |
| 52 void SendRequest(); | |
| 53 | |
| 54 virtual bool ShouldSendRequest(); | |
| 55 | |
| 56 // Show the warning dialog before sign out user and close assoicated browser | |
|
Roger Tawa OOO till Jul 10th
2017/04/10 15:15:20
Nit:
sign out -> signing out
close -> closing
zmin
2017/04/10 22:27:49
Done.
| |
| 57 // window. | |
| 58 virtual void ShowDialog(); | |
| 59 | |
| 60 std::unique_ptr<OAuth2TokenService::Request> access_token_request_; | |
| 61 | |
| 62 // Indicates whether the verification is finished successfully or with a | |
| 63 // persistent error. | |
| 64 bool has_token_verified_; | |
| 65 net::BackoffEntry backoff_entry_; | |
| 66 base::OneShotTimer backoff_request_timer_; | |
|
Roger Tawa OOO till Jul 10th
2017/04/10 15:15:20
All data members should be private. You can add a
zmin
2017/04/10 22:27:49
I create a public method for |has_token_verified_|
| |
| 67 | |
| 68 private: | |
| 69 OAuth2TokenService* oauth2_token_service_; | |
| 70 SigninManager* signin_manager_; | |
| 71 | |
| 72 base::Time token_request_time_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier); | |
| 75 }; | |
| 76 | |
| 77 #endif // CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ | |
| OLD | NEW |