| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/drive/auth_service.h" | 5 #include "google_apis/drive/auth_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const std::vector<std::string>& scopes) | 123 const std::vector<std::string>& scopes) |
| 124 : oauth2_token_service_(oauth2_token_service), | 124 : oauth2_token_service_(oauth2_token_service), |
| 125 account_id_(account_id), | 125 account_id_(account_id), |
| 126 url_request_context_getter_(url_request_context_getter), | 126 url_request_context_getter_(url_request_context_getter), |
| 127 scopes_(scopes), | 127 scopes_(scopes), |
| 128 weak_ptr_factory_(this) { | 128 weak_ptr_factory_(this) { |
| 129 DCHECK(oauth2_token_service); | 129 DCHECK(oauth2_token_service); |
| 130 | 130 |
| 131 // Get OAuth2 refresh token (if we have any) and register for its updates. | 131 // Get OAuth2 refresh token (if we have any) and register for its updates. |
| 132 oauth2_token_service_->AddObserver(this); | 132 oauth2_token_service_->AddObserver(this); |
| 133 has_refresh_token_ = oauth2_token_service_->RefreshTokenIsAvailable( | 133 has_refresh_token_ = !account_id_.empty() && |
| 134 account_id_); | 134 oauth2_token_service_->RefreshTokenIsAvailable(account_id_); |
| 135 } | 135 } |
| 136 | 136 |
| 137 AuthService::~AuthService() { | 137 AuthService::~AuthService() { |
| 138 oauth2_token_service_->RemoveObserver(this); | 138 oauth2_token_service_->RemoveObserver(this); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void AuthService::StartAuthentication(const AuthStatusCallback& callback) { | 141 void AuthService::StartAuthentication(const AuthStatusCallback& callback) { |
| 142 DCHECK(thread_checker_.CalledOnValidThread()); | 142 DCHECK(thread_checker_.CalledOnValidThread()); |
| 143 | 143 |
| 144 if (HasAccessToken()) { | 144 if (HasAccessToken()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void AuthService::OnHandleRefreshToken(bool has_refresh_token) { | 223 void AuthService::OnHandleRefreshToken(bool has_refresh_token) { |
| 224 access_token_.clear(); | 224 access_token_.clear(); |
| 225 has_refresh_token_ = has_refresh_token; | 225 has_refresh_token_ = has_refresh_token; |
| 226 | 226 |
| 227 FOR_EACH_OBSERVER(AuthServiceObserver, | 227 FOR_EACH_OBSERVER(AuthServiceObserver, |
| 228 observers_, | 228 observers_, |
| 229 OnOAuth2RefreshTokenChanged()); | 229 OnOAuth2RefreshTokenChanged()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace google_apis | 232 } // namespace google_apis |
| OLD | NEW |