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

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: rebase from master 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
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
(...skipping 10 matching lines...) Expand all
21 // ForceSigninVerifier will verify profile's auth token when profile is loaded 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 22 // into memory by the first time via gaia server. It will retry on any transient
23 // error. 23 // error.
24 class ForceSigninVerifier 24 class ForceSigninVerifier
25 : public OAuth2TokenService::Consumer, 25 : public OAuth2TokenService::Consumer,
26 public net::NetworkChangeNotifier::NetworkChangeObserver { 26 public net::NetworkChangeNotifier::NetworkChangeObserver {
27 public: 27 public:
28 explicit ForceSigninVerifier(Profile* profile); 28 explicit ForceSigninVerifier(Profile* profile);
29 ~ForceSigninVerifier() override; 29 ~ForceSigninVerifier() override;
30 30
31 // OAuth2TokenService::Consumer implementation 31 // override OAuth2TokenService::Consumer
32 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 32 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
33 const std::string& access_token, 33 const std::string& access_token,
34 const base::Time& expiration_time) override; 34 const base::Time& expiration_time) override;
35 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 35 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
36 const GoogleServiceAuthError& error) override; 36 const GoogleServiceAuthError& error) override;
37 37
38 // net::NetworkChangeNotifier::NetworkChangeObserver 38 // override net::NetworkChangeNotifier::NetworkChangeObserver
39 void OnNetworkChanged( 39 void OnNetworkChanged(
40 net::NetworkChangeNotifier::ConnectionType type) override; 40 net::NetworkChangeNotifier::ConnectionType type) override;
41 41
42 // Cancel any pending or ongoing verification. 42 // Cancel any pending or ongoing verification.
43 void Cancel(); 43 void Cancel();
44 44
45 // Return the value of |has_token_verified_|. 45 // Return the value of |has_token_verified_|.
46 bool HasTokenBeenVerified(); 46 bool HasTokenBeenVerified();
47 47
48 // Abort signout countdown.
49 void AbortSignoutCountdownIfExisted();
50
48 protected: 51 protected:
49 // Send the token verification request. The request will be sent only if 52 // Send the token verification request. The request will be sent only if
50 // - The token has never been verified before. 53 // - The token has never been verified before.
51 // - There is no on going verification. 54 // - There is no on going verification.
52 // - There is network connection. 55 // - There is network connection.
53 // - The profile has signed in. 56 // - The profile has signed in.
54 // 57 //
55 void SendRequest(); 58 void SendRequest();
56 59
57 virtual bool ShouldSendRequest(); 60 virtual bool ShouldSendRequest();
58 61
59 // Show the warning dialog before signing out user and closing assoicated 62 // Show the warning dialog before signing out user and closing assoicated
60 // browser window. 63 // browser window.
61 virtual void ShowDialog(); 64 virtual void ShowDialog();
62 65
66 // Start the window closing countdown, return the duration.
67 base::TimeDelta StartCountdown();
68
63 OAuth2TokenService::Request* GetRequestForTesting(); 69 OAuth2TokenService::Request* GetRequestForTesting();
64 net::BackoffEntry* GetBackoffEntryForTesting(); 70 net::BackoffEntry* GetBackoffEntryForTesting();
65 base::OneShotTimer* GetOneShotTimerForTesting(); 71 base::OneShotTimer* GetOneShotTimerForTesting();
72 base::OneShotTimer* GetWindowCloseTimerForTesting();
66 73
67 private: 74 private:
75 void CloseAllBrowserWindows();
76
68 std::unique_ptr<OAuth2TokenService::Request> access_token_request_; 77 std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
69 78
79 #if !defined(OS_MACOSX)
80 Profile* profile_;
81 #endif
70 // Indicates whether the verification is finished successfully or with a 82 // Indicates whether the verification is finished successfully or with a
71 // persistent error. 83 // persistent error.
72 bool has_token_verified_; 84 bool has_token_verified_;
73 net::BackoffEntry backoff_entry_; 85 net::BackoffEntry backoff_entry_;
74 base::OneShotTimer backoff_request_timer_; 86 base::OneShotTimer backoff_request_timer_;
75 87
76 OAuth2TokenService* oauth2_token_service_; 88 OAuth2TokenService* oauth2_token_service_;
77 SigninManager* signin_manager_; 89 SigninManager* signin_manager_;
78 90
79 base::Time token_request_time_; 91 base::Time token_request_time_;
80 92
93 // The countdown of window closing.
94 base::OneShotTimer window_close_timer_;
95
81 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier); 96 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier);
82 }; 97 };
83 98
84 #endif // CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_ 99 #endif // CHROME_BROWSER_SIGNIN_FORCE_SIGNIN_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698