OLD | NEW |
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 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" | 5 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 void WildcardLoginChecker::StartWithSigninContext( | 37 void WildcardLoginChecker::StartWithSigninContext( |
38 scoped_refptr<net::URLRequestContextGetter> signin_context, | 38 scoped_refptr<net::URLRequestContextGetter> signin_context, |
39 const StatusCallback& callback) { | 39 const StatusCallback& callback) { |
40 CHECK(!token_fetcher_); | 40 CHECK(!token_fetcher_); |
41 CHECK(!user_info_fetcher_); | 41 CHECK(!user_info_fetcher_); |
42 | 42 |
43 start_timestamp_ = base::Time::Now(); | 43 start_timestamp_ = base::Time::Now(); |
44 callback_ = callback; | 44 callback_ = callback; |
45 | 45 |
46 token_fetcher_.reset(new PolicyOAuth2TokenFetcher()); | 46 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance()); |
47 token_fetcher_->StartWithSigninContext( | 47 token_fetcher_->StartWithSigninContext( |
48 signin_context.get(), g_browser_process->system_request_context(), | 48 signin_context.get(), g_browser_process->system_request_context(), |
49 base::Bind(&WildcardLoginChecker::OnPolicyTokenFetched, | 49 base::Bind(&WildcardLoginChecker::OnPolicyTokenFetched, |
50 base::Unretained(this))); | 50 base::Unretained(this))); |
51 } | 51 } |
52 | 52 |
53 void WildcardLoginChecker::StartWithRefreshToken( | 53 void WildcardLoginChecker::StartWithRefreshToken( |
54 const std::string& refresh_token, | 54 const std::string& refresh_token, |
55 const StatusCallback& callback) { | 55 const StatusCallback& callback) { |
56 CHECK(!token_fetcher_); | 56 CHECK(!token_fetcher_); |
57 CHECK(!user_info_fetcher_); | 57 CHECK(!user_info_fetcher_); |
58 | 58 |
59 start_timestamp_ = base::Time::Now(); | 59 start_timestamp_ = base::Time::Now(); |
60 callback_ = callback; | 60 callback_ = callback; |
61 | 61 |
62 token_fetcher_.reset(new PolicyOAuth2TokenFetcher()); | 62 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance()); |
63 token_fetcher_->StartWithRefreshToken( | 63 token_fetcher_->StartWithRefreshToken( |
64 refresh_token, g_browser_process->system_request_context(), | 64 refresh_token, g_browser_process->system_request_context(), |
65 base::Bind(&WildcardLoginChecker::OnPolicyTokenFetched, | 65 base::Bind(&WildcardLoginChecker::OnPolicyTokenFetched, |
66 base::Unretained(this))); | 66 base::Unretained(this))); |
67 } | 67 } |
68 | 68 |
69 void WildcardLoginChecker::StartWithAccessToken( | 69 void WildcardLoginChecker::StartWithAccessToken( |
70 const std::string& access_token, | 70 const std::string& access_token, |
71 const StatusCallback& callback) { | 71 const StatusCallback& callback) { |
72 CHECK(!token_fetcher_); | 72 CHECK(!token_fetcher_); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 new UserInfoFetcher(this, g_browser_process->system_request_context())); | 123 new UserInfoFetcher(this, g_browser_process->system_request_context())); |
124 user_info_fetcher_->Start(access_token); | 124 user_info_fetcher_->Start(access_token); |
125 } | 125 } |
126 | 126 |
127 void WildcardLoginChecker::OnCheckCompleted(Result result) { | 127 void WildcardLoginChecker::OnCheckCompleted(Result result) { |
128 if (!callback_.is_null()) | 128 if (!callback_.is_null()) |
129 callback_.Run(result); | 129 callback_.Run(result); |
130 } | 130 } |
131 | 131 |
132 } // namespace policy | 132 } // namespace policy |
OLD | NEW |