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

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

Powered by Google App Engine
This is Rietveld 408576698