#include "chrome/browser/extensions/webstore_data_fetcher.h"
#include <optional>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/values.h"
#include "chrome/browser/extensions/webstore_data_fetcher_delegate.h"
#include "components/safe_browsing/core/common/features.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_urls.h"
#include "google_apis/common/api_key_request_util.h"
#include "google_apis/google_api_keys.h"
#include "net/base/load_flags.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
namespace {
const char kInvalidWebstoreResponseError[] = …;
constexpr net::NetworkTrafficAnnotationTag
kWebstoreDataFetcherItemJsonApiTrafficAnnotation = …;
constexpr net::NetworkTrafficAnnotationTag
kWebstoreDataFetcherItemSnippetApiTrafficAnnotation = …;
bool g_log_response_code_for_testing_ = …;
extensions::FetchItemSnippetResponse* g_mock_item_snippet_response_ = …;
}
namespace extensions {
WebstoreDataFetcher::WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate,
const GURL& referrer_url,
const std::string webstore_item_id)
: … { … }
WebstoreDataFetcher::~WebstoreDataFetcher() = default;
void WebstoreDataFetcher::SetLogResponseCodeForTesting(bool enabled) { … }
void WebstoreDataFetcher::SetMockItemSnippetReponseForTesting(
FetchItemSnippetResponse* mock_response) { … }
void WebstoreDataFetcher::Start(
network::mojom::URLLoaderFactory* url_loader_factory) { … }
void WebstoreDataFetcher::FetchFromItemJSONAPI(
network::mojom::URLLoaderFactory* url_loader_factory) { … }
void WebstoreDataFetcher::FetchItemSnippet(
network::mojom::URLLoaderFactory* url_loader_factory) { … }
void WebstoreDataFetcher::InitializeSimpleLoaderForRequest(
std::unique_ptr<network::ResourceRequest> request,
const net::NetworkTrafficAnnotationTag& annotation) { … }
void WebstoreDataFetcher::OnResponseStarted(
const GURL& final_url,
const network::mojom::URLResponseHead& response_head) { … }
void WebstoreDataFetcher::OnJsonParsed(
data_decoder::DataDecoder::ValueOrError result) { … }
void WebstoreDataFetcher::OnSimpleLoaderComplete(
std::unique_ptr<std::string> response_body) { … }
void WebstoreDataFetcher::OnFetchItemSnippetResponseReceived(
std::unique_ptr<std::string> response_body) { … }
}