Chromium Code Reviews| Index: extensions/shell/browser/shell_oauth2_token_service_delegate.cc |
| diff --git a/extensions/shell/browser/shell_oauth2_token_service_delegate.cc b/extensions/shell/browser/shell_oauth2_token_service_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f9088d88a01f6e4f88c165d286b5af16c6e0717e |
| --- /dev/null |
| +++ b/extensions/shell/browser/shell_oauth2_token_service_delegate.cc |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "extensions/shell/browser/shell_oauth2_token_service_delegate.h" |
| + |
| +#include <vector> |
| + |
| +namespace extensions { |
| + |
| +ShellOAuth2TokenServiceDelegate::ShellOAuth2TokenServiceDelegate( |
| + content::BrowserContext* browser_context, |
| + std::string account_id, |
| + std::string refresh_token) |
| + : browser_context_(browser_context), |
| + account_id_(account_id), |
| + refresh_token_(refresh_token) { |
| +} |
| + |
| +ShellOAuth2TokenServiceDelegate::~ShellOAuth2TokenServiceDelegate() { |
| +} |
| + |
| +bool ShellOAuth2TokenServiceDelegate::RefreshTokenIsAvailable( |
| + const std::string& account_id) const { |
| + if (account_id != account_id_) |
| + return false; |
| + |
| + return !refresh_token_.empty(); |
| +} |
| + |
| +OAuth2AccessTokenFetcher* |
| +ShellOAuth2TokenServiceDelegate::CreateAccessTokenFetcher( |
| + const std::string& account_id, |
| + net::URLRequestContextGetter* getter, |
| + OAuth2AccessTokenConsumer* consumer) { |
| + DCHECK(!refresh_token_.empty()); |
|
Roger Tawa OOO till Jul 10th
2015/06/04 18:19:55
Should this DCHECK_EQ(account_id, account_id_); ?
gogerald1
2015/06/25 14:06:19
Acknowledged. We may need to do both.
Roger Tawa OOO till Jul 10th
2015/06/26 14:58:51
did you forget to add new DCHECK?
|
| + return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token_); |
| +} |
| + |
| +net::URLRequestContextGetter* |
| +ShellOAuth2TokenServiceDelegate::GetRequestContext() const { |
| + return browser_context_->GetRequestContext(); |
| +} |
| + |
| +void ShellOAuth2TokenServiceDelegate::UpdateAuthError( |
| + const std::string& account_id, |
| + const GoogleServiceAuthError& error) { |
| +} |
| + |
| +std::vector<std::string> ShellOAuth2TokenServiceDelegate::GetAccounts() { |
| + std::vector<std::string> accounts; |
| + accounts.push_back(account_id_); |
| + return accounts; |
| +} |
| + |
| +void ShellOAuth2TokenServiceDelegate::RevokeAllCredentials() { |
| +} |
| + |
| +void ShellOAuth2TokenServiceDelegate::UpdateCredentials( |
| + const std::string& account_id, |
| + const std::string& refresh_token) { |
| + account_id_ = account_id; |
| + refresh_token_ = refresh_token; |
| +} |
| + |
| +} // namespace extensions |