diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-09-01 11:08:40 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-01 12:16:21 +0000 |
commit | 03c549e0392f92c02536d3f86d5e1d8dfa3435ac (patch) | |
tree | fe49d170a929b34ba82cd10db1a0bd8e3760fa4b /chromium/chrome/browser/ui/webui/settings | |
parent | 5d013f5804a0d91fcf6c626b2d6fb6eca5c845b0 (diff) |
BASELINE: Update Chromium to 91.0.4472.160
Change-Id: I0def1f08a2412aeed79a9ab95dd50eb5c3f65f31
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui/settings')
106 files changed, 1095 insertions, 946 deletions
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc index 09b82022336..8f73464b90f 100644 --- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc @@ -17,7 +17,6 @@ #include "base/macros.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -34,6 +33,7 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/chrome_pages.h" +#include "chrome/browser/ui/webui/theme_source.h" #include "chrome/browser/upgrade_detector/upgrade_detector.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -53,11 +53,11 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/constants/ash_switches.h" #include "base/i18n/time_formatting.h" +#include "chrome/browser/ash/arc/arc_util.h" +#include "chrome/browser/ash/ownership/owner_settings_service_ash.h" +#include "chrome/browser/ash/ownership/owner_settings_service_ash_factory.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ash/settings/cros_settings.h" -#include "chrome/browser/chromeos/arc/arc_util.h" -#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" -#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" #include "chrome/browser/chromeos/tpm_firmware_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -100,7 +100,7 @@ struct RegulatoryLabel { // Returns message that informs user that for update it's better to // connect to a network of one of the allowed types. -base::string16 GetAllowedConnectionTypesMessage() { +std::u16string GetAllowedConnectionTypesMessage() { if (help_utils_chromeos::IsUpdateOverCellularAllowed( /*interactive=*/true)) { const bool metered = chromeos::NetworkHandler::Get() @@ -123,8 +123,8 @@ bool CanChangeChannel(Profile* profile) { bool value = false; // On a managed machine we delegate this setting to the affiliated users // only if the policy value is true. - chromeos::CrosSettings::Get()->GetBoolean( - chromeos::kReleaseChannelDelegated, &value); + ash::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated, + &value); if (!value) return false; @@ -136,9 +136,9 @@ bool CanChangeChannel(Profile* profile) { } // On non-managed machines, only the local owner can change the channel. - chromeos::OwnerSettingsServiceChromeOS* service = - chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance() - ->GetForBrowserContext(profile); + ash::OwnerSettingsServiceAsh* service = + ash::OwnerSettingsServiceAshFactory::GetInstance()->GetForBrowserContext( + profile); return service && service->IsOwner(); } @@ -338,6 +338,8 @@ void AboutHandler::RegisterMessages() { content::URLDataSource::Add(profile_, std::make_unique<chromeos::ImageSource>()); #endif + content::URLDataSource::Add(profile_, + std::make_unique<ThemeSource>(profile_)); } void AboutHandler::OnJavascriptAllowed() { @@ -466,7 +468,7 @@ void AboutHandler::HandleSetChannel(const base::ListValue* args) { return; } - base::string16 channel; + std::u16string channel; bool is_powerwash_allowed; if (!args->GetString(0, &channel) || !args->GetBoolean(1, &is_powerwash_allowed)) { @@ -551,8 +553,8 @@ void AboutHandler::OnGetTargetChannel(std::string callback_id, // For the LTS pilot simply check whether the device policy is set and ignore // its value. std::string value; - bool is_lts = chromeos::CrosSettings::Get()->GetString( - chromeos::kReleaseLtsTag, &value); + bool is_lts = + ash::CrosSettings::Get()->GetString(chromeos::kReleaseLtsTag, &value); channel_info->SetBoolean("isLts", is_lts); ResolveJavascriptCallback(base::Value(callback_id), *channel_info); @@ -654,7 +656,7 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status, bool powerwash, const std::string& version, int64_t size, - const base::string16& message) { + const std::u16string& message) { // Only UPDATING state should have progress set. DCHECK(status == VersionUpdater::UPDATING || progress == 0); @@ -670,7 +672,7 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status, #if BUILDFLAG(IS_CHROMEOS_ASH) if (status == VersionUpdater::FAILED_OFFLINE || status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { - base::string16 types_msg = GetAllowedConnectionTypesMessage(); + std::u16string types_msg = GetAllowedConnectionTypesMessage(); if (!types_msg.empty()) event->SetString("connectionTypes", types_msg); else @@ -694,7 +696,7 @@ void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) { bool actionable = state == VersionUpdater::PROMOTE_DISABLED || state == VersionUpdater::PROMOTE_ENABLED; - base::string16 text = base::string16(); + std::u16string text = std::u16string(); if (actionable) text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL); else if (state == VersionUpdater::PROMOTED) diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h index 4b5aafa848d..eb45490feb4 100644 --- a/chromium/chrome/browser/ui/webui/settings/about_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h @@ -11,7 +11,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/ui/webui/help/version_updater.h" @@ -52,7 +51,7 @@ class AboutHandler : public settings::SettingsPageUIHandler, void OnUpgradeRecommended() override; // Returns the browser version as a string. - static base::string16 BuildBrowserVersionString(); + static std::u16string BuildBrowserVersionString(); protected: // Used to test the EOL string displayed in the About details page. @@ -146,7 +145,7 @@ class AboutHandler : public settings::SettingsPageUIHandler, bool powerwash, const std::string& version, int64_t size, - const base::string16& fail_message); + const std::u16string& fail_message); #if defined(OS_MAC) // Callback method which forwards promotion state to the page. diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc index c67cf0a431f..1b9a64a66ad 100644 --- a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc @@ -13,6 +13,7 @@ #include "chrome/grit/generated_resources.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_ui.h" +#include "media/base/media_switches.h" #include "ui/base/l10n/l10n_util.h" #if defined(OS_WIN) || defined(OS_MAC) @@ -33,8 +34,8 @@ void CaptionsHandler::RegisterMessages() { base::BindRepeating(&CaptionsHandler::HandleOpenSystemCaptionsDialog, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "captionsSubpageReady", - base::BindRepeating(&CaptionsHandler::HandleCaptionsSubpageReady, + "liveCaptionSectionReady", + base::BindRepeating(&CaptionsHandler::HandleLiveCaptionSectionReady, base::Unretained(this))); } @@ -46,7 +47,8 @@ void CaptionsHandler::OnJavascriptDisallowed() { speech::SodaInstaller::GetInstance()->RemoveObserver(this); } -void CaptionsHandler::HandleCaptionsSubpageReady(const base::ListValue* args) { +void CaptionsHandler::HandleLiveCaptionSectionReady( + const base::ListValue* args) { AllowJavascript(); } @@ -59,21 +61,24 @@ void CaptionsHandler::HandleOpenSystemCaptionsDialog( void CaptionsHandler::OnSodaInstalled() { speech::SodaInstaller::GetInstance()->RemoveObserver(this); - FireWebUIListener("enable-live-caption-subtitle-changed", + FireWebUIListener("soda-download-progress-changed", base::Value(l10n_util::GetStringUTF16( IDS_SETTINGS_CAPTIONS_LIVE_CAPTION_DOWNLOAD_COMPLETE))); } void CaptionsHandler::OnSodaError() { - prefs_->SetBoolean(prefs::kLiveCaptionEnabled, false); - FireWebUIListener("enable-live-caption-subtitle-changed", + if (!base::FeatureList::IsEnabled(media::kLiveCaptionMultiLanguage)) { + prefs_->SetBoolean(prefs::kLiveCaptionEnabled, false); + } + + FireWebUIListener("soda-download-progress-changed", base::Value(l10n_util::GetStringUTF16( IDS_SETTINGS_CAPTIONS_LIVE_CAPTION_DOWNLOAD_ERROR))); } void CaptionsHandler::OnSodaProgress(int progress) { FireWebUIListener( - "enable-live-caption-subtitle-changed", + "soda-download-progress-changed", base::Value(l10n_util::GetStringFUTF16Int( IDS_SETTINGS_CAPTIONS_LIVE_CAPTION_DOWNLOAD_PROGRESS, progress))); } diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.h b/chromium/chrome/browser/ui/webui/settings/captions_handler.h index 9924dc6d2cb..53cd6a2d9e5 100644 --- a/chromium/chrome/browser/ui/webui/settings/captions_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.h @@ -27,7 +27,7 @@ class CaptionsHandler : public SettingsPageUIHandler, void OnJavascriptDisallowed() override; private: - void HandleCaptionsSubpageReady(const base::ListValue* args); + void HandleLiveCaptionSectionReady(const base::ListValue* args); void HandleOpenSystemCaptionsDialog(const base::ListValue* args); // SodaInstaller::Observer overrides: diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc index ca6c5e50300..c7aa55a9836 100644 --- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc +++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc @@ -15,7 +15,6 @@ #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" -#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/synchronization/lock.h" #include "base/values.h" @@ -296,9 +295,9 @@ void ChromeCleanupHandler::GetPluralString(int id, int num_items = 0; args->GetInteger(1, &num_items); - const base::string16 plural_string = + const std::u16string plural_string = num_items > 0 ? l10n_util::GetPluralStringFUTF16(id, num_items) - : base::string16(); + : std::u16string(); ResolveJavascriptCallback(base::Value(callback_id), base::Value(plural_string)); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc index 8a8384d6426..5533f8e22f0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc @@ -12,7 +12,7 @@ #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "base/system/sys_info.h" -#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ash/arc/arc_util.h" #include "chrome/browser/obsolete_system/obsolete_system.h" #include "chrome/browser/ui/webui/management/management_ui.h" #include "chrome/browser/ui/webui/settings/about_handler.h" @@ -279,6 +279,8 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) { {"aboutOsProductTitle", IDS_PRODUCT_OS_NAME}, {"aboutReleaseNotesOffline", IDS_SETTINGS_ABOUT_PAGE_RELEASE_NOTES}, {"aboutShowReleaseNotes", IDS_SETTINGS_ABOUT_PAGE_SHOW_RELEASE_NOTES}, + {"aboutManagedEndOfLifeSubtitle", + IDS_SETTINGS_ABOUT_PAGE_MANAGED_END_OF_LIFE_SUBTITLE}, }; html_source->AddLocalizedStrings(kLocalizedStrings); @@ -306,7 +308,9 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) { l10n_util::GetStringUTF16(version_info::IsOfficialBuild() ? IDS_VERSION_UI_OFFICIAL : IDS_VERSION_UI_UNOFFICIAL), - base::UTF8ToUTF16(chrome::GetChannelName()), + // Extended stable channel is not supported on Chrome OS Ash. + base::UTF8ToUTF16( + chrome::GetChannelName(chrome::WithExtendedStable(false))), l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation()))); html_source->AddString( "aboutProductCopyright", @@ -314,16 +318,16 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) { l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT), base::Time::Now())); - base::string16 license = l10n_util::GetStringFUTF16( + std::u16string license = l10n_util::GetStringFUTF16( IDS_VERSION_UI_LICENSE, base::ASCIIToUTF16(chrome::kChromiumProjectURL), base::ASCIIToUTF16(chrome::kChromeUICreditsURL)); html_source->AddString("aboutProductLicense", license); - base::string16 os_license = l10n_util::GetStringFUTF16( + std::u16string os_license = l10n_util::GetStringFUTF16( IDS_ABOUT_CROS_VERSION_LICENSE, base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); html_source->AddString("aboutProductOsLicense", os_license); - base::string16 os_with_linux_license = l10n_util::GetStringFUTF16( + std::u16string os_with_linux_license = l10n_util::GetStringFUTF16( IDS_ABOUT_CROS_WITH_LINUX_VERSION_LICENSE, base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL), base::ASCIIToUTF16(chrome::kChromeUICrostiniCreditsURL)); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc index b35cc7976ac..7c721c3d528 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc @@ -41,6 +41,7 @@ #include "ui/accessibility/accessibility_switches.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/webui/web_ui_util.h" +#include "ui/chromeos/events/keyboard_layout_util.h" namespace chromeos { namespace settings { @@ -345,6 +346,10 @@ bool IsSwitchAccessTextAllowed() { ::switches::kEnableExperimentalAccessibilitySwitchAccessText); } +bool IsSwitchAccessPointScanningEnabled() { + return features::IsSwitchAccessPointScanningEnabled(); +} + bool IsSwitchAccessSetupGuideAllowed() { return base::CommandLine::ForCurrentProcess()->HasSwitch( ::switches::kEnableExperimentalAccessibilitySwitchAccessSetupGuide); @@ -440,6 +445,7 @@ void AccessibilitySection::AddLoadTimeData( {"chromeVoxLabel", IDS_SETTINGS_CHROMEVOX_LABEL}, {"chromeVoxOptionsLabel", IDS_SETTINGS_CHROMEVOX_OPTIONS_LABEL}, {"screenMagnifierLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_LABEL}, + {"screenMagnifierHintLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_HINT_LABEL}, {"screenMagnifierMouseFollowingModeContinuous", IDS_SETTINGS_SCREEN_MANIFIER_MOUSE_FOLLOWING_MODE_CONTINUOUS}, {"screenMagnifierMouseFollowingModeCentered", @@ -449,6 +455,8 @@ void AccessibilitySection::AddLoadTimeData( {"screenMagnifierFocusFollowingLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_FOCUS_FOLLOWING_LABEL}, {"screenMagnifierZoomLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_LABEL}, + {"screenMagnifierZoomHintLabel", + IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_HINT_LABEL}, {"dockedMagnifierLabel", IDS_SETTINGS_DOCKED_MAGNIFIER_LABEL}, {"dockedMagnifierZoomLabel", IDS_SETTINGS_DOCKED_MAGNIFIER_ZOOM_LABEL}, {"screenMagnifierZoom2x", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_2_X}, @@ -584,6 +592,8 @@ void AccessibilitySection::AddLoadTimeData( IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_SPEED_LABEL}, {"switchAccessAutoScanKeyboardSpeedLabel", IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_KEYBOARD_SPEED_LABEL}, + {"switchAccessPointScanSpeedLabel", + IDS_SETTINGS_SWITCH_ACCESS_POINT_SCAN_SPEED_LABEL}, {"durationInSeconds", IDS_SETTINGS_DURATION_IN_SECONDS}, {"manageAccessibilityFeatures", IDS_SETTINGS_ACCESSIBILITY_MANAGE_ACCESSIBILITY_FEATURES}, @@ -655,6 +665,11 @@ void AccessibilitySection::AddLoadTimeData( }; html_source->AddLocalizedStrings(kLocalizedStrings); + html_source->AddLocalizedString("screenMagnifierHintSearchKey", + ui::DeviceUsesKeyboardLayout2() + ? IDS_SETTINGS_KEYBOARD_KEY_LAUNCHER + : IDS_SETTINGS_KEYBOARD_KEY_SEARCH); + html_source->AddString("a11yLearnMoreUrl", chrome::kChromeAccessibilityHelpURL); @@ -662,6 +677,9 @@ void AccessibilitySection::AddLoadTimeData( "showExperimentalAccessibilitySwitchAccessImprovedTextInput", IsSwitchAccessTextAllowed()); + html_source->AddBoolean("isSwitchAccessPointScanningEnabled", + IsSwitchAccessPointScanningEnabled()); + html_source->AddBoolean("showSwitchAccessSetupGuide", IsSwitchAccessSetupGuideAllowed()); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc index 3d591a99b11..bf3c5b53ea0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc @@ -17,6 +17,7 @@ #include "base/values.h" #include "chrome/browser/account_manager_facade_factory.h" #include "chrome/browser/ash/profiles/profile_helper.h" +#include "chrome/browser/enterprise/util/managed_browser_utils.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.h" @@ -46,17 +47,6 @@ constexpr int kToastDurationMs = 2500; constexpr char kAccountRemovedToastId[] = "settings_account_manager_account_removed"; -std::string GetEnterpriseDomainFromUsername(const std::string& username) { - size_t email_separator_pos = username.find('@'); - bool is_email = email_separator_pos != std::string::npos && - email_separator_pos < username.length() - 1; - - if (!is_email) - return std::string(); - - return gaia::ExtractDomainName(username); -} - ::account_manager::AccountKey GetAccountKeyFromJsCallback( const base::DictionaryValue* const dictionary) { const base::Value* id_value = dictionary->FindKey("id"); @@ -89,7 +79,7 @@ bool IsSameAccount(const ::account_manager::AccountKey& account_key, } } -void ShowToast(const std::string& id, const base::string16& message) { +void ShowToast(const std::string& id, const std::u16string& message) { ash::ToastManager::Get()->Show(ash::ToastData( id, message, kToastDurationMs, /*dismiss_text=*/base::nullopt)); } @@ -175,9 +165,13 @@ class AccountBuilder { AccountManagerUIHandler::AccountManagerUIHandler( AccountManager* account_manager, + account_manager::AccountManagerFacade* account_manager_facade, signin::IdentityManager* identity_manager) - : account_manager_(account_manager), identity_manager_(identity_manager) { + : account_manager_(account_manager), + account_manager_facade_(account_manager_facade), + identity_manager_(identity_manager) { DCHECK(account_manager_); + DCHECK(account_manager_facade_); DCHECK(identity_manager_); } @@ -273,12 +267,13 @@ void AccountManagerUIHandler::OnCheckDummyGaiaTokenForAllAccounts( device_account.SetOrganization(organization); } else if (user->IsActiveDirectoryUser()) { device_account.SetOrganization( - GetEnterpriseDomainFromUsername(user->GetDisplayEmail())); + chrome::enterprise_util::GetDomainFromEmail(user->GetDisplayEmail())); } else if (profile_->GetProfilePolicyConnector()->IsManaged()) { - device_account.SetOrganization(GetEnterpriseDomainFromUsername( - identity_manager_ - ->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired) - .email)); + device_account.SetOrganization( + chrome::enterprise_util::GetDomainFromEmail( + identity_manager_ + ->GetPrimaryAccountInfo(signin::ConsentLevel::kSignin) + .email)); } // Device account must show up at the top. @@ -307,7 +302,12 @@ base::ListValue AccountManagerUIHandler::GetSecondaryGaiaAccounts( identity_manager_ ->FindExtendedAccountInfoForAccountWithRefreshTokenByGaiaId( account_key.id); - DCHECK(maybe_account_info.has_value()); + if (!maybe_account_info.has_value()) { + // This account hasn't propagated to IdentityManager yet. When this + // happens, `IdentityManager` will call `OnRefreshTokenUpdatedForAccount` + // which will trigger another UI update. + continue; + } AccountBuilder account; account.SetId(account_key.id) @@ -408,20 +408,20 @@ void AccountManagerUIHandler::HandleShowWelcomeDialogIfRequired( } void AccountManagerUIHandler::OnJavascriptAllowed() { - account_manager_observation_.Observe(account_manager_); + account_manager_facade_observation_.Observe(account_manager_facade_); identity_manager_observation_.Observe(identity_manager_); } void AccountManagerUIHandler::OnJavascriptDisallowed() { - account_manager_observation_.Reset(); + account_manager_facade_observation_.Reset(); identity_manager_observation_.Reset(); } -// |AccountManager::Observer| overrides. Note: We need to listen on -// |AccountManager| in addition to |IdentityManager| because there is no +// |AccountManagerFacade::Observer| overrides. Note: We need to listen on +// |AccountManagerFacade| in addition to |IdentityManager| because there is no // guarantee that |AccountManager| (our source of truth) will have a newly added // account by the time |IdentityManager| has it. -void AccountManagerUIHandler::OnTokenUpserted( +void AccountManagerUIHandler::OnAccountUpserted( const ::account_manager::Account& account) { RefreshUI(); } @@ -432,7 +432,14 @@ void AccountManagerUIHandler::OnAccountRemoved( } // |signin::IdentityManager::Observer| overrides. -// +// `GetSecondaryGaiaAccounts` skips all accounts that haven't been added to +// `IdentityManager` yet. Thus, we should trigger an updated whenever a new +// account is added into `IdentityManager`. +void AccountManagerUIHandler::OnRefreshTokenUpdatedForAccount( + const CoreAccountInfo& info) { + RefreshUI(); +} + // For newly added accounts, |signin::IdentityManager| may take some time to // fetch user's full name and account image. Whenever that is completed, we may // need to update the UI with this new set of information. Note that we may be diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h index 90b45c38d5b..ade2cb2cbe0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h @@ -15,6 +15,7 @@ #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "components/account_id/account_id.h" #include "components/account_manager_core/account.h" +#include "components/account_manager_core/account_manager_facade.h" #include "components/signin/public/identity_manager/identity_manager.h" class Profile; @@ -22,14 +23,17 @@ class Profile; namespace chromeos { namespace settings { -class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler, - public AccountManager::Observer, - public signin::IdentityManager::Observer { +class AccountManagerUIHandler + : public ::settings::SettingsPageUIHandler, + public account_manager::AccountManagerFacade::Observer, + public signin::IdentityManager::Observer { public: - // Accepts non-owning pointers to |AccountManager|, |AccountTrackerService| + // Accepts non-owning pointers to |AccountManager|, |AccountManagerFacade| // and |IdentityManager|. Both of these must outlive |this| instance. - AccountManagerUIHandler(AccountManager* account_manager, - signin::IdentityManager* identity_manager); + AccountManagerUIHandler( + AccountManager* account_manager, + account_manager::AccountManagerFacade* account_manager_facade, + signin::IdentityManager* identity_manager); ~AccountManagerUIHandler() override; // WebUIMessageHandler implementation. @@ -37,13 +41,14 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler, void OnJavascriptAllowed() override; void OnJavascriptDisallowed() override; - // |AccountManager::Observer| overrides. + // |AccountManagerFacade::Observer| overrides. // |AccountManager| is considered to be the source of truth for account // information. - void OnTokenUpserted(const ::account_manager::Account& account) override; + void OnAccountUpserted(const ::account_manager::Account& account) override; void OnAccountRemoved(const ::account_manager::Account& account) override; // |signin::IdentityManager::Observer| overrides. + void OnRefreshTokenUpdatedForAccount(const CoreAccountInfo& info) override; void OnExtendedAccountInfoUpdated(const AccountInfo& info) override; void OnErrorStateOfRefreshTokenUpdatedForAccount( const CoreAccountInfo& account_info, @@ -99,13 +104,17 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler, // A non-owning pointer to |AccountManager|. AccountManager* const account_manager_; + // A non-owning pointer to |AccountManagerFacade|. + account_manager::AccountManagerFacade* const account_manager_facade_; + // A non-owning pointer to |IdentityManager|. signin::IdentityManager* const identity_manager_; - // An observer for |AccountManager|. Automatically deregisters when |this| is - // destructed. - base::ScopedObservation<AccountManager, AccountManager::Observer> - account_manager_observation_{this}; + // An observer for |AccountManagerFacade|. Automatically deregisters when + // |this| is destructed. + base::ScopedObservation<account_manager::AccountManagerFacade, + account_manager::AccountManagerFacade::Observer> + account_manager_facade_observation_{this}; // An observer for |signin::IdentityManager|. Automatically deregisters when // |this| is destructed. diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc index 37bf9bbfb66..0554e6e9199 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc @@ -10,14 +10,16 @@ #include "ash/components/account_manager/account_manager.h" #include "ash/components/account_manager/account_manager_factory.h" #include "base/test/bind.h" +#include "chrome/browser/account_manager_facade_factory.h" +#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/supervised_user/supervised_user_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_profile.h" +#include "components/account_manager_core/account_manager_facade.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/user_manager/scoped_user_manager.h" @@ -105,10 +107,14 @@ namespace settings { class TestingAccountManagerUIHandler : public AccountManagerUIHandler { public: - TestingAccountManagerUIHandler(AccountManager* account_manager, - signin::IdentityManager* identity_manager, - content::WebUI* web_ui) - : AccountManagerUIHandler(account_manager, identity_manager) { + TestingAccountManagerUIHandler( + AccountManager* account_manager, + account_manager::AccountManagerFacade* account_manager_facade, + signin::IdentityManager* identity_manager, + content::WebUI* web_ui) + : AccountManagerUIHandler(account_manager, + account_manager_facade, + identity_manager) { set_web_ui(web_ui); } @@ -136,7 +142,7 @@ class AccountManagerUIHandlerTest } profile_ = profile_builder.Build(); - auto user_manager = std::make_unique<chromeos::FakeChromeUserManager>(); + auto user_manager = std::make_unique<FakeChromeUserManager>(); const user_manager::User* user; if (GetDeviceAccountInfo().user_type == user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY) { @@ -173,8 +179,11 @@ class AccountManagerUIHandlerTest GetDeviceAccountInfo().account_type}, GetDeviceAccountInfo().email, GetDeviceAccountInfo().token); + auto* account_manager_facade = + ::GetAccountManagerFacade(profile_->GetPath().value()); + handler_ = std::make_unique<TestingAccountManagerUIHandler>( - account_manager_, identity_manager_, &web_ui_); + account_manager_, account_manager_facade, identity_manager_, &web_ui_); handler_->SetProfileForTesting(profile_.get()); handler_->RegisterMessages(); handler_->AllowJavascriptForTesting(); @@ -235,8 +244,8 @@ class AccountManagerUIHandlerTest AccountManager* account_manager() { return account_manager_; } private: - chromeos::FakeChromeUserManager* GetFakeUserManager() const { - return static_cast<chromeos::FakeChromeUserManager*>( + FakeChromeUserManager* GetFakeUserManager() const { + return static_cast<FakeChromeUserManager*>( user_manager::UserManager::Get()); } @@ -302,6 +311,9 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest, GetAccountsFromAccountManager(); ASSERT_EQ(3UL, account_manager_accounts.size()); + // Wait for accounts to propagate to IdentityManager. + base::RunLoop().RunUntilIdle(); + // Call "getAccounts". base::ListValue args; args.AppendString(kHandleFunctionName); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc index f4e541f277e..b83273b0738 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc @@ -21,7 +21,6 @@ #include "base/memory/ref_counted_memory.h" #include "base/optional.h" #include "base/stl_util.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/values.h" @@ -107,7 +106,7 @@ void EncodeImage(const gfx::ImageSkia& image, } } -base::string16 GetAlbumDescription(const ash::PersonalAlbum& album) { +std::u16string GetAlbumDescription(const ash::PersonalAlbum& album) { if (album.album_id == ash::kAmbientModeRecentHighlightsAlbumId) { return l10n_util::GetStringUTF16( IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_RECENT_DESC); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc index 9ddec3c9294..864db882f6d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc @@ -9,7 +9,7 @@ #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/launch_utils.h" -#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ash/arc/arc_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" // kSettingsAppId #include "components/services/app_service/public/cpp/intent_util.h" @@ -21,8 +21,9 @@ namespace chromeos { namespace settings { -AndroidAppsHandler::AndroidAppsHandler(Profile* profile, - apps::AppServiceProxy* app_service_proxy) +AndroidAppsHandler::AndroidAppsHandler( + Profile* profile, + apps::AppServiceProxyChromeOs* app_service_proxy) : profile_(profile), app_service_proxy_(app_service_proxy) {} AndroidAppsHandler::~AndroidAppsHandler() {} diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h index c1811b1d019..070e2800ce9 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h @@ -12,8 +12,8 @@ #include "base/memory/weak_ptr.h" #include "base/scoped_observation.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" -#include "chrome/browser/chromeos/arc/session/arc_session_manager.h" -#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h" +#include "chrome/browser/ash/arc/session/arc_session_manager.h" +#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" @@ -31,7 +31,7 @@ class AndroidAppsHandler : public ::settings::SettingsPageUIHandler, public arc::ArcSessionManagerObserver { public: explicit AndroidAppsHandler(Profile* profile, - apps::AppServiceProxy* app_service_proxy); + apps::AppServiceProxyChromeOs* app_service_proxy); ~AndroidAppsHandler() override; // SettingsPageUIHandler @@ -63,7 +63,7 @@ class AndroidAppsHandler : public ::settings::SettingsPageUIHandler, arc::ArcSessionManagerObserver> arc_session_manager_observation_{this}; Profile* profile_; // unowned - apps::AppServiceProxy* app_service_proxy_; + apps::AppServiceProxyChromeOs* app_service_proxy_; base::WeakPtrFactory<AndroidAppsHandler> weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(AndroidAppsHandler); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc index 13a569f6124..0fa80764681 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc @@ -8,10 +8,10 @@ #include "base/feature_list.h" #include "base/no_destructor.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/chromeos/arc/arc_util.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_features.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_pref_names.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h" +#include "chrome/browser/ash/arc/arc_util.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_features.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_pref_names.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_util.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/webui/app_management/app_management_page_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h" @@ -178,7 +178,7 @@ AppsSection::AppsSection(Profile* profile, SearchTagRegistry* search_tag_registry, PrefService* pref_service, ArcAppListPrefs* arc_app_list_prefs, - apps::AppServiceProxy* app_service_proxy) + apps::AppServiceProxyChromeOs* app_service_proxy) : OsSettingsSection(profile, search_tag_registry), pref_service_(pref_service), arc_app_list_prefs_(arc_app_list_prefs), diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h index 042ac25ac87..ce3c0304f1f 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h @@ -29,7 +29,7 @@ class AppsSection : public OsSettingsSection, public ArcAppListPrefs::Observer { SearchTagRegistry* search_tag_registry, PrefService* pref_service, ArcAppListPrefs* arc_app_list_prefs, - apps::AppServiceProxy* app_service_proxy); + apps::AppServiceProxyChromeOs* app_service_proxy); ~AppsSection() override; private: @@ -54,7 +54,7 @@ class AppsSection : public OsSettingsSection, public ArcAppListPrefs::Observer { PrefService* pref_service_; ArcAppListPrefs* arc_app_list_prefs_; - apps::AppServiceProxy* app_service_proxy_; + apps::AppServiceProxyChromeOs* app_service_proxy_; PrefChangeRegistrar pref_change_registrar_; }; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc index eef4fac6f63..f68d8ba2d75 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc @@ -6,6 +6,7 @@ #include <numeric> +#include "base/callback_helpers.h" #include "base/system/sys_info.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h" @@ -15,7 +16,8 @@ #include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/profiles/profile.h" #include "chromeos/cryptohome/cryptohome_util.h" -#include "chromeos/dbus/cryptohome/cryptohome_client.h" +#include "chromeos/cryptohome/userdataauth_util.h" +#include "chromeos/dbus/userdataauth/userdataauth_client.h" #include "components/arc/arc_service_manager.h" #include "components/arc/session/arc_bridge_service.h" #include "components/arc/storage_manager/arc_storage_manager.h" @@ -363,10 +365,12 @@ void OtherUsersSizeCalculator::PerformCalculation() { if (user->is_active()) continue; other_users_.push_back(user); - CryptohomeClient::Get()->GetAccountDiskUsage( - cryptohome::CreateAccountIdentifierFromAccountId(user->GetAccountId()), - base::BindOnce(&OtherUsersSizeCalculator::OnGetOtherUserSize, - weak_ptr_factory_.GetWeakPtr())); + user_data_auth::GetAccountDiskUsageRequest request; + *request.mutable_identifier() = + cryptohome::CreateAccountIdentifierFromAccountId(user->GetAccountId()); + UserDataAuthClient::Get()->GetAccountDiskUsage( + request, base::BindOnce(&OtherUsersSizeCalculator::OnGetOtherUserSize, + weak_ptr_factory_.GetWeakPtr())); } // We should show "0 B" if there is no other user. if (other_users_.empty()) { @@ -375,8 +379,9 @@ void OtherUsersSizeCalculator::PerformCalculation() { } void OtherUsersSizeCalculator::OnGetOtherUserSize( - base::Optional<cryptohome::BaseReply> reply) { - user_sizes_.push_back(cryptohome::AccountDiskUsageReplyToUsageSize(reply)); + base::Optional<user_data_auth::GetAccountDiskUsageReply> reply) { + user_sizes_.push_back( + user_data_auth::AccountDiskUsageReplyToUsageSize(reply)); if (user_sizes_.size() != other_users_.size()) return; int64_t other_users_total_bytes; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h index 8f483f50b95..0dd5ae4ec56 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h @@ -17,6 +17,7 @@ #include "base/values.h" #include "chrome/browser/browsing_data/site_data_size_collector.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h" +#include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "components/arc/mojom/storage_manager.mojom.h" #include "components/arc/session/connection_observer.h" @@ -277,7 +278,8 @@ class OtherUsersSizeCalculator : public SizeCalculator { void PerformCalculation() override; // Callback to update the sizes of the other users. - void OnGetOtherUserSize(base::Optional<cryptohome::BaseReply> reply); + void OnGetOtherUserSize( + base::Optional<::user_data_auth::GetAccountDiskUsageReply> reply); // The list of other users whose directory sizes will be accumulated as the // size of "Other users". diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h index 2e0850df244..59a6c340901 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h @@ -141,7 +141,8 @@ class OtherUsersSizeTestAPI { user_manager::UserList(user_count); } - void SimulateOnGetOtherUserSize(base::Optional<cryptohome::BaseReply> reply) { + void SimulateOnGetOtherUserSize( + base::Optional<user_data_auth::GetAccountDiskUsageReply> reply) { other_users_size_calculator_->OnGetOtherUserSize(reply); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc index 8f203997c01..f06a0d7df98 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc @@ -22,11 +22,11 @@ #include "base/task/thread_pool.h" #include "base/values.h" #include "chrome/browser/ash/accessibility/accessibility_manager.h" +#include "chrome/browser/ash/login/users/avatar/user_image_manager.h" +#include "chrome/browser/ash/login/users/chrome_user_manager.h" +#include "chrome/browser/ash/login/users/default_user_image/default_user_images.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/chromeos/camera_presence_notifier.h" -#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" -#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" -#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/chrome_select_file_policy.h" @@ -273,7 +273,7 @@ void ChangePictureHandler::SendProfileImage(const gfx::ImageSkia& image, } void ChangePictureHandler::UpdateProfileImage() { - UserImageManager* user_image_manager = + auto* user_image_manager = ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); // If we have a downloaded profile image and haven't sent it in // |SendSelectedImage|, send it now (without selecting). @@ -307,7 +307,7 @@ void ChangePictureHandler::HandleSelectImage(const base::ListValue* args) { // |image_url| may be empty unless |image_type| is "default". DCHECK(!image_type.empty()); - UserImageManager* user_image_manager = + auto* user_image_manager = ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); bool waiting_for_camera_photo = false; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom index 94db45d7cc1..fae1ea69d6f 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom @@ -80,7 +80,8 @@ enum Subpage { // Note: Value 502 was for deprecated kAmbientModePhotos. Do not reuse. kAmbientModeGooglePhotosAlbum = 503, kAmbientModeArtGalleryAlbum = 504, - kWallpaper = 505, + // 505 was used for kWallpaper. Do not reuse. + // 506 was used for kWallpaperImages. Do not reuse. // Search and Assistant section. kAssistant = 600, @@ -187,7 +188,6 @@ const string kPowerSubpagePath = "power"; // Personalization section. const string kPersonalizationSectionPath = "personalization"; const string kChangePictureSubpagePath = "changePicture"; -const string kWallpaperSubpagePath = "wallpaper"; const string kAmbientModeSubpagePath = "ambientMode"; const string kAmbientModeGooglePhotosAlbumSubpagePath = "ambientMode/photos?topicSource=0"; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc index ee8497629a5..341704d873d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc @@ -61,7 +61,6 @@ bool IsOSSettingsSubPage(const std::string& sub_page) { // Personalization section. chromeos::settings::mojom::kPersonalizationSectionPath, chromeos::settings::mojom::kChangePictureSubpagePath, - chromeos::settings::mojom::kWallpaperSubpagePath, chromeos::settings::mojom::kAmbientModeSubpagePath, // Search and Assistant section. diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom index e975fd423ec..db80053db2d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom @@ -38,6 +38,7 @@ enum Setting { kCellularAddNetwork = 26, kCellularRemoveESimNetwork = 27, kCellularRenameESimNetwork = 28, + kWifiHidden = 29, // Bluetooth section. kBluetoothOnOff = 100, diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc index 9e831c79f9e..c409b56d6b7 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc @@ -7,7 +7,6 @@ #include <set> #include <utility> -#include "ash/constants/ash_features.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/containers/flat_map.h" @@ -28,7 +27,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/printing/cups_printers_manager.h" #include "chrome/browser/chromeos/printing/ppd_provider_factory.h" -#include "chrome/browser/chromeos/printing/print_management/print_management_uma.h" #include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_event_tracker.h" #include "chrome/browser/chromeos/printing/printer_event_tracker_factory.h" @@ -44,7 +42,6 @@ #include "chrome/browser/ui/webui/settings/chromeos/server_printer_url_util.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_names.h" -#include "chromeos/components/scanning/scanning_uma.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/debug_daemon/debug_daemon_client.h" #include "chromeos/printing/ppd_line_reader.h" @@ -86,7 +83,8 @@ void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) { // Log if the IPP attributes request was succesful. void RecordIppQueryResult(const PrinterQueryResult& result) { - bool reachable = (result != PrinterQueryResult::kUnreachable); + bool reachable = result != PrinterQueryResult::kHostnameResolution && + result != PrinterQueryResult::kUnreachable; UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.IppDeviceReachable", reachable); if (reachable) { @@ -128,8 +126,6 @@ std::unique_ptr<chromeos::Printer> DictToPrinter( std::string printer_id; std::string printer_name; std::string printer_description; - std::string printer_manufacturer; - std::string printer_model; std::string printer_make_and_model; std::string printer_address; std::string printer_protocol; @@ -138,8 +134,6 @@ std::unique_ptr<chromeos::Printer> DictToPrinter( if (!printer_dict.GetString("printerId", &printer_id) || !printer_dict.GetString("printerName", &printer_name) || !printer_dict.GetString("printerDescription", &printer_description) || - !printer_dict.GetString("printerManufacturer", &printer_manufacturer) || - !printer_dict.GetString("printerModel", &printer_model) || !printer_dict.GetString("printerMakeAndModel", &printer_make_and_model) || !printer_dict.GetString("printerAddress", &printer_address) || !printer_dict.GetString("printerProtocol", &printer_protocol) || @@ -159,8 +153,6 @@ std::unique_ptr<chromeos::Printer> DictToPrinter( auto printer = std::make_unique<chromeos::Printer>(printer_id); printer->set_display_name(printer_name); printer->set_description(printer_description); - printer->set_manufacturer(printer_manufacturer); - printer->set_model(printer_model); printer->set_make_and_model(printer_make_and_model); printer->set_print_server_uri(print_server_uri); @@ -355,12 +347,10 @@ void CupsPrintersHandler::RegisterMessages() { "openPrintManagementApp", base::BindRepeating(&CupsPrintersHandler::HandleOpenPrintManagementApp, base::Unretained(this))); - if (base::FeatureList::IsEnabled(chromeos::features::kScanningUI)) { - web_ui()->RegisterMessageCallback( - "openScanningApp", - base::BindRepeating(&CupsPrintersHandler::HandleOpenScanningApp, - base::Unretained(this))); - } + web_ui()->RegisterMessageCallback( + "openScanningApp", + base::BindRepeating(&CupsPrintersHandler::HandleOpenScanningApp, + base::Unretained(this))); } void CupsPrintersHandler::OnJavascriptAllowed() { @@ -487,7 +477,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) { !IsValidPrinterUri(uri)) { // Run the failure callback. OnAutoconfQueried(callback_id, PrinterQueryResult::kUnknownFailure, - printing::PrinterStatus(), "", "", "", {}, false); + printing::PrinterStatus(), "", {}, false); return; } @@ -501,8 +491,6 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered( Printer printer, PrinterQueryResult result, const printing::PrinterStatus& printer_status, - const std::string& make, - const std::string& model, const std::string& make_and_model, const std::vector<std::string>& document_formats, bool ipp_everywhere) { @@ -514,11 +502,6 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered( // guaranteed to have it. However, don't overwrite it if the printer // advertises an empty value through printer-make-and-model. if (!make_and_model.empty()) { - // manufacturer and model are set with make_and_model because they are - // derived from make_and_model for compatability and are slated for - // removal. - printer.set_manufacturer(make); - printer.set_model(model); printer.set_make_and_model(make_and_model); PRINTER_LOG(DEBUG) << "Printer queried for make and model " << make_and_model; @@ -548,15 +531,14 @@ void CupsPrintersHandler::OnAutoconfQueried( const std::string& callback_id, PrinterQueryResult result, const printing::PrinterStatus& printer_status, - const std::string& make, - const std::string& model, const std::string& make_and_model, const std::vector<std::string>& document_formats, bool ipp_everywhere) { RecordIppQueryResult(result); const bool success = result == PrinterQueryResult::kSuccess; - if (result == PrinterQueryResult::kUnreachable) { + if (result == PrinterQueryResult::kHostnameResolution || + result == PrinterQueryResult::kUnreachable) { PRINTER_LOG(DEBUG) << "Could not reach printer"; RejectJavascriptCallback( base::Value(callback_id), @@ -579,8 +561,6 @@ void CupsPrintersHandler::OnAutoconfQueried( // Bundle printer metadata base::Value info(base::Value::Type::DICTIONARY); - info.SetKey("manufacturer", base::Value(make)); - info.SetKey("model", base::Value(model)); info.SetKey("makeAndModel", base::Value(make_and_model)); info.SetKey("autoconf", base::Value(ipp_everywhere)); @@ -717,10 +697,6 @@ void CupsPrintersHandler::AddOrReconfigurePrinter(const base::ListValue* args, } if (printer->make_and_model().empty()) { - // In lieu of more accurate information, populate the make and model - // fields with the PPD information. - printer->set_manufacturer(ppd_manufacturer); - printer->set_model(ppd_model); // PPD Model names are actually make and model. printer->set_make_and_model(ppd_model); } @@ -899,7 +875,7 @@ void CupsPrintersHandler::HandleSelectPPDFile(const base::ListValue* args) { file_type_info.extensions.push_back({"ppd"}); file_type_info.extensions.push_back({"ppd.gz"}); select_file_dialog_->SelectFile( - ui::SelectFileDialog::SELECT_OPEN_FILE, base::string16(), downloads_path, + ui::SelectFileDialog::SELECT_OPEN_FILE, std::u16string(), downloads_path, &file_type_info, 0, FILE_PATH_LITERAL(""), owning_window, nullptr); } @@ -1313,15 +1289,12 @@ void CupsPrintersHandler::OnQueryPrintServerCompleted( void CupsPrintersHandler::HandleOpenPrintManagementApp( const base::ListValue* args) { DCHECK(args->empty()); - chrome::ShowPrintManagementApp(profile_, - PrintManagementAppEntryPoint::kSettings); + chrome::ShowPrintManagementApp(profile_); } void CupsPrintersHandler::HandleOpenScanningApp(const base::ListValue* args) { DCHECK(args->empty()); - DCHECK(base::FeatureList::IsEnabled(chromeos::features::kScanningUI)); - chrome::ShowScanningApp(profile_, - chromeos::scanning::ScanAppEntryPoint::kSettings); + chrome::ShowScanningApp(profile_); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h index 1cc8e7fc66c..ac2cd672199 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h @@ -82,17 +82,13 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, // Handles the callback for HandleGetPrinterInfo. |callback_id| is the // identifier to resolve the correct Promise. |result| indicates if the query // was successful. |printer_status| contains the current status of the - // printer. |make| is the detected printer manufacturer. |model| is the - // detected model. |make_and_model| is the unparsed printer-make-and-model - // string. |ipp_everywhere| indicates if configuration using the CUPS IPP - // Everywhere driver should be attempted. If |result| is not SUCCESS, the - // values of |printer_status|, |make|, |model|, |make_and_model|, and - // |ipp_everywhere| are not specified. + // printer. |make_and_model| is the unparsed printer-make-and-model string. + // |ipp_everywhere| indicates if configuration using the CUPS IPP Everywhere + // driver should be attempted. If |result| is not SUCCESS, the values of + // |printer_status|, |make_and_model|, and |ipp_everywhere| are not specified. void OnAutoconfQueried(const std::string& callback_id, printing::PrinterQueryResult result, const printing::PrinterStatus& printer_status, - const std::string& make, - const std::string& model, const std::string& make_and_model, const std::vector<std::string>& document_formats, bool ipp_everywhere); @@ -103,8 +99,6 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, Printer printer, printing::PrinterQueryResult result, const printing::PrinterStatus& printer_status, - const std::string& make, - const std::string& model, const std::string& make_and_model, const std::vector<std::string>& document_formats, bool ipp_everywhere); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc index 3cbc84137cd..d956397ffdf 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc @@ -10,16 +10,13 @@ #include "base/callback_helpers.h" #include "base/files/file_path.h" #include "base/json/json_string_value_serializer.h" -#include "base/test/metrics/histogram_tester.h" #include "base/values.h" -#include "chrome/browser/chromeos/printing/print_management/print_management_uma.h" #include "chrome/browser/chromeos/printing/printing_stubs.h" #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/browser/download/download_core_service_factory.h" #include "chrome/browser/download/download_core_service_impl.h" #include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/test/base/testing_profile.h" -#include "chromeos/components/scanning/scanning_uma.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/debug_daemon/debug_daemon_client.h" #include "content/public/test/browser_task_environment.h" @@ -111,7 +108,7 @@ class FakeSelectFileDialog : public ui::SelectFileDialog { protected: void SelectFileImpl(Type type, - const base::string16& title, + const std::u16string& title, const base::FilePath& default_path, const FileTypeInfo* file_types, int file_type_index, @@ -204,7 +201,6 @@ class CupsPrintersHandlerTest : public testing::Test { protected: // Must outlive |profile_|. - base::HistogramTester histogram_tester_; content::BrowserTaskEnvironment task_environment_; TestingProfile profile_; content::TestWebUI web_ui_; @@ -258,35 +254,5 @@ TEST_F(CupsPrintersHandlerTest, VerifyOnlyPpdFilesAllowed) { &base::Value::AsListValue(args)); } -TEST_F(CupsPrintersHandlerTest, VerifyPrintManagementAppEntryPointHistogram) { - base::Value args(base::Value::Type::LIST); - web_ui_.HandleReceivedMessage("openPrintManagementApp", - &base::Value::AsListValue(args)); - histogram_tester_.ExpectBucketCount( - "Printing.CUPS.PrintManagementAppEntryPoint", - PrintManagementAppEntryPoint::kSettings, 1); - histogram_tester_.ExpectBucketCount( - "Printing.CUPS.PrintManagementAppEntryPoint", - PrintManagementAppEntryPoint::kNotification, 0); - histogram_tester_.ExpectBucketCount( - "Printing.CUPS.PrintManagementAppEntryPoint", - PrintManagementAppEntryPoint::kLauncher, 0); - histogram_tester_.ExpectBucketCount( - "Printing.CUPS.PrintManagementAppEntryPoint", - PrintManagementAppEntryPoint::kBrowser, 0); -} - -TEST_F(CupsPrintersHandlerTest, VerifyScanAppEntryPointHistogram) { - base::Value args(base::Value::Type::LIST); - web_ui_.HandleReceivedMessage("openScanningApp", - &base::Value::AsListValue(args)); - histogram_tester_.ExpectBucketCount( - "Scanning.ScanAppEntryPoint", - chromeos::scanning::ScanAppEntryPoint::kSettings, 1); - histogram_tester_.ExpectBucketCount( - "Scanning.ScanAppEntryPoint", - chromeos::scanning::ScanAppEntryPoint::kLauncher, 0); -} - } // namespace settings. } // namespace chromeos. diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc index 1c5867a610e..17b4267c337 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc @@ -11,11 +11,11 @@ #include "base/command_line.h" #include "base/time/time.h" #include "base/values.h" +#include "chrome/browser/ash/child_accounts/parent_access_code/parent_access_service.h" #include "chrome/browser/ash/system/timezone_resolver_manager.h" #include "chrome/browser/ash/system/timezone_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" -#include "chrome/browser/chromeos/child_accounts/parent_access_code/parent_access_service.h" #include "chrome/browser/chromeos/set_time_dialog.h" #include "chrome/common/pref_names.h" #include "chromeos/dbus/system_clock/system_clock_client.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc index 31fe09897d5..a20eed2fb35 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc @@ -200,7 +200,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { base::FilePath("/devices/platform/i8042/serio0/input/input1"), 1, 1, 0xab41); fake_udev->AddFakeDevice(internal_kbd.name, internal_kbd.sys_path.value(), - /*subsystem=*/"input", /*sysattrs=*/{}, + /*subsystem=*/"input", /*devnode=*/base::nullopt, + /*devtype=*/base::nullopt, /*sysattrs=*/{}, /*properties=*/{}); // Generic external USB keyboard. const ui::InputDevice external_generic_kbd( @@ -211,7 +212,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { 0x046d, 0xc31c, 0x0111); fake_udev->AddFakeDevice(external_generic_kbd.name, external_generic_kbd.sys_path.value(), - /*subsystem=*/"input", /*sysattrs=*/{}, + /*subsystem=*/"input", /*devnode=*/base::nullopt, + /*devtype=*/base::nullopt, /*sysattrs=*/{}, /*properties=*/{}); // Apple keyboard. const ui::InputDevice external_apple_kbd( @@ -221,7 +223,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { 0x05ac, 0x026c, 0x0111); fake_udev->AddFakeDevice(external_apple_kbd.name, external_apple_kbd.sys_path.value(), - /*subsystem=*/"input", /*sysattrs=*/{}, + /*subsystem=*/"input", /*devnode=*/base::nullopt, + /*devtype=*/base::nullopt, /*sysattrs=*/{}, /*properties=*/{}); // Chrome OS external USB keyboard. const ui::InputDevice external_chromeos_kbd( @@ -231,7 +234,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { 0x04ca, 0x0082, 0x0111); fake_udev->AddFakeDevice( external_chromeos_kbd.name, external_chromeos_kbd.sys_path.value(), - /*subsystem=*/"input", /*sysattrs=*/{}, + /*subsystem=*/"input", /*devnode=*/base::nullopt, + /*devtype=*/base::nullopt, /*sysattrs=*/{}, /*properties=*/{{"CROS_KEYBOARD_TOP_ROW_LAYOUT", "1"}}); // An internal keyboard shouldn't change the defaults. diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc index 6bf1eca2d85..266ebfe378d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc @@ -29,12 +29,12 @@ namespace chromeos { namespace settings { namespace { -base::string16 GetBatteryTimeText(base::TimeDelta time_left) { +std::u16string GetBatteryTimeText(base::TimeDelta time_left) { int hour = 0; int min = 0; ash::power_utils::SplitTimeIntoHoursAndMinutes(time_left, &hour, &min); - base::string16 time_text; + std::u16string time_text; if (hour == 0 || min == 0) { // Display only one unit ("2 hours" or "10 minutes"). return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION, @@ -314,7 +314,7 @@ void PowerHandler::SendBatteryStatus() { show_time = ash::power_utils::ShouldDisplayBatteryTime(time_left); } - base::string16 status_text; + std::u16string status_text; if (show_time) { status_text = l10n_util::GetStringFUTF16( charging ? IDS_SETTINGS_BATTERY_STATUS_CHARGING diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h index 699802af8ae..dcda34138f2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h @@ -7,12 +7,12 @@ #include <memory> #include <set> +#include <string> #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/scoped_observation.h" -#include "base/strings/string16.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chromeos/dbus/power/power_manager_client.h" #include "chromeos/dbus/power/power_policy_controller.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc index 519773e5bda..8973f4bad3e 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc @@ -17,7 +17,6 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ash/login/demo_mode/demo_session.h" -#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/webui/settings/chromeos/device_display_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h" @@ -853,9 +852,8 @@ void DeviceSection::AddLoadTimeData(content::WebUIDataSource* html_source) { html_source->AddBoolean("isDemoSession", chromeos::DemoSession::IsDeviceInDemoMode()); - html_source->AddBoolean("enableLanguageSettingsV2", - base::FeatureList::IsEnabled( - ::chromeos::features::kLanguageSettingsUpdate)); + // TODO(crbug.com/1097328): Delete this. + html_source->AddBoolean("enableLanguageSettingsV2", true); AddDevicePointersStrings(html_source); AddDeviceKeyboardStrings(html_source); @@ -1228,9 +1226,6 @@ void DeviceSection::AddDevicePointersStrings( "allowDisableMouseAcceleration", base::FeatureList::IsEnabled(::features::kAllowDisableMouseAcceleration)); html_source->AddBoolean("allowScrollSettings", AreScrollSettingsAllowed()); - html_source->AddBoolean( - "separatePointingStickSettings", - base::FeatureList::IsEnabled(::features::kSeparatePointingStickSettings)); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc index ad8de481a8d..7b94e1cdb60 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc @@ -10,7 +10,7 @@ #include <string> #include <utility> -#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ash/arc/arc_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h" @@ -274,7 +274,7 @@ void StorageHandler::UpdateStorageItem( if (calculation_type != calculator::SizeCalculator::CalculationType::kSystem) UpdateSystemSize(calculation_type, total_bytes); - base::string16 message; + std::u16string message; if (total_bytes < 0) { message = l10n_util::GetStringUTF16(IDS_SETTINGS_STORAGE_SIZE_UNKNOWN); } else { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h index 0819ea175cb..b11961161e6 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h @@ -8,8 +8,8 @@ #include <string> #include "base/scoped_observation.h" -#include "chrome/browser/chromeos/arc/session/arc_session_manager.h" -#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h" +#include "chrome/browser/ash/arc/session/arc_session_manager.h" +#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h" #include "chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chromeos/disks/disk_mount_manager.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc index e82018ceead..3e161ee77c4 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc @@ -13,8 +13,8 @@ #include "base/strings/utf_string_conversions.h" #include "base/system/sys_info.h" #include "base/test/scoped_running_on_chromeos.h" -#include "chrome/browser/chromeos/arc/session/arc_session_manager.h" -#include "chrome/browser/chromeos/arc/test/test_arc_session_manager.h" +#include "chrome/browser/ash/arc/session/arc_session_manager.h" +#include "chrome/browser/ash/arc/test/test_arc_session_manager.h" #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h" #include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h" @@ -463,12 +463,9 @@ TEST_F(StorageHandlerTest, SystemSize) { std::vector<int64_t>{200 * GB, 50 * GB, 50 * GB}; other_users_size_test_api_->InitializeOtherUserSize(other_user_sizes.size()); for (std::size_t i = 0; i < other_user_sizes.size(); i++) { - cryptohome::BaseReply result; - result.set_error(cryptohome::CRYPTOHOME_ERROR_NOT_SET); - cryptohome::GetAccountDiskUsageReply* usage_reply = - result.MutableExtension(cryptohome::GetAccountDiskUsageReply::reply); - usage_reply->set_size(other_user_sizes[i]); - base::Optional<cryptohome::BaseReply> reply = std::move(result); + base::Optional<::user_data_auth::GetAccountDiskUsageReply> reply = + ::user_data_auth::GetAccountDiskUsageReply(); + reply->set_size(other_user_sizes[i]); other_users_size_test_api_->SimulateOnGetOtherUserSize(reply); if (i < other_user_sizes.size() - 1) { ASSERT_FALSE(GetWebUICallbackMessage("storage-other-users-size-changed")); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc index c9be5570431..c18dde7c358 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc @@ -13,7 +13,7 @@ #include "base/bind.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" -#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ash/arc/arc_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc index 75f9d4652ec..ff4ff98f1af 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/settings/chromeos/files_section.h" +#include "base/callback_helpers.h" #include "base/no_destructor.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc index b92e54c9b8b..3c7919f7867 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc @@ -10,8 +10,8 @@ #include "base/bind.h" #include "base/callback_helpers.h" +#include "chrome/browser/ash/guest_os/guest_os_share_path.h" #include "chrome/browser/chromeos/file_manager/path_util.h" -#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_thread.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h index 41c4888116e..e6340387135 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h @@ -7,8 +7,8 @@ #include "base/memory/weak_ptr.h" #include "base/scoped_observation.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_manager.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_manager_factory.h" #include "chrome/browser/chromeos/usb/cros_usb_detector.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.cc index 2f586566acc..8e69018adc6 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.cc @@ -267,7 +267,7 @@ std::string Hierarchy::ModifySearchResultUrl( url_to_modify); } -std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( +std::vector<std::u16string> Hierarchy::GenerateAncestorHierarchyStrings( mojom::Subpage subpage) const { const SubpageMetadata& subpage_metadata = GetSubpageMetadata(subpage); @@ -276,7 +276,7 @@ std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( return GenerateHierarchyStrings(subpage_metadata.section); // Nested subpage; use recursive call, then append parent subpage name itself. - std::vector<base::string16> hierarchy_strings = + std::vector<std::u16string> hierarchy_strings = GenerateAncestorHierarchyStrings(*subpage_metadata.parent_subpage); hierarchy_strings.push_back( GetSubpageMetadata(*subpage_metadata.parent_subpage) @@ -285,7 +285,7 @@ std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( return hierarchy_strings; } -std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( +std::vector<std::u16string> Hierarchy::GenerateAncestorHierarchyStrings( mojom::Setting setting) const { const SettingMetadata& setting_metadata = GetSettingMetadata(setting); @@ -294,7 +294,7 @@ std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( return GenerateHierarchyStrings(setting_metadata.primary.first); // Nested setting; use subpage ancestors, then append subpage name itself. - std::vector<base::string16> hierarchy_strings = + std::vector<std::u16string> hierarchy_strings = GenerateAncestorHierarchyStrings(*setting_metadata.primary.second); hierarchy_strings.push_back( GetSubpageMetadata(*setting_metadata.primary.second) @@ -303,9 +303,9 @@ std::vector<base::string16> Hierarchy::GenerateAncestorHierarchyStrings( return hierarchy_strings; } -std::vector<base::string16> Hierarchy::GenerateHierarchyStrings( +std::vector<std::u16string> Hierarchy::GenerateHierarchyStrings( mojom::Section section) const { - std::vector<base::string16> hierarchy_strings; + std::vector<std::u16string> hierarchy_strings; hierarchy_strings.push_back( l10n_util::GetStringUTF16(IDS_INTERNAL_APP_SETTINGS)); hierarchy_strings.push_back(GetSectionMetadata(section) diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h index 14b915670d4..53334ca524d 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h @@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_HIERARCHY_H_ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_HIERARCHY_H_ +#include <string> #include <unordered_map> #include <utility> #include <vector> #include "base/optional.h" -#include "base/strings/string16.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h" #include "chrome/browser/ui/webui/settings/chromeos/os_settings_identifier.h" @@ -137,11 +137,11 @@ class Hierarchy { // ["Settings", "Network"] // Example 2 - External storage (has parent subpage): // ["Settings", "Device", "Storage management"] - std::vector<base::string16> GenerateAncestorHierarchyStrings( + std::vector<std::u16string> GenerateAncestorHierarchyStrings( mojom::Subpage subpage) const; // Same as above, but for settings. - std::vector<base::string16> GenerateAncestorHierarchyStrings( + std::vector<std::u16string> GenerateAncestorHierarchyStrings( mojom::Setting setting) const; protected: @@ -153,7 +153,7 @@ class Hierarchy { class PerSectionHierarchyGenerator; // Generates an array with the Settings app name and |section|'s name. - std::vector<base::string16> GenerateHierarchyStrings( + std::vector<std::u16string> GenerateHierarchyStrings( mojom::Section section) const; virtual std::string ModifySearchResultUrl( diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc index aaab88f1523..cbe5f880487 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc @@ -8,6 +8,7 @@ #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/network_config_service.h" #include "base/bind.h" +#include "base/metrics/histogram_functions.h" #include "base/no_destructor.h" #include "base/strings/stringprintf.h" #include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h" @@ -225,6 +226,19 @@ const std::vector<SearchConcept>& GetWifiMeteredSearchConcepts() { return *tags; } +const std::vector<SearchConcept>& GetWifiHiddenSearchConcepts() { + static const base::NoDestructor<std::vector<SearchConcept>> tags({ + {IDS_OS_SETTINGS_TAG_HIDDEN_NETWORK, + mojom::kWifiDetailsSubpagePath, + mojom::SearchResultIcon::kWifi, + mojom::SearchResultDefaultRank::kMedium, + mojom::SearchResultType::kSetting, + {.setting = mojom::Setting::kWifiHidden}, + {IDS_OS_SETTINGS_TAG_HIDDEN_NETWORK_ALT1, SearchConcept::kAltTagEnd}}, + }); + return *tags; +} + const std::vector<SearchConcept>& GetCellularSearchConcepts() { static const base::NoDestructor<std::vector<SearchConcept>> tags({ {IDS_OS_SETTINGS_TAG_CELLULAR, @@ -465,6 +479,7 @@ const std::vector<mojom::Setting>& GetWifiDetailsSettings() { mojom::Setting::kWifiProxy, mojom::Setting::kWifiAutoConnectToNetwork, mojom::Setting::kWifiMetered, + mojom::Setting::kWifiHidden, }); return *settings; } @@ -620,6 +635,8 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) { {"networkButtonForget", IDS_SETTINGS_INTERNET_BUTTON_FORGET}, {"networkButtonViewAccount", IDS_SETTINGS_INTERNET_BUTTON_VIEW_ACCOUNT}, {"networkConnectNotAllowed", IDS_SETTINGS_INTERNET_CONNECT_NOT_ALLOWED}, + {"networkHidden", IDS_SETTINGS_INTERNET_NETWORK_HIDDEN}, + {"networkHiddenSublabel", IDS_SETTINGS_INTERNET_NETWORK_HIDDEN_SUBLABEL}, {"networkIPAddress", IDS_SETTINGS_INTERNET_NETWORK_IP_ADDRESS}, {"networkIPConfigAuto", IDS_SETTINGS_INTERNET_NETWORK_IP_CONFIG_AUTO}, {"networkMetered", IDS_SETTINGS_INTERNET_NETWORK_METERED}, @@ -648,10 +665,6 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) { {"networkSharedNotOwner", IDS_SETTINGS_INTERNET_NETWORK_SHARED_NOT_OWNER}, {"networkVpnBuiltin", IDS_NETWORK_TYPE_VPN_BUILTIN}, {"networkOutOfRange", IDS_SETTINGS_INTERNET_WIFI_NETWORK_OUT_OF_RANGE}, - {"cellularContactSpecificCarrier", - IDS_SETTINGS_INTERNET_CELLULAR_CONTACT_SPECIFIC_CARRIER}, - {"cellularContactDefaultCarrier", - IDS_SETTINGS_INTERNET_CELLULAR_CONTACT_DEFAULT_CARRIER}, {"cellularSetupDialogTitle", IDS_SETTINGS_INTERNET_CELLULAR_SETUP_DIALOG_TITLE}, {"tetherPhoneOutOfRange", @@ -697,19 +710,22 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) { {"tetherEnableBluetooth", IDS_ENABLE_BLUETOOTH}, {"cellularNetworkEsimLabel", IDS_SETTINGS_INTERNET_ESIM_LABEL}, {"cellularNetworkPsimLabel", IDS_SETTINGS_INTERNET_PSIM_LABEL}, - {"pSimNetworkNotSetup", - IDS_SETTINGS_INTERNET_PSIM_NOT_SETUP_WITH_SETUP_LINK}, + {"pSimNotInsertedLabel", IDS_SETTINGS_INTERNET_PSIM_NOT_INSERTED_LABEL}, {"eSimNetworkNotSetup", IDS_SETTINGS_INTERNET_ESIM_NOT_SETUP_WITH_SETUP_LINK}, {"cellularNetworkTetherLabel", IDS_SETTINGS_INTERNET_TETHER_LABEL}, {"showEidPopupButtonLabel", IDS_SETTINGS_INTERNET_SHOW_EID_POPUP_BUTTON_LABEL}, + {"eSimNoConnectionErrorToast", + IDS_SETTINGS_INTERNET_ESIM_NO_CONNECTION_ERROR_TOAST}, {"eSimInstallErrorDialogTitle", IDS_SETTINGS_INTERNET_NETWORK_INSTALL_ERROR_DIALOG_TITLE}, {"eSimInstallErrorDialogConfirmationCodeMessage", IDS_SETTINGS_INTERNET_NETWORK_INSTALL_ERROR_DIALOG_CONFIRMATION_CODE_MESSAGE}, {"eSimInstallErrorDialogConfirmationCodeError", IDS_CELLULAR_SETUP_ESIM_PAGE_INSTALL_ERROR_DIALOG_CONFIRMATION_CODE_ERROR}, + {"eSimInstallErrorDialogGenericErrorMessage", + IDS_SETTINGS_INTERNET_NETWORK_INSTALL_ERROR_DIALOG_GENERIC_ERROR_MESSAGE}, {"eSimRenameProfileDialogLabel", IDS_SETTINGS_INTERNET_NETWORK_RENAME_DIALOG_RENAME_PROFILE}, {"eSimRenameProfileDialogDone", @@ -730,6 +746,16 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) { IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_OKAY}, {"eSimDialogConnectionWarning", IDS_SETTINGS_INTERNET_ESIM_DIALOG_CONNECTION_WARNING}, + {"cellularNetworkInstallingProfile", + IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_INSTALLING_PROFILE}, + {"cellularNetworkRemovingProfile", + IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REMOVING_PROFILE}, + {"cellularNetworkRenamingProfile", + IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_RENAMING_PROFILE}, + {"cellularNetworkConnectingToProfile", + IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_CONNECTING_TO_PROFILE}, + {"cellularNetworRefreshingProfileListProfile", + IDS_SETTINGS_INTERNET_NETWORK_CELLULAR_REFRESHING_PROFILE_LIST}, }; html_source->AddLocalizedStrings(kLocalizedStrings); @@ -748,10 +774,16 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) { html_source->AddBoolean( "showMeteredToggle", base::FeatureList::IsEnabled(::features::kMeteredShowToggle)); + html_source->AddBoolean( + "showHiddenToggle", + base::FeatureList::IsEnabled(::features::kShowHiddenNetworkToggle)); html_source->AddString("networkGoogleNameserversLearnMoreUrl", chrome::kGoogleNameserversLearnMoreURL); + html_source->AddString("wifiHiddenNetworkLearnMoreUrl", + chrome::kWifiHiddenNetworkURL); + html_source->AddString( "networkNotSynced", l10n_util::GetStringFUTF16( @@ -801,8 +833,15 @@ std::string InternetSection::GetSectionPath() const { bool InternetSection::LogMetric(mojom::Setting setting, base::Value& value) const { - // Unimplemented. - return false; + switch (setting) { + case mojom::Setting::kWifiHidden: + base::UmaHistogramBoolean("ChromeOS.Settings.Wifi.Hidden", + value.GetBool()); + return true; + + default: + return false; + } } void InternetSection::RegisterHierarchy(HierarchyGenerator* generator) const { @@ -1012,6 +1051,7 @@ void InternetSection::OnNetworkList( updater.RemoveSearchTags(GetEthernetNotConnectedSearchConcepts()); updater.RemoveSearchTags(GetWifiConnectedSearchConcepts()); updater.RemoveSearchTags(GetWifiMeteredSearchConcepts()); + updater.RemoveSearchTags(GetWifiHiddenSearchConcepts()); updater.RemoveSearchTags(GetCellularSearchConcepts()); updater.RemoveSearchTags(GetCellularConnectedSearchConcepts()); updater.RemoveSearchTags(GetCellularSetupAndDetailMenuSearchConcepts()); @@ -1048,6 +1088,8 @@ void InternetSection::OnNetworkList( updater.AddSearchTags(GetWifiConnectedSearchConcepts()); if (base::FeatureList::IsEnabled(::features::kMeteredShowToggle)) updater.AddSearchTags(GetWifiMeteredSearchConcepts()); + if (base::FeatureList::IsEnabled(::features::kShowHiddenNetworkToggle)) + updater.AddSearchTags(GetWifiHiddenSearchConcepts()); break; case NetworkType::kCellular: diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc index 06f1ec6d9ef..928c18302cb 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc @@ -4,12 +4,12 @@ #include "chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h" +#include <string> #include <utility> #include "ash/constants/ash_features.h" #include "base/bind.h" #include "base/memory/ptr_util.h" -#include "base/strings/string16.h" #include "base/strings/stringprintf.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -110,6 +110,8 @@ void AddKerberosAddAccountDialogStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_KERBEROS_CONFIG_ERROR_SECTION_NOT_SUPPORTED}, {"kerberosConfigErrorKrb5FailedToParse", IDS_SETTINGS_KERBEROS_CONFIG_ERROR_KRB5_FAILED_TO_PARSE}, + {"kerberosConfigErrorTooManyNestedGroups", + IDS_SETTINGS_KERBEROS_CONFIG_ERROR_TOO_MANY_NESTED_GROUPS}, {"addKerberosAccountRefreshButtonLabel", IDS_SETTINGS_ADD_KERBEROS_ACCOUNT_REFRESH_BUTTON_LABEL}, {"addKerberosAccount", IDS_SETTINGS_ADD_KERBEROS_ACCOUNT}, @@ -266,7 +268,7 @@ void KerberosAccountsHandler::OnListAccounts( // 'nn days' otherwise. base::TimeDelta tgt_validity = base::TimeDelta::FromSeconds(account.tgt_validity_seconds()); - const base::string16 valid_for_duration = ui::TimeFormat::Detailed( + const std::u16string valid_for_duration = ui::TimeFormat::Detailed( ui::TimeFormat::FORMAT_DURATION, ui::TimeFormat::LENGTH_LONG, tgt_validity < base::TimeDelta::FromDays(1) ? -1 : 0, tgt_validity); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc index ea6d1082978..f94798ccf67 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc @@ -17,7 +17,9 @@ namespace chromeos { namespace settings { namespace { -const std::vector<SearchConcept>& GetKerberosSearchConcepts() { +// Provides search tags that are always available when the feature is enabled by +// policy/flag. +const std::vector<SearchConcept>& GetFixedKerberosSearchConcepts() { static const base::NoDestructor<std::vector<SearchConcept>> tags({ {IDS_OS_SETTINGS_TAG_KERBEROS_SECTION, mojom::kKerberosSectionPath, @@ -37,6 +39,14 @@ const std::vector<SearchConcept>& GetKerberosSearchConcepts() { mojom::SearchResultDefaultRank::kMedium, mojom::SearchResultType::kSetting, {.setting = mojom::Setting::kAddKerberosTicketV2}}, + }); + return *tags; +} + +// Provides search tags that are only available when the feature is enabled by +// policy/flag and there is at least one Kerberos ticket. +const std::vector<SearchConcept>& GetDynamicKerberosSearchConcepts() { + static const base::NoDestructor<std::vector<SearchConcept>> tags({ {IDS_OS_SETTINGS_TAG_KERBEROS_REMOVE, mojom::kKerberosAccountsV2SubpagePath, mojom::SearchResultIcon::kAuthKey, @@ -68,7 +78,7 @@ KerberosSection::KerberosSection( if (kerberos_credentials_manager_) { // Kerberos search tags are added/removed dynamically. kerberos_credentials_manager_->AddObserver(this); - OnKerberosEnabledStateChanged(); + UpdateKerberosSearchConcepts(); } } @@ -140,13 +150,34 @@ void KerberosSection::RegisterHierarchy(HierarchyGenerator* generator) const { kKerberosAccountsV2Settings, generator); } +void KerberosSection::OnAccountsChanged() { + UpdateKerberosSearchConcepts(); +} + void KerberosSection::OnKerberosEnabledStateChanged() { + UpdateKerberosSearchConcepts(); +} + +// Updates search tags according to the KerberosEnabled state and the presence +// of Kerberos tickets in the system. +void KerberosSection::UpdateKerberosSearchConcepts() { + CHECK(kerberos_credentials_manager_); + SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); - if (kerberos_credentials_manager_->IsKerberosEnabled()) - updater.AddSearchTags(GetKerberosSearchConcepts()); - else - updater.RemoveSearchTags(GetKerberosSearchConcepts()); + // Removes all search tags first. They will be added conditionally later. + updater.RemoveSearchTags(GetFixedKerberosSearchConcepts()); + updater.RemoveSearchTags(GetDynamicKerberosSearchConcepts()); + + if (kerberos_credentials_manager_->IsKerberosEnabled()) { + updater.AddSearchTags(GetFixedKerberosSearchConcepts()); + + const std::string account_name = + kerberos_credentials_manager_->GetActiveAccount(); + if (!account_name.empty()) { + updater.AddSearchTags(GetDynamicKerberosSearchConcepts()); + } + } } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.h index 63a1150bb73..12c7d8b8846 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.h @@ -42,8 +42,11 @@ class KerberosSection : public OsSettingsSection, void RegisterHierarchy(HierarchyGenerator* generator) const override; // KerberosCredentialsManager::Observer: + void OnAccountsChanged() override; void OnKerberosEnabledStateChanged() override; + void UpdateKerberosSearchConcepts(); + KerberosCredentialsManager* kerberos_credentials_manager_; }; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc index b28881b432c..1b37da15afb 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc @@ -26,38 +26,6 @@ namespace chromeos { namespace settings { namespace { -const std::vector<SearchConcept>& GetLanguagesSearchConceptsV1() { - static const base::NoDestructor<std::vector<SearchConcept>> tags({ - {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT, - mojom::kLanguagesAndInputDetailsSubpagePath, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSubpage, - {.subpage = mojom::Subpage::kLanguagesAndInputDetails}}, - {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_METHODS, - mojom::kManageInputMethodsSubpagePath, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSubpage, - {.subpage = mojom::Subpage::kManageInputMethods}}, - {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_ADD_LANGUAGE, - mojom::kLanguagesAndInputDetailsSubpagePath, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSetting, - {.setting = mojom::Setting::kAddLanguage}}, - {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_INPUT_OPTIONS_SHELF, - mojom::kLanguagesAndInputDetailsSubpagePath, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSetting, - {.setting = mojom::Setting::kShowInputOptionsInShelf}, - {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_INPUT_OPTIONS_SHELF_ALT1, - SearchConcept::kAltTagEnd}}, - }); - return *tags; -} - const std::vector<SearchConcept>& GetLanguagesPageSearchConceptsV2() { static const base::NoDestructor<std::vector<SearchConcept>> tags({ {IDS_OS_SETTINGS_TAG_LANGUAGES, @@ -132,9 +100,9 @@ const std::vector<SearchConcept>& GetEditDictionarySearchConceptsV2() { return *tags; } -bool IsLanguageSettingsV2Enabled() { +bool IsLanguageSettingsV2Update2Enabled() { return base::FeatureList::IsEnabled( - ::chromeos::features::kLanguageSettingsUpdate); + ::chromeos::features::kLanguageSettingsUpdate2); } const std::vector<SearchConcept>& GetSmartInputsSearchConcepts() { @@ -322,6 +290,12 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) { IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGES_LIST_TITLE}, {"spellCheckLanguagesListDescription", IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGES_LIST_DESCRIPTION}, + {"addSpellCheckLanguagesTitle", + IDS_OS_SETTINGS_LANGUAGES_ADD_SPELL_CHECK_LANGUAGES_TITLE}, + {"spellCheckLanguageNotAllowed", + IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGE_NOT_ALLOWED}, + {"removeSpellCheckLanguageTooltip", + IDS_OS_SETTINGS_LANGUAGES_REMOVE_SPELL_CHECK_LANGUAGE_TOOLTIP}, {"languagesDictionaryDownloadError", IDS_OS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_FAILED}, {"languagesDictionaryDownloadRetryLabel", @@ -353,19 +327,15 @@ LanguagesSection::LanguagesSection(Profile* profile, : OsSettingsSection(profile, search_tag_registry), pref_service_(pref_service) { SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); - if (IsLanguageSettingsV2Enabled()) { - pref_change_registrar_.Init(pref_service_); - pref_change_registrar_.Add( - spellcheck::prefs::kSpellCheckEnable, - base::BindRepeating(&LanguagesSection::UpdateSpellCheckSearchTags, - base::Unretained(this))); - - updater.AddSearchTags(GetLanguagesPageSearchConceptsV2()); - updater.AddSearchTags(GetInputPageSearchConceptsV2()); - UpdateSpellCheckSearchTags(); - } else { - updater.AddSearchTags(GetLanguagesSearchConceptsV1()); - } + pref_change_registrar_.Init(pref_service_); + pref_change_registrar_.Add( + spellcheck::prefs::kSpellCheckEnable, + base::BindRepeating(&LanguagesSection::UpdateSpellCheckSearchTags, + base::Unretained(this))); + + updater.AddSearchTags(GetLanguagesPageSearchConceptsV2()); + updater.AddSearchTags(GetInputPageSearchConceptsV2()); + UpdateSpellCheckSearchTags(); if (IsAssistivePersonalInfoAllowed() || IsEmojiSuggestionAllowed()) { updater.AddSearchTags(GetSmartInputsSearchConcepts()); @@ -426,8 +396,10 @@ void LanguagesSection::AddLoadTimeData(content::WebUIDataSource* html_source) { html_source->AddBoolean("imeOptionsInSettings", base::FeatureList::IsEnabled( ::chromeos::features::kImeOptionsInSettings)); - html_source->AddBoolean("enableLanguageSettingsV2", - IsLanguageSettingsV2Enabled()); + // TODO(crbug.com/1097328): Delete this. + html_source->AddBoolean("enableLanguageSettingsV2", true); + html_source->AddBoolean("enableLanguageSettingsV2Update2", + IsLanguageSettingsV2Update2Enabled()); } void LanguagesSection::AddHandlers(content::WebUI* web_ui) { @@ -496,37 +468,17 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const { mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium, mojom::kLanguagesAndInputDetailsSubpagePath); - // Shared settings between existing pages and the updated pages. - if (IsLanguageSettingsV2Enabled()) { - generator->RegisterNestedSetting(mojom::Setting::kAddLanguage, - mojom::Subpage::kLanguages); - generator->RegisterNestedSetting(mojom::Setting::kShowInputOptionsInShelf, - mojom::Subpage::kInput); - - // Input method options. - generator->RegisterNestedSubpage( - IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE, - mojom::Subpage::kInputMethodOptions, mojom::Subpage::kInput, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::kInputMethodOptionsSubpagePath); - } else { - static constexpr mojom::Setting kLanguagesAndInputDetailsSettings[] = { - mojom::Setting::kAddLanguage, - mojom::Setting::kShowInputOptionsInShelf, - }; - RegisterNestedSettingBulk(mojom::Subpage::kLanguagesAndInputDetails, - kLanguagesAndInputDetailsSettings, generator); - - // Input method options. - generator->RegisterNestedSubpage( - IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE, - mojom::Subpage::kInputMethodOptions, - mojom::Subpage::kLanguagesAndInputDetails, - mojom::SearchResultIcon::kGlobe, - mojom::SearchResultDefaultRank::kMedium, - mojom::kInputMethodOptionsSubpagePath); - } + generator->RegisterNestedSetting(mojom::Setting::kAddLanguage, + mojom::Subpage::kLanguages); + generator->RegisterNestedSetting(mojom::Setting::kShowInputOptionsInShelf, + mojom::Subpage::kInput); + + // Input method options. + generator->RegisterNestedSubpage( + IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE, + mojom::Subpage::kInputMethodOptions, mojom::Subpage::kInput, + mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium, + mojom::kInputMethodOptionsSubpagePath); // Manage input methods. generator->RegisterNestedSubpage( diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc index 023895cfeb0..e63667017f2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc @@ -69,7 +69,7 @@ void AddUpdateRequiredEolStrings(content::WebUIDataSource* html_source) { // |eol_return_banner_text| contains the update required end of life banner // text which is left empty when the banner should not be shown. - base::string16 eol_return_banner_text; + std::u16string eol_return_banner_text; if (device_managed && handler->ShouldShowUpdateRequiredEolBanner()) { base::Optional<int> days = handler->GetTimeRemainingInDays(); // We only need to show the banner if less than equal to one week remains to @@ -78,9 +78,9 @@ void AddUpdateRequiredEolStrings(content::WebUIDataSource* html_source) { // |days| could have value equal to zero if we are very close to the // deadline. int days_remaining = days.value() ? days.value() : 1; - base::string16 domain_name = + std::u16string domain_name = base::UTF8ToUTF16(connector->GetEnterpriseDomainManager()); - base::string16 link_url = + std::u16string link_url = base::UTF8ToUTF16(chrome::kChromeUIManagementURL); if (days_remaining == 7) { eol_return_banner_text = l10n_util::GetStringFUTF16( @@ -254,6 +254,10 @@ std::unique_ptr<PluralStringHandler> MainSection::CreatePluralStringHandler() { plural_string_handler->AddLocalizedString( "nearbyShareContactVisibilityNumUnreachable", IDS_NEARBY_CONTACT_VISIBILITY_NUM_UNREACHABLE); + + plural_string_handler->AddLocalizedString( + "lockScreenNumberFingerprints", + IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NUM_FINGERPRINTS); return plural_string_handler; } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc index 2ead0548f4d..14dacce7199 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc @@ -66,6 +66,8 @@ GenerateDefaultFeatureStatesMap() { {multidevice_setup::mojom::Feature::kPhoneHubTaskContinuation, multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost}, {multidevice_setup::mojom::Feature::kWifiSync, + multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost}, + {multidevice_setup::mojom::Feature::kEche, multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost}}; } @@ -176,7 +178,8 @@ class MultideviceHandlerTest : public testing::Test { handler_->RegisterMessages(); handler_->AllowJavascript(); - scoped_feature_list_.InitWithFeatures({chromeos::features::kPhoneHub}, {}); + scoped_feature_list_.InitWithFeatures( + {chromeos::features::kPhoneHub, chromeos::features::kEcheSWA}, {}); } void CallGetPageContentData() { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc index 9190e6f6ba9..d6be25b4068 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h" #include "base/feature_list.h" -#include "chrome/browser/chromeos/arc/arc_util.h" +#include "chrome/browser/ash/arc/arc_util.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc index 552e7c79439..752b433e03b 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc @@ -29,7 +29,7 @@ OsSettingsManager::OsSettingsManager( signin::IdentityManager* identity_manager, android_sms::AndroidSmsService* android_sms_service, CupsPrintersManager* printers_manager, - apps::AppServiceProxy* app_service_proxy) + apps::AppServiceProxyChromeOs* app_service_proxy) : search_tag_registry_( std::make_unique<SearchTagRegistry>(local_search_service_proxy)), sections_( diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h index 5377a69d657..fe45e845663 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h @@ -15,7 +15,7 @@ class Profile; class SupervisedUserService; namespace apps { -class AppServiceProxy; +class AppServiceProxyChromeOs; } // namespace apps namespace content { @@ -100,7 +100,7 @@ class OsSettingsManager : public KeyedService { signin::IdentityManager* identity_manager, android_sms::AndroidSmsService* android_sms_service, CupsPrintersManager* printers_manager, - apps::AppServiceProxy* app_service_proxy); + apps::AppServiceProxyChromeOs* app_service_proxy); OsSettingsManager(const OsSettingsManager& other) = delete; OsSettingsManager& operator=(const OsSettingsManager& other) = delete; ~OsSettingsManager() override; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc index a600d86be7c..f0211f64dac 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc @@ -18,7 +18,7 @@ namespace settings { constexpr const char OsSettingsSection::kSettingIdUrlParam[]; // static -base::string16 OsSettingsSection::GetHelpUrlWithBoard( +std::u16string OsSettingsSection::GetHelpUrlWithBoard( const std::string& original_url) { return base::ASCIIToUTF16(original_url + "&b=" + base::SysInfo::GetLsbReleaseBoard()); @@ -60,7 +60,7 @@ mojom::SearchResultPtr OsSettingsSection::GenerateSectionSearchResult( ModifySearchResultUrl(mojom::SearchResultType::kSection, {.section = GetSection()}, GetSectionPath()), GetSectionIcon(), relevance_score, - std::vector<base::string16>{ + std::vector<std::u16string>{ l10n_util::GetStringUTF16(IDS_INTERNAL_APP_SETTINGS), l10n_util::GetStringUTF16(GetSectionNameMessageId())}, mojom::SearchResultDefaultRank::kMedium, diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h index 52202657387..a7f7a76db39 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h @@ -9,7 +9,6 @@ #include <vector> #include "base/containers/span.h" -#include "base/strings/string16.h" #include "base/values.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h" @@ -142,7 +141,7 @@ class OsSettingsSection { mojom::SearchResultPtr GenerateSectionSearchResult( double relevance_score) const; - static base::string16 GetHelpUrlWithBoard(const std::string& original_url); + static std::u16string GetHelpUrlWithBoard(const std::string& original_url); protected: static void RegisterNestedSettingBulk( diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc index 57434b8dc17..63a5f528fd0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc @@ -43,7 +43,7 @@ OsSettingsSections::OsSettingsSections( signin::IdentityManager* identity_manager, android_sms::AndroidSmsService* android_sms_service, CupsPrintersManager* printers_manager, - apps::AppServiceProxy* app_service_proxy) { + apps::AppServiceProxyChromeOs* app_service_proxy) { // Special case: Main section does not have an associated enum value. sections_.push_back( std::make_unique<MainSection>(profile, search_tag_registry)); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h index 2cef92ca7d6..bd98112e4c5 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h @@ -16,7 +16,7 @@ class Profile; class SupervisedUserService; namespace apps { -class AppServiceProxy; +class AppServiceProxyChromeOs; } // namespace apps namespace signin { @@ -61,7 +61,7 @@ class OsSettingsSections { signin::IdentityManager* identity_manager, android_sms::AndroidSmsService* android_sms_service, CupsPrintersManager* printers_manager, - apps::AppServiceProxy* app_service_proxy); + apps::AppServiceProxyChromeOs* app_service_proxy); OsSettingsSections(const OsSettingsSections& other) = delete; OsSettingsSections& operator=(const OsSettingsSections& other) = delete; virtual ~OsSettingsSections(); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc index 273c191c8a8..b56089a88e0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc @@ -64,27 +64,10 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui) std::make_unique<chromeos::settings::StorageHandler>(profile, html_source)); - int default_resource = - base::FeatureList::IsEnabled(chromeos::features::kOsSettingsPolymer3) - ? IDR_OS_SETTINGS_OS_SETTINGS_V3_HTML -#if BUILDFLAG(OPTIMIZE_WEBUI) - : IDR_OS_SETTINGS_VULCANIZED_HTML; -#else - : IDR_OS_SETTINGS_CHROMEOS_OS_SETTINGS_HTML; -#endif - webui::SetupWebUIDataSource( html_source, base::make_span(kOsSettingsResources, kOsSettingsResourcesSize), - default_resource); - - // For Polymer 2 optimized builds that rely on loading individual subpages, - // set the default resource for tests. -#if BUILDFLAG(OPTIMIZE_WEBUI) - if (!base::FeatureList::IsEnabled(chromeos::features::kOsSettingsPolymer3)) { - html_source->SetDefaultResource(default_resource); - } -#endif + IDR_OS_SETTINGS_OS_SETTINGS_V3_HTML); ManagedUIHandler::Initialize(web_ui, html_source); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc index 364bfc38d0f..a304871edf7 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc @@ -62,7 +62,7 @@ void ParentalControlsHandler::HandleLaunchFamilyLinkSettings( const base::ListValue* args) { DCHECK(args->empty()); - apps::AppServiceProxy* proxy = + apps::AppServiceProxyChromeOs* proxy = apps::AppServiceProxyFactory::GetForProfile(profile_); apps::AppRegistryCache& registry = proxy->AppRegistryCache(); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc index a955e25b506..9fc306e9cad 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc @@ -15,6 +15,7 @@ #include "base/strings/strcat.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/browser/account_manager_facade_factory.h" #include "chrome/browser/ash/account_manager/account_manager_util.h" #include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h" #include "chrome/browser/ash/profiles/profile_helper.h" @@ -41,6 +42,7 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" +#include "components/account_manager_core/account_manager_facade.h" #include "components/google/core/common/google_util.h" #include "components/omnibox/common/omnibox_features.h" #include "components/prefs/pref_service.h" @@ -444,8 +446,6 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_PEOPLE_LOCK_SCREEN_CHANGE_PIN_BUTTON}, {"lockScreenEditFingerprintsDescription", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_EDIT_FINGERPRINTS_DESCRIPTION}, - {"lockScreenNumberFingerprints", - IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NUM_FINGERPRINTS}, {"lockScreenNone", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NONE}, {"lockScreenFingerprintNewName", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME}, @@ -483,6 +483,13 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source, "lockScreenHideSensitiveNotificationsSupported", ash::features::IsLockScreenHideSensitiveNotificationsSupported()); + html_source->AddString("lockScreenFingerprintNotice", + l10n_util::GetStringFUTF16( + IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_NOTICE, + ui::GetChromeOSDeviceName())); + html_source->AddString("fingerprintLearnMoreLink", + chrome::kFingerprintLearnMoreURL); + if (chromeos::features::IsAccountManagementFlowsV2Enabled()) { html_source->AddLocalizedString( "lockScreenTitleLoginLock", @@ -506,28 +513,16 @@ void AddFingerprintListStrings(content::WebUIDataSource* html_source) { html_source->AddLocalizedStrings(kLocalizedStrings); } -void AddFingerprintStrings(content::WebUIDataSource* html_source, - bool are_fingerprint_settings_allowed) { +void AddFingerprintResources(content::WebUIDataSource* html_source, + bool are_fingerprint_settings_allowed) { html_source->AddBoolean("fingerprintUnlockEnabled", are_fingerprint_settings_allowed); if (are_fingerprint_settings_allowed) { - html_source->AddInteger( - "fingerprintReaderLocation", - static_cast<int32_t>(chromeos::quick_unlock::GetFingerprintLocation())); - - // To use lottie, the worker-src CSP needs to be updated for the web ui that - // is using it. Since as of now there are only a couple of webuis using - // lottie animations, this update has to be performed manually. As the usage - // increases, set this as the default so manual override is no longer - // required. - html_source->OverrideContentSecurityPolicy( - network::mojom::CSPDirectiveName::WorkerSrc, - "worker-src blob: 'self';"); - html_source->AddResourcePath("finger_print.json", - IDR_LOGIN_FINGER_PRINT_TABLET_ANIMATION); + chromeos::quick_unlock::AddFingerprintResources(html_source); } int instruction_id, aria_label_id; + bool aria_label_includes_device = false; using FingerprintLocation = chromeos::quick_unlock::FingerprintLocation; switch (chromeos::quick_unlock::GetFingerprintLocation()) { case FingerprintLocation::TABLET_POWER_BUTTON: @@ -554,11 +549,37 @@ void AddFingerprintStrings(content::WebUIDataSource* html_source, aria_label_id = IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD_TOP_RIGHT_ARIA_LABEL; break; + case quick_unlock::FingerprintLocation::RIGHT_SIDE: + instruction_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD; + aria_label_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_RIGHT_SIDE_ARIA_LABEL; + aria_label_includes_device = true; + break; + case quick_unlock::FingerprintLocation::LEFT_SIDE: + instruction_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD; + aria_label_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_LEFT_SIDE_ARIA_LABEL; + aria_label_includes_device = true; + break; + case FingerprintLocation::UNKNOWN: + instruction_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD; + aria_label_id = + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD; + break; } html_source->AddLocalizedString( "configureFingerprintInstructionLocateScannerStep", instruction_id); - html_source->AddLocalizedString("configureFingerprintScannerStepAriaLabel", - aria_label_id); + if (aria_label_includes_device) { + html_source->AddString( + "configureFingerprintScannerStepAriaLabel", + l10n_util::GetStringFUTF16(aria_label_id, ui::GetChromeOSDeviceName())); + } else { + html_source->AddLocalizedString("configureFingerprintScannerStepAriaLabel", + aria_label_id); + } } void AddSetupFingerprintDialogStrings(content::WebUIDataSource* html_source) { @@ -669,13 +690,13 @@ void AddParentalControlStrings(content::WebUIDataSource* html_source, bool is_child = user_manager::UserManager::Get()->IsLoggedInAsChildUser(); html_source->AddBoolean("isChild", is_child); - base::string16 tooltip; + std::u16string tooltip; if (is_child) { std::string custodian = supervised_user_service->GetCustodianName(); std::string second_custodian = supervised_user_service->GetSecondCustodianName(); - base::string16 child_managed_tooltip; + std::u16string child_managed_tooltip; if (second_custodian.empty()) { child_managed_tooltip = l10n_util::GetStringFUTF16( IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_MANAGED_BY_ONE_PARENT_TOOLTIP, @@ -734,8 +755,10 @@ PeopleSection::PeopleSection( g_browser_process->platform_part()->GetAccountManagerFactory(); account_manager_ = factory->GetAccountManager(profile->GetPath().value()); DCHECK(account_manager_); - - account_manager_->AddObserver(this); + account_manager_facade_ = + ::GetAccountManagerFacade(profile->GetPath().value()); + DCHECK(account_manager_facade_); + account_manager_facade_observation_.Observe(account_manager_facade_); FetchAccounts(); } @@ -788,9 +811,6 @@ PeopleSection::~PeopleSection() { if (chromeos::features::IsSplitSettingsSyncEnabled() && sync_service_) sync_service_->RemoveObserver(this); - - if (account_manager_) - account_manager_->RemoveObserver(this); } void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) { @@ -835,7 +855,7 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) { // Toggles the Chrome OS Account Manager submenu in the People section. html_source->AddBoolean("isAccountManagerEnabled", - account_manager_ != nullptr); + account_manager_facade_ != nullptr); html_source->AddBoolean( "isAccountManagementFlowsV2Enabled", chromeos::features::IsAccountManagementFlowsV2Enabled()); @@ -884,7 +904,7 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) { html_source, kerberos_credentials_manager_); AddLockScreenPageStrings(html_source, profile()->GetPrefs()); AddFingerprintListStrings(html_source); - AddFingerprintStrings(html_source, AreFingerprintSettingsAllowed()); + AddFingerprintResources(html_source, AreFingerprintSettingsAllowed()); AddSetupFingerprintDialogStrings(html_source); AddSetupPinDialogStrings(html_source); AddSyncControlsStrings(html_source); @@ -905,10 +925,10 @@ void PeopleSection::AddHandlers(content::WebUI* web_ui) { web_ui->AddMessageHandler( std::make_unique<::settings::ProfileInfoHandler>(profile())); - if (account_manager_) { + if (account_manager_facade_) { web_ui->AddMessageHandler( std::make_unique<chromeos::settings::AccountManagerUIHandler>( - account_manager_, identity_manager_)); + account_manager_, account_manager_facade_, identity_manager_)); } if (chromeos::features::IsSplitSettingsSyncEnabled()) @@ -1070,12 +1090,13 @@ void PeopleSection::RegisterHierarchy(HierarchyGenerator* generator) const { } void PeopleSection::FetchAccounts() { - account_manager_->GetAccounts( + account_manager_facade_->GetAccounts( base::BindOnce(&PeopleSection::UpdateAccountManagerSearchTags, weak_factory_.GetWeakPtr())); } -void PeopleSection::OnTokenUpserted(const ::account_manager::Account& account) { +void PeopleSection::OnAccountUpserted( + const ::account_manager::Account& account) { FetchAccounts(); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h index 43fee276baa..61fe0e022c9 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h @@ -7,10 +7,12 @@ #include "ash/components/account_manager/account_manager.h" #include "base/memory/weak_ptr.h" +#include "base/scoped_observation.h" #include "base/values.h" #include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h" #include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h" #include "components/account_manager_core/account.h" +#include "components/account_manager_core/account_manager_facade.h" #include "components/prefs/pref_change_registrar.h" #include "components/sync/driver/sync_service_observer.h" @@ -43,7 +45,7 @@ class SearchTagRegistry; // they are allowed by policy/flags. Different sets of Sync tags are shown // depending on whether the feature is enabed or disabled. class PeopleSection : public OsSettingsSection, - public AccountManager::Observer, + public account_manager::AccountManagerFacade::Observer, public syncer::SyncServiceObserver, public KerberosCredentialsManager::Observer { public: @@ -67,8 +69,8 @@ class PeopleSection : public OsSettingsSection, bool LogMetric(mojom::Setting setting, base::Value& value) const override; void RegisterHierarchy(HierarchyGenerator* generator) const override; - // AccountManager::Observer: - void OnTokenUpserted(const ::account_manager::Account& account) override; + // AccountManagerFacade::Observer: + void OnAccountUpserted(const ::account_manager::Account& account) override; void OnAccountRemoved(const ::account_manager::Account& account) override; // syncer::SyncServiceObserver: @@ -84,12 +86,20 @@ class PeopleSection : public OsSettingsSection, void UpdateRemoveFingerprintSearchTags(); AccountManager* account_manager_ = nullptr; + account_manager::AccountManagerFacade* account_manager_facade_ = nullptr; syncer::SyncService* sync_service_; SupervisedUserService* supervised_user_service_; KerberosCredentialsManager* kerberos_credentials_manager_; signin::IdentityManager* identity_manager_; PrefService* pref_service_; PrefChangeRegistrar fingerprint_pref_change_registrar_; + + // An observer for `AccountManagerFacade`. Automatically deregisters when + // `this` is destructed. + base::ScopedObservation<account_manager::AccountManagerFacade, + account_manager::AccountManagerFacade::Observer> + account_manager_facade_observation_{this}; + base::WeakPtrFactory<PeopleSection> weak_factory_{this}; }; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc index 94f0e039785..eaaa465e7a0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc @@ -13,7 +13,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h" -#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom-forward.h" #include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h" #include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h" #include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h" @@ -42,6 +41,14 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() { {.section = mojom::Section::kPersonalization}, {IDS_OS_SETTINGS_TAG_PERSONALIZATION_ALT1, IDS_OS_SETTINGS_TAG_PERSONALIZATION_ALT2, SearchConcept::kAltTagEnd}}, + {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER, + mojom::kPersonalizationSectionPath, + mojom::SearchResultIcon::kWallpaper, + mojom::SearchResultDefaultRank::kMedium, + mojom::SearchResultType::kSetting, + {.setting = mojom::Setting::kOpenWallpaper}, + {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1, + IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2, SearchConcept::kAltTagEnd}}, {IDS_OS_SETTINGS_TAG_CHANGE_DEVICE_ACCOUNT_IMAGE, mojom::kChangePictureSubpagePath, mojom::SearchResultIcon::kAvatar, @@ -57,34 +64,6 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() { return *tags; } -const std::vector<SearchConcept>& GetWallpaperChromeAppSearchConcepts() { - static const base::NoDestructor<std::vector<SearchConcept>> tags( - {{IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER, - mojom::kPersonalizationSectionPath, - mojom::SearchResultIcon::kWallpaper, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSetting, - {.setting = mojom::Setting::kOpenWallpaper}, - {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1, - IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2, - SearchConcept::kAltTagEnd}}}); - return *tags; -} - -const std::vector<SearchConcept>& GetWallpaperWebUISearchConcepts() { - static const base::NoDestructor<std::vector<SearchConcept>> tags( - {{IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER, - mojom::kWallpaperSubpagePath, - mojom::SearchResultIcon::kWallpaper, - mojom::SearchResultDefaultRank::kMedium, - mojom::SearchResultType::kSubpage, - {.subpage = mojom::Subpage::kWallpaper}, - {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1, - IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2, - SearchConcept::kAltTagEnd}}}); - return *tags; -} - const std::vector<SearchConcept>& GetAmbientModeSearchConcepts() { static const base::NoDestructor<std::vector<SearchConcept>> tags({ {IDS_OS_SETTINGS_TAG_AMBIENT_MODE, @@ -173,11 +152,6 @@ PersonalizationSection::PersonalizationSection( SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); updater.AddSearchTags(GetPersonalizationSearchConcepts()); - if (chromeos::features::IsWallpaperWebUIEnabled()) - updater.AddSearchTags(GetWallpaperWebUISearchConcepts()); - else - updater.AddSearchTags(GetWallpaperChromeAppSearchConcepts()); - if (IsAmbientModeAllowed()) { updater.AddSearchTags(GetAmbientModeSearchConcepts()); @@ -256,8 +230,6 @@ void PersonalizationSection::AddLoadTimeData( IDS_SETTINGS_PHOTO_DISCARD_ACCESSIBLE_TEXT}, {"photoModeAccessibleText", IDS_SETTINGS_PHOTO_MODE_ACCESSIBLE_TEXT}, {"videoModeAccessibleText", IDS_SETTINGS_VIDEO_MODE_ACCESSIBLE_TEXT}, - // TODO(b/178399962) finalize error string for WallpaperWebUI. - {"wallpaperCollectionsError", IDS_WALLPAPER_MANAGER_NETWORK_ERROR}, }; html_source->AddLocalizedStrings(kLocalizedStrings); @@ -277,9 +249,6 @@ void PersonalizationSection::AddLoadTimeData( l10n_util::GetStringFUTF16( IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_GOOGLE_PHOTOS_NO_ALBUM, base::UTF8ToUTF16(GetGooglePhotosURL().spec()))); - - html_source->AddBoolean("isWallpaperWebUIEnabled", - chromeos::features::IsWallpaperWebUIEnabled()); } void PersonalizationSection::AddHandlers(content::WebUI* web_ui) { @@ -330,12 +299,6 @@ void PersonalizationSection::RegisterHierarchy( generator->RegisterNestedSetting(mojom::Setting::kChangeDeviceAccountImage, mojom::Subpage::kChangePicture); - // Wallpaper. - generator->RegisterTopLevelSubpage( - IDS_OS_SETTINGS_SET_WALLPAPER, mojom::Subpage::kWallpaper, - mojom::SearchResultIcon::kWallpaper, - mojom::SearchResultDefaultRank::kMedium, mojom::kWallpaperSubpagePath); - // Ambient mode. generator->RegisterTopLevelSubpage( IDS_OS_SETTINGS_AMBIENT_MODE_TITLE, mojom::Subpage::kAmbientMode, diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc index f6ae5f23922..10e938f32be 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc @@ -10,8 +10,8 @@ #include "base/bind.h" #include "base/callback_helpers.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h" -#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_manager.h" +#include "chrome/browser/ash/plugin_vm/plugin_vm_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_thread.h" diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc index 6e42c805de8..fcb6da225cc 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc @@ -4,8 +4,6 @@ #include "chrome/browser/ui/webui/settings/chromeos/printing_section.h" -#include "ash/constants/ash_features.h" -#include "base/feature_list.h" #include "base/no_destructor.h" #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" #include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h" @@ -80,10 +78,6 @@ const std::vector<SearchConcept>& GetScanningAppSearchConcepts() { return *tags; } -bool IsScanningAppEnabled() { - return base::FeatureList::IsEnabled(chromeos::features::kScanningUI); -} - } // namespace PrintingSection::PrintingSection(Profile* profile, @@ -94,9 +88,7 @@ PrintingSection::PrintingSection(Profile* profile, SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); updater.AddSearchTags(GetPrintingSearchConcepts()); updater.AddSearchTags(GetPrintingManagementSearchConcepts()); - - if (IsScanningAppEnabled()) - updater.AddSearchTags(GetScanningAppSearchConcepts()); + updater.AddSearchTags(GetScanningAppSearchConcepts()); // Saved Printers search tags are added/removed dynamically. if (printers_manager_) { @@ -265,7 +257,6 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) { html_source->AddString( "printingCUPSPrintPpdLearnMoreUrl", GetHelpUrlWithBoard(chrome::kCupsPrintPPDLearnMoreURL)); - html_source->AddBoolean("scanningAppEnabled", IsScanningAppEnabled()); } void PrintingSection::AddHandlers(content::WebUI* web_ui) { diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc index 671c8b66a3b..21f04bb91a2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc @@ -66,7 +66,7 @@ void SearchHandler::BindInterface( receivers_.Add(this, std::move(pending_receiver)); } -void SearchHandler::Search(const base::string16& query, +void SearchHandler::Search(const std::u16string& query, uint32_t max_num_results, mojom::ParentResultBehavior parent_result_behavior, SearchCallback callback) { @@ -260,7 +260,7 @@ mojom::SearchResultPtr SearchHandler::ResultToSearchResult( std::string url; mojom::SearchResultIdentifierPtr result_id; - std::vector<base::string16> hierarchy_strings; + std::vector<std::u16string> hierarchy_strings; switch (concept->type) { case mojom::SearchResultType::kSection: { mojom::Section section = concept->id.section; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h index 592fc768909..ef6666f14b8 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h @@ -51,7 +51,7 @@ class SearchHandler : public mojom::SearchHandler, mojo::PendingReceiver<mojom::SearchHandler> pending_receiver); // mojom::SearchHandler: - void Search(const base::string16& query, + void Search(const std::u16string& query, uint32_t max_num_results, mojom::ParentResultBehavior parent_result_behavior, SearchCallback callback) override; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc index 5d2bb644d0e..c298276df3b 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc @@ -74,10 +74,10 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() { // Creates a result with some default values. mojom::SearchResultPtr CreateDummyResult() { return mojom::SearchResult::New( - /*result_text=*/base::string16(), - /*canonical_result_text=*/base::string16(), /*url=*/"", + /*result_text=*/std::u16string(), + /*canonical_result_text=*/std::u16string(), /*url=*/"", mojom::SearchResultIcon::kPrinter, /*relevance_score=*/0.5, - /*hierarchy_strings=*/std::vector<base::string16>(), + /*hierarchy_strings=*/std::vector<std::u16string>(), mojom::SearchResultDefaultRank::kMedium, /*was_generated_from_text_match=*/false, mojom::SearchResultType::kSection, @@ -151,7 +151,7 @@ TEST_F(SearchHandlerTest, AddAndRemove) { // 3 results should be available for a "Print" query. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Print"), + .Search(u"Print", /*max_num_results=*/3u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -159,7 +159,7 @@ TEST_F(SearchHandlerTest, AddAndRemove) { // Limit results to 1 max and ensure that only 1 result is returned. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Print"), + .Search(u"Print", /*max_num_results=*/1u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -167,7 +167,7 @@ TEST_F(SearchHandlerTest, AddAndRemove) { // Search for a query which should return no results. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("QueryWithNoResults"), + .Search(u"QueryWithNoResults", /*max_num_results=*/3u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -177,7 +177,7 @@ TEST_F(SearchHandlerTest, AddAndRemove) { // returned for "Printing". RemoveSearchTags(GetPrintingSearchConcepts()); mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Print"), + .Search(u"Print", /*max_num_results=*/3u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -190,7 +190,7 @@ TEST_F(SearchHandlerTest, UrlModification) { AddSearchTags(GetPrintingSearchConcepts()); std::vector<mojom::SearchResultPtr> search_results; mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Saved"), + .Search(u"Saved", /*max_num_results=*/3u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -200,9 +200,8 @@ TEST_F(SearchHandlerTest, UrlModification) { // The URL should have bee modified according to the FakeOsSettingSection // scheme. - EXPECT_EQ( - std::string("Section::kPrinting::") + mojom::kPrintingDetailsSubpagePath, - search_results[0]->url_path_with_parameters); + EXPECT_EQ(std::string("kPrinting::") + mojom::kPrintingDetailsSubpagePath, + search_results[0]->url_path_with_parameters); } TEST_F(SearchHandlerTest, AltTagMatch) { @@ -214,7 +213,7 @@ TEST_F(SearchHandlerTest, AltTagMatch) { // tag "CUPS" (referring to the Unix printing protocol), so we should receive // one match. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("CUPS"), + .Search(u"CUPS", /*max_num_results=*/3u, mojom::ParentResultBehavior::kDoNotIncludeParentResults, &search_results); @@ -236,7 +235,7 @@ TEST_F(SearchHandlerTest, AllowParentResult) { // Pass the kAllowParentResults flag, which should also cause its parent // subpage item to be returned. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Saved"), + .Search(u"Saved", /*max_num_results=*/3u, mojom::ParentResultBehavior::kAllowParentResults, &search_results); @@ -253,7 +252,7 @@ TEST_F(SearchHandlerTest, DefaultRank) { // contains the word "Printing", but the other results have the similar word // "Printer". Thus, "Printing" has a higher relevance score. mojom::SearchHandlerAsyncWaiter(handler_remote_.get()) - .Search(base::ASCIIToUTF16("Print"), + .Search(u"Print", /*max_num_results=*/3u, mojom::ParentResultBehavior::kAllowParentResults, &search_results); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc index a1f17aafc7c..eb5b8964043 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc @@ -5,9 +5,7 @@ #include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h" #include "base/bind.h" -#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper.pb.h" -#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper_handlers.h" -#include "chrome/browser/ui/ash/wallpaper_controller_client.h" +#include "chrome/browser/ui/ash/wallpaper_controller_client_impl.h" #include "content/public/browser/web_ui.h" namespace chromeos { @@ -35,11 +33,6 @@ void WallpaperHandler::RegisterMessages() { "isWallpaperPolicyControlled", base::BindRepeating(&WallpaperHandler::HandleIsWallpaperPolicyControlled, base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "fetchWallpaperCollections", - base::BindRepeating(&WallpaperHandler::HandleFetchWallpaperCollections, - base::Unretained(this))); } void WallpaperHandler::HandleIsWallpaperSettingVisible( @@ -47,49 +40,19 @@ void WallpaperHandler::HandleIsWallpaperSettingVisible( CHECK_EQ(args->GetSize(), 1U); ResolveCallback( args->GetList()[0], - WallpaperControllerClient::Get()->ShouldShowWallpaperSetting()); + WallpaperControllerClientImpl::Get()->ShouldShowWallpaperSetting()); } void WallpaperHandler::HandleIsWallpaperPolicyControlled( const base::ListValue* args) { CHECK_EQ(args->GetSize(), 1U); - bool result = WallpaperControllerClient::Get() + bool result = WallpaperControllerClientImpl::Get() ->IsActiveUserWallpaperControlledByPolicy(); ResolveCallback(args->GetList()[0], result); } void WallpaperHandler::HandleOpenWallpaperManager(const base::ListValue* args) { - WallpaperControllerClient::Get()->OpenWallpaperPickerIfAllowed(); -} - -void WallpaperHandler::HandleFetchWallpaperCollections( - const base::ListValue* args) { - CHECK_EQ(args->GetSize(), 1U); - DCHECK(IsJavascriptAllowed()) << "Page should already be initialized"; - backdrop_api_weak_factory_.InvalidateWeakPtrs(); - collection_info_fetcher_.Start( - base::BindOnce(&WallpaperHandler::OnFetchWallpaperCollections, - backdrop_api_weak_factory_.GetWeakPtr(), - args->GetList().front().Clone())); -} - -void WallpaperHandler::OnFetchWallpaperCollections( - const base::Value& callback_id, - bool success, - const std::vector<backdrop::Collection>& collections) { - if (!success || collections.empty()) { - RejectJavascriptCallback(callback_id, base::Value(base::Value::Type::NONE)); - return; - } - - base::Value result(base::Value::Type::LIST); - for (const auto& collection : collections) { - base::Value item(base::Value::Type::DICTIONARY); - item.SetKey("id", base::Value(collection.collection_id())); - item.SetKey("name", base::Value(collection.collection_name())); - result.Append(std::move(item)); - } - ResolveJavascriptCallback(callback_id, result); + WallpaperControllerClientImpl::Get()->OpenWallpaperPickerIfAllowed(); } void WallpaperHandler::ResolveCallback(const base::Value& callback_id, diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h index 645671d06a1..f6bd13d61de 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h @@ -6,14 +6,8 @@ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_WALLPAPER_HANDLER_H_ #include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper_handlers.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" -namespace backdrop { -class Collection; -} // namespace backdrop - namespace base { class ListValue; } // namespace base @@ -42,21 +36,9 @@ class WallpaperHandler : public ::settings::SettingsPageUIHandler { // Open the wallpaper manager app. void HandleOpenWallpaperManager(const base::ListValue* args); - // Begin to fetch wallpaper collection info. - void HandleFetchWallpaperCollections(const base::ListValue* args); - - void OnFetchWallpaperCollections( - const base::Value& callback_id, - bool success, - const std::vector<backdrop::Collection>& collections); - // Helper function to resolve the Javascript callback. void ResolveCallback(const base::Value& callback_id, bool result); - backdrop_wallpaper_handlers::CollectionInfoFetcher collection_info_fetcher_; - - base::WeakPtrFactory<WallpaperHandler> backdrop_api_weak_factory_{this}; - DISALLOW_COPY_AND_ASSIGN(WallpaperHandler); }; diff --git a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc index b4b0df20082..d724b704126 100644 --- a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc +++ b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc @@ -37,7 +37,7 @@ struct CustomHomePagesTableModel::Entry { GURL url; // Page title. If this is empty, we'll display the URL as the entry. - base::string16 title; + std::u16string title; // If not |base::CancelableTaskTracker::kBadTaskId|, indicates we're loading // the title for the page. @@ -189,15 +189,15 @@ int CustomHomePagesTableModel::RowCount() { return static_cast<int>(entries_.size()); } -base::string16 CustomHomePagesTableModel::GetText(int row, int column_id) { +std::u16string CustomHomePagesTableModel::GetText(int row, int column_id) { DCHECK(column_id == 0); DCHECK(row >= 0 && row < RowCount()); return entries_[row].title.empty() ? FormattedURL(row) : entries_[row].title; } -base::string16 CustomHomePagesTableModel::GetTooltip(int row) { +std::u16string CustomHomePagesTableModel::GetTooltip(int row) { return entries_[row].title.empty() - ? base::string16() + ? std::u16string() : l10n_util::GetStringFUTF16(IDS_SETTINGS_ON_STARTUP_PAGE_TOOLTIP, entries_[row].title, FormattedURL(row)); @@ -288,8 +288,8 @@ void CustomHomePagesTableModel::OnGotTitle(const GURL& entry_url, } } -base::string16 CustomHomePagesTableModel::FormattedURL(int row) const { - base::string16 url = url_formatter::FormatUrl(entries_[row].url); +std::u16string CustomHomePagesTableModel::FormattedURL(int row) const { + std::u16string url = url_formatter::FormatUrl(entries_[row].url); url = base::i18n::GetDisplayStringInLTRDirectionality(url); return url; } diff --git a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h index cbe342ab191..a4d0bf0393b 100644 --- a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h +++ b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h @@ -57,8 +57,8 @@ class CustomHomePagesTableModel : public ui::TableModel { // TableModel overrides: int RowCount() override; - base::string16 GetText(int row, int column_id) override; - base::string16 GetTooltip(int row) override; + std::u16string GetText(int row, int column_id) override; + std::u16string GetTooltip(int row) override; void SetObserver(ui::TableModelObserver* observer) override; private: @@ -96,7 +96,7 @@ class CustomHomePagesTableModel : public ui::TableModel { void RemoveWithoutNotification(int index); // Returns the URL for a particular row, formatted for display to the user. - base::string16 FormattedURL(int row) const; + std::u16string FormattedURL(int row) const; // Set of entries we're showing. std::vector<Entry> entries_; diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler_unittest.cc index 80ea9d4632c..330647db6af 100644 --- a/chromium/chrome/browser/ui/webui/settings/downloads_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler_unittest.cc @@ -65,9 +65,8 @@ class DownloadsHandlerTest : public testing::Test { std::string event; ASSERT_TRUE(data.arg1()->GetAsString(&event)); EXPECT_EQ("auto-open-downloads-changed", event); - bool auto_open_downloads = false; - ASSERT_TRUE(data.arg2()->GetAsBoolean(&auto_open_downloads)); - EXPECT_FALSE(auto_open_downloads); + ASSERT_TRUE(data.arg2()->is_bool()); + EXPECT_FALSE(data.arg2()->GetBool()); } Profile* profile() { return &profile_; } diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.cc b/chromium/chrome/browser/ui/webui/settings/font_handler.cc index 26ae033e95f..27fa6f75890 100644 --- a/chromium/chrome/browser/ui/webui/settings/font_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/font_handler.cc @@ -64,7 +64,7 @@ void FontHandler::FontListHasLoaded(std::string callback_id, bool has_font = list->GetList(i, &font); DCHECK(has_font); - base::string16 value; + std::u16string value; bool has_value = font->GetString(1, &value); DCHECK(has_value); diff --git a/chromium/chrome/browser/ui/webui/settings/hats_handler.cc b/chromium/chrome/browser/ui/webui/settings/hats_handler.cc index 74723f1b870..3c814af569f 100644 --- a/chromium/chrome/browser/ui/webui/settings/hats_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/hats_handler.cc @@ -9,9 +9,45 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/hats/hats_service.h" #include "chrome/browser/ui/hats/hats_service_factory.h" +#include "chrome/common/chrome_features.h" +#include "components/content_settings/core/browser/cookie_settings.h" +#include "components/content_settings/core/common/pref_names.h" +#include "components/prefs/pref_service.h" +#include "components/privacy_sandbox/privacy_sandbox_prefs.h" #include "content/public/browser/visibility.h" #include "content/public/browser/web_contents.h" +namespace { + +// Requests that the HaTS service for |profile|, if available, attempt to +// launch the survey associated with |trigger| on |web_contents|. Where the +// survey for |trigger| is configured to accept product specific data related to +// the user's 3P cookie & privacy sandbox setting. +void LaunchHatsSurveyWithProductSpecificData(Profile* profile, + content::WebContents* web_contents, + const std::string& trigger) { + HatsService* hats_service = HatsServiceFactory::GetForProfile( + profile, /* create_if_necessary = */ true); + + // The HaTS service may not be available for the profile, for example if it + // is a guest profile. + if (!hats_service) + return; + + const bool third_party_cookies_blocked = + static_cast<content_settings::CookieControlsMode>( + profile->GetPrefs()->GetInteger(prefs::kCookieControlsMode)) == + content_settings::CookieControlsMode::kBlockThirdParty; + const bool privacy_sandbox_enabled = + profile->GetPrefs()->GetBoolean(prefs::kPrivacySandboxApisEnabled); + hats_service->LaunchDelayedSurveyForWebContents( + trigger, web_contents, 20000, + {{"3P cookies blocked", third_party_cookies_blocked}, + {"Privacy Sandbox enabled", privacy_sandbox_enabled}}); +} + +} // namespace + namespace settings { HatsHandler::HatsHandler() = default; @@ -23,15 +59,33 @@ void HatsHandler::RegisterMessages() { "tryShowHatsSurvey", base::BindRepeating(&HatsHandler::HandleTryShowHatsSurvey, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "tryShowPrivacySandboxSurvey", + base::BindRepeating(&HatsHandler::HandleTryShowPrivacySandboxHatsSurvey, + base::Unretained(this))); } void HatsHandler::HandleTryShowHatsSurvey(const base::ListValue* args) { - HatsService* hats_service = HatsServiceFactory::GetForProfile( - Profile::FromWebUI(web_ui()), /* create_if_necessary = */ true); - if (hats_service) { - hats_service->LaunchDelayedSurveyForWebContents( - kHatsSurveyTriggerSettingsPrivacy, web_ui()->GetWebContents(), 20000); + // If the privacy settings survey is explicitly targeting users who have not + // viewed the Privacy Sandbox page, and this user has viewed the page, do + // not attempt to show the privacy settings survey. + if (features::kHappinessTrackingSurveysForDesktopSettingsPrivacyNoSandbox + .Get() && + Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean( + prefs::kPrivacySandboxPageViewed)) { + return; } + + LaunchHatsSurveyWithProductSpecificData(Profile::FromWebUI(web_ui()), + web_ui()->GetWebContents(), + kHatsSurveyTriggerSettingsPrivacy); +} + +void HatsHandler::HandleTryShowPrivacySandboxHatsSurvey( + const base::ListValue* args) { + LaunchHatsSurveyWithProductSpecificData(Profile::FromWebUI(web_ui()), + web_ui()->GetWebContents(), + kHatsSurveyTriggerPrivacySandbox); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/hats_handler.h b/chromium/chrome/browser/ui/webui/settings/hats_handler.h index f2e22b4a0c5..69197fccb77 100644 --- a/chromium/chrome/browser/ui/webui/settings/hats_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/hats_handler.h @@ -25,6 +25,8 @@ class HatsHandler : public SettingsPageUIHandler { void HandleTryShowHatsSurvey(const base::ListValue* args); + void HandleTryShowPrivacySandboxHatsSurvey(const base::ListValue* args); + private: friend class HatsHandlerTest; FRIEND_TEST_ALL_PREFIXES(HatsHandlerTest, HandleTryShowHatsSurvey); diff --git a/chromium/chrome/browser/ui/webui/settings/hats_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/hats_handler_unittest.cc index dc459945792..c7e564190b1 100644 --- a/chromium/chrome/browser/ui/webui/settings/hats_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/hats_handler_unittest.cc @@ -11,7 +11,12 @@ #include "chrome/browser/ui/hats/hats_service.h" #include "chrome/browser/ui/hats/hats_service_factory.h" #include "chrome/browser/ui/hats/mock_hats_service.h" +#include "chrome/common/chrome_features.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" +#include "components/content_settings/core/browser/cookie_settings.h" +#include "components/content_settings/core/common/pref_names.h" +#include "components/prefs/pref_service.h" +#include "components/privacy_sandbox/privacy_sandbox_prefs.h" #include "content/public/test/test_web_ui.h" #include "testing/gmock/include/gmock/gmock.h" @@ -48,18 +53,64 @@ class HatsHandlerTest : public ChromeRenderViewHostTestHarness { HatsHandler* handler() { return handler_.get(); } MockHatsService* mock_hats_service_; + protected: + base::test::ScopedFeatureList scoped_feature_list_; + private: std::unique_ptr<content::TestWebUI> web_ui_; std::unique_ptr<HatsHandler> handler_; }; TEST_F(HatsHandlerTest, HandleTryShowHatsSurvey) { - EXPECT_CALL(*mock_hats_service_, - LaunchDelayedSurveyForWebContents( - kHatsSurveyTriggerSettingsPrivacy, web_contents(), 20000)); + profile()->GetPrefs()->SetBoolean(prefs::kPrivacySandboxApisEnabled, false); + profile()->GetPrefs()->SetInteger( + prefs::kCookieControlsMode, + static_cast<int>(content_settings::CookieControlsMode::kBlockThirdParty)); + std::map<std::string, bool> expected_product_specific_data = { + {"3P cookies blocked", true}, {"Privacy Sandbox enabled", false}}; + + EXPECT_CALL(*mock_hats_service_, LaunchDelayedSurveyForWebContents( + kHatsSurveyTriggerSettingsPrivacy, + web_contents(), 20000, expected_product_specific_data)); base::ListValue args; handler()->HandleTryShowHatsSurvey(&args); task_environment()->RunUntilIdle(); + + testing::Mock::VerifyAndClearExpectations(mock_hats_service_); + + // Enable targeting for users who have not seen the Privacy Sandbox page and + // ensure the handler does not attempt to launch the survey. + EXPECT_CALL(*mock_hats_service_, + LaunchDelayedSurveyForWebContents(testing::_, testing::_, + testing::_, testing::_)) + .Times(0); + + base::test::ScopedFeatureList::FeatureAndParams feature_and_params{ + features::kHappinessTrackingSurveysForDesktopSettingsPrivacy, + {{"no-sandbox", "true"}}}; + scoped_feature_list_.InitWithFeaturesAndParameters({feature_and_params}, {}); + + profile()->GetPrefs()->SetBoolean(prefs::kPrivacySandboxPageViewed, true); + + handler()->HandleTryShowHatsSurvey(&args); + task_environment()->RunUntilIdle(); +} + +TEST_F(HatsHandlerTest, HandleTryShowPrivacySandboxHatsSurvey) { + // Check that the handler correctly forwards the survey request to the + // HaTS service and also includes the appropriate product specific data. + profile()->GetPrefs()->SetBoolean(prefs::kPrivacySandboxApisEnabled, false); + profile()->GetPrefs()->SetInteger( + prefs::kCookieControlsMode, + static_cast<int>(content_settings::CookieControlsMode::kBlockThirdParty)); + std::map<std::string, bool> expected_product_specific_data = { + {"3P cookies blocked", true}, {"Privacy Sandbox enabled", false}}; + EXPECT_CALL(*mock_hats_service_, LaunchDelayedSurveyForWebContents( + kHatsSurveyTriggerPrivacySandbox, + web_contents(), 20000, expected_product_specific_data)); + base::ListValue args; + handler()->HandleTryShowPrivacySandboxHatsSurvey(&args); + task_environment()->RunUntilIdle(); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc b/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc index 5eca85a0c62..7d2161fdf5e 100644 --- a/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc @@ -12,7 +12,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -178,7 +177,7 @@ void ImportDataHandler::HandleImportFromBookmarksFile( chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); select_file_dialog_->SelectFile( - ui::SelectFileDialog::SELECT_OPEN_FILE, base::string16(), + ui::SelectFileDialog::SELECT_OPEN_FILE, std::u16string(), base::FilePath(), &file_type_info, 0, base::FilePath::StringType(), browser->window()->GetNativeWindow(), nullptr); } diff --git a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc index 46b3d283ad4..6772fa07b0a 100644 --- a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc +++ b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc @@ -100,7 +100,7 @@ void IncompatibleApplicationsHandler::HandleRequestIncompatibleApplicationsList( // Also add the application to the list that is passed to the javascript. base::Value dict(base::Value::Type::DICTIONARY); - dict.SetKey("name", base::Value(application.info.name)); + dict.SetKey("name", base::Value(base::WideToUTF8(application.info.name))); dict.SetKey("type", base::Value(application.blocklist_action->message_type())); dict.SetKey("url", @@ -123,7 +123,7 @@ void IncompatibleApplicationsHandler::HandleStartApplicationUninstallation( // Open the Apps & Settings page with the application name highlighted. uninstall_application::LaunchUninstallFlow( - base::UTF8ToUTF16(args->GetList()[0].GetString())); + base::UTF8ToWide(args->GetList()[0].GetString())); } void IncompatibleApplicationsHandler::HandleGetSubtitlePluralString( @@ -165,7 +165,7 @@ void IncompatibleApplicationsHandler::OnApplicationRemoved( registry_key_watchers_.erase(application); FireWebUIListener("incompatible-application-removed", - base::Value(application.name)); + base::Value(base::WideToUTF8(application.name))); } } // namespace settings diff --git a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc index f28bfd2e3b4..cce93cf6169 100644 --- a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc @@ -15,8 +15,8 @@ #include "content/public/browser/web_ui.h" #if BUILDFLAG(IS_CHROMEOS_ASH) +#include "chrome/browser/ash/base/locale_util.h" #include "chrome/browser/ash/profiles/profile_helper.h" -#include "chrome/browser/chromeos/base/locale_util.h" #include "chrome/browser/profiles/profile.h" #include "components/user_manager/user_manager.h" #include "components/user_manager/user_type.h" diff --git a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc index 6aebbaeefd4..51518ded9bc 100644 --- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "build/branding_buildflags.h" #include "build/chromeos_buildflags.h" -#if defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ui/webui/settings/metrics_reporting_handler.h" @@ -150,4 +151,4 @@ void MetricsReportingHandler::SendMetricsReportingChange() { } // namespace settings -#endif // defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH) diff --git a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h index 420eac58251..d7bb54f00c0 100644 --- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h @@ -5,9 +5,10 @@ #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_ +#include "build/branding_buildflags.h" #include "build/chromeos_buildflags.h" -#if defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH) #include <memory> @@ -80,6 +81,6 @@ class MetricsReportingHandler : public SettingsPageUIHandler { } // namespace settings -#endif // defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH) #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc index d8346169635..ca3fb4508b6 100644 --- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc @@ -11,7 +11,7 @@ #include "base/values.h" #include "build/build_config.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" +#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" #include "components/user_manager/scoped_user_manager.h" #endif #include "build/chromeos_buildflags.h" @@ -48,8 +48,7 @@ class OnStartupHandlerTest : public testing::Test { ASSERT_TRUE(profile_manager_.SetUp()); #if BUILDFLAG(IS_CHROMEOS_ASH) - chromeos::FakeChromeUserManager* fake_user_manager = - new chromeos::FakeChromeUserManager; + auto* fake_user_manager = new ash::FakeChromeUserManager; user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>( base::WrapUnique(fake_user_manager)); constexpr char kFakeEmail[] = "fake_id@gmail.com"; diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc index eb6cf74a3c1..312b78877ac 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc @@ -180,7 +180,7 @@ base::Value GetAccountValue(const AccountInfo& account) { return dictionary; } -base::string16 GetEnterPassphraseBody(syncer::PassphraseType passphrase_type, +std::u16string GetEnterPassphraseBody(syncer::PassphraseType passphrase_type, base::Time passphrase_time) { DCHECK(syncer::IsExplicitPassphrase(passphrase_type)); switch (passphrase_type) { @@ -204,10 +204,10 @@ base::string16 GetEnterPassphraseBody(syncer::PassphraseType passphrase_type, break; } NOTREACHED(); - return base::string16(); + return std::u16string(); } -base::string16 GetFullEncryptionBody(syncer::PassphraseType passphrase_type, +std::u16string GetFullEncryptionBody(syncer::PassphraseType passphrase_type, base::Time passphrase_time) { DCHECK(syncer::IsExplicitPassphrase(passphrase_type)); if (passphrase_time.is_null()) { @@ -226,7 +226,7 @@ base::string16 GetFullEncryptionBody(syncer::PassphraseType passphrase_type, break; } NOTREACHED(); - return base::string16(); + return std::u16string(); } } // namespace @@ -378,7 +378,7 @@ void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow( // then sign in again. identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent( signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, - signin_metrics::SignoutDelete::IGNORE_METRIC); + signin_metrics::SignoutDelete::kIgnoreMetric); } // If the identity manager already has a primary account, this is a @@ -491,7 +491,7 @@ base::Value PeopleHandler::GetStoredAccountsList() { auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_); base::Optional<AccountInfo> primary_account_info = identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken( - identity_manager->GetPrimaryAccountInfo(ConsentLevel::kNotRequired)); + identity_manager->GetPrimaryAccountInfo(ConsentLevel::kSignin)); if (primary_account_info.has_value()) accounts.Append(GetAccountValue(primary_account_info.value())); return accounts; @@ -641,7 +641,7 @@ void PeopleHandler::HandleTurnOffSync(const base::ListValue* args) { identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent( signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, - signin_metrics::SignoutDelete::IGNORE_METRIC); + signin_metrics::SignoutDelete::kIgnoreMetric); } #endif // BUILDFLAG(IS_CHROMEOS_ASH) @@ -677,8 +677,8 @@ void PeopleHandler::HandleSignout(const base::ListValue* args) { auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_); if (identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) { signin_metrics::SignoutDelete delete_metric = - delete_profile ? signin_metrics::SignoutDelete::DELETED - : signin_metrics::SignoutDelete::KEEPING; + delete_profile ? signin_metrics::SignoutDelete::kDeleted + : signin_metrics::SignoutDelete::kKeeping; // Only revoke the sync consent. // * If the primary account is still valid, then it will be removed by @@ -776,7 +776,7 @@ void PeopleHandler::CloseSyncSetup() { ->GetPrimaryAccountMutator() ->RevokeSyncConsent( signin_metrics::ABORT_SIGNIN, - signin_metrics::SignoutDelete::IGNORE_METRIC); + signin_metrics::SignoutDelete::kIgnoreMetric); } #endif } diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc index 10dcebabbce..fd32782c108 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc @@ -292,9 +292,8 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { std::string callback_id; ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); EXPECT_EQ(kTestCallbackId, callback_id); - bool success = false; - ASSERT_TRUE(data.arg2()->GetAsBoolean(&success)); - EXPECT_TRUE(success); + ASSERT_TRUE(data.arg2()->is_bool()); + EXPECT_TRUE(data.arg2()->GetBool()); std::string status; ASSERT_TRUE(data.arg3()->GetAsString(&status)); EXPECT_EQ(expected_status, status); diff --git a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc index 8a695265d04..747b4651bb5 100644 --- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc @@ -88,7 +88,7 @@ void ProfileInfoHandler::OnUserImageChanged(const user_manager::User& user) { void ProfileInfoHandler::OnProfileNameChanged( const base::FilePath& /* profile_path */, - const base::string16& /* old_profile_name */) { + const std::u16string& /* old_profile_name */) { PushProfileInfo(); } diff --git a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h index cd5be0f13e1..59a7d6c85f9 100644 --- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h @@ -50,7 +50,7 @@ class ProfileInfoHandler : public SettingsPageUIHandler, // ProfileAttributesStorage::Observer implementation. void OnProfileNameChanged(const base::FilePath& profile_path, - const base::string16& old_profile_name) override; + const std::u16string& old_profile_name) override; void OnProfileAvatarChanged(const base::FilePath& profile_path) override; private: diff --git a/chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc index 76feb8d9130..e7ff776badb 100644 --- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc @@ -24,7 +24,7 @@ #include "url/gurl.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" +#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" #include "components/user_manager/scoped_user_manager.h" #endif @@ -57,8 +57,7 @@ class ProfileInfoHandlerTest : public testing::Test { ASSERT_TRUE(profile_manager_.SetUp()); #if BUILDFLAG(IS_CHROMEOS_ASH) - chromeos::FakeChromeUserManager* fake_user_manager = - new chromeos::FakeChromeUserManager; + auto* fake_user_manager = new ash::FakeChromeUserManager; user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>( base::WrapUnique(fake_user_manager)); profile_ = profile_manager_.CreateTestingProfile(fake_email); @@ -128,9 +127,8 @@ TEST_F(ProfileInfoHandlerTest, GetProfileInfo) { ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); EXPECT_EQ("get-profile-info-callback-id", callback_id); - bool success = false; - ASSERT_TRUE(data.arg2()->GetAsBoolean(&success)); - EXPECT_TRUE(success); + ASSERT_TRUE(data.arg2()->is_bool()); + EXPECT_TRUE(data.arg2()->GetBool()); VerifyProfileInfo(data.arg3()); } diff --git a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc index b453a5ebf1f..8c0eea5add4 100644 --- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc @@ -172,8 +172,8 @@ void ProtocolHandlersHandler::HandleSetDefault(const base::ListValue* args) { ProtocolHandler ProtocolHandlersHandler::ParseHandlerFromArgs( const base::ListValue* args) const { - base::string16 protocol; - base::string16 url; + std::u16string protocol; + std::u16string url; bool ok = args->GetString(0, &protocol) && args->GetString(1, &url); if (!ok) return ProtocolHandler::EmptyProtocolHandler(); diff --git a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc index 7f63fe98b0e..53b8ae1f551 100644 --- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc @@ -4,13 +4,13 @@ #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" +#include <string> #include <utility> #include "base/bind.h" #include "base/callback_helpers.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" -#include "base/strings/string16.h" #include "base/time/time.h" #include "base/values.h" #include "build/build_config.h" @@ -276,7 +276,7 @@ void ResetSettingsHandler::HandleGetTriggeredResetToolName( // Set up the localized strings for the triggered profile reset dialog. // Custom reset tool names are supported on Windows only. - base::string16 reset_tool_name; + std::u16string reset_tool_name; #if defined(OS_WIN) Profile* profile = Profile::FromWebUI(web_ui()); TriggeredProfileResetter* triggered_profile_resetter = diff --git a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc index 3c08e46999f..2d38cfbf440 100644 --- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc @@ -4,6 +4,9 @@ #include "chrome/browser/ui/webui/settings/safety_check_handler.h" +#include <memory> +#include <string> + #include "base/bind.h" #include "base/feature_list.h" #include "base/i18n/number_formatting.h" @@ -11,7 +14,6 @@ #include "base/metrics/histogram_functions.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_process.h" @@ -278,7 +280,7 @@ void SafetyCheckHandler::SendSafetyCheckStartedWebUiUpdates() { void SafetyCheckHandler::PerformSafetyCheck() { // Checks common to desktop, Android, and iOS are handled by // safety_check::SafetyCheck. - safety_check_.reset(new safety_check::SafetyCheck(this)); + safety_check_ = std::make_unique<safety_check::SafetyCheck>(this); safety_check_->CheckSafeBrowsing(Profile::FromWebUI(web_ui())->GetPrefs()); if (!version_updater_) { @@ -286,10 +288,10 @@ void SafetyCheckHandler::PerformSafetyCheck() { } DCHECK(version_updater_); if (!update_helper_) { - update_helper_.reset(new safety_check::UpdateCheckHelper( + update_helper_ = std::make_unique<safety_check::UpdateCheckHelper>( content::BrowserContext::GetDefaultStoragePartition( Profile::FromWebUI(web_ui())) - ->GetURLLoaderFactoryForBrowserProcess())); + ->GetURLLoaderFactoryForBrowserProcess()); } DCHECK(update_helper_); CheckUpdates(); @@ -552,7 +554,7 @@ void SafetyCheckHandler::OnChromeCleanerCheckResult( } #endif -base::string16 SafetyCheckHandler::GetStringForParent(ParentStatus status) { +std::u16string SafetyCheckHandler::GetStringForParent(ParentStatus status) { switch (status) { case ParentStatus::kBefore: return l10n_util::GetStringUTF16( @@ -565,10 +567,10 @@ base::string16 SafetyCheckHandler::GetStringForParent(ParentStatus status) { } } -base::string16 SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) { +std::u16string SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) { switch (status) { case UpdateStatus::kChecking: - return base::UTF8ToUTF16(""); + return u""; case UpdateStatus::kUpdated: #if BUILDFLAG(IS_CHROMEOS_ASH) return ui::SubstituteChromeOSDeviceType(IDS_SETTINGS_UPGRADE_UP_TO_DATE); @@ -598,20 +600,21 @@ base::string16 SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) { l10n_util::GetStringUTF16(version_info::IsOfficialBuild() ? IDS_VERSION_UI_OFFICIAL : IDS_VERSION_UI_UNOFFICIAL), - base::UTF8ToUTF16(chrome::GetChannelName()), + base::UTF8ToUTF16( + chrome::GetChannelName(chrome::WithExtendedStable(true))), l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation())); // This state is only used on Android for recording metrics. This codepath // is unreachable. case UpdateStatus::kOutdated: - return base::UTF8ToUTF16(""); + return u""; } } -base::string16 SafetyCheckHandler::GetStringForSafeBrowsing( +std::u16string SafetyCheckHandler::GetStringForSafeBrowsing( SafeBrowsingStatus status) { switch (status) { case SafeBrowsingStatus::kChecking: - return base::UTF8ToUTF16(""); + return u""; case SafeBrowsingStatus::kEnabled: case SafeBrowsingStatus::kEnabledStandard: return l10n_util::GetStringUTF16( @@ -635,7 +638,7 @@ base::string16 SafetyCheckHandler::GetStringForSafeBrowsing( } } -base::string16 SafetyCheckHandler::GetStringForPasswords( +std::u16string SafetyCheckHandler::GetStringForPasswords( PasswordsStatus status, Compromised compromised, Weak weak, @@ -645,7 +648,7 @@ base::string16 SafetyCheckHandler::GetStringForPasswords( case PasswordsStatus::kChecking: { // Unable to get progress for some reason. if (total.value() == 0) { - return base::UTF8ToUTF16(""); + return u""; } return l10n_util::GetStringFUTF16(IDS_SETTINGS_CHECK_PASSWORDS_PROGRESS, base::FormatNumber(done.value()), @@ -700,14 +703,14 @@ base::string16 SafetyCheckHandler::GetStringForPasswords( } } -base::string16 SafetyCheckHandler::GetStringForExtensions( +std::u16string SafetyCheckHandler::GetStringForExtensions( ExtensionsStatus status, Blocklisted blocklisted, ReenabledUser reenabled_user, ReenabledAdmin reenabled_admin) { switch (status) { case ExtensionsStatus::kChecking: - return base::UTF8ToUTF16(""); + return u""; case ExtensionsStatus::kError: return l10n_util::GetStringUTF16( IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_ERROR); @@ -739,14 +742,14 @@ base::string16 SafetyCheckHandler::GetStringForExtensions( } #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) -base::string16 SafetyCheckHandler::GetStringForChromeCleaner( +std::u16string SafetyCheckHandler::GetStringForChromeCleaner( ChromeCleanerStatus status, base::Time cct_completion_time, base::Time system_time) { switch (status) { case ChromeCleanerStatus::kHidden: case ChromeCleanerStatus::kChecking: - return base::UTF8ToUTF16(""); + return u""; case ChromeCleanerStatus::kInfected: return l10n_util::GetStringUTF16( IDS_SETTINGS_SAFETY_CHECK_CHROME_CLEANER_INFECTED); @@ -776,7 +779,7 @@ base::string16 SafetyCheckHandler::GetStringForChromeCleaner( } #endif -base::string16 SafetyCheckHandler::GetStringForTimePassed( +std::u16string SafetyCheckHandler::GetStringForTimePassed( base::Time completion_timestamp, base::Time system_time, int less_than_one_minute_ago_message_id, @@ -827,7 +830,7 @@ base::string16 SafetyCheckHandler::GetStringForTimePassed( } } -base::string16 SafetyCheckHandler::GetStringForParentRan( +std::u16string SafetyCheckHandler::GetStringForParentRan( base::Time safety_check_completion_time, base::Time system_time) { return SafetyCheckHandler::GetStringForTimePassed( @@ -839,14 +842,14 @@ base::string16 SafetyCheckHandler::GetStringForParentRan( IDS_SETTINGS_SAFETY_CHECK_PARENT_PRIMARY_LABEL_AFTER_DAYS); } -base::string16 SafetyCheckHandler::GetStringForParentRan( +std::u16string SafetyCheckHandler::GetStringForParentRan( base::Time safety_check_completion_time) { return SafetyCheckHandler::GetStringForParentRan(safety_check_completion_time, base::Time::Now()); } #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) -base::string16 SafetyCheckHandler::GetStringForChromeCleanerRan( +std::u16string SafetyCheckHandler::GetStringForChromeCleanerRan( base::Time cct_completion_time, base::Time system_time) { if (cct_completion_time.is_null()) { @@ -912,7 +915,7 @@ void SafetyCheckHandler::OnVersionUpdaterResult(VersionUpdater::Status status, bool powerwash, const std::string& version, int64_t update_size, - const base::string16& message) { + const std::u16string& message) { if (status == VersionUpdater::FAILED) { update_helper_->CheckConnectivity( base::BindOnce(&SafetyCheckHandler::DetermineIfOfflineOrError, @@ -1111,7 +1114,7 @@ void SafetyCheckHandler::CompleteParentIfChildrenCompleted() { void SafetyCheckHandler::FireBasicSafetyCheckWebUiListener( const std::string& event_name, int new_state, - const base::string16& display_string) { + const std::u16string& display_string) { base::DictionaryValue event; event.SetIntKey(kNewState, new_state); event.SetStringKey(kDisplayString, display_string); diff --git a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h index 774f6eb199c..63f90a9f297 100644 --- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h @@ -119,7 +119,7 @@ class SafetyCheckHandler // Constructs a string depicting how much time passed since the completion of // something from the corresponding timestamps and strings IDs. - base::string16 GetStringForTimePassed(base::Time completion_timestamp, + std::u16string GetStringForTimePassed(base::Time completion_timestamp, base::Time system_time, int less_than_one_minute_ago_message_id, int minutes_ago_message_id, @@ -129,15 +129,15 @@ class SafetyCheckHandler // Constructs the 'safety check ran' display string by how long ago safety // check ran. - base::string16 GetStringForParentRan(base::Time safety_check_completion_time); - base::string16 GetStringForParentRan(base::Time safety_check_completion_time, + std::u16string GetStringForParentRan(base::Time safety_check_completion_time); + std::u16string GetStringForParentRan(base::Time safety_check_completion_time, base::Time system_time); #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) // Constructs the string for the Chrome cleaner 'safe' state which depicts // how long ago its last check ran. - base::string16 GetStringForChromeCleanerRan(); - base::string16 GetStringForChromeCleanerRan(base::Time cct_completion_time, + std::u16string GetStringForChromeCleanerRan(); + std::u16string GetStringForChromeCleanerRan(base::Time cct_completion_time, base::Time system_time); // safe_browsing::ChromeCleanerController::Observer overrides. @@ -228,20 +228,20 @@ class SafetyCheckHandler // Methods for building user-visible strings based on the safety check // state. - base::string16 GetStringForParent(ParentStatus status); - base::string16 GetStringForUpdates(UpdateStatus status); - base::string16 GetStringForSafeBrowsing(SafeBrowsingStatus status); - base::string16 GetStringForPasswords(PasswordsStatus status, + std::u16string GetStringForParent(ParentStatus status); + std::u16string GetStringForUpdates(UpdateStatus status); + std::u16string GetStringForSafeBrowsing(SafeBrowsingStatus status); + std::u16string GetStringForPasswords(PasswordsStatus status, Compromised compromised, Weak weak, Done done, Total total); - base::string16 GetStringForExtensions(ExtensionsStatus status, + std::u16string GetStringForExtensions(ExtensionsStatus status, Blocklisted blocklisted, ReenabledUser reenabled_user, ReenabledAdmin reenabled_admin); #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) - base::string16 GetStringForChromeCleaner(ChromeCleanerStatus status, + std::u16string GetStringForChromeCleaner(ChromeCleanerStatus status, base::Time cct_completion_time, base::Time system_time); #endif @@ -271,7 +271,7 @@ class SafetyCheckHandler bool powerwash, const std::string& version, int64_t update_size, - const base::string16& message); + const std::u16string& message); // SafetyCheck::SafetyCheckHandlerInterface implementation. void OnSafeBrowsingCheckResult(SafeBrowsingStatus status) override; @@ -300,7 +300,7 @@ class SafetyCheckHandler // Fire a safety check element WebUI update with a state and string. void FireBasicSafetyCheckWebUiListener(const std::string& event_name, int new_state, - const base::string16& display_string); + const std::u16string& display_string); // The current status of the safety check elements. Before safety // check is started, the parent is in the 'before' state. diff --git a/chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc index 34991ccfa08..38e1563742f 100644 --- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/optional.h" #include "base/strings/strcat.h" -#include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -171,12 +170,12 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate { // Credentials have to be unique, so the callback is always invoked. form.username_value = base::ASCIIToUTF16( "test" + base::NumberToString(test_credential_counter_++)); - form.password_value = base::ASCIIToUTF16("password"); - form.username_element = base::ASCIIToUTF16("username_element"); + form.password_value = u"password"; + form.username_element = u"username_element"; store_->AddLogin(form); base::RunLoop().RunUntilIdle(); - store_->AddInsecureCredential(password_manager::CompromisedCredentials( + store_->AddInsecureCredential(password_manager::InsecureCredential( form.signon_realm, form.username_value, base::Time(), password_manager::InsecureType::kLeaked, password_manager::IsMuted(false))); @@ -295,14 +294,14 @@ class SafetyCheckHandlerTest : public testing::Test { std::string GenerateExtensionId(char char_to_repeat); void VerifyDisplayString(const base::DictionaryValue* event, - const base::string16& expected); + const std::u16string& expected); void VerifyDisplayString(const base::DictionaryValue* event, const std::string& expected); // Replaces any instances of browser name (e.g. Google Chrome, Chromium, // etc) with "browser" to make sure tests work both on Chromium and // Google Chrome. - void ReplaceBrowserName(base::string16* s); + void ReplaceBrowserName(std::u16string* s); protected: content::BrowserTaskEnvironment browser_task_environment_; @@ -397,14 +396,14 @@ std::string SafetyCheckHandlerTest::GenerateExtensionId(char char_to_repeat) { void SafetyCheckHandlerTest::VerifyDisplayString( const base::DictionaryValue* event, - const base::string16& expected) { - base::string16 display; + const std::u16string& expected) { + std::u16string display; ASSERT_TRUE(event->GetString("displayString", &display)); ReplaceBrowserName(&display); // Need to also replace any instances of Chrome and Chromium in the // expected string due to an edge case on ChromeOS, where a device name // is "Chrome", which gets replaced in the display string. - base::string16 expected_replaced = expected; + std::u16string expected_replaced = expected; ReplaceBrowserName(&expected_replaced); EXPECT_EQ(expected_replaced, display); } @@ -415,13 +414,10 @@ void SafetyCheckHandlerTest::VerifyDisplayString( VerifyDisplayString(event, base::ASCIIToUTF16(expected)); } -void SafetyCheckHandlerTest::ReplaceBrowserName(base::string16* s) { - base::ReplaceSubstringsAfterOffset(s, 0, base::ASCIIToUTF16("Google Chrome"), - base::ASCIIToUTF16("Browser")); - base::ReplaceSubstringsAfterOffset(s, 0, base::ASCIIToUTF16("Chrome"), - base::ASCIIToUTF16("Browser")); - base::ReplaceSubstringsAfterOffset(s, 0, base::ASCIIToUTF16("Chromium"), - base::ASCIIToUTF16("Browser")); +void SafetyCheckHandlerTest::ReplaceBrowserName(std::u16string* s) { + base::ReplaceSubstringsAfterOffset(s, 0, u"Google Chrome", u"Browser"); + base::ReplaceSubstringsAfterOffset(s, 0, u"Chrome", u"Browser"); + base::ReplaceSubstringsAfterOffset(s, 0, u"Chromium", u"Browser"); } TEST_F(SafetyCheckHandlerTest, CheckUpdates_Checking) { @@ -432,7 +428,7 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Checking) { kUpdates, static_cast<int>(SafetyCheckHandler::UpdateStatus::kChecking)); ASSERT_TRUE(event); - VerifyDisplayString(event, base::UTF8ToUTF16("")); + VerifyDisplayString(event, u""); // Checking state should not get recorded. histogram_tester_.ExpectTotalCount("Settings.SafetyCheck.UpdatesResult", 0); } @@ -446,9 +442,8 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Updated) { static_cast<int>(SafetyCheckHandler::UpdateStatus::kUpdated)); ASSERT_TRUE(event); #if BUILDFLAG(IS_CHROMEOS_ASH) - base::string16 expected = base::ASCIIToUTF16("Your ") + - ui::GetChromeOSDeviceName() + - base::ASCIIToUTF16(" is up to date"); + std::u16string expected = + u"Your " + ui::GetChromeOSDeviceName() + u" is up to date"; VerifyDisplayString(event, expected); #else VerifyDisplayString(event, "Browser is up to date"); @@ -532,7 +527,9 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Disabled) { event, "Version " + version_info::GetVersionNumber() + " (" + (version_info::IsOfficialBuild() ? "Official Build" : "Developer Build") + - ") " + chrome::GetChannelName() + processor_variation); + ") " + + chrome::GetChannelName(chrome::WithExtendedStable(true)) + + processor_variation); histogram_tester_.ExpectBucketCount( "Settings.SafetyCheck.UpdatesResult", SafetyCheckHandler::UpdateStatus::kUnknown, 1); @@ -772,7 +769,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_ObserverRemovedAfterError) { kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); ASSERT_TRUE(event); - VerifyDisplayString(event, base::UTF8ToUTF16("")); + VerifyDisplayString(event, u""); histogram_tester_.ExpectTotalCount("Settings.SafetyCheck.PasswordsResult", 0); // Second, an "offline" state. test_leak_service_->set_state_and_notify( @@ -812,7 +809,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_InterruptedAndRefreshed) { kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); ASSERT_TRUE(event); - VerifyDisplayString(event, base::UTF8ToUTF16("")); + VerifyDisplayString(event, u""); // The check gets interrupted and the page is refreshed. safety_check_->DisallowJavascript(); safety_check_->AllowJavascript(); @@ -926,9 +923,8 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_StaleSafeThenCompromised) { // Not a "safe" state, so send an |OnCredentialDone| with is_leaked=true. static_cast<password_manager::BulkLeakCheckService::Observer*>( safety_check_.get()) - ->OnCredentialDone( - {base::ASCIIToUTF16("login"), base::ASCIIToUTF16("password")}, - password_manager::IsLeaked(true)); + ->OnCredentialDone({u"login", u"password"}, + password_manager::IsLeaked(true)); // The service goes idle, but the disk still has a stale "safe" state. test_leak_service_->set_state_and_notify( password_manager::BulkLeakCheckService::State::kIdle); @@ -1195,8 +1191,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_NoPasswords) { } TEST_F(SafetyCheckHandlerTest, CheckPasswords_Progress) { - auto credential = password_manager::LeakCheckCredential( - base::UTF8ToUTF16("test"), base::UTF8ToUTF16("test")); + auto credential = password_manager::LeakCheckCredential(u"test", u"test"); auto is_leaked = password_manager::IsLeaked(false); safety_check_->PerformSafetyCheck(); test_passwords_delegate_.SetPasswordCheckState( @@ -1210,7 +1205,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_Progress) { kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); EXPECT_TRUE(event); - VerifyDisplayString(event, base::UTF8ToUTF16("Checking passwords (1 of 3)…")); + VerifyDisplayString(event, u"Checking passwords (1 of 3)…"); test_passwords_delegate_.SetProgress(2, 3); static_cast<password_manager::BulkLeakCheckService::Observer*>( @@ -1221,8 +1216,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_Progress) { kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); EXPECT_TRUE(event2); - VerifyDisplayString(event2, - base::UTF8ToUTF16("Checking passwords (2 of 3)…")); + VerifyDisplayString(event2, u"Checking passwords (2 of 3)…"); // Final update comes after status change, so no new progress message should // be present. @@ -1238,8 +1232,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_Progress) { static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); EXPECT_TRUE(event3); // Still 2/3 event. - VerifyDisplayString(event3, - base::UTF8ToUTF16("Checking passwords (2 of 3)…")); + VerifyDisplayString(event3, u"Checking passwords (2 of 3)…"); } TEST_F(SafetyCheckHandlerTest, CheckExtensions_NoExtensions) { @@ -1431,7 +1424,7 @@ class SafetyCheckHandlerChromeCleanerIdleTest public testing::WithParamInterface< std::tuple<safe_browsing::ChromeCleanerController::IdleReason, SafetyCheckHandler::ChromeCleanerStatus, - base::string16>> { + std::u16string>> { protected: void SetUp() override { SafetyCheckHandlerTest::SetUp(); @@ -1442,7 +1435,7 @@ class SafetyCheckHandlerChromeCleanerIdleTest safe_browsing::ChromeCleanerController::IdleReason idle_reason_; SafetyCheckHandler::ChromeCleanerStatus expected_cct_status_; - base::string16 expected_display_string_; + std::u16string expected_display_string_; }; TEST_P(SafetyCheckHandlerChromeCleanerIdleTest, CheckChromeCleanerIdleStates) { @@ -1495,7 +1488,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::make_tuple( safe_browsing::ChromeCleanerController::IdleReason::kReporterFailed, SafetyCheckHandler::ChromeCleanerStatus::kError, - base::UTF8ToUTF16("Something went wrong. Click for more details.")))); + u"Something went wrong. Click for more details."))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_ScanningFoundNothing, @@ -1513,7 +1506,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::make_tuple( safe_browsing::ChromeCleanerController::IdleReason::kScanningFailed, SafetyCheckHandler::ChromeCleanerStatus::kError, - base::UTF8ToUTF16("Something went wrong. Click for more details.")))); + u"Something went wrong. Click for more details."))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_ConnectionLost, @@ -1521,16 +1514,16 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::make_tuple( safe_browsing::ChromeCleanerController::IdleReason::kConnectionLost, SafetyCheckHandler::ChromeCleanerStatus::kInfected, - base::UTF8ToUTF16("Browser found harmful software on your computer")))); + u"Browser found harmful software on your computer"))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_UserDeclinedCleanup, SafetyCheckHandlerChromeCleanerIdleTest, - ::testing::Values(std::make_tuple( - safe_browsing::ChromeCleanerController::IdleReason:: - kUserDeclinedCleanup, - SafetyCheckHandler::ChromeCleanerStatus::kInfected, - base::UTF8ToUTF16("Browser found harmful software on your computer")))); + ::testing::Values( + std::make_tuple(safe_browsing::ChromeCleanerController::IdleReason:: + kUserDeclinedCleanup, + SafetyCheckHandler::ChromeCleanerStatus::kInfected, + u"Browser found harmful software on your computer"))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_CleaningFailed, @@ -1538,7 +1531,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::make_tuple( safe_browsing::ChromeCleanerController::IdleReason::kCleaningFailed, SafetyCheckHandler::ChromeCleanerStatus::kError, - base::UTF8ToUTF16("Something went wrong. Click for more details.")))); + u"Something went wrong. Click for more details."))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_CleaningSucceed, @@ -1552,18 +1545,18 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_CleanerDownloadFailed, SafetyCheckHandlerChromeCleanerIdleTest, - ::testing::Values(std::make_tuple( - safe_browsing::ChromeCleanerController::IdleReason:: - kCleanerDownloadFailed, - SafetyCheckHandler::ChromeCleanerStatus::kError, - base::UTF8ToUTF16("Something went wrong. Click for more details.")))); + ::testing::Values( + std::make_tuple(safe_browsing::ChromeCleanerController::IdleReason:: + kCleanerDownloadFailed, + SafetyCheckHandler::ChromeCleanerStatus::kError, + u"Something went wrong. Click for more details."))); class SafetyCheckHandlerChromeCleanerNonIdleTest : public SafetyCheckHandlerTest, public testing::WithParamInterface< std::tuple<safe_browsing::ChromeCleanerController::State, SafetyCheckHandler::ChromeCleanerStatus, - base::string16>> { + std::u16string>> { protected: void SetUp() override { SafetyCheckHandlerTest::SetUp(); @@ -1574,7 +1567,7 @@ class SafetyCheckHandlerChromeCleanerNonIdleTest safe_browsing::ChromeCleanerController::State state_; SafetyCheckHandler::ChromeCleanerStatus expected_cct_status_; - base::string16 expected_display_string_; + std::u16string expected_display_string_; }; TEST_P(SafetyCheckHandlerChromeCleanerNonIdleTest, @@ -1635,7 +1628,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::make_tuple( safe_browsing::ChromeCleanerController::State::kInfected, SafetyCheckHandler::ChromeCleanerStatus::kInfected, - base::UTF8ToUTF16("Browser found harmful software on your computer")))); + u"Browser found harmful software on your computer"))); INSTANTIATE_TEST_SUITE_P( CheckChromeCleaner_RebootRequired, @@ -1723,7 +1716,7 @@ TEST_F(SafetyCheckHandlerTest, CheckParentRanDisplayString) { for (auto tuple : tuples) { const base::Time time = system_time - base::TimeDelta::FromSeconds(std::get<1>(tuple)); - const base::string16 display_string = + const std::u16string display_string = safety_check_->GetStringForParentRan(time, system_time); EXPECT_EQ(base::UTF8ToUTF16( base::StrCat({"Safety check ran ", std::get<0>(tuple)})), @@ -1735,7 +1728,7 @@ TEST_F(SafetyCheckHandlerTest, CheckParentRanDisplayString) { TEST_F(SafetyCheckHandlerTest, CheckChromeCleanerRanDisplayString) { // Test string without timestamp. base::Time null_time; - base::string16 display_string = + std::u16string display_string = safety_check_->GetStringForChromeCleanerRan(null_time, null_time); ReplaceBrowserName(&display_string); EXPECT_EQ(display_string, @@ -1789,31 +1782,31 @@ TEST_F(SafetyCheckHandlerTest, CheckSafetyCheckStartedWebUiEvents) { kParent, static_cast<int>(SafetyCheckHandler::ParentStatus::kChecking)); ASSERT_TRUE(event_parent); - VerifyDisplayString(event_parent, base::UTF8ToUTF16("Running…")); + VerifyDisplayString(event_parent, u"Running…"); const base::DictionaryValue* event_updates = GetSafetyCheckStatusChangedWithDataIfExists( kUpdates, static_cast<int>(SafetyCheckHandler::UpdateStatus::kChecking)); ASSERT_TRUE(event_updates); - VerifyDisplayString(event_updates, base::UTF8ToUTF16("")); + VerifyDisplayString(event_updates, u""); const base::DictionaryValue* event_pws = GetSafetyCheckStatusChangedWithDataIfExists( kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)); ASSERT_TRUE(event_pws); - VerifyDisplayString(event_pws, base::UTF8ToUTF16("")); + VerifyDisplayString(event_pws, u""); const base::DictionaryValue* event_sb = GetSafetyCheckStatusChangedWithDataIfExists( kSafeBrowsing, static_cast<int>(SafetyCheckHandler::SafeBrowsingStatus::kChecking)); ASSERT_TRUE(event_sb); - VerifyDisplayString(event_sb, base::UTF8ToUTF16("")); + VerifyDisplayString(event_sb, u""); const base::DictionaryValue* event_extensions = GetSafetyCheckStatusChangedWithDataIfExists( kExtensions, static_cast<int>(SafetyCheckHandler::ExtensionsStatus::kChecking)); ASSERT_TRUE(event_extensions); - VerifyDisplayString(event_extensions, base::UTF8ToUTF16("")); + VerifyDisplayString(event_extensions, u""); } TEST_F(SafetyCheckHandlerTest, CheckSafetyCheckCompletedWebUiEvents) { @@ -1836,8 +1829,7 @@ TEST_F(SafetyCheckHandlerTest, CheckSafetyCheckCompletedWebUiEvents) { GetSafetyCheckStatusChangedWithDataIfExists( kParent, static_cast<int>(SafetyCheckHandler::ParentStatus::kAfter)); ASSERT_TRUE(event_parent); - VerifyDisplayString(event_parent, - base::UTF8ToUTF16("Safety check ran a moment ago")); + VerifyDisplayString(event_parent, u"Safety check ran a moment ago"); #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) // Subsequent Chrome cleaner status updates without the user running safety diff --git a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc index 6f0374d327b..fcc19c65815 100644 --- a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc @@ -288,8 +288,8 @@ void SearchEnginesHandler::HandleSearchEngineEditStarted( } void SearchEnginesHandler::OnEditedKeyword(TemplateURL* template_url, - const base::string16& title, - const base::string16& keyword, + const std::u16string& title, + const std::u16string& keyword, const std::string& url) { DCHECK(!url.empty()); if (template_url) diff --git a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h index 5452f1ee59e..a36946a8d3c 100644 --- a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h @@ -44,8 +44,8 @@ class SearchEnginesHandler : public SettingsPageUIHandler, // EditSearchEngineControllerDelegate implementation. void OnEditedKeyword(TemplateURL* template_url, - const base::string16& title, - const base::string16& keyword, + const std::u16string& title, + const std::u16string& keyword, const std::string& url) override; // SettingsPageUIHandler implementation. diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc index 6a8860ce957..287961269dd 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc @@ -278,10 +278,10 @@ void CookiesViewHandler::HandleGetNumCookiesString( int num_cookies = args->GetList()[1].GetInt(); AllowJavascript(); - const base::string16 string = + const std::u16string string = num_cookies > 0 ? l10n_util::GetPluralStringFUTF16( IDS_SETTINGS_SITE_SETTINGS_NUM_COOKIES, num_cookies) - : base::string16(); + : std::u16string(); ResolveJavascriptCallback(base::Value(callback_id), base::Value(string)); } @@ -289,7 +289,7 @@ void CookiesViewHandler::HandleGetNumCookiesString( void CookiesViewHandler::HandleGetDisplayList(const base::ListValue* args) { CHECK_EQ(2U, args->GetList().size()); std::string callback_id = args->GetList()[0].GetString(); - base::string16 filter = base::UTF8ToUTF16(args->GetList()[1].GetString()); + std::u16string filter = base::UTF8ToUTF16(args->GetList()[1].GetString()); AllowJavascript(); pending_requests_.emplace( @@ -302,7 +302,7 @@ void CookiesViewHandler::HandleGetDisplayList(const base::ListValue* args) { } void CookiesViewHandler::GetDisplayList(std::string callback_id, - const base::string16& filter) { + const std::u16string& filter) { if (filter != filter_) { filter_ = filter; cookies_tree_model_->UpdateSearchResults(filter_); @@ -387,8 +387,7 @@ void CookiesViewHandler::HandleRemoveThirdParty(const base::ListValue* args) { content::ClearSameSiteNoneData, base::BindOnce(&CookiesViewHandler::RecreateCookiesTreeModel, callback_weak_ptr_factory_.GetWeakPtr()), - profile, - /* clear_storage */ true), + profile), base::BindOnce(&CookiesViewHandler::ResolveJavascriptCallback, callback_weak_ptr_factory_.GetWeakPtr(), base::Value(callback_id), base::Value())); @@ -414,7 +413,7 @@ void CookiesViewHandler::RemoveShownItems() { void CookiesViewHandler::HandleRemoveSite(const base::ListValue* args) { CHECK_EQ(1U, args->GetList().size()); - base::string16 site = base::UTF8ToUTF16(args->GetList()[0].GetString()); + std::u16string site = base::UTF8ToUTF16(args->GetList()[0].GetString()); AllowJavascript(); pending_requests_.emplace( Request::NO_BATCH, @@ -423,7 +422,7 @@ void CookiesViewHandler::HandleRemoveSite(const base::ListValue* args) { ProcessPendingRequests(); } -void CookiesViewHandler::RemoveSite(const base::string16& site) { +void CookiesViewHandler::RemoveSite(const std::u16string& site) { CookieTreeNode* parent = cookies_tree_model_->GetRoot(); const auto i = std::find_if( parent->children().cbegin(), parent->children().cend(), @@ -445,10 +444,10 @@ void CookiesViewHandler::ReturnLocalDataList(const std::string& callback_id) { // Gather list of sites with some highlights of the categories and items. base::ListValue site_list; for (const auto& site : parent->children()) { - base::string16 description; + std::u16string description; for (const auto& category : site->children()) { if (!description.empty()) - description += base::ASCIIToUTF16(", "); + description += u", "; const auto node_type = category->GetDetailedInfo().node_type; size_t item_count = category->children().size(); switch (node_type) { diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h index c98b2c9708b..1c3d0725bbc 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h @@ -12,7 +12,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/strings/string16.h" #include "chrome/browser/browsing_data/cookies_tree_model.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" @@ -69,7 +68,7 @@ class CookiesViewHandler : public SettingsPageUIHandler, // Set |filter_| and get a portion (or all) of the list items. void HandleGetDisplayList(const base::ListValue* args); - void GetDisplayList(std::string callback_id, const base::string16& filter); + void GetDisplayList(std::string callback_id, const std::u16string& filter); // Remove all items matching the current |filter_|. void HandleRemoveShownItems(const base::ListValue* args); @@ -77,7 +76,7 @@ class CookiesViewHandler : public SettingsPageUIHandler, // Remove selected sites data. void HandleRemoveSite(const base::ListValue* args); - void RemoveSite(const base::string16& site); + void RemoveSite(const std::u16string& site); // Retrieve cookie details for a specific site. void HandleGetCookieDetails(const base::ListValue* args); @@ -115,7 +114,7 @@ class CookiesViewHandler : public SettingsPageUIHandler, std::unique_ptr<CookiesTreeModel> cookies_tree_model_for_testing_; // Only show items that contain |filter|. - base::string16 filter_; + std::u16string filter_; struct Request { // Specifies the batch behavior of the tree model when this request is run @@ -174,7 +173,7 @@ class CookiesViewHandler : public SettingsPageUIHandler, void RequestComplete(); // Sorted index list, by site. Indexes refer to |model->GetRoot()| children. - typedef std::pair<base::string16, size_t> LabelAndIndex; + typedef std::pair<std::u16string, size_t> LabelAndIndex; std::vector<LabelAndIndex> sorted_sites_; std::unique_ptr<CookiesTreeModelUtil> model_util_; diff --git a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc index 3cbe948cb6d..92ebcec5e49 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc @@ -22,10 +22,8 @@ bool DefaultBrowserIsDisabledByPolicy() { g_browser_process->local_state()->FindPreference( prefs::kDefaultBrowserSettingEnabled); DCHECK(pref); - bool may_set_default_browser; - bool success = pref->GetValue()->GetAsBoolean(&may_set_default_browser); - DCHECK(success); - return pref->IsManaged() && !may_set_default_browser; + DCHECK(pref->GetValue()->is_bool()); + return pref->IsManaged() && !pref->GetValue()->GetBool(); } } // namespace diff --git a/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index f384bc355db..5483a4d9f89 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -102,9 +102,9 @@ #include "chrome/browser/ash/account_manager/account_manager_util.h" #include "chrome/browser/ash/assistant/assistant_util.h" #include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h" +#include "chrome/browser/ash/ownership/owner_settings_service_ash.h" +#include "chrome/browser/ash/ownership/owner_settings_service_ash_factory.h" #include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h" -#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" -#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" #include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h" #include "chrome/common/webui_url_constants.h" @@ -211,10 +211,6 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_ACCESSIBLE_IMAGE_LABELS_SUBTITLE}, {"settingsSliderRoleDescription", IDS_SETTINGS_SLIDER_MIN_MAX_ARIA_ROLE_DESCRIPTION}, - {"captionsEnableLiveCaptionTitle", - IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_TITLE}, - {"captionsEnableLiveCaptionSubtitle", - IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE}, {"caretBrowsingTitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_TITLE}, {"caretBrowsingSubtitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_SUBTITLE}, #if BUILDFLAG(IS_CHROMEOS_ASH) @@ -241,9 +237,6 @@ void AddA11yStrings(content::WebUIDataSource* html_source) { base::FeatureList::IsEnabled(features::kAccessibilityFocusHighlight)); #endif - html_source->AddBoolean("enableLiveCaption", - base::FeatureList::IsEnabled(media::kLiveCaption)); - AddCaptionSubpageStrings(html_source); } @@ -287,7 +280,8 @@ void AddAboutStrings(content::WebUIDataSource* html_source, Profile* profile) { l10n_util::GetStringUTF16(version_info::IsOfficialBuild() ? IDS_VERSION_UI_OFFICIAL : IDS_VERSION_UI_UNOFFICIAL), - base::UTF8ToUTF16(chrome::GetChannelName()), + base::UTF8ToUTF16( + chrome::GetChannelName(chrome::WithExtendedStable(true))), l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation()))); html_source->AddString( "aboutProductCopyright", @@ -295,7 +289,7 @@ void AddAboutStrings(content::WebUIDataSource* html_source, Profile* profile) { l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT), base::Time::Now())); - base::string16 license = l10n_util::GetStringFUTF16( + std::u16string license = l10n_util::GetStringFUTF16( IDS_VERSION_UI_LICENSE, base::ASCIIToUTF16(chrome::kChromiumProjectURL), base::ASCIIToUTF16(chrome::kChromeUICreditsURL)); html_source->AddString("aboutProductLicense", license); @@ -361,6 +355,8 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source, #endif {"readerMode", IDS_SETTINGS_READER_MODE}, {"readerModeDescription", IDS_SETTINGS_READER_MODE_DESCRIPTION}, + {"themeManagedDialogTitle", IDS_NTP_THEME_MANAGED_DIALOG_TITLE}, + {"themeManagedDialogBody", IDS_NTP_THEME_MANAGED_DIALOG_BODY}, }; html_source->AddLocalizedStrings(kLocalizedStrings); @@ -466,9 +462,9 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) { #if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) void AddChromeCleanupStrings(content::WebUIDataSource* html_source) { - const wchar_t kUnwantedSoftwareProtectionWhitePaperUrl[] = - L"https://www.google.ca/chrome/browser/privacy/" - "whitepaper.html#unwantedsoftware"; + const char16_t kUnwantedSoftwareProtectionWhitePaperUrl[] = + u"https://www.google.ca/chrome/browser/privacy/" + u"whitepaper.html#unwantedsoftware"; static constexpr webui::LocalizedString kLocalizedStrings[] = { {"chromeCleanupPageTitle", @@ -547,12 +543,12 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) { ui::ResourceBundle::GetSharedInstance().LoadDataResourceString( IDR_CHROME_CLEANUP_PARTNER), "</span>"}); - const base::string16 powered_by_html = + const std::u16string powered_by_html = l10n_util::GetStringFUTF16(IDS_SETTINGS_RESET_CLEANUP_FOOTER_POWERED_BY, base::UTF8ToUTF16(powered_by_element)); html_source->AddString("chromeCleanupPoweredByHtml", powered_by_html); - const base::string16 cleanup_details_explanation = + const std::u16string cleanup_details_explanation = l10n_util::GetStringFUTF16(IDS_SETTINGS_RESET_CLEANUP_DETAILS_EXPLANATION, kUnwantedSoftwareProtectionWhitePaperUrl); html_source->AddString("chromeCleanupDetailsExplanation", @@ -580,7 +576,7 @@ void AddIncompatibleApplicationsStrings(content::WebUIDataSource* html_source) { // The help URL is provided via Field Trial param. If none is provided, the // "Learn How" text is left empty so that no link is displayed. - base::string16 learn_how_text; + std::u16string learn_how_text; std::string help_url = GetFieldTrialParamValueByFeature( features::kIncompatibleApplicationsWarning, "HelpURL"); if (!help_url.empty()) { @@ -692,6 +688,9 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_LABEL}, {"spellCheckEnhancedDescription", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_DESCRIPTION}, + // Managed dialog strings: + {"languageManagedDialogTitle", IDS_SETTINGS_LANGUAGES_MANAGED_DIALOG_TITLE}, + {"languageManagedDialogBody", IDS_SETTINGS_LANGUAGES_MANAGED_DIALOG_BODY}, #if !defined(OS_MAC) {"spellCheckDisabledReason", IDS_SETTING_LANGUAGES_SPELL_CHECK_DISABLED_REASON}, @@ -749,9 +748,8 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source, html_source->AddString( "chromeOSLanguagesSettingsPath", chromeos::settings::mojom::kLanguagesAndInputSectionPath); - html_source->AddBoolean("isChromeOSLanguagesSettingsUpdate", - base::FeatureList::IsEnabled( - chromeos::features::kLanguageSettingsUpdate)); + // TODO(crbug.com/1097328): Delete this. + html_source->AddBoolean("isChromeOSLanguagesSettingsUpdate", true); #endif // BUILDFLAG(IS_CHROMEOS_ASH) } @@ -973,14 +971,18 @@ void AddAutofillStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT_AND_DEVICE}, {"passwordMovePasswordsToAccount", IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT}, - {"passwordMovePasswordsToAccountDialogFooter", - IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_DIALOG_FOOTER}, + {"passwordMovePasswordsToAccountDialogBodyText", + IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_DIALOG_BODY_TEXT}, {"passwordMovePasswordsToAccountDialogTitle", IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_DIALOG_TITLE}, {"passwordMoveToAccountDialogTitle", IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_TITLE}, {"passwordMoveToAccountDialogBody", IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_BODY}, + {"passwordMoveMultiplePasswordsToAccountDialogMoveButtonText", + IDS_SETTINGS_PASSWORD_MOVE_MULTIPLE_PASSWORDS_TO_ACCOUNT_DIALOG_MOVE_BUTTON_TEXT}, + {"passwordMoveMultiplePasswordsToAccountDialogCancelButtonText", + IDS_SETTINGS_PASSWORD_MOVE_MULTIPLE_PASSWORDS_TO_ACCOUNT_DIALOG_CANCEL_BUTTON_TEXT}, {"passwordMoveToAccountDialogMoveButtonText", IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_MOVE_BUTTON_TEXT}, {"passwordMoveToAccountDialogCancelButtonText", @@ -1182,8 +1184,8 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source, html_source->AddString( "syncDisconnectManagedProfileExplanation", l10n_util::GetStringFUTF8( - IDS_SETTINGS_SYNC_DISCONNECT_MANAGED_PROFILE_EXPLANATION, - base::ASCIIToUTF16("$1"), base::ASCIIToUTF16(sync_dashboard_url))); + IDS_SETTINGS_SYNC_DISCONNECT_MANAGED_PROFILE_EXPLANATION, u"$1", + base::ASCIIToUTF16(sync_dashboard_url))); #endif } @@ -1222,6 +1224,10 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL}, {"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC}, {"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL}, + + // Managed theme dialog strings: + {"themeManagedDialogTitle", IDS_NTP_THEME_MANAGED_DIALOG_TITLE}, + {"themeManagedDialogBody", IDS_NTP_THEME_MANAGED_DIALOG_BODY}, #endif {"deleteProfileWarningExpandA11yLabel", IDS_SETTINGS_SYNC_DISCONNECT_EXPAND_ACCESSIBILITY_LABEL}, @@ -1244,6 +1250,11 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { html_source->AddBoolean("profileShortcutsEnabled", ProfileShortcutManager::IsFeatureEnabled()); +#if BUILDFLAG(ENABLE_DICE_SUPPORT) + html_source->AddBoolean("signinAvailable", + AccountConsistencyModeManager::IsDiceSignInAllowed()); +#endif + #if BUILDFLAG(IS_CHROMEOS_ASH) // Toggles the Chrome OS Account Manager submenu in the People section. html_source->AddBoolean("isAccountManagerEnabled", @@ -1542,7 +1553,7 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) { }; html_source->AddLocalizedStrings(kLocalizedStrings); - base::string16 help_text = l10n_util::GetStringFUTF16( + std::u16string help_text = l10n_util::GetStringFUTF16( IDS_SETTINGS_SEARCH_NO_RESULTS_HELP, base::ASCIIToUTF16(chrome::kSettingsSearchHelpURL)); html_source->AddString("searchNoResultsHelp", help_text); @@ -1769,6 +1780,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_PDF_DOWNLOAD_PDFS}, {"siteSettingsProtectedContent", IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT}, + {"siteSettingsProtectedContentMidSentence", + IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_MID_SENTENCE}, {"siteSettingsProtectedContentIdentifiers", IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_IDENTIFIERS}, {"siteSettingsProtectedContentEnable", @@ -1825,15 +1838,15 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsBluetoothDevicesBlock", IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_BLOCK}, {"siteSettingsFileSystemWrite", - IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE}, + IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_ACCESS_WRITE}, {"siteSettingsFileSystemWriteMidSentence", - IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_MID_SENTENCE}, + IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_ACCESS_WRITE_MID_SENTENCE}, {"siteSettingsFileSystemWriteAsk", - IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_ASK}, + IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_ACCESS_WRITE_ASK}, {"siteSettingsFileSystemWriteAskRecommended", - IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_ASK_RECOMMENDED}, + IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_ACCESS_WRITE_ASK_RECOMMENDED}, {"siteSettingsFileSystemWriteBlock", - IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_BLOCK}, + IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_ACCESS_WRITE_BLOCK}, {"siteSettingsRemoveZoomLevel", IDS_SETTINGS_SITE_SETTINGS_REMOVE_ZOOM_LEVEL}, {"siteSettingsZoomLevels", IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS}, @@ -2073,6 +2086,12 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_ALLOWED_EXCEPTIONS}, {"siteSettingsBackgroundSyncBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_BLOCKED_EXCEPTIONS}, + {"siteSettingsBluetoothDevicesDescription", + IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_DESCRIPTION}, + {"siteSettingsBluetoothDevicesAllowed", + IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_ALLOWED}, + {"siteSettingsBluetoothDevicesBlocked", + IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_BLOCKED}, {"siteSettingsCameraDescription", IDS_SETTINGS_SITE_SETTINGS_CAMERA_DESCRIPTION}, {"siteSettingsCameraAllowed", IDS_SETTINGS_SITE_SETTINGS_CAMERA_ALLOWED}, @@ -2093,6 +2112,26 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_ALLOWED_EXCEPTIONS}, {"siteSettingsClipboardBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_BLOCKED_EXCEPTIONS}, + {"siteSettingsDeviceUseDescription", + IDS_SETTINGS_SITE_SETTINGS_DEVICE_USE_DESCRIPTION}, + {"siteSettingsDeviceUseAllowed", + IDS_SETTINGS_SITE_SETTINGS_DEVICE_USE_ALLOWED}, + {"siteSettingsDeviceUseBlocked", + IDS_SETTINGS_SITE_SETTINGS_DEVICE_USE_BLOCKED}, + {"siteSettingsDeviceUseAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_DEVICE_USE_ALLOWED_EXCEPTIONS}, + {"siteSettingsDeviceUseBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_DEVICE_USE_BLOCKED_EXCEPTIONS}, + {"siteSettingsFileHandlingDescription", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_DESCRIPTION}, + {"siteSettingsFileHandlingAllowed", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_ALLOWED}, + {"siteSettingsFileHandlingBlocked", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_BLOCKED}, + {"siteSettingsFileHandlingAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_ALLOWED_EXCEPTIONS}, + {"siteSettingsFileHandlingBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_BLOCKED_EXCEPTIONS}, {"siteSettingsFileSystemWriteDescription", IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_DESCRIPTION}, {"siteSettingsFileSystemWriteAllowed", @@ -2101,18 +2140,20 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_BLOCKED}, {"siteSettingsFileSystemWriteBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_BLOCKED_EXCEPTIONS}, - {"siteSettingsLocationDescription", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_DESCRIPTION}, - {"siteSettingsLocationAllowed", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_ALLOWED}, - {"siteSettingsLocationBlocked", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED}, - {"siteSettingsLocationBlockedSubLabel", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED_SUB_LABEL}, - {"siteSettingsLocationAllowedExceptions", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_ALLOWED_EXCEPTIONS}, - {"siteSettingsLocationBlockedExceptions", - IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED_EXCEPTIONS}, + {"siteSettingsFontsDescription", + IDS_SETTINGS_SITE_SETTINGS_FONTS_DESCRIPTION}, + {"siteSettingsFontsAllowed", IDS_SETTINGS_SITE_SETTINGS_FONTS_ALLOWED}, + {"siteSettingsFontsBlocked", IDS_SETTINGS_SITE_SETTINGS_FONTS_BLOCKED}, + {"siteSettingsFontsAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_FONTS_ALLOWED_EXCEPTIONS}, + {"siteSettingsFontsBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_FONTS_BLOCKED_EXCEPTIONS}, + {"siteSettingsHidDevicesDescription", + IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_DESCRIPTION}, + {"siteSettingsHidDevicesAllowed", + IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_ALLOWED}, + {"siteSettingsHidDevicesBlocked", + IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_BLOCKED}, {"siteSettingsImagesDescription", IDS_SETTINGS_SITE_SETTINGS_IMAGES_DESCRIPTION}, {"siteSettingsImagesAllowed", IDS_SETTINGS_SITE_SETTINGS_IMAGES_ALLOWED}, @@ -2121,6 +2162,12 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_IMAGES_ALLOWED_EXCEPTIONS}, {"siteSettingsImagedBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_IMAGES_BLOCKED_EXCEPTIONS}, + {"siteSettingsInsecureContentDescription", + IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_DESCRIPTION}, + {"siteSettingsInsecureContentAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_ALLOWED_EXCEPTIONS}, + {"siteSettingsInsecureContentBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_BLOCKED_EXCEPTIONS}, {"siteSettingsJavascriptDescription", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_DESCRIPTION}, {"siteSettingsJavascriptAllowed", @@ -2131,6 +2178,18 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_ALLOWED_EXCEPTIONS}, {"siteSettingsJavascriptBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_BLOCKED_EXCEPTIONS}, + {"siteSettingsLocationDescription", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_DESCRIPTION}, + {"siteSettingsLocationAllowed", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_ALLOWED}, + {"siteSettingsLocationBlocked", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED}, + {"siteSettingsLocationBlockedSubLabel", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED_SUB_LABEL}, + {"siteSettingsLocationAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_ALLOWED_EXCEPTIONS}, + {"siteSettingsLocationBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED_EXCEPTIONS}, {"siteSettingsMicDescription", IDS_SETTINGS_SITE_SETTINGS_MIC_DESCRIPTION}, {"siteSettingsMicAllowed", IDS_SETTINGS_SITE_SETTINGS_MIC_ALLOWED}, {"siteSettingsMicBlocked", IDS_SETTINGS_SITE_SETTINGS_MIC_BLOCKED}, @@ -2148,10 +2207,18 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_MIDI_ALLOWED_EXCEPTIONS}, {"siteSettingsMidiBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_MIDI_BLOCKED_EXCEPTIONS}, - {"siteSettingsInsecureContentAllowedExceptions", - IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_ALLOWED_EXCEPTIONS}, - {"siteSettingsInsecureContentBlockedExceptions", - IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_BLOCKED_EXCEPTIONS}, + {"siteSettingsMotionSensorsDescription", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_DESCRIPTION}, + {"siteSettingsMotionSensorsAllowed", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOWED}, + {"siteSettingsMotionSensorsBlocked", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED}, + {"siteSettingsMotionSensorsBlockedSubLabel", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED_SUB_LABEL}, + {"siteSettingsMotionSensorsAllowedExceptions", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOWED_EXCEPTIONS}, + {"siteSettingsMotionSensorsBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED_EXCEPTIONS}, {"siteSettingsNotificationsDescription", IDS_SETTINGS_SITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, {"siteSettingsNotificationsAllowed", @@ -2178,6 +2245,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLERS_ALLOWED_EXCEPTIONS}, {"siteSettingsPaymentHandlersBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLERS_BLOCKED_EXCEPTIONS}, + {"siteSettingsPdfsDescription", + IDS_SETTINGS_SITE_SETTINGS_PDFS_DESCRIPTION}, + {"siteSettingsPdfsAllowed", IDS_SETTINGS_SITE_SETTINGS_PDFS_ALLOWED}, + {"siteSettingsPdfsBlocked", IDS_SETTINGS_SITE_SETTINGS_PDFS_BLOCKED}, {"siteSettingsPopupsDescription", IDS_SETTINGS_SITE_SETTINGS_POPUPS_DESCRIPTION}, {"siteSettingsPopupsAllowed", IDS_SETTINGS_SITE_SETTINGS_POPUPS_ALLOWED}, @@ -2196,18 +2267,14 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_ALLOWED_EXCEPTIONS}, {"siteSettingsProtectedContentBlockedExceptions", IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_BLOCKED_EXCEPTIONS}, - {"siteSettingsMotionSensorsDescription", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_DESCRIPTION}, - {"siteSettingsMotionSensorsAllowed", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOWED}, - {"siteSettingsMotionSensorsBlocked", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED}, - {"siteSettingsMotionSensorsBlockedSubLabel", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED_SUB_LABEL}, - {"siteSettingsMotionSensorsAllowedExceptions", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOWED_EXCEPTIONS}, - {"siteSettingsMotionSensorsBlockedExceptions", - IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED_EXCEPTIONS}, + {"siteSettingsProtocolHandlersDescription", + IDS_SETTINGS_SITE_SETTINGS_PROTOCOL_HANDLERS_DESCRIPTION}, + {"siteSettingsProtocolHandlersAllowed", + IDS_SETTINGS_SITE_SETTINGS_PROTOCOL_HANDLERS_ALLOWED}, + {"siteSettingsProtocolHandlersBlocked", + IDS_SETTINGS_SITE_SETTINGS_PROTOCOL_HANDLERS_BLOCKED}, + {"siteSettingsProtocolHandlersBlockedExceptions", + IDS_SETTINGS_SITE_SETTINGS_PROTOCOL_HANDLERS_BLOCKED_EXCEPTIONS}, {"siteSettingsSerialPortsDescription", IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_DESCRIPTION}, {"siteSettingsSerialPortsAllowed", @@ -2296,6 +2363,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_ASK}, {"siteSettingsIdleDetectionBlock", IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_BLOCK}, + {"siteSettingsFileHandling", IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING}, + {"siteSettingsFileHandlingMidSentence", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_MID_SENTENCE}, + {"siteSettingsFileHandlingAsk", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_ASK}, + {"siteSettingsFileHandlingBlock", + IDS_SETTINGS_SITE_SETTINGS_FILE_HANDLING_BLOCK}, }; html_source->AddLocalizedStrings(kLocalizedStrings); @@ -2355,6 +2429,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, "enableFontAccessContentSetting", base::FeatureList::IsEnabled(::blink::features::kFontAccess)); + html_source->AddBoolean( + "enableFileHandlingContentSetting", + base::FeatureList::IsEnabled(::blink::features::kFileHandlingAPI)); + // The exception placeholder should not be translated. See crbug.com/1095878. html_source->AddString("addSiteExceptionPlaceholder", "[*.]example.com"); } @@ -2500,10 +2578,8 @@ void AddSecurityKeysStrings(content::WebUIDataSource* html_source) { #endif html_source->AddBoolean("enableSecurityKeysSubpage", !win_native_api_available); - html_source->AddBoolean( - "enableSecurityKeysBioEnrollment", - base::FeatureList::IsEnabled(device::kWebAuthBiometricEnrollment) && - !win_native_api_available); + html_source->AddBoolean("enableSecurityKeysBioEnrollment", + !win_native_api_available); } } // namespace diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc index 0759f545164..753ca0a5e91 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc @@ -24,12 +24,14 @@ #include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/signin/profile_colors_util.h" +#include "chrome/browser/ui/webui/theme_source.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 "content/public/browser/browser_thread.h" +#include "content/public/browser/url_data_source.h" #include "content/public/browser/web_ui.h" #include "google_apis/gaia/gaia_auth_util.h" #include "ui/base/l10n/l10n_util.h" @@ -82,6 +84,8 @@ void ManageProfileHandler::RegisterMessages() { "removeProfileShortcut", base::BindRepeating(&ManageProfileHandler::HandleRemoveProfileShortcut, base::Unretained(this))); + content::URLDataSource::Add(profile_, + std::make_unique<ThemeSource>(profile_)); } void ManageProfileHandler::OnJavascriptAllowed() { @@ -219,7 +223,7 @@ void ManageProfileHandler::HandleSetProfileName(const base::ListValue* args) { CHECK(args); CHECK_EQ(1u, args->GetSize()); - base::string16 new_profile_name; + std::u16string new_profile_name; CHECK(args->GetString(0, &new_profile_name)); base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name); diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc index a0fa5517e2d..061263c6783 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc @@ -55,7 +55,7 @@ class ManageProfileHandlerTest : public testing::Test { void SetSignedInProfile() { gfx::Image gaia_image(gfx::test::CreateImage(256, 256)); - entry()->SetAuthInfo("gaia_id", base::UTF8ToUTF16("user@gmail.com"), false); + entry()->SetAuthInfo("gaia_id", u"user@gmail.com", false); entry()->SetGAIAPicture("GAIA_IMAGE_URL_WITH_SIZE", gaia_image); EXPECT_TRUE(entry()->IsUsingDefaultAvatar()); EXPECT_TRUE(entry()->IsUsingGAIAPicture()); @@ -271,7 +271,7 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsSignedInProfile) { /*gaia_selected=*/false); // Sign out. - entry()->SetAuthInfo("", base::string16(), false); + entry()->SetAuthInfo("", std::u16string(), false); entry()->SetGAIAPicture(std::string(), gfx::Image()); const content::TestWebUI::CallData& data_2 = *web_ui()->call_data().back(); diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc index ae1a6e96af2..9d31f5f1ec0 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc @@ -18,6 +18,7 @@ #include "build/branding_buildflags.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#include "chrome/browser/account_manager_facade_factory.h" #include "chrome/browser/privacy_sandbox/privacy_sandbox_settings.h" #include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h" #include "chrome/browser/profiles/profile.h" @@ -67,6 +68,7 @@ #include "chrome/grit/generated_resources.h" #include "chrome/grit/settings_resources.h" #include "chrome/grit/settings_resources_map.h" +#include "components/account_manager_core/account_manager_facade.h" #include "components/favicon_base/favicon_url_parser.h" #include "components/password_manager/core/common/password_manager_features.h" #include "components/pref_registry/pref_registry_syncable.h" @@ -95,6 +97,10 @@ #include "chrome/browser/ui/webui/settings/languages_handler.h" #endif // defined(OS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS) +#include "components/language/core/common/language_experiments.h" +#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS) + #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/components/account_manager/account_manager.h" #include "ash/components/account_manager/account_manager_factory.h" @@ -253,15 +259,6 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) profile->GetPrefs()->GetBoolean( prefs::kSigninAllowed)); - html_source->AddBoolean( - "safeBrowsingEnhancedEnabled", - base::FeatureList::IsEnabled(safe_browsing::kEnhancedProtection)); - - html_source->AddBoolean( - "editPasswordsInSettings", - base::FeatureList::IsEnabled( - password_manager::features::kEditPasswordsInSettings)); - html_source->AddBoolean("showImportPasswords", base::FeatureList::IsEnabled( password_manager::features::kPasswordImport)); @@ -291,6 +288,12 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) features::kChromeCleanupScanCompletedNotification)); #endif +#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS) + html_source->AddBoolean("enableDesktopRestructuredLanguageSettings", + base::FeatureList::IsEnabled( + language::kDesktopRestructuredLanguageSettings)); +#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS) + #if BUILDFLAG(IS_CHROMEOS_ASH) html_source->AddBoolean("splitSettingsSyncEnabled", chromeos::features::IsSplitSettingsSyncEnabled()); @@ -315,6 +318,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui) AddSettingsPageUIHandler(std::make_unique<AboutHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<ResetSettingsHandler>(profile)); + html_source->AddBoolean( + "searchHistoryLink", + base::FeatureList::IsEnabled(features::kSearchHistoryLink)); + // Add a handler to provide pluralized strings. auto plural_string_handler = std::make_unique<PluralStringHandler>(); plural_string_handler->AddLocalizedString( @@ -379,10 +386,14 @@ void SettingsUI::InitBrowserSettingsWebUIHandlers() { auto* account_manager = factory->GetAccountManager(profile->GetPath().value()); DCHECK(account_manager); + auto* account_manager_facade = + ::GetAccountManagerFacade(profile->GetPath().value()); + DCHECK(account_manager_facade); web_ui()->AddMessageHandler( std::make_unique<chromeos::settings::AccountManagerUIHandler>( - account_manager, IdentityManagerFactory::GetForProfile(profile))); + account_manager, account_manager_facade, + IdentityManagerFactory::GetForProfile(profile))); } // MultideviceHandler is required in browser settings to show a special note diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc index fea44d1b3ba..bde9f8e8a3c 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc @@ -54,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(SettingsUITest, TriggerHappinessTrackingSurveys) { HatsServiceFactory::GetInstance()->SetTestingFactoryAndUse( browser()->profile(), base::BindRepeating(&BuildMockHatsService))); EXPECT_CALL(*mock_hats_service_, LaunchDelayedSurveyForWebContents( - kHatsSurveyTriggerSettings, _, _)); + kHatsSurveyTriggerSettings, _, _, _)); NavigateToURL(browser(), GURL(chrome::kChromeUISettingsURL)); base::RunLoop().RunUntilIdle(); } diff --git a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc index 3a5ab607cf1..b2d09de33a6 100644 --- a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc +++ b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc @@ -20,6 +20,7 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/google/core/common/google_util.h" +#include "components/soda/constants.h" #include "components/strings/grit/components_strings.h" #include "components/user_manager/user_manager.h" #include "content/public/browser/web_ui_data_source.h" @@ -41,7 +42,7 @@ namespace { // Generates a Google Help URL which includes a "board type" parameter. Some // help pages need to be adjusted depending on the type of CrOS device that is // accessing the page. -base::string16 GetHelpUrlWithBoard(const std::string& original_url) { +std::u16string GetHelpUrlWithBoard(const std::string& original_url) { return base::ASCIIToUTF16(original_url + "&b=" + base::SysInfo::GetLsbReleaseBoard()); } @@ -82,15 +83,66 @@ void AddCaptionSubpageStrings(content::WebUIDataSource* html_source) { {"captionsColorCyan", IDS_SETTINGS_CAPTIONS_COLOR_CYAN}, {"captionsColorMagenta", IDS_SETTINGS_CAPTIONS_COLOR_MAGENTA}, {"captionsDefaultSetting", IDS_SETTINGS_CAPTIONS_DEFAULT_SETTING}, - {"captionsEnableLiveCaptionTitle", - IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_TITLE}, - {"captionsEnableLiveCaptionSubtitle", - IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE}, }; html_source->AddLocalizedStrings(kLocalizedStrings); + AddLiveCaptionSectionStrings(html_source); +} + +void AddLiveCaptionSectionStrings(content::WebUIDataSource* html_source) { + html_source->AddLocalizedString( + "captionsEnableLiveCaptionTitle", + IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_TITLE); + + const bool liveCaptionMultiLanguageEnabled = + base::FeatureList::IsEnabled(media::kLiveCaptionMultiLanguage) && + base::FeatureList::IsEnabled(media::kUseSodaForLiveCaption); + const int live_caption_subtitle_message = + liveCaptionMultiLanguageEnabled + ? IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE + : IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE_ENGLISH_ONLY; + html_source->AddLocalizedString("captionsEnableLiveCaptionSubtitle", + live_caption_subtitle_message); + + base::Optional<speech::SodaLanguagePackComponentConfig> englishConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kEnUs); + html_source->AddString("sodaLanguageCodeEnglish", + englishConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameEnglish", + englishConfig->display_name); + base::Optional<speech::SodaLanguagePackComponentConfig> frenchConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kFrFr); + html_source->AddString("sodaLanguageCodeFrench", frenchConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameFrench", + frenchConfig->display_name); + base::Optional<speech::SodaLanguagePackComponentConfig> germanConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kDeDe); + html_source->AddString("sodaLanguageCodeGerman", germanConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameGerman", + germanConfig->display_name); + base::Optional<speech::SodaLanguagePackComponentConfig> italianConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kItIt); + html_source->AddString("sodaLanguageCodeItalian", + italianConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameItalian", + italianConfig->display_name); + base::Optional<speech::SodaLanguagePackComponentConfig> japaneseConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kJaJp); + html_source->AddString("sodaLanguageCodeJapanese", + japaneseConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameJapanese", + japaneseConfig->display_name); + base::Optional<speech::SodaLanguagePackComponentConfig> spanishConfig = + speech::GetLanguageComponentConfig(speech::LanguageCode::kEsEs); + html_source->AddString("sodaLanguageCodeSpanish", + spanishConfig->language_name); + html_source->AddLocalizedString("sodaLanguageDisplayNameSpanish", + spanishConfig->display_name); + html_source->AddBoolean("enableLiveCaption", base::FeatureList::IsEnabled(media::kLiveCaption)); + html_source->AddBoolean("enableLiveCaptionMultiLanguage", + liveCaptionMultiLanguageEnabled); } void AddPersonalizationOptionsStrings(content::WebUIDataSource* html_source) { diff --git a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h index d0138b68721..b05355d9f25 100644 --- a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h +++ b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h @@ -16,6 +16,9 @@ namespace settings { // Adds strings used by the <settings-captions> element. void AddCaptionSubpageStrings(content::WebUIDataSource* html_source); +// Adds strings used by the <settings-live-caption> element. +void AddLiveCaptionSectionStrings(content::WebUIDataSource* html_source); + // Adds strings used by the <settings-personalization-options> element. void AddPersonalizationOptionsStrings(content::WebUIDataSource* html_source); diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc index 73dd3c48952..2050cc2c12a 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc @@ -74,6 +74,8 @@ #include "components/user_manager/user_manager.h" #endif +using extensions::mojom::APIPermissionID; + namespace settings { namespace { @@ -107,35 +109,36 @@ enum class AllSitesAction2 { }; // Return an appropriate API Permission ID for the given string name. -extensions::APIPermission::APIPermission::ID APIPermissionFromGroupName( - std::string type) { +APIPermissionID APIPermissionFromGroupName(std::string type) { // Once there are more than two groups to consider, this should be changed to // something better than if's. if (site_settings::ContentSettingsTypeFromGroupName(type) == - ContentSettingsType::GEOLOCATION) - return extensions::APIPermission::APIPermission::kGeolocation; + ContentSettingsType::GEOLOCATION) { + return APIPermissionID::kGeolocation; + } if (site_settings::ContentSettingsTypeFromGroupName(type) == - ContentSettingsType::NOTIFICATIONS) - return extensions::APIPermission::APIPermission::kNotifications; + ContentSettingsType::NOTIFICATIONS) { + return APIPermissionID::kNotifications; + } - return extensions::APIPermission::APIPermission::kInvalid; + return APIPermissionID::kInvalid; } // Asks the |profile| for hosted apps which have the |permission| set, and // adds their web extent and launch URL to the |exceptions| list. -void AddExceptionsGrantedByHostedApps( - content::BrowserContext* context, - extensions::APIPermission::APIPermission::ID permission, - base::ListValue* exceptions) { +void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, + APIPermissionID permission, + base::ListValue* exceptions) { const extensions::ExtensionSet& extensions = extensions::ExtensionRegistry::Get(context)->enabled_extensions(); for (extensions::ExtensionSet::const_iterator extension = extensions.begin(); extension != extensions.end(); ++extension) { if (!(*extension)->is_hosted_app() || - !(*extension)->permissions_data()->HasAPIPermission(permission)) + !(*extension)->permissions_data()->HasAPIPermission(permission)) { continue; + } const extensions::URLPatternSet& web_extent = (*extension)->web_extent(); // Add patterns from web extent. @@ -917,7 +920,7 @@ void SiteSettingsHandler::HandleGetFormattedBytes(const base::ListValue* args) { double num_bytes; CHECK(args->GetDouble(1, &num_bytes)); - const base::string16 string = ui::FormatBytes(int64_t(num_bytes)); + const std::u16string string = ui::FormatBytes(int64_t(num_bytes)); ResolveJavascriptCallback(*callback_id, base::Value(string)); } @@ -1237,7 +1240,6 @@ void SiteSettingsHandler::HandleResetChooserExceptionForSite( permissions::ChooserContextBase* chooser_context = chooser_type->get_context(profile_); chooser_context->RevokeObjectPermission( - url::Origin::Create(requesting_origin), url::Origin::Create(embedding_origin), args->GetList()[3]); } diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h index 70758bf88d5..64d624a1f5a 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h @@ -211,6 +211,9 @@ class SiteSettingsHandler void HandleResetCategoryPermissionForPattern(const base::ListValue* args); void HandleSetCategoryPermissionForPattern(const base::ListValue* args); + // TODO(andypaicu, crbug.com/880684): Update to only expect a list of three + // arguments, replacing the current (requesting,embedding) arguments with + // simply (origin) and update all call sites. // Handles resetting a chooser exception for the given site. void HandleResetChooserExceptionForSite(const base::ListValue* args); diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc index b54f5d0d7fa..f695c1ac4b2 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc @@ -69,7 +69,7 @@ #include "ui/webui/webui_allowlist.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/chromeos/login/users/mock_user_manager.h" +#include "chrome/browser/ash/login/users/mock_user_manager.h" #include "components/user_manager/scoped_user_manager.h" #endif @@ -157,7 +157,7 @@ class SiteSettingsHandlerTest : public testing::Test { ContentSettingsType::COOKIES)) { #if BUILDFLAG(IS_CHROMEOS_ASH) user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>( - std::make_unique<chromeos::MockUserManager>()); + std::make_unique<ash::MockUserManager>()); #endif // Fully initialize |profile_| in the constructor since some children @@ -176,7 +176,10 @@ class SiteSettingsHandlerTest : public testing::Test { // AllowJavascript() adds a callback to create leveldb_env::ChromiumEnv // which reads the FeatureList. Wait for the callback to be finished so that // we won't destruct |feature_list_| before the callback is executed. - base::RunLoop().RunUntilIdle(); + // We also want to let the storage system finish setting up, to avoid test + // flakiness caused by the quota storage system shutting down at test end, + // while still being set up. + task_environment_.RunUntilIdle(); web_ui()->ClearTrackedCalls(); } @@ -1200,8 +1203,10 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) { EXPECT_EQ( *ukm_recorder.GetEntryMetric(entry, "Source"), static_cast<int64_t>(permissions::PermissionSourceUI::SITE_SETTINGS)); + size_t num_values = 0; EXPECT_EQ(*ukm_recorder.GetEntryMetric(entry, "PermissionType"), - static_cast<int64_t>(ContentSettingsType::NOTIFICATIONS)); + ContentSettingTypeToHistogramValue( + ContentSettingsType::NOTIFICATIONS, &num_values)); EXPECT_EQ(*ukm_recorder.GetEntryMetric(entry, "Action"), static_cast<int64_t>(permissions::PermissionAction::REVOKED)); } @@ -1991,17 +1996,15 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest { // Add the user granted permissions for testing. // These two persistent device permissions should be lumped together with // the policy permissions, since they apply to the same device and URL. - chooser_context->GrantDevicePermission(kChromiumOrigin, kChromiumOrigin, - *persistent_device_info_); - chooser_context->GrantDevicePermission(kChromiumOrigin, kGoogleOrigin, + chooser_context->GrantDevicePermission(kChromiumOrigin, *persistent_device_info_); - chooser_context->GrantDevicePermission(kAndroidOrigin, kChromiumOrigin, + chooser_context->GrantDevicePermission(kGoogleOrigin, *persistent_device_info_); - chooser_context->GrantDevicePermission(kWebUIOrigin, kWebUIOrigin, + chooser_context->GrantDevicePermission(kWebUIOrigin, *persistent_device_info_); - chooser_context->GrantDevicePermission(kAndroidOrigin, kAndroidOrigin, + chooser_context->GrantDevicePermission(kAndroidOrigin, *ephemeral_device_info_); - chooser_context->GrantDevicePermission(kAndroidOrigin, kAndroidOrigin, + chooser_context->GrantDevicePermission(kAndroidOrigin, *user_granted_device_info_); // Add the policy granted permissions for testing. @@ -2029,9 +2032,8 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest { base::DoNothing::Once<std::vector<device::mojom::UsbDeviceInfoPtr>>()); base::RunLoop().RunUntilIdle(); - const auto kAndroidOrigin = url::Origin::Create(AndroidUrl()); const auto kChromiumOrigin = url::Origin::Create(ChromiumUrl()); - chooser_context->GrantDevicePermission(kChromiumOrigin, kAndroidOrigin, + chooser_context->GrantDevicePermission(kChromiumOrigin, *off_the_record_device_); // Add the observer for permission changes. @@ -2083,26 +2085,18 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest { // Iterate through the exception's sites array and return true if a site // exception matches |requesting_origin| and |embedding_origin|. - bool ChooserExceptionContainsSiteException( - const base::Value& exception, - const std::string& requesting_origin, - const std::string& embedding_origin) { + bool ChooserExceptionContainsSiteException(const base::Value& exception, + const std::string& origin) { const base::Value* sites = exception.FindListKey(site_settings::kSites); if (!sites) return false; for (const auto& site : sites->GetList()) { - const std::string* origin = site.FindStringKey(site_settings::kOrigin); - if (!origin) - continue; - if (*origin != requesting_origin) - continue; - - const std::string* exception_embedding_origin = - site.FindStringKey(site_settings::kEmbeddingOrigin); - if (!exception_embedding_origin) + const std::string* exception_origin = + site.FindStringKey(site_settings::kOrigin); + if (!exception_origin) continue; - if (*exception_embedding_origin == embedding_origin) + if (*exception_origin == origin) return true; } return false; @@ -2110,12 +2104,10 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest { // Iterate through the |exception_list| array and return true if there is a // chooser exception with |display_name| that contains a site exception for - // |requesting_origin| and |embedding_origin|. - bool ChooserExceptionContainsSiteException( - const base::Value& exceptions, - const std::string& display_name, - const std::string& requesting_origin, - const std::string& embedding_origin) { + // |origin|. + bool ChooserExceptionContainsSiteException(const base::Value& exceptions, + const std::string& display_name, + const std::string& origin) { if (!exceptions.is_list()) return false; @@ -2126,8 +2118,7 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest { continue; if (*exception_display_name == display_name) { - return ChooserExceptionContainsSiteException( - exception, requesting_origin, embedding_origin); + return ChooserExceptionContainsSiteException(exception, origin); } } return false; @@ -2157,8 +2148,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, // Don't include WebUI schemes. const std::string kWebUIOriginStr = WebUIUrl().GetOrigin().spec(); - EXPECT_FALSE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kWebUIOriginStr, kWebUIOriginStr)); + EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Gizmo", + kWebUIOriginStr)); } TEST_F(SiteSettingsHandlerChooserExceptionTest, @@ -2206,8 +2197,10 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, .as_string(); const auto kAndroidOrigin = url::Origin::Create(AndroidUrl()); const auto kChromiumOrigin = url::Origin::Create(ChromiumUrl()); + const auto kGoogleOrigin = url::Origin::Create(GoogleUrl()); const std::string kAndroidOriginStr = AndroidUrl().GetOrigin().spec(); const std::string kChromiumOriginStr = ChromiumUrl().GetOrigin().spec(); + const std::string kGoogleOriginStr = GoogleUrl().GetOrigin().spec(); { const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData( @@ -2220,15 +2213,15 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, // from the list. base::ListValue args; args.AppendString(kUsbChooserGroupName); - args.AppendString(kAndroidOriginStr); - args.AppendString(kChromiumOriginStr); + args.AppendString("https://unused.com"); + args.AppendString(kGoogleOriginStr); args.Append(base::Value::ToUniquePtrValue( UsbChooserContext::DeviceInfoToValue(*persistent_device_info_))); EXPECT_CALL(observer_, OnChooserObjectPermissionChanged( ContentSettingsType::USB_GUARD, ContentSettingsType::USB_CHOOSER_DATA)); - EXPECT_CALL(observer_, OnPermissionRevoked(kAndroidOrigin, kChromiumOrigin)); + EXPECT_CALL(observer_, OnPermissionRevoked(kGoogleOrigin)); handler()->HandleResetChooserExceptionForSite(&args); // The HandleResetChooserExceptionForSite() method should have also caused the @@ -2244,15 +2237,15 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, // Ensure that the sites list does not contain the URLs of the removed // permission. - EXPECT_FALSE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kAndroidOriginStr, kChromiumOriginStr)); + EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Gizmo", + kGoogleOriginStr)); } // User granted USB permissions that are also granted by policy should not // be able to be reset. args.Clear(); args.AppendString(kUsbChooserGroupName); - args.AppendString(kChromiumOriginStr); + args.AppendString("https://unused.com"); args.AppendString(kChromiumOriginStr); args.Append(base::Value::ToUniquePtrValue( UsbChooserContext::DeviceInfoToValue(*persistent_device_info_))); @@ -2263,19 +2256,18 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, EXPECT_EQ(exceptions.GetList().size(), 5u); // User granted exceptions that are also granted by policy are only - // displayed through the policy granted site exception, so ensure that a - // site exception entry for a requesting and embedding origin of - // kChromiumOriginStr does not exist. - EXPECT_TRUE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kChromiumOriginStr, std::string())); - EXPECT_FALSE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kChromiumOriginStr, kChromiumOriginStr)); + // displayed through the policy granted site exception, so ensure that the + // policy exception is present under the "Gizmo" device. + EXPECT_TRUE(ChooserExceptionContainsSiteException(exceptions, "Gizmo", + kChromiumOriginStr)); + EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Gizmo", + kGoogleOriginStr)); } EXPECT_CALL(observer_, OnChooserObjectPermissionChanged( ContentSettingsType::USB_GUARD, ContentSettingsType::USB_CHOOSER_DATA)); - EXPECT_CALL(observer_, OnPermissionRevoked(kChromiumOrigin, kChromiumOrigin)); + EXPECT_CALL(observer_, OnPermissionRevoked(kChromiumOrigin)); handler()->HandleResetChooserExceptionForSite(&args); // The HandleResetChooserExceptionForSite() method should have also caused the @@ -2287,12 +2279,16 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, kUsbChooserGroupName, /*expected_total_calls=*/8u); EXPECT_EQ(exceptions.GetList().size(), 5u); - // Ensure that the sites list still displays a site exception entry for a - // requesting origin of kChromiumOriginStr and a wildcard embedding origin. + // Ensure that the sites list still displays a site exception entry for an + // origin of kGoogleOriginStr. Since now the device has had its + // permission revoked, the policy-provided object will not be able to deduce + // the name "Gizmo" from the connected device. As such we check that the + // policy is still active by looking for the genericly constructed name. EXPECT_TRUE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kChromiumOriginStr, std::string())); - EXPECT_FALSE(ChooserExceptionContainsSiteException( - exceptions, "Gizmo", kChromiumOriginStr, kChromiumOriginStr)); + exceptions, "Unknown product 0x162E from Google Inc.", + kChromiumOriginStr)); + EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Gizmo", + kGoogleOriginStr)); } // User granted USB permissions that are not covered by policy should be able @@ -2300,7 +2296,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, // when the exception only has one site exception granted to it.. args.Clear(); args.AppendString(kUsbChooserGroupName); - args.AppendString(kAndroidOriginStr); + args.AppendString("https://unused.com"); args.AppendString(kAndroidOriginStr); args.Append(base::Value::ToUniquePtrValue( UsbChooserContext::DeviceInfoToValue(*user_granted_device_info_))); @@ -2309,14 +2305,14 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(kUsbChooserGroupName, 9u); EXPECT_EQ(exceptions.GetList().size(), 5u); - EXPECT_TRUE(ChooserExceptionContainsSiteException( - exceptions, "Widget", kAndroidOriginStr, kAndroidOriginStr)); + EXPECT_TRUE(ChooserExceptionContainsSiteException(exceptions, "Widget", + kAndroidOriginStr)); } EXPECT_CALL(observer_, OnChooserObjectPermissionChanged( ContentSettingsType::USB_GUARD, ContentSettingsType::USB_CHOOSER_DATA)); - EXPECT_CALL(observer_, OnPermissionRevoked(kAndroidOrigin, kAndroidOrigin)); + EXPECT_CALL(observer_, OnPermissionRevoked(kAndroidOrigin)); handler()->HandleResetChooserExceptionForSite(&args); // The HandleResetChooserExceptionForSite() method should have also caused the @@ -2327,8 +2323,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest, const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData( kUsbChooserGroupName, /*expected_total_calls=*/12u); EXPECT_EQ(exceptions.GetList().size(), 4u); - EXPECT_FALSE(ChooserExceptionContainsSiteException( - exceptions, "Widget", kAndroidOriginStr, kAndroidOriginStr)); + EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Widget", + kAndroidOriginStr)); } } diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc index af39c456668..f92f91351d6 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc @@ -11,7 +11,6 @@ #include "base/containers/contains.h" #include "base/feature_list.h" -#include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/bluetooth/bluetooth_chooser_context.h" @@ -113,6 +112,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { kBluetoothChooserDataGroupType}, {ContentSettingsType::WINDOW_PLACEMENT, "window-placement"}, {ContentSettingsType::FONT_ACCESS, "font-access"}, + {ContentSettingsType::FILE_HANDLING, "file-handling"}, // Add new content settings here if a corresponding Javascript string // representation for it is not required. Note some exceptions do have UI in @@ -151,9 +151,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { {ContentSettingsType::DISPLAY_CAPTURE, nullptr}, }; -// TODO(crbug.com/1149878): After removing -// ContentSettingsType::DEPRECATED_PLUGINS, remove +1. -static_assert(base::size(kContentSettingsTypeGroupNames) + 1 == +static_assert(base::size(kContentSettingsTypeGroupNames) == // ContentSettingsType starts at -1, so add 1 here. static_cast<int32_t>(ContentSettingsType::NUM_TYPES) + 1, "kContentSettingsTypeGroupNames should have " @@ -794,7 +792,7 @@ const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name) { // in a chooser permission exceptions table. The chooser permission will contain // a list of site exceptions that correspond to the exception. base::Value CreateChooserExceptionObject( - const base::string16& display_name, + const std::u16string& display_name, const base::Value& object, const std::string& chooser_type, const ChooserExceptionDetails& chooser_exception_details) { @@ -880,32 +878,31 @@ base::Value GetChooserExceptionListFromProfile( // Maps from a chooser exception name/object pair to a // ChooserExceptionDetails. This will group and sort the exceptions by the UI // string and object for display. - std::map<std::pair<base::string16, base::Value>, ChooserExceptionDetails> + std::map<std::pair<std::u16string, base::Value>, ChooserExceptionDetails> all_chooser_objects; for (const auto& object : objects) { // Don't include WebUI settings. - if (content::HasWebUIScheme(object->requesting_origin)) + if (content::HasWebUIScheme(object->origin)) continue; - base::string16 name = chooser_context->GetObjectDisplayName(object->value); + std::u16string name = chooser_context->GetObjectDisplayName(object->value); auto& chooser_exception_details = all_chooser_objects[std::make_pair(name, object->value.Clone())]; std::string source = GetSourceStringForChooserException( profile, content_type, object->source); - const auto requesting_origin_source_pair = - std::make_pair(object->requesting_origin, source); - auto& embedding_origin_incognito_pair_set = - chooser_exception_details[requesting_origin_source_pair]; + const auto origin_source_pair = std::make_pair(object->origin, source); + auto& origin_incognito_pair_set = + chooser_exception_details[origin_source_pair]; - const auto embedding_origin_incognito_pair = - std::make_pair(object->embedding_origin, object->incognito); - embedding_origin_incognito_pair_set.insert(embedding_origin_incognito_pair); + const auto origin_incognito_pair = + std::make_pair(object->origin, object->incognito); + origin_incognito_pair_set.insert(origin_incognito_pair); } for (const auto& all_chooser_objects_entry : all_chooser_objects) { - const base::string16& name = all_chooser_objects_entry.first.first; + const std::u16string& name = all_chooser_objects_entry.first.first; const base::Value& object = all_chooser_objects_entry.first.second; const ChooserExceptionDetails& chooser_exception_details = all_chooser_objects_entry.second; diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h index 34704af033a..c2774159fcd 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h @@ -12,7 +12,6 @@ #include <utility> #include <vector> -#include "base/strings/string16.h" #include "base/strings/string_piece.h" #include "base/values.h" #include "components/content_settings/core/common/content_settings.h" @@ -205,7 +204,7 @@ const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name); // The structure of the SiteException objects is the same as the objects // returned by GetExceptionForPage(). base::Value CreateChooserExceptionObject( - const base::string16& display_name, + const std::u16string& display_name, const base::Value& object, const std::string& chooser_type, const ChooserExceptionDetails& chooser_exception_details); diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc index 93d30f0b05d..b4228e1061c 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc @@ -482,11 +482,14 @@ GURL ChromiumUrl() { GURL AndroidUrl() { return GURL("https://android.com"); } +GURL TestUrl() { + return GURL("https://test.com"); +} void ExpectValidChooserExceptionObject( const base::Value& actual_exception_object, const std::string& chooser_type, - const base::string16& display_name, + const std::u16string& display_name, const base::Value& chooser_object) { const base::Value* chooser_type_value = actual_exception_object.FindKeyOfType( kChooserType, base::Value::Type::STRING); @@ -510,7 +513,6 @@ void ExpectValidChooserExceptionObject( void ExpectValidSiteExceptionObject(const base::Value& actual_site_object, const GURL& origin, - const GURL& embedding_origin, const std::string source, bool incognito) { ASSERT_TRUE(actual_site_object.is_dict()); @@ -525,12 +527,6 @@ void ExpectValidSiteExceptionObject(const base::Value& actual_site_object, ASSERT_TRUE(origin_value); EXPECT_EQ(origin_value->GetString(), origin.GetOrigin().spec()); - const base::Value* embedding_origin_value = actual_site_object.FindKeyOfType( - kEmbeddingOrigin, base::Value::Type::STRING); - ASSERT_TRUE(embedding_origin_value); - EXPECT_EQ(embedding_origin_value->GetString(), - embedding_origin.GetOrigin().spec()); - const base::Value* setting_value = actual_site_object.FindKeyOfType(kSetting, base::Value::Type::STRING); ASSERT_TRUE(setting_value); @@ -548,14 +544,6 @@ void ExpectValidSiteExceptionObject(const base::Value& actual_site_object, EXPECT_EQ(incognito_value->GetBool(), incognito); } -void ExpectValidSiteExceptionObject(const base::Value& actual_site_object, - const GURL& origin, - const std::string source, - bool incognito) { - ExpectValidSiteExceptionObject(actual_site_object, origin, GURL::EmptyGURL(), - source, incognito); -} - } // namespace TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) { @@ -566,7 +554,7 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) { SiteSettingSourceToString(SiteSettingSource::kPolicy); const std::string& kPreferenceSource = SiteSettingSourceToString(SiteSettingSource::kPreference); - const base::string16& kObjectName = base::ASCIIToUTF16("Gadget"); + const std::u16string& kObjectName = u"Gadget"; ChooserExceptionDetails exception_details; // Create a chooser object for testing. @@ -591,7 +579,6 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) { const auto& sites_list = exception.FindKey(kSites)->GetList(); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0], /*origin=*/GoogleUrl(), - /*embedding_origin=*/ChromiumUrl(), /*source=*/kPreferenceSource, /*incognito=*/false); } @@ -617,12 +604,10 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) { const auto& sites_list = exception.FindKey(kSites)->GetList(); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0], /*origin=*/AndroidUrl(), - /*embedding_origin=*/AndroidUrl(), /*source=*/kPreferenceSource, /*incognito=*/true); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[1], /*origin=*/GoogleUrl(), - /*embedding_origin=*/ChromiumUrl(), /*source=*/kPreferenceSource, /*incognito=*/false); } @@ -649,17 +634,14 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) { const auto& sites_list = exception.FindKey(kSites)->GetList(); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0], /*origin=*/GoogleUrl(), - /*embedding_origin=*/GURL::EmptyGURL(), /*source=*/kPolicySource, /*incognito=*/false); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[1], /*origin=*/AndroidUrl(), - /*embedding_origin=*/AndroidUrl(), /*source=*/kPreferenceSource, /*incognito=*/true); ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[2], /*origin=*/GoogleUrl(), - /*embedding_origin=*/ChromiumUrl(), /*source=*/kPreferenceSource, /*incognito=*/false); } @@ -712,18 +694,16 @@ class SiteSettingsHelperChooserExceptionTest : public testing::Test { const auto kAndroidOrigin = url::Origin::Create(AndroidUrl()); const auto kChromiumOrigin = url::Origin::Create(ChromiumUrl()); - const auto kGoogleOrigin = url::Origin::Create(GoogleUrl()); + const auto kTestOrigin = url::Origin::Create(TestUrl()); - // Add the user granted permissions for testing. - // These two persistent device permissions should be lumped together with - // the policy permissions, since they apply to the same device and URL. - chooser_context->GrantDevicePermission(kChromiumOrigin, kChromiumOrigin, - *persistent_device_info); - chooser_context->GrantDevicePermission(kChromiumOrigin, kGoogleOrigin, + // Add the user granted permissions for testing. "Gizmo" is allowed on two + // origins, one overlapping with the policy and one distinct. "Gadget" is + // allowed on one origin which is overlapping with the policy. + chooser_context->GrantDevicePermission(kTestOrigin, *persistent_device_info); - chooser_context->GrantDevicePermission(kAndroidOrigin, kChromiumOrigin, + chooser_context->GrantDevicePermission(kChromiumOrigin, *persistent_device_info); - chooser_context->GrantDevicePermission(kAndroidOrigin, kAndroidOrigin, + chooser_context->GrantDevicePermission(kAndroidOrigin, *ephemeral_device_info); // Add the policy granted permissions for testing. @@ -775,8 +755,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, // This exception should describe the permissions for any device with the // vendor ID corresponding to "Google Inc.". There are no user granted // permissions that intersect with this permission, and this policy only - // grants one permission to the following site pair: - // * ("https://google.com", "https://android.com") + // grants one permission to the "https://android.com" origin. { const auto& exception = exceptions_list[0]; ExpectDisplayNameEq(exception, @@ -785,16 +764,15 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, const auto& sites_list = exception.FindKey(kSites)->GetList(); ASSERT_EQ(sites_list.size(), 1u); ExpectValidSiteExceptionObject(sites_list[0], - /*origin=*/GoogleUrl(), - /*embedding_origin=*/AndroidUrl(), + /*origin=*/AndroidUrl(), /*source=*/kPolicySource, /*incognito=*/false); } // This exception should describe the permissions for any device. // There are no user granted permissions that intersect with this permission, - // and this policy only grants one permission to the following site pair: - // * ("https://google.com", "https://google.com") + // and this policy only grants one permission to the following site: + // "https://google.com". { const auto& exception = exceptions_list[1]; ExpectDisplayNameEq(exception, @@ -804,7 +782,6 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, ASSERT_EQ(sites_list.size(), 1u); ExpectValidSiteExceptionObject(sites_list[0], /*origin=*/GoogleUrl(), - /*embedding_origin=*/GoogleUrl(), /*source=*/kPolicySource, /*incognito=*/false); } @@ -812,8 +789,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, // This exception should describe the permissions for any device with the // vendor ID 6354. There is a user granted permission for a device with that // vendor ID, so the site list for this exception will only have the policy - // granted permission, which is the following: - // * ("https://android.com", "") + // granted permission, which is the following: "https://android.com" { const auto& exception = exceptions_list[2]; ExpectDisplayNameEq(exception, @@ -829,17 +805,13 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, // This exception should describe the permissions for the "Gizmo" device. // The user granted permissions are the following: - // * ("https://chromium.org", "https://chromium.org") - // * ("https://chromium.org", "https://google.com") - // * ("https://android.com", "https://chromium.org") + // * "https://chromium.org" + // * "https://test.org" // The policy granted permission is the following: - // * ("https://chromium.org", "") - // The embedding origin is a wildcard, so the policy granted permission covers - // any user granted permissions that contain a requesting origin of - // "https://chromium.org", so the site list for this exception will only have - // the following permissions: - // * ("https://chromium.org", "") - // * ("https://android.com", "https://chromium.org") + // * "https://chromium.org" + // The chromium granted permission should be coalesced into the policy + // permissions. The test one does not overlap with any policy permission so + // it will be a separate preference-sourced exception. { const auto& exception = exceptions_list[3]; ExpectDisplayNameEq(exception, /*display_name=*/"Gizmo"); @@ -851,8 +823,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest, /*source=*/kPolicySource, /*incognito=*/false); ExpectValidSiteExceptionObject(sites_list[1], - /*origin=*/AndroidUrl(), - /*embedding_origin=*/ChromiumUrl(), + /*origin=*/TestUrl(), /*source=*/kPreferenceSource, /*incognito=*/false); } |