chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.cc

// Copyright 2021 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/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h"

#include <stdint.h>

#include <concepts>
#include <sstream>
#include <string>

#include "base/feature_list.h"
#include "base/i18n/time_formatting.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/global_features.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/internals/user_education/user_education_internals.mojom-forward.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "chrome/browser/user_education/user_education_service_factory.h"
#include "components/feature_engagement/public/tracker.h"
#include "components/user_education/common/feature_promo_data.h"
#include "components/user_education/common/feature_promo_registry.h"
#include "components/user_education/common/feature_promo_specification.h"
#include "components/user_education/common/feature_promo_storage_service.h"
#include "components/user_education/common/tutorial_description.h"
#include "components/user_education/common/user_education_features.h"
#include "components/user_education/common/user_education_metadata.h"
#include "components/user_education/webui/whats_new_registry.h"
#include "content/public/browser/web_ui.h"
#include "third_party/abseil-cpp/absl/strings/ascii.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/resource_path.h"

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "net/base/url_util.h"
#endif

FeaturePromoDemoPageData;
FeaturePromoDemoPageDataPtr;
FeaturePromoDemoPageInfo;
FeaturePromoDemoPageInfoPtr;
WhatsNewEditionDemoPageInfo;
WhatsNewEditionDemoPageInfoPtr;
WhatsNewModuleDemoPageInfo;
WhatsNewModuleDemoPageInfoPtr;

namespace user_education::features {
extern bool IsRateLimitingDisabled();
}

namespace {

user_education::TutorialService* GetTutorialService(Profile* profile) {}

user_education::FeaturePromoRegistry* GetFeaturePromoRegistry(
    Profile* profile) {}

user_education::NewBadgeRegistry* GetNewBadgeRegistry(Profile* profile) {}

whats_new::WhatsNewRegistry* GetWhatsNewRegistry() {}

user_education::FeaturePromoStorageService* GetStorageService(
    Profile* profile) {}

user_education::FeaturePromoController* GetFeaturePromoController(
    content::WebUI* web_ui) {}

std::string GetPromoTypeString(
    const user_education::FeaturePromoSpecification& spec) {}

const base::Feature* GetFeatureByName(const std::string& feature_name,
                                      Profile* profile) {}

std::string RemovePrefixAndCamelCase(std::string str, const char* prefix) {}

// Takes the name of a feature and creates a human-readable title out of it to
// be displayed on the tester page.
std::string GetTitleFromFeaturePromoData(
    const base::Feature* feature,
    const user_education::FeaturePromoSpecification& spec) {}

std::vector<std::string> GetSupportedPlatforms(
    const user_education::Metadata::PlatformSet& platforms) {}

std::vector<std::string> GetRequiredFeatures(
    const user_education::Metadata::FeatureSet& required_features) {}

// Takes a string resource which may have placeholder substitutions and/or
// plural variations, and creates a single, readable exemplar string.
//
// This is used to describe the title and text of an IPH which normally
// requires specific parameters to be passed at runtime via a
// `FeaturePromoSpecification::FormatParameters`.
//
// For example, say the string was:
// ```
//   {COUNT, plural,
//       =0 {All tabs were opened in Incognito window.}
//       =1 {One tab was opened in Incognito window.}
//       other {{COUNT} tabs were opened in Incognito window.}}
// ```
//
// Then the resulting example text to be displayed on the tester page would be:
//
//   "All tabs were opened in Incognito window."
//
// This is not perfect, but it at least shows the form the text could take; an
// unmodified string resource with singular/plural substitutions is quite messy.
std::string RemoveStringPlaceholders(int message_id) {}

// Converts the title and text of a promo into the multi-part "instructions"
// format shared by IPH and Tutorials on the tester page.
//
// Substitutions and plurals are stripped out of both to produce more readable
// text; see `RemoveStringPlaceholders()`.
std::vector<std::string> GetPromoInstructions(
    const user_education::FeaturePromoSpecification& spec) {}

std::string GetPromoFollowedBy(
    const user_education::FeaturePromoSpecification& spec) {}

template <typename T>
auto FormatDemoPageData(const char* key,
                        const T& value,
                        bool is_constant = false) {}

auto FormatDemoPageData(const char* key, bool value) {}

auto FormatDemoPageData(const char* key, base::Time value) {}

auto GetPromoData(
    const user_education::FeaturePromoSpecification& spec,
    const user_education::FeaturePromoStorageService* storage_service,
    const feature_engagement::Tracker* tracker) {}

auto GetNewBadgeData(
    const base::Feature& feature,
    const user_education::FeaturePromoStorageService* storage_service) {}

std::vector<std::string> GetTutorialInstructions(
    const user_education::TutorialDescription& desc) {}

std::string GetTutorialTypeString(
    const user_education::TutorialDescription& desc) {}

}  // namespace

UserEducationInternalsPageHandlerImpl::UserEducationInternalsPageHandlerImpl(
    content::WebUI* web_ui,
    Profile* profile,
    mojo::PendingReceiver<
        mojom::user_education_internals::UserEducationInternalsPageHandler>
        receiver)
    :{}

UserEducationInternalsPageHandlerImpl::
    ~UserEducationInternalsPageHandlerImpl() = default;

void UserEducationInternalsPageHandlerImpl::GetTutorials(
    GetTutorialsCallback callback) {}

void UserEducationInternalsPageHandlerImpl::StartTutorial(
    const std::string& tutorial_id,
    StartTutorialCallback callback) {}

void UserEducationInternalsPageHandlerImpl::GetSessionData(
    GetSessionDataCallback callback) {}

void UserEducationInternalsPageHandlerImpl::GetFeaturePromos(
    GetFeaturePromosCallback callback) {}

void UserEducationInternalsPageHandlerImpl::ShowFeaturePromo(
    const std::string& feature_name,
    ShowFeaturePromoCallback callback) {}

void UserEducationInternalsPageHandlerImpl::ClearFeaturePromoData(
    const std::string& feature_name,
    ClearFeaturePromoDataCallback callback) {}

void UserEducationInternalsPageHandlerImpl::ClearSessionData(
    ClearSessionDataCallback callback) {}

void UserEducationInternalsPageHandlerImpl::GetNewBadges(
    GetNewBadgesCallback callback) {}

void UserEducationInternalsPageHandlerImpl::GetWhatsNewModules(
    GetWhatsNewModulesCallback callback) {}

void UserEducationInternalsPageHandlerImpl::GetWhatsNewEditions(
    GetWhatsNewEditionsCallback callback) {}

void UserEducationInternalsPageHandlerImpl::ClearNewBadgeData(
    const std::string& feature_name,
    ClearNewBadgeDataCallback callback) {}

void UserEducationInternalsPageHandlerImpl::ClearWhatsNewData(
    ClearWhatsNewDataCallback callback) {}

void UserEducationInternalsPageHandlerImpl::LaunchWhatsNewStaging() {}