#include "chrome/browser/new_tab_page/promos/promo_service.h"
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_string_value_serializer.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/google/core/common/google_util.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/search/ntp_features.h"
#include "extensions/common/extension_features.h"
#include "net/base/load_flags.h"
#include "net/base/url_util.h"
#include "net/traffic_annotation/network_traffic_annotation.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 "ui/base/l10n/l10n_util.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
namespace {
const int kDaysThatBlocklistExpiresIn = …;
const char kNewTabPromosApiPath[] = …;
const char kXSSIResponsePreamble[] = …;
constexpr char kWarningSymbol[] = …;
constexpr char kFakePromo[] = …;
bool CanBlockPromos() { … }
GURL GetGoogleBaseUrl() { … }
GURL GetApiUrl() { … }
bool JsonToPromoData(const base::Value& value, std::optional<PromoData>* data) { … }
}
PromoService::PromoService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
Profile* profile)
: … { … }
PromoService::~PromoService() = default;
void PromoService::Refresh() { … }
void PromoService::OnLoadDone(std::unique_ptr<std::string> response_body) { … }
void PromoService::OnJsonParsed(
data_decoder::DataDecoder::ValueOrError result) { … }
void PromoService::Shutdown() { … }
void PromoService::RegisterProfilePrefs(PrefRegistrySimple* registry) { … }
const std::optional<PromoData>& PromoService::promo_data() const { … }
void PromoService::AddObserver(PromoServiceObserver* observer) { … }
void PromoService::RemoveObserver(PromoServiceObserver* observer) { … }
void PromoService::BlocklistPromo(const std::string& promo_id) { … }
void PromoService::UndoBlocklistPromo(const std::string& promo_id) { … }
void PromoService::PromoDataLoaded(Status status,
const std::optional<PromoData>& data) { … }
void PromoService::NotifyObservers() { … }
bool PromoService::IsBlockedAfterClearingExpired(
const std::string& promo_id) const { … }
GURL PromoService::GetLoadURLForTesting() const { … }