#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) { … }
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) { … }
std::string RemoveStringPlaceholders(int message_id) { … }
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) { … }
}
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() { … }