| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 callback_ = callback; | 45 callback_ = callback; |
| 46 token_fetcher_.reset(new PolicyOAuth2TokenFetcher( | 46 token_fetcher_.reset(new PolicyOAuth2TokenFetcher( |
| 47 signin_context.get(), | 47 signin_context.get(), |
| 48 g_browser_process->system_request_context(), | 48 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 token_fetcher_->Start(); | 51 token_fetcher_->Start(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void WildcardLoginChecker::StartWithRefreshToken( |
| 55 const std::string& refresh_token, |
| 56 const StatusCallback& callback) { |
| 57 CHECK(!token_fetcher_); |
| 58 CHECK(!user_info_fetcher_); |
| 59 |
| 60 start_timestamp_ = base::Time::Now(); |
| 61 |
| 62 callback_ = callback; |
| 63 token_fetcher_.reset(new PolicyOAuth2TokenFetcher( |
| 64 std::string(), g_browser_process->system_request_context(), |
| 65 base::Bind(&WildcardLoginChecker::OnPolicyTokenFetched, |
| 66 base::Unretained(this)))); |
| 67 token_fetcher_->StartWithRefreshToken(refresh_token); |
| 68 } |
| 69 |
| 54 void WildcardLoginChecker::StartWithAccessToken( | 70 void WildcardLoginChecker::StartWithAccessToken( |
| 55 const std::string& access_token, | 71 const std::string& access_token, |
| 56 const StatusCallback& callback) { | 72 const StatusCallback& callback) { |
| 57 CHECK(!token_fetcher_); | 73 CHECK(!token_fetcher_); |
| 58 CHECK(!user_info_fetcher_); | 74 CHECK(!user_info_fetcher_); |
| 59 callback_ = callback; | 75 callback_ = callback; |
| 60 | 76 |
| 61 StartUserInfoFetcher(access_token); | 77 StartUserInfoFetcher(access_token); |
| 62 } | 78 } |
| 63 | 79 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 new UserInfoFetcher(this, g_browser_process->system_request_context())); | 122 new UserInfoFetcher(this, g_browser_process->system_request_context())); |
| 107 user_info_fetcher_->Start(access_token); | 123 user_info_fetcher_->Start(access_token); |
| 108 } | 124 } |
| 109 | 125 |
| 110 void WildcardLoginChecker::OnCheckCompleted(Result result) { | 126 void WildcardLoginChecker::OnCheckCompleted(Result result) { |
| 111 if (!callback_.is_null()) | 127 if (!callback_.is_null()) |
| 112 callback_.Run(result); | 128 callback_.Run(result); |
| 113 } | 129 } |
| 114 | 130 |
| 115 } // namespace policy | 131 } // namespace policy |
| OLD | NEW |