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

Side by Side Diff: chrome/browser/chromeos/policy/wildcard_login_checker.h

Issue 181363002: Properly handle failure modes in the wildcard login check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "components/policy/core/common/cloud/user_info_fetcher.h" 12 #include "components/policy/core/common/cloud/user_info_fetcher.h"
13 #include "google_apis/gaia/google_service_auth_error.h" 13 #include "google_apis/gaia/google_service_auth_error.h"
14 14
15 namespace net { 15 namespace net {
16 class URLRequestContextGetter; 16 class URLRequestContextGetter;
17 } 17 }
18 18
19 namespace policy { 19 namespace policy {
20 20
21 class PolicyOAuth2TokenFetcher; 21 class PolicyOAuth2TokenFetcher;
22 22
23 // Performs online verification whether wildcard login is allowed, i.e. whether 23 // Performs online verification whether wildcard login is allowed, i.e. whether
24 // the user is a hosted user. This class performs an asynchronous check and 24 // the user is a hosted user. This class performs an asynchronous check and
25 // reports the result via a callback. 25 // reports the result via a callback.
26 class WildcardLoginChecker : public UserInfoFetcher::Delegate { 26 class WildcardLoginChecker : public UserInfoFetcher::Delegate {
27 public: 27 public:
28 typedef base::Callback<void(bool)> StatusCallback; 28 // Indicates result of the wildcard login check.
29 enum Result {
30 RESULT_ALLOWED, // Wildcard check succeeded, login allowed.
31 RESULT_BLOCKED, // Check completed, but user should be blocked.
32 RESULT_FAILED, // Failure due to network errors etc.
33 };
34
35 typedef base::Callback<void(Result)> StatusCallback;
29 36
30 WildcardLoginChecker(); 37 WildcardLoginChecker();
31 virtual ~WildcardLoginChecker(); 38 virtual ~WildcardLoginChecker();
32 39
33 // Starts checking. The result will be reported via |callback_|. 40 // Starts checking. The result will be reported via |callback_|.
34 void Start(scoped_refptr<net::URLRequestContextGetter> signin_context, 41 void Start(scoped_refptr<net::URLRequestContextGetter> signin_context,
35 const StatusCallback& callback); 42 const StatusCallback& callback);
36 43
37 // Starts checking with a provided access token. 44 // Starts checking with a provided access token.
38 void StartWithAccessToken(const std::string& access_token, 45 void StartWithAccessToken(const std::string& access_token,
39 const StatusCallback& callback); 46 const StatusCallback& callback);
40 47
41 // UserInfoFetcher::Delegate: 48 // UserInfoFetcher::Delegate:
42 virtual void OnGetUserInfoSuccess(const base::DictionaryValue* response) 49 virtual void OnGetUserInfoSuccess(const base::DictionaryValue* response)
43 OVERRIDE; 50 OVERRIDE;
44 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) 51 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error)
45 OVERRIDE; 52 OVERRIDE;
46 53
47 private: 54 private:
48 // Starts the check after successful token minting. 55 // Starts the check after successful token minting.
49 void OnPolicyTokenFetched(const std::string& access_token, 56 void OnPolicyTokenFetched(const std::string& access_token,
50 const GoogleServiceAuthError& error); 57 const GoogleServiceAuthError& error);
51 58
52 // Starts the user info fetcher. 59 // Starts the user info fetcher.
53 void StartUserInfoFetcher(const std::string& access_token); 60 void StartUserInfoFetcher(const std::string& access_token);
54 61
55 // Handles the response of the check and calls ReportResult(). 62 // Handles the response of the check and calls ReportResult().
56 void OnCheckCompleted(bool result); 63 void OnCheckCompleted(Result result);
57 64
58 StatusCallback callback_; 65 StatusCallback callback_;
59 66
60 scoped_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; 67 scoped_ptr<PolicyOAuth2TokenFetcher> token_fetcher_;
61 scoped_ptr<UserInfoFetcher> user_info_fetcher_; 68 scoped_ptr<UserInfoFetcher> user_info_fetcher_;
62 69
63 base::Time start_timestamp_; 70 base::Time start_timestamp_;
64 base::Time token_available_timestamp_; 71 base::Time token_available_timestamp_;
65 72
66 DISALLOW_COPY_AND_ASSIGN(WildcardLoginChecker); 73 DISALLOW_COPY_AND_ASSIGN(WildcardLoginChecker);
67 }; 74 };
68 75
69 } // namespace policy 76 } // namespace policy
70 77
71 #endif // CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_ 78 #endif // CHROME_BROWSER_CHROMEOS_POLICY_WILDCARD_LOGIN_CHECKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698