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

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

Issue 2802373002: Add ForceSigninVerifier. (Closed)
Patch Set: rogers' comments Created 3 years, 8 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
(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() override;
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 // Return the value of |has_token_verified_|.
46 bool HasTokenBeenVerified();
47
48 protected:
49 // Send the token verification request. The request will be sent only if
50 // - The token has never been verified before.
51 // - There is no on going verification.
52 // - There is network connection.
53 // - The profile has signed in.
54 //
55 void SendRequest();
56
57 virtual bool ShouldSendRequest();
58
59 // Show the warning dialog before signing out user and closing assoicated
60 // browser window.
61 virtual void ShowDialog();
62
63 OAuth2TokenService::Request* GetRequestForTesting();
64 net::BackoffEntry* GetBackoffEntryForTesting();
65 base::OneShotTimer* GetOneShotTimerForTesting();
66
67 private:
68 std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
69
70 // Indicates whether the verification is finished successfully or with a
71 // persistent error.
72 bool has_token_verified_;
73 net::BackoffEntry backoff_entry_;
74 base::OneShotTimer backoff_request_timer_;
75
76 OAuth2TokenService* oauth2_token_service_;
77 SigninManager* signin_manager_;
78
79 base::Time token_request_time_;
80
81 DISALLOW_COPY_AND_ASSIGN(ForceSigninVerifier);
82 };
83
84 #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