Commit 2f8423b3 authored by Kushagra Sinha's avatar Kushagra Sinha Committed by Commit Bot

Code Cleanup: Remove redundant getters from ArcAuthContext

Bug: 871690
Test: browser_tests --gtest_filter="*ArcAuthServiceTest*"
Change-Id: I6a5f3a0ae9831b7db59d8995129877acd49d15e1
Reviewed-on: https://chromium-review.googlesource.com/1190624Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586616}
parent 84cbd27f
......@@ -6,6 +6,7 @@
#include <utility>
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
......@@ -89,6 +90,14 @@ void ArcAuthContext::Prepare(const PrepareCallback& callback) {
StartFetchers();
}
std::unique_ptr<OAuth2TokenService::Request>
ArcAuthContext::StartAccessTokenRequest(
const OAuth2TokenService::ScopeSet& scopes,
OAuth2TokenService::Consumer* consumer) {
DCHECK(token_service_->RefreshTokenIsAvailable(account_id_));
return token_service_->StartRequest(account_id_, scopes, consumer);
}
void ArcAuthContext::OnRefreshTokenAvailable(const std::string& account_id) {
if (account_id != account_id_)
return;
......
......@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/timer/timer.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "google_apis/gaia/ubertoken_fetcher.h"
#include "net/base/backoff_entry.h"
......@@ -34,11 +35,6 @@ class ArcAuthContext : public UbertokenConsumer,
ArcAuthContext(Profile* profile, const std::string& account_id);
~ArcAuthContext() override;
ProfileOAuth2TokenService* token_service() { return token_service_; }
// TODO(sinhak): Check usages of |account_id()| and see if we can remove it.
const std::string& account_id() const { return account_id_; }
// Prepares the context. Calling while an inflight operation exists will
// cancel the inflight operation.
// On completion, |context| is passed to the callback. On error, |context|
......@@ -47,6 +43,14 @@ class ArcAuthContext : public UbertokenConsumer,
base::Callback<void(net::URLRequestContextGetter* context)>;
void Prepare(const PrepareCallback& callback);
// Creates and starts a request to fetch an access token for the given
// |scopes|. The caller owns the returned request. |consumer| is the object
// that will be called back with results if the returned request is not
// deleted.
std::unique_ptr<OAuth2TokenService::Request> StartAccessTokenRequest(
const OAuth2TokenService::ScopeSet& scopes,
OAuth2TokenService::Consumer* consumer);
// OAuth2TokenService::Observer:
void OnRefreshTokenAvailable(const std::string& account_id) override;
void OnRefreshTokensLoaded() override;
......
......@@ -13,7 +13,6 @@
#include "base/values.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "components/account_id/account_id.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/user_manager/known_user.h"
#include "content/public/browser/browser_context.h"
#include "content/public/common/url_constants.h"
......@@ -76,14 +75,9 @@ void ArcBackgroundAuthCodeFetcher::OnPrepared(
return;
}
// Get token service and account ID to fetch auth tokens.
ProfileOAuth2TokenService* const token_service = context_.token_service();
DCHECK(token_service->RefreshTokenIsAvailable(context_.account_id()));
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kOAuth1LoginScope);
login_token_request_ =
token_service->StartRequest(context_.account_id(), scopes, this);
login_token_request_ = context_.StartAccessTokenRequest(scopes, this);
}
void ArcBackgroundAuthCodeFetcher::OnGetTokenSuccess(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment