chromium/chrome/browser/new_tab_page/promos/promo_service.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// The number of days until a blocklist entry expires.
const int kDaysThatBlocklistExpiresIn =;

const char kNewTabPromosApiPath[] =;

const char kXSSIResponsePreamble[] =;

constexpr char kWarningSymbol[] =;
constexpr char kFakePromo[] =;

bool CanBlockPromos() {}

GURL GetGoogleBaseUrl() {}

GURL GetApiUrl() {}

// Parses an update proto from |value|. Will return false if |value| is not of
// the form: {"update":{"promos":{"middle_announce_payload": ""}}}, and true
// otherwise.
// Additionally, there can be a "log_url" or "id" field in the promo. Those are
// populated if found. They're not set for emergency promos. |data| will never
// be std::nullopt if top level dictionary keys of "update" and "promos" are
// present. Note: the "log_url" (if found), is resolved against
// GetGoogleBaseUrl() to form a valid GURL.
bool JsonToPromoData(const base::Value& value, std::optional<PromoData>* data) {}

}  // namespace

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() {}

// static
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 {}