#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h"
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/escape.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/settings_api_helpers.h"
#include "chrome/browser/new_tab_page/modules/new_tab_page_modules.h"
#include "chrome/browser/new_tab_page/new_tab_page_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/background/ntp_background_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/search/ntp_user_data_types.h"
#include "chrome/browser/ui/webui/new_tab_page/ntp_pref_names.h"
#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_section.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/search/ntp_features.h"
#include "components/search_engines/template_url_service.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/color/color_provider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/shell_dialogs/selected_file_info.h"
namespace {
void OpenWebPage(Profile* profile, const GURL& url) { … }
}
bool CustomizeChromePageHandler::IsSupported(
NtpCustomBackgroundService* ntp_custom_background_service,
Profile* profile) { … }
CustomizeChromePageHandler::CustomizeChromePageHandler(
mojo::PendingReceiver<side_panel::mojom::CustomizeChromePageHandler>
pending_page_handler,
mojo::PendingRemote<side_panel::mojom::CustomizeChromePage> pending_page,
NtpCustomBackgroundService* ntp_custom_background_service,
content::WebContents* web_contents,
const std::vector<std::pair<const std::string, int>> module_id_names,
std::optional<base::RepeatingCallback<void(const GURL&)>> open_url_callback)
: … { … }
CustomizeChromePageHandler::~CustomizeChromePageHandler() { … }
void CustomizeChromePageHandler::ScrollToSection(
CustomizeChromeSection section) { … }
void CustomizeChromePageHandler::AttachedTabStateUpdated(
bool is_source_tab_first_party_ntp) { … }
bool CustomizeChromePageHandler::IsNtpManagedByThirdPartySearchEngine() const { … }
void CustomizeChromePageHandler::SetDefaultColor() { … }
void CustomizeChromePageHandler::SetFollowDeviceTheme(bool follow) { … }
void CustomizeChromePageHandler::SetBackgroundImage(
const std::string& attribution_1,
const std::string& attribution_2,
const GURL& attribution_url,
const GURL& image_url,
const GURL& thumbnail_url,
const std::string& collection_id) { … }
void CustomizeChromePageHandler::SetDailyRefreshCollectionId(
const std::string& collection_id) { … }
void CustomizeChromePageHandler::GetBackgroundCollections(
GetBackgroundCollectionsCallback callback) { … }
void CustomizeChromePageHandler::GetBackgroundImages(
const std::string& collection_id,
GetBackgroundImagesCallback callback) { … }
void CustomizeChromePageHandler::ChooseLocalCustomBackground(
ChooseLocalCustomBackgroundCallback callback) { … }
void CustomizeChromePageHandler::RemoveBackgroundImage() { … }
void CustomizeChromePageHandler::UpdateTheme() { … }
void CustomizeChromePageHandler::OpenChromeWebStore() { … }
void CustomizeChromePageHandler::OpenThirdPartyThemePage(
const std::string& theme_id) { … }
void CustomizeChromePageHandler::OpenChromeWebStoreCategoryPage(
side_panel::mojom::ChromeWebStoreCategory category) { … }
void CustomizeChromePageHandler::OpenChromeWebStoreCollectionPage(
side_panel::mojom::ChromeWebStoreCollection collection) { … }
void CustomizeChromePageHandler::OpenChromeWebStoreHomePage() { … }
void CustomizeChromePageHandler::OpenNtpManagedByPage() { … }
void CustomizeChromePageHandler::SetMostVisitedSettings(
bool custom_links_enabled,
bool visible) { … }
void CustomizeChromePageHandler::UpdateMostVisitedSettings() { … }
void CustomizeChromePageHandler::SetModulesVisible(bool visible) { … }
void CustomizeChromePageHandler::SetModuleDisabled(const std::string& module_id,
bool disabled) { … }
void CustomizeChromePageHandler::UpdateModulesSettings() { … }
void CustomizeChromePageHandler::UpdateScrollToSection() { … }
void CustomizeChromePageHandler::UpdateAttachedTabState() { … }
void CustomizeChromePageHandler::UpdateNtpManagedByName() { … }
void CustomizeChromePageHandler::LogEvent(NTPLoggingEventType event) { … }
bool CustomizeChromePageHandler::IsCustomLinksEnabled() const { … }
bool CustomizeChromePageHandler::IsShortcutsVisible() const { … }
std::u16string CustomizeChromePageHandler::GetManagingThirdPartyName() const { … }
void CustomizeChromePageHandler::OnNativeThemeUpdated(
ui::NativeTheme* observed_theme) { … }
void CustomizeChromePageHandler::OnThemeChanged() { … }
void CustomizeChromePageHandler::OnCustomBackgroundImageUpdated() { … }
void CustomizeChromePageHandler::OnCollectionInfoAvailable() { … }
void CustomizeChromePageHandler::OnCollectionImagesAvailable() { … }
void CustomizeChromePageHandler::OnNextCollectionImageAvailable() { … }
void CustomizeChromePageHandler::OnNtpBackgroundServiceShuttingDown() { … }
void CustomizeChromePageHandler::OnTemplateURLServiceChanged() { … }
void CustomizeChromePageHandler::OnTemplateURLServiceShuttingDown() { … }
void CustomizeChromePageHandler::FileSelected(const ui::SelectedFileInfo& file,
int index) { … }
void CustomizeChromePageHandler::FileSelectionCanceled() { … }