#include "chrome/browser/device_identity/device_oauth2_token_service.h"
#include <string>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/device_identity/device_oauth2_token_store.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/prefs/pref_service.h"
#include "google_apis/gaia/gaia_access_token_fetcher.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_access_token_consumer.h"
#include "google_apis/gaia/oauth2_access_token_fetcher.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
struct DeviceOAuth2TokenService::PendingRequest { … };
DeviceOAuth2TokenService::DeviceOAuth2TokenService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<DeviceOAuth2TokenStore> store)
: … { … }
DeviceOAuth2TokenService::~DeviceOAuth2TokenService() { … }
void DeviceOAuth2TokenService::SetAndSaveRefreshToken(
const std::string& refresh_token,
StatusCallback result_callback) { … }
CoreAccountId DeviceOAuth2TokenService::GetRobotAccountId() const { … }
void DeviceOAuth2TokenService::set_robot_account_id_for_testing(
const CoreAccountId& account_id) { … }
void DeviceOAuth2TokenService::SetRefreshTokenAvailableCallback(
RefreshTokenAvailableCallback callback) { … }
std::unique_ptr<OAuth2AccessTokenManager::Request>
DeviceOAuth2TokenService::StartAccessTokenRequest(
const OAuth2AccessTokenManager::ScopeSet& scopes,
OAuth2AccessTokenManager::Consumer* consumer) { … }
void DeviceOAuth2TokenService::InvalidateAccessToken(
const OAuth2AccessTokenManager::ScopeSet& scopes,
const std::string& access_token) { … }
bool DeviceOAuth2TokenService::RefreshTokenIsAvailable() const { … }
OAuth2AccessTokenManager* DeviceOAuth2TokenService::GetAccessTokenManager() { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void DeviceOAuth2TokenService::SetServiceAccountEmail(
const std::string& account_email) { … }
#endif
void DeviceOAuth2TokenService::OnRefreshTokenResponse(
const std::string& access_token,
int expires_in_seconds) { … }
void DeviceOAuth2TokenService::OnGetTokenInfoResponse(
const base::Value::Dict& token_info) { … }
void DeviceOAuth2TokenService::OnOAuthError() { … }
void DeviceOAuth2TokenService::OnNetworkError(int response_code) { … }
void DeviceOAuth2TokenService::OnInitComplete(bool init_result,
bool validation_required) { … }
void DeviceOAuth2TokenService::OnPrepareTrustedAccountIdFinished(
const CoreAccountId& gaia_robot_id,
bool check_passed) { … }
void DeviceOAuth2TokenService::OnRefreshTokenAvailable() { … }
std::unique_ptr<OAuth2AccessTokenFetcher>
DeviceOAuth2TokenService::CreateAccessTokenFetcher(
const CoreAccountId& account_id,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
OAuth2AccessTokenConsumer* consumer,
const std::string& token_binding_challenge) { … }
bool DeviceOAuth2TokenService::HasRefreshToken(
const CoreAccountId& account_id) const { … }
scoped_refptr<network::SharedURLLoaderFactory>
DeviceOAuth2TokenService::GetURLLoaderFactory() const { … }
void DeviceOAuth2TokenService::FireRefreshTokenAvailable() { … }
bool DeviceOAuth2TokenService::HandleAccessTokenFetch(
OAuth2AccessTokenManager::RequestImpl* request,
const CoreAccountId& account_id,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const std::string& client_id,
const std::string& client_secret,
const OAuth2AccessTokenManager::ScopeSet& scopes) { … }
void DeviceOAuth2TokenService::FlushPendingRequests(
bool token_is_valid,
GoogleServiceAuthError::State error) { … }
void DeviceOAuth2TokenService::FailRequest(
OAuth2AccessTokenManager::RequestImpl* request,
GoogleServiceAuthError::State error) { … }
std::string DeviceOAuth2TokenService::GetRefreshToken() const { … }
void DeviceOAuth2TokenService::StartValidation() { … }
void DeviceOAuth2TokenService::RequestValidation() { … }
void DeviceOAuth2TokenService::ReportServiceError(
GoogleServiceAuthError::State error) { … }
bool DeviceOAuth2TokenService::HasValidationResult() const { … }