#include "components/endpoint_fetcher/endpoint_fetcher.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/access_token_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/version_info/channel.h"
#include "google_apis/common/api_key_request_util.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/google_api_keys.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace {
const char kContentTypeKey[] = …;
const char kDeveloperKey[] = …;
const int kNumRetries = …;
constexpr base::TimeDelta kDefaultTimeOut = …;
}
EndpointFetcher::RequestParams::Builder::Builder()
: … { … }
EndpointFetcher::RequestParams::Builder::~Builder() = default;
EndpointFetcher::RequestParams
EndpointFetcher::RequestParams::Builder::Build() { … }
EndpointFetcher::EndpointFetcher(
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
const std::string& oauth_consumer_name,
const GURL& url,
const std::string& http_method,
const std::string& content_type,
const std::vector<std::string>& scopes,
const base::TimeDelta& timeout,
const std::string& post_data,
const net::NetworkTrafficAnnotationTag& annotation_tag,
signin::IdentityManager* identity_manager,
signin::ConsentLevel consent_level)
: … { … }
EndpointFetcher::EndpointFetcher(
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
const GURL& url,
const std::string& http_method,
const std::string& content_type,
const base::TimeDelta& timeout,
const std::string& post_data,
const std::vector<std::string>& headers,
const std::vector<std::string>& cors_exempt_headers,
const net::NetworkTrafficAnnotationTag& annotation_tag,
version_info::Channel channel,
const std::optional<RequestParams> request_params)
: … { … }
EndpointFetcher::EndpointFetcher(
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
const GURL& url,
const net::NetworkTrafficAnnotationTag& annotation_tag)
: … { … }
EndpointFetcher::EndpointFetcher(
const std::string& oauth_consumer_name,
const GURL& url,
const std::string& http_method,
const std::string& content_type,
const std::vector<std::string>& scopes,
const base::TimeDelta& timeout,
const std::string& post_data,
const net::NetworkTrafficAnnotationTag& annotation_tag,
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
signin::IdentityManager* identity_manager,
signin::ConsentLevel consent_level)
: … { … }
EndpointFetcher::EndpointFetcher(
const GURL& url,
const std::string& http_method,
const std::string& content_type,
const base::TimeDelta& timeout,
const std::string& post_data,
const std::vector<std::string>& headers,
const std::vector<std::string>& cors_exempt_headers,
const net::NetworkTrafficAnnotationTag& annotation_tag,
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
bool is_oauth_fetch)
: … { … }
EndpointFetcher::EndpointFetcher(
const net::NetworkTrafficAnnotationTag& annotation_tag)
: … { … }
EndpointFetcher::~EndpointFetcher() = default;
void EndpointFetcher::Fetch(EndpointFetcherCallback endpoint_fetcher_callback) { … }
void EndpointFetcher::OnAuthTokenFetched(
EndpointFetcherCallback endpoint_fetcher_callback,
GoogleServiceAuthError error,
signin::AccessTokenInfo access_token_info) { … }
void EndpointFetcher::PerformRequest(
EndpointFetcherCallback endpoint_fetcher_callback,
const char* key) { … }
void EndpointFetcher::OnResponseFetched(
EndpointFetcherCallback endpoint_fetcher_callback,
std::unique_ptr<std::string> response_body) { … }
void EndpointFetcher::OnSanitizationResult(
std::unique_ptr<EndpointResponse> response,
EndpointFetcherCallback endpoint_fetcher_callback,
data_decoder::JsonSanitizer::Result result) { … }
network::mojom::CredentialsMode EndpointFetcher::GetCredentialsMode() { … }
int EndpointFetcher::GetMaxRetries() { … }
std::string EndpointFetcher::GetUrlForTesting() { … }