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

Side by Side Diff: chrome/browser/signin/force_signin_verifier.h

Issue 2944713003: After signin token check failed, show force reauth dialog and start window closing countdown. (Closed)
Patch Set: nit Created 3 years, 5 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 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_FORCE_SIGNIN_VERIFIER_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_
6 #define CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ 6 #define CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "google_apis/gaia/oauth2_token_service.h" 14 #include "google_apis/gaia/oauth2_token_service.h"
15 #include "net/base/backoff_entry.h" 15 #include "net/base/backoff_entry.h"
16 #include "net/base/network_change_notifier.h" 16 #include "net/base/network_change_notifier.h"
17 17
18 class ForcedReauthenticationDialog;
18 class Profile; 19 class Profile;
19 class SigninManager; 20 class SigninManager;
20 21
21 // ForceSigninVerifier will verify profile's auth token when profile is loaded 22 // 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 // into memory by the first time via gaia server. It will retry on any transient
23 // error. 24 // error.
24 class ForceSigninVerifier 25 class ForceSigninVerifier
25 : public OAuth2TokenService::Consumer, 26 : public OAuth2TokenService::Consumer,
26 public net::NetworkChangeNotifier::NetworkChangeObserver { 27 public net::NetworkChangeNotifier::NetworkChangeObserver {
27 public: 28 public:
28 explicit ForceSigninVerifier(Profile* profile); 29 explicit ForceSigninVerifier(Profile* profile);
29 ~ForceSigninVerifier() override; 30 ~ForceSigninVerifier() override;
30 31
31 // OAuth2TokenService::Consumer implementation 32 // override OAuth2TokenService::Consumer
32 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 33 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
33 const std::string& access_token, 34 const std::string& access_token,
34 const base::Time& expiration_time) override; 35 const base::Time& expiration_time) override;
35 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 36 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
36 const GoogleServiceAuthError& error) override; 37 const GoogleServiceAuthError& error) override;
37 38
38 // net::NetworkChangeNotifier::NetworkChangeObserver 39 // override net::NetworkChangeNotifier::NetworkChangeObserver
39 void OnNetworkChanged( 40 void OnNetworkChanged(
40 net::NetworkChangeNotifier::ConnectionType type) override; 41 net::NetworkChangeNotifier::ConnectionType type) override;
41 42
42 // Cancel any pending or ongoing verification. 43 // Cancel any pending or ongoing verification.
43 void Cancel(); 44 void Cancel();
44 45
45 // Return the value of |has_token_verified_|. 46 // Return the value of |has_token_verified_|.
46 bool HasTokenBeenVerified(); 47 bool HasTokenBeenVerified();
47 48
49 // Abort signout countdown.
50 void AbortSignoutCountdownIfExisted();
51
48 protected: 52 protected:
49 // Send the token verification request. The request will be sent only if 53 // Send the token verification request. The request will be sent only if
50 // - The token has never been verified before. 54 // - The token has never been verified before.
51 // - There is no on going verification. 55 // - There is no on going verification.
52 // - There is network connection. 56 // - There is network connection.
53 // - The profile has signed in. 57 // - The profile has signed in.
54 // 58 //
55 void SendRequest(); 59 void SendRequest();
56 60
57 virtual bool ShouldSendRequest(); 61 virtual bool ShouldSendRequest();
58 62
59 // Show the warning dialog before signing out user and closing assoicated 63 // Show the warning dialog before signing out user and closing assoicated
60 // browser window. 64 // browser window.
61 virtual void ShowDialog(); 65 virtual void ShowDialog();
62 66
67 // Start the window closing countdown, return the duration.
68 base::TimeDelta StartCountdown();
69
63 OAuth2TokenService::Request* GetRequestForTesting(); 70 OAuth2TokenService::Request* GetRequestForTesting();
64 net::BackoffEntry* GetBackoffEntryForTesting(); 71 net::BackoffEntry* GetBackoffEntryForTesting();
65 base::OneShotTimer* GetOneShotTimerForTesting(); 72 base::OneShotTimer* GetOneShotTimerForTesting();
73 base::OneShotTimer* GetWindowCloseTimerForTesting();
66 74
67 private: 75 private:
76 void CloseAllBrowserWindows();
77
68 std::unique_ptr<OAuth2TokenService::Request> access_token_request_; 78 std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
69 79
80 #if !defined(OS_MACOSX)
81 Profile* profile_;
82
83 std::unique_ptr<ForcedReauthenticationDialog> dialog_;
84 #endif
85
70 // Indicates whether the verification is finished successfully or with a 86 // Indicates whether the verification is finished successfully or with a
71 // persistent error. 87 // persistent error.
72 bool has_token_verified_; 88 bool has_token_verified_;
73 net::BackoffEntry backoff_entry_; 89 net::BackoffEntry backoff_entry_;
74 base::OneShotTimer backoff_request_timer_; 90 base::OneShotTimer backoff_request_timer_;
75 91
76 OAuth2TokenService* oauth2_token_service_; 92 OAuth2TokenService* oauth2_token_service_;
77 SigninManager* signin_manager_; 93 SigninManager* signin_manager_;
78 94
79 base::Time token_request_time_; 95 base::Time token_request_time_;
80 96
97 // The countdown of window closing.
98 base::OneShotTimer window_close_timer_;
99
81 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier); 100 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier);
82 }; 101 };
83 102
84 #endif // CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ 103 #endif // CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_
OLDNEW
« no previous file with comments | « chrome/browser/signin/chrome_signin_client_unittest.cc ('k') | chrome/browser/signin/force_signin_verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698