summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/ui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-29 16:16:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:04:06 +0000
commita95a7417ad456115a1ef2da4bb8320531c0821f1 (patch)
treeedcd59279e486d2fd4a8f88a7ed025bcf925c6e6 /chromium/chrome/browser/ui
parent33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (diff)
downloadqtwebengine-chromium-a95a7417ad456115a1ef2da4bb8320531c0821f1.tar.gz
BASELINE: Update Chromium to 106.0.5249.126
Change-Id: Ib0bb21c437a7d1686e21c33f2d329f2ac425b7ab Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438936 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui')
-rw-r--r--chromium/chrome/browser/ui/BUILD.gn452
-rw-r--r--chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn22
-rw-r--r--chromium/chrome/browser/ui/android/autofill/internal/BUILD.gn5
-rw-r--r--chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn6
-rw-r--r--chromium/chrome/browser/ui/android/fast_checkout/BUILD.gn50
-rw-r--r--chromium/chrome/browser/ui/android/fast_checkout/internal/BUILD.gn51
-rw-r--r--chromium/chrome/browser/ui/android/fast_checkout/internal/java/strings/android_fast_checkout_strings.grd193
-rw-r--r--chromium/chrome/browser/ui/android/layouts/BUILD.gn7
-rw-r--r--chromium/chrome/browser/ui/android/logo/BUILD.gn29
-rw-r--r--chromium/chrome/browser/ui/android/multiwindow/BUILD.gn9
-rw-r--r--chromium/chrome/browser/ui/android/native_page/BUILD.gn7
-rw-r--r--chromium/chrome/browser/ui/android/night_mode/BUILD.gn18
-rw-r--r--chromium/chrome/browser/ui/android/omnibox/BUILD.gn77
-rw-r--r--chromium/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/android/searchactivityutils/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/android/signin/BUILD.gn71
-rw-r--r--chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd412
-rw-r--r--chromium/chrome/browser/ui/android/toolbar/BUILD.gn70
-rw-r--r--chromium/chrome/browser/ui/android/webid/BUILD.gn6
-rw-r--r--chromium/chrome/browser/ui/android/webid/internal/BUILD.gn24
-rw-r--r--chromium/chrome/browser/ui/ash/holding_space/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/ash/system_web_apps/BUILD.gn30
-rw-r--r--chromium/chrome/browser/ui/color/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/messages/android/BUILD.gn11
-rw-r--r--chromium/chrome/browser/ui/side_search/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/web_applications/BUILD.gn131
-rw-r--r--chromium/chrome/browser/ui/webui/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/DEPS14
-rw-r--r--chromium/chrome/browser/ui/webui/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast.mojom3
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog_browsertest.cc60
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_browsertest.cc124
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_unittest.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/apc_internals/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.cc153
-rw-r--r--chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.h40
-rw-r--r--chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h54
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/BUILD.gn (renamed from chromium/chrome/browser/ui/webui/side_panel/read_anything/BUILD.gn)9
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/DIR_METADATA1
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home.mojom35
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.cc121
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.h63
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home_page_handler_test.cc128
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home_ui.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/app_home_ui.h48
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.h26
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc172
-rw-r--r--chromium/chrome/browser/ui/webui/app_service_internals/app_service_internals_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/app_settings/web_app_settings_navigation_throttle.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui_browsertest.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/browser_command/DEPS4
-rw-r--r--chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.cc78
-rw-r--r--chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/browser_command/browser_command_handler_unittest.cc153
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc114
-rw-r--r--chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc274
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h79
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc314
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc466
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_viewer_webui.h51
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.cc114
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_configs_chromeos.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_configs_chromeos.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc155
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/OWNERS6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc120
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/audio/audio_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc58
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/network_settings_dialog.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/BUILD.gn15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom29
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.cc72
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_unittest.cc58
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc119
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/guest_os_installer/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/human_presence_internals_ui.cc175
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/image_source.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/image_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_captive_portal_dialog.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_network_dialog.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc45
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h20
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/OWNERS11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc35
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc86
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc74
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h29
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.cc143
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h67
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc73
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h39
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h31
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc121
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h29
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/quick_start_screen_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc60
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc77
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/ssh_configured_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/BUILD.gn16
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/DIR_METADATA1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom43
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h35
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog_browsertest.cc444
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.cc169
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h67
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h47
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc83
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_ui.cc355
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/DEPS3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.cc247
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h75
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.proto33
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_dialog.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl_browsertest.cc155
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/power_ui.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.cc46
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.cc73
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/user_image_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/video_source.cc114
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/video_source.h56
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_handler.cc60
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_handler.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_handler_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h10
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/connectors_internals/connectors_internals.mojom2
-rw-r--r--chromium/chrome/browser/ui/webui/connectors_internals/zero_trust_utils.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_unittest.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc65
-rw-r--r--chromium/chrome/browser/ui/webui/cookies_tree_model_util.h9
-rw-r--r--chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h3
-rw-r--r--chromium/chrome/browser/ui/webui/crashes_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/device_log_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/devtools_ui_data_source.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/devtools_ui_data_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards_ui.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc73
-rw-r--r--chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h54
-rw-r--r--chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads.mojom6
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/ash/kiosk_apps_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_icon_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc85
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/favicon_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/favicon_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/favicon_source_unittest.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/feed/feed_ui.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/feed/feed_ui.h4
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom7
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/feedback/feedback_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/feedback/feedback_handler.h14
-rw-r--r--chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/fileicon_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/fileicon_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/gcm_internals_ui.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/help/test_version_updater.h1
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater.h10
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc98
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h7
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_mac.h9
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_mac.mm79
-rw-r--r--chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/history/browsing_history_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/history/foreign_session_handler.cc156
-rw-r--r--chromium/chrome/browser/ui/webui/history/foreign_session_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_login_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_login_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/history/navigation_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/history/navigation_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc156
-rw-r--r--chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h14
-rw-r--r--chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler_browsertest.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/identity_internals_ui.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/image_editor/image_editor_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/internals/internals_ui.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/internals/internals_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/internals/lens/lens_internals_ui_message_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h5
-rw-r--r--chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/intro/DIR_METADATA1
-rw-r--r--chromium/chrome/browser/ui/webui/intro/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/intro/intro_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/intro/intro_handler.h27
-rw-r--r--chromium/chrome/browser/ui/webui/intro/intro_ui.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/intro/intro_ui.h24
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler.cc574
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler.h67
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc218
-rw-r--r--chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc110
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/memory_internals_ui.cc65
-rw-r--r--chromium/chrome/browser/ui/webui/nacl_ui.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/quick_pair/quick_pair_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/net_export_ui.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc150
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom10
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc260
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc67
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h20
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc191
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h28
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler_unittest.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc55
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h3
-rw-r--r--chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc72
-rw-r--r--chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.cc45
-rw-r--r--chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.h19
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc337
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h64
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h41
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h42
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h39
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h50
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h26
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.cc75
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.h32
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.cc67
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h34
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h49
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h40
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h41
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h41
-rw-r--r--chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc77
-rw-r--r--chromium/chrome/browser/ui/webui/predictors/predictors_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/prefs_internals_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/prefs_internals_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h8
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc262
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h14
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.h20
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_utils_unittest.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/printer_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/privacy_sandbox/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/realbox_handler_browsertest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/sanitized_image_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/sanitized_image_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/sanitized_image_source_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc152
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler_unittest.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/BUILD.gn (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn)4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/OWNERS (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS)0
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker_unittest.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search.mojom (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search.mojom)2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_concept.h (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_concept.h)10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc)8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.h (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h)14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_handler_unittest.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc)8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom)10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h)10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry_unittest.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom)0
-rw-r--r--chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.h65
-rw-r--r--chromium/chrome/browser/ui/webui/settings/captions_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/captions_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/BUILD.gn3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/DEPS1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc310
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc105
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc695
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h182
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc860
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler_unittest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc92
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc123
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_display_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc60
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.h20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.cc251
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h71
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler_unittest.cc618
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc112
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc115
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc193
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.cc99
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h47
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler_unittest.cc214
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc86
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.h18
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/font_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/font_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/import_data_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/on_startup_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc126
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc163
-rw-r--r--chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler_unittest.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc112
-rw-r--r--chromium/chrome/browser/ui/webui/settings/search_engines_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc90
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler_browsertest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_interactive_uitest.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc760
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc78
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc177
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h41
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc249
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc697
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc178
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper.h46
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc164
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom20
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h22
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/BUILD.gn13
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom15
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_browsertest.cc106
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h41
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h42
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/DEPS5
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom53
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.h34
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h30
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/reading_list/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/reading_list/DEPS3
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/signin/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler_unittest.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos_browsertest.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc74
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_ui.h5
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc139
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h34
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.h3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos_browsertest.cc270
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_url_utils.cc100
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_url_utils.h40
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_url_utils_unittest.cc108
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h8
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc141
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.cc139
-rw-r--r--chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.h20
-rw-r--r--chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_policy_fetch_tracker.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_unittest.cc112
-rw-r--r--chromium/chrome/browser/ui/webui/signin_internals_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin_internals_ui.h4
-rw-r--r--chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc278
-rw-r--r--chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.cc264
-rw-r--r--chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h74
-rw-r--r--chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils_unittest.cc85
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js51
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc58
-rw-r--r--chromium/chrome/browser/ui/webui/system_info_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip.mojom3
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc107
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler_unittest.cc87
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.h10
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h1
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/test_data_source.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/test_data_source.h2
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/theme_source.cc131
-rw-r--r--chromium/chrome/browser/ui/webui/theme_source.h9
-rw-r--r--chromium/chrome/browser/ui/webui/theme_source_unittest.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h5
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_ui.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.h6
-rw-r--r--chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/webui_allowlist_provider_unittest.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/webui_util.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc131
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/helpers.h2
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/ntp_background_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/whats_new/whats_new_ui.cc9
804 files changed, 17729 insertions, 14394 deletions
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn
index 583a685cd12..17c1f3e28c7 100644
--- a/chromium/chrome/browser/ui/BUILD.gn
+++ b/chromium/chrome/browser/ui/BUILD.gn
@@ -3,7 +3,7 @@
# found in the LICENSE file.
import("//build/config/buildflags_paint_preview.gni")
-import("//build/config/chromecast_build.gni")
+import("//build/config/chromebox_for_meetings/buildflags.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni")
@@ -12,7 +12,6 @@ import("//build/config/ui.gni")
import("//chrome/browser/buildflags.gni")
import("//chrome/common/features.gni")
import("//chromeos/ash/components/assistant/assistant.gni")
-import("//chromeos/components/chromebox_for_meetings/buildflags/buildflags.gni")
import("//chromeos/dbus/config/use_real_dbus_clients.gni")
import("//components/feed/features.gni")
import("//components/nacl/features.gni")
@@ -109,8 +108,6 @@ static_library("ui") {
"find_bar/find_bar_state.h",
"find_bar/find_bar_state_factory.cc",
"find_bar/find_bar_state_factory.h",
- "interventions/framebust_block_message_delegate.cc",
- "interventions/framebust_block_message_delegate.h",
"interventions/intervention_delegate.h",
"interventions/intervention_infobar_delegate.cc",
"interventions/intervention_infobar_delegate.h",
@@ -144,9 +141,6 @@ static_library("ui") {
"passwords/password_manager_navigation_throttle.h",
"passwords/settings/password_manager_porter.cc",
"passwords/settings/password_manager_porter.h",
- "passwords/settings/password_manager_presenter.cc",
- "passwords/settings/password_manager_presenter.h",
- "passwords/settings/password_ui_view.h",
"passwords/ui_utils.cc",
"passwords/ui_utils.h",
"passwords/well_known_change_password_navigation_throttle.cc",
@@ -222,6 +216,8 @@ static_library("ui") {
"webui/about_ui.h",
"webui/apc_internals/apc_internals_handler.cc",
"webui/apc_internals/apc_internals_handler.h",
+ "webui/apc_internals/apc_internals_logins_request.cc",
+ "webui/apc_internals/apc_internals_logins_request.h",
"webui/apc_internals/apc_internals_ui.cc",
"webui/apc_internals/apc_internals_ui.h",
"webui/autofill_and_password_manager_internals/autofill_internals_ui.cc",
@@ -248,8 +244,6 @@ static_library("ui") {
"webui/crashes_ui.h",
"webui/device_log_ui.cc",
"webui/device_log_ui.h",
- "webui/domain_reliability_internals_ui.cc",
- "webui/domain_reliability_internals_ui.h",
"webui/download_internals/download_internals_ui.cc",
"webui/download_internals/download_internals_ui.h",
"webui/download_internals/download_internals_ui_message_handler.cc",
@@ -300,12 +294,6 @@ static_library("ui") {
"webui/policy/policy_ui.h",
"webui/policy/policy_ui_handler.cc",
"webui/policy/policy_ui_handler.h",
- "webui/policy/status_provider/cloud_policy_core_status_provider.cc",
- "webui/policy/status_provider/cloud_policy_core_status_provider.h",
- "webui/policy/status_provider/status_provider_util.cc",
- "webui/policy/status_provider/status_provider_util.h",
- "webui/policy/status_provider/user_cloud_policy_status_provider.cc",
- "webui/policy/status_provider/user_cloud_policy_status_provider.h",
"webui/predictors/predictors_handler.cc",
"webui/predictors/predictors_handler.h",
"webui/predictors/predictors_ui.cc",
@@ -394,6 +382,7 @@ static_library("ui") {
"//base/allocator:buildflags",
"//build:branding_buildflags",
"//build:chromeos_buildflags",
+ "//build/config/chromebox_for_meetings:buildflags",
"//cc/paint",
"//chrome:extra_resources",
"//chrome:resources",
@@ -409,8 +398,8 @@ static_library("ui") {
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resource_prefetch_predictor_proto",
"//chrome/browser/breadcrumbs",
- "//chrome/browser/commerce/shopping_list",
"//chrome/browser/devtools",
+ "//chrome/browser/favicon",
"//chrome/browser/image_decoder",
"//chrome/browser/media:mojo_bindings",
"//chrome/browser/media/router:media_router_feature",
@@ -430,20 +419,16 @@ static_library("ui") {
"//chrome/browser/share",
"//chrome/browser/ui/webui:configs",
"//chrome/browser/ui/webui/bluetooth_internals",
- "//chrome/browser/ui/webui/downloads:mojo_bindings",
"//chrome/browser/ui/webui/omnibox:mojo_bindings",
- "//chrome/browser/ui/webui/realbox:mojo_bindings",
"//chrome/browser/ui/webui/segmentation_internals:mojo_bindings",
- "//chrome/browser/ui/webui/side_panel/bookmarks:mojo_bindings",
- "//chrome/browser/ui/webui/side_panel/read_anything:mojo_bindings",
- "//chrome/browser/ui/webui/side_panel/reading_list:mojo_bindings",
- "//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings",
"//chrome/browser/video_tutorials",
"//chrome/common",
"//chrome/common/net",
"//chrome/common/search:mojo_bindings",
"//chrome/installer/util:with_no_strings",
+ "//chrome/services/media_gallery_util/public/cpp",
+ "//chrome/services/media_gallery_util/public/mojom",
"//chrome/services/qrcode_generator/public/cpp",
"//chrome/services/qrcode_generator/public/mojom",
"//components/about_ui",
@@ -522,7 +507,6 @@ static_library("ui") {
"//components/live_caption:utils",
"//components/local_state",
"//components/lookalikes/core",
- "//components/metrics:content",
"//components/metrics_services_manager",
"//components/navigation_metrics",
"//components/net_log",
@@ -540,7 +524,9 @@ static_library("ui") {
"//components/password_manager/content/browser",
"//components/password_manager/core/browser",
"//components/password_manager/core/browser:affiliation",
- "//components/password_manager/core/browser:csv",
+ "//components/password_manager/core/browser:import_results",
+ "//components/password_manager/core/browser/import:csv",
+ "//components/password_manager/core/browser/import:importer",
"//components/password_manager/core/common",
"//components/payments/content:utils",
"//components/payments/content/icon",
@@ -565,6 +551,7 @@ static_library("ui") {
"//components/safe_browsing/core/browser/db:database_manager",
"//components/safe_browsing/core/browser/db:util",
"//components/safe_browsing/core/browser/password_protection:password_protection_metrics_util",
+ "//components/safe_browsing/core/browser/tailored_security_service",
"//components/safe_browsing/core/common",
"//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/safe_browsing/core/common/proto:csd_proto",
@@ -676,6 +663,7 @@ static_library("ui") {
allow_circular_includes_from = [
# TODO(crbug.com/1158905): Remove this circular dependency.
"//chrome/browser/devtools",
+ "//chrome/browser/favicon",
"//chrome/browser/safe_browsing",
"//chrome/browser/ui/webui/bluetooth_internals",
"//chrome/browser/profiling_host",
@@ -774,6 +762,10 @@ static_library("ui") {
"android/device_dialog/usb_chooser_dialog_android.cc",
"android/device_dialog/usb_chooser_dialog_android.h",
"android/external_protocol_dialog_android.cc",
+ "android/fast_checkout/fast_checkout_view_impl.cc",
+ "android/fast_checkout/fast_checkout_view_impl.h",
+ "android/fast_checkout/ui_view_android_utils.cc",
+ "android/fast_checkout/ui_view_android_utils.h",
"android/infobars/autofill_credit_card_filling_infobar.cc",
"android/infobars/autofill_credit_card_filling_infobar.h",
"android/infobars/autofill_offer_notification_infobar.cc",
@@ -784,8 +776,6 @@ static_library("ui") {
"android/infobars/autofill_virtual_card_enrollment_infobar.h",
"android/infobars/duplicate_download_infobar.cc",
"android/infobars/duplicate_download_infobar.h",
- "android/infobars/framebust_block_infobar.cc",
- "android/infobars/framebust_block_infobar.h",
"android/infobars/generated_password_saved_infobar.cc",
"android/infobars/generated_password_saved_infobar.h",
"android/infobars/grouped_permission_infobar.cc",
@@ -869,6 +859,10 @@ static_library("ui") {
"autofill/payments/virtual_card_enroll_bubble_controller_impl.cc",
"autofill/payments/virtual_card_enroll_bubble_controller_impl.h",
"browser_otr_state_android.cc",
+ "fast_checkout/fast_checkout_controller.h",
+ "fast_checkout/fast_checkout_controller_impl.cc",
+ "fast_checkout/fast_checkout_controller_impl.h",
+ "fast_checkout/fast_checkout_view.h",
"javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_android.cc",
"javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_android.h",
"page_info/about_this_site_message_delegate_android.cc",
@@ -965,6 +959,7 @@ static_library("ui") {
"apps/chrome_app_window_client.h",
"apps/directory_access_confirmation_dialog.cc",
"apps/directory_access_confirmation_dialog.h",
+ "autofill_assistant/password_change/apc_scrim_manager.h",
"autofill_assistant/password_change/apc_utils.cc",
"autofill_assistant/password_change/apc_utils.h",
"autofill_assistant/password_change/assistant_display_delegate.h",
@@ -1001,6 +996,8 @@ static_library("ui") {
"bookmarks/bookmark_utils_desktop.h",
"bookmarks/recently_used_folders_combo_model.cc",
"bookmarks/recently_used_folders_combo_model.h",
+ "bookmarks/test_bookmark_navigation_wrapper.cc",
+ "bookmarks/test_bookmark_navigation_wrapper.h",
"breadcrumb_manager_browser_agent.cc",
"breadcrumb_manager_browser_agent.h",
"browser.cc",
@@ -1207,9 +1204,9 @@ static_library("ui") {
"omnibox/clipboard_utils.h",
"omnibox/omnibox_tab_helper.cc",
"omnibox/omnibox_tab_helper.h",
- "omnibox/omnibox_theme.cc",
"omnibox/omnibox_theme.h",
"page_action/page_action_icon_type.h",
+ "page_info/about_this_site_side_panel.h",
"page_info/chrome_accuracy_tip_ui.h",
"page_info/page_info_dialog.cc",
"page_info/page_info_dialog.h",
@@ -1337,8 +1334,6 @@ static_library("ui") {
"tabs/pinned_tab_service.h",
"tabs/pinned_tab_service_factory.cc",
"tabs/pinned_tab_service_factory.h",
- "tabs/saved_tab_groups/saved_tab_group.cc",
- "tabs/saved_tab_groups/saved_tab_group.h",
"tabs/saved_tab_groups/saved_tab_group_keyed_service.cc",
"tabs/saved_tab_groups/saved_tab_group_keyed_service.h",
"tabs/saved_tab_groups/saved_tab_group_model.cc",
@@ -1348,6 +1343,7 @@ static_library("ui") {
"tabs/saved_tab_groups/saved_tab_group_model_observer.h",
"tabs/saved_tab_groups/saved_tab_group_service_factory.cc",
"tabs/saved_tab_groups/saved_tab_group_service_factory.h",
+ "tabs/tab.h",
"tabs/tab_change_type.h",
"tabs/tab_group.cc",
"tabs/tab_group.h",
@@ -1370,10 +1366,11 @@ static_library("ui") {
"tabs/tab_strip_model_delegate.h",
"tabs/tab_strip_model_observer.cc",
"tabs/tab_strip_model_observer.h",
- "tabs/tab_strip_model_order_controller.cc",
- "tabs/tab_strip_model_order_controller.h",
"tabs/tab_strip_model_stats_recorder.cc",
"tabs/tab_strip_model_stats_recorder.h",
+ "tabs/tab_strip_scrubbing_metrics.cc",
+ "tabs/tab_strip_scrubbing_metrics.h",
+ "tabs/tab_strip_user_gesture_details.h",
"tabs/tab_style.cc",
"tabs/tab_style.h",
"tabs/tab_switch_event_latency_recorder.cc",
@@ -1578,6 +1575,8 @@ static_library("ui") {
"webui/ntp/ntp_resource_cache_factory.h",
"webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc",
"webui/page_not_available_for_guest/page_not_available_for_guest_ui.h",
+ "webui/password_manager/password_manager_ui.cc",
+ "webui/password_manager/password_manager_ui.h",
"webui/plural_string_handler.cc",
"webui/plural_string_handler.h",
"webui/policy_indicator_localized_strings_provider.cc",
@@ -1602,6 +1601,8 @@ static_library("ui") {
"webui/settings/accessibility_main_handler.h",
"webui/settings/appearance_handler.cc",
"webui/settings/appearance_handler.h",
+ "webui/settings/autofill_assistant_handler.cc",
+ "webui/settings/autofill_assistant_handler.h",
"webui/settings/browser_lifetime_handler.cc",
"webui/settings/browser_lifetime_handler.h",
"webui/settings/captions_handler.cc",
@@ -1670,10 +1671,16 @@ static_library("ui") {
"webui/side_panel/bookmarks/bookmarks_page_handler.h",
"webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc",
"webui/side_panel/bookmarks/bookmarks_side_panel_ui.h",
+ "webui/side_panel/customize_chrome/customize_chrome_page_handler.cc",
+ "webui/side_panel/customize_chrome/customize_chrome_page_handler.h",
+ "webui/side_panel/customize_chrome/customize_chrome_ui.cc",
+ "webui/side_panel/customize_chrome/customize_chrome_ui.h",
"webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc",
"webui/side_panel/history_clusters/history_clusters_side_panel_ui.h",
"webui/side_panel/read_anything/read_anything_page_handler.cc",
"webui/side_panel/read_anything/read_anything_page_handler.h",
+ "webui/side_panel/read_anything/read_anything_prefs.cc",
+ "webui/side_panel/read_anything/read_anything_prefs.h",
"webui/side_panel/read_anything/read_anything_ui.cc",
"webui/side_panel/read_anything/read_anything_ui.h",
"webui/side_panel/reading_list/reading_list_page_handler.cc",
@@ -1741,7 +1748,6 @@ static_library("ui") {
"//chrome/browser:browser_themes",
"//chrome/browser:theme_properties",
"//chrome/browser/ash/system_web_apps/types:types",
- "//chrome/browser/autofill_assistant/password_change/proto:proto",
"//chrome/browser/autofill_assistant/password_change/vector_icons",
"//chrome/browser/browsing_data:constants",
"//chrome/browser/cart:mojo_bindings",
@@ -1752,8 +1758,9 @@ static_library("ui") {
"//chrome/browser/media/router/discovery/access_code:access_code_sink_service",
"//chrome/browser/new_tab_page/chrome_colors:generate_chrome_colors_info",
"//chrome/browser/new_tab_page/modules/drive:mojo_bindings",
+ "//chrome/browser/new_tab_page/modules/feed:mojo_bindings",
"//chrome/browser/new_tab_page/modules/photos:mojo_bindings",
- "//chrome/browser/new_tab_page/modules/task_module:mojo_bindings",
+ "//chrome/browser/new_tab_page/modules/recipes:mojo_bindings",
"//chrome/browser/profile_resetter:profile_reset_report_proto",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
"//chrome/browser/resource_coordinator/tab_ranker",
@@ -1767,21 +1774,32 @@ static_library("ui") {
"//chrome/browser/ui/commander:fuzzy_finder",
"//chrome/browser/ui/webui/access_code_cast:mojo_bindings",
"//chrome/browser/ui/webui/app_service_internals:mojo_bindings",
+ "//chrome/browser/ui/webui/downloads:mojo_bindings",
"//chrome/browser/ui/webui/feed:mojo_bindings",
"//chrome/browser/ui/webui/image_editor:image_editor_ui",
"//chrome/browser/ui/webui/image_editor:mojo_bindings",
"//chrome/browser/ui/webui/internals/user_education:mojo_bindings",
"//chrome/browser/ui/webui/new_tab_page:mojo_bindings",
"//chrome/browser/ui/webui/new_tab_page_third_party:mojo_bindings",
+ "//chrome/browser/ui/webui/realbox:mojo_bindings",
+ "//chrome/browser/ui/webui/side_panel/bookmarks:mojo_bindings",
+ "//chrome/browser/ui/webui/side_panel/customize_chrome:mojo_bindings",
+ "//chrome/browser/ui/webui/side_panel/reading_list:mojo_bindings",
+ "//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/tab_strip:mojo_bindings",
"//chrome/browser/web_applications",
"//chrome/common:buildflags",
"//chrome/common:version_header",
+ "//chrome/common/accessibility:mojo_bindings",
"//chrome/common/search:mojo_bindings",
"//chrome/common/themes:autogenerated_theme_util",
"//components/app_constants",
+ "//components/autofill_assistant/browser/public/password_change/proto:proto",
"//components/commerce/content/browser:hint",
+ "//components/commerce/core:cart_db_content_proto",
"//components/commerce/core:feature_list",
+ "//components/commerce/core/mojom:mojo_bindings",
+ "//components/commerce/core/webui",
"//components/enterprise/common:download_item_reroute_info",
"//components/feedback/proto",
"//components/keep_alive_registry",
@@ -1793,6 +1811,7 @@ static_library("ui") {
"//components/reading_list/features:flags",
"//components/safe_browsing/core/common:safe_browsing_policy_handler",
"//components/safety_check",
+ "//components/saved_tab_groups:core",
"//components/search_provider_logos",
"//components/services/app_service/public/cpp:app_types",
"//components/services/app_service/public/cpp:app_update",
@@ -1806,6 +1825,7 @@ static_library("ui") {
"//components/url_formatter",
"//components/url_param_filter/content",
"//components/user_education/common",
+ "//components/user_education/webui",
"//components/user_notes:features",
"//components/vector_icons",
"//components/web_modal",
@@ -1824,6 +1844,7 @@ static_library("ui") {
"//ui/base/dragdrop/mojom",
"//ui/events",
"//ui/webui/resources/cr_components/app_management:mojo_bindings",
+ "//ui/webui/resources/cr_components/help_bubble:mojo_bindings",
"//ui/webui/resources/cr_components/history_clusters:mojo_bindings",
"//ui/webui/resources/js/browser_command:mojo_bindings",
"//ui/webui/resources/js/metrics_reporter:mojo_bindings",
@@ -1834,6 +1855,7 @@ static_library("ui") {
"//ui/base/dragdrop/mojom:mojom_headers",
]
+ # TODO(crbug.com/1030821): Resolve circular dependencies.
allow_circular_includes_from += [ "//chrome/browser/media/router" ]
if (use_ozone && !is_chromeos_ash) {
@@ -1885,8 +1907,7 @@ static_library("ui") {
assert(is_chromeos)
sources += [
"supervised_user/parent_permission_dialog.h",
- "views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc",
- "views/supervised_user/extension_install_blocked_by_parent_dialog_view.h",
+ "views/supervised_user/extension_install_blocked_by_parent_dialog.cc",
"views/supervised_user/parent_permission_dialog_view.cc",
"views/supervised_user/parent_permission_dialog_view.h",
]
@@ -2082,6 +2103,7 @@ static_library("ui") {
"app_list/search/omnibox_provider.h",
"app_list/search/omnibox_result.cc",
"app_list/search/omnibox_result.h",
+ "app_list/search/omnibox_util.cc",
"app_list/search/omnibox_util.h",
"app_list/search/open_tab_result.cc",
"app_list/search/open_tab_result.h",
@@ -2170,6 +2192,8 @@ static_library("ui") {
"ash/accessibility/accessibility_controller_client.h",
"ash/ambient/ambient_client_impl.cc",
"ash/ambient/ambient_client_impl.h",
+ "ash/app_access_notifier.cc",
+ "ash/app_access_notifier.h",
"ash/app_icon_color_cache.cc",
"ash/app_icon_color_cache.h",
"ash/arc_custom_tab_modal_dialog_host.cc",
@@ -2235,6 +2259,8 @@ static_library("ui") {
"ash/default_pinned_apps.h",
"ash/desks/chrome_desks_templates_delegate.cc",
"ash/desks/chrome_desks_templates_delegate.h",
+ "ash/desks/chrome_desks_util.cc",
+ "ash/desks/chrome_desks_util.h",
"ash/desks/desks_client.cc",
"ash/desks/desks_client.h",
"ash/desks/desks_templates_app_launch_handler.cc",
@@ -2245,6 +2271,10 @@ static_library("ui") {
"ash/device_scheduled_reboot/scheduled_reboot_dialog.h",
"ash/fwupd_download_client_impl.cc",
"ash/fwupd_download_client_impl.h",
+ "ash/global_media_controls/cast_media_notification_producer_keyed_service.cc",
+ "ash/global_media_controls/cast_media_notification_producer_keyed_service.h",
+ "ash/global_media_controls/cast_media_notification_producer_keyed_service_factory.cc",
+ "ash/global_media_controls/cast_media_notification_producer_keyed_service_factory.h",
"ash/holding_space/holding_space_client_impl.cc",
"ash/holding_space/holding_space_client_impl.h",
"ash/holding_space/holding_space_downloads_delegate.cc",
@@ -2267,6 +2297,8 @@ static_library("ui") {
"ash/ime_controller_client_impl.h",
"ash/in_session_auth_dialog_client.cc",
"ash/in_session_auth_dialog_client.h",
+ "ash/in_session_auth_token_provider_impl.cc",
+ "ash/in_session_auth_token_provider_impl.h",
"ash/keyboard/chrome_keyboard_bounds_observer.cc",
"ash/keyboard/chrome_keyboard_bounds_observer.h",
"ash/keyboard/chrome_keyboard_controller_client.cc",
@@ -2282,8 +2314,6 @@ static_library("ui") {
"ash/login_screen_shown_observer.h",
"ash/media_client_impl.cc",
"ash/media_client_impl.h",
- "ash/microphone_mute_notification_delegate_impl.cc",
- "ash/microphone_mute_notification_delegate_impl.h",
"ash/multi_user/multi_profile_support.cc",
"ash/multi_user/multi_profile_support.h",
"ash/multi_user/multi_user_context_menu.h",
@@ -2312,10 +2342,14 @@ static_library("ui") {
"ash/projector/projector_app_client_impl.h",
"ash/projector/projector_client_impl.cc",
"ash/projector/projector_client_impl.h",
+ "ash/projector/projector_drivefs_provider.cc",
+ "ash/projector/projector_drivefs_provider.h",
"ash/projector/projector_soda_installation_controller.cc",
"ash/projector/projector_soda_installation_controller.h",
"ash/projector/projector_utils.cc",
"ash/projector/projector_utils.h",
+ "ash/projector/screencast_manager.cc",
+ "ash/projector/screencast_manager.h",
"ash/screen_orientation_delegate_chromeos.cc",
"ash/screen_orientation_delegate_chromeos.h",
"ash/screenshot_area.cc",
@@ -2426,6 +2460,10 @@ static_library("ui") {
"ash/test_ime_controller.h",
"ash/thumbnail_loader.cc",
"ash/thumbnail_loader.h",
+ "ash/touch_selection_menu_chromeos.cc",
+ "ash/touch_selection_menu_chromeos.h",
+ "ash/touch_selection_menu_runner_chromeos.cc",
+ "ash/touch_selection_menu_runner_chromeos.h",
"ash/vpn_list_forwarder.cc",
"ash/vpn_list_forwarder.h",
"ash/wallpaper_controller_client_impl.cc",
@@ -2471,8 +2509,6 @@ static_library("ui") {
"views/crostini/crostini_uninstaller_view.h",
"views/crostini/crostini_update_filesystem_view.cc",
"views/crostini/crostini_update_filesystem_view.h",
- "views/extensions/request_file_system_dialog_view.cc",
- "views/extensions/request_file_system_dialog_view.h",
"views/frame/browser_frame_ash.cc",
"views/frame/browser_frame_ash.h",
"views/frame/custom_tab_browser_frame.cc",
@@ -2490,16 +2526,10 @@ static_library("ui") {
"views/select_file_dialog_extension.h",
"views/select_file_dialog_extension_factory.cc",
"views/select_file_dialog_extension_factory.h",
- "views/touch_selection_menu_chromeos.cc",
- "views/touch_selection_menu_chromeos.h",
- "views/touch_selection_menu_runner_chromeos.cc",
- "views/touch_selection_menu_runner_chromeos.h",
"web_applications/file_stream_data_pipe_getter.cc",
"web_applications/file_stream_data_pipe_getter.h",
"webui/app_management/app_management_shelf_delegate_chromeos.cc",
"webui/app_management/app_management_shelf_delegate_chromeos.h",
- "webui/certificate_provisioning_ui_handler.cc",
- "webui/certificate_provisioning_ui_handler.h",
"webui/chromeos/account_manager/account_manager_error_ui.cc",
"webui/chromeos/account_manager/account_manager_error_ui.h",
"webui/chromeos/account_manager/account_migration_welcome_dialog.cc",
@@ -2545,6 +2575,12 @@ static_library("ui") {
"webui/chromeos/cellular_setup/mobile_setup_ui.h",
"webui/chromeos/certificate_manager_dialog_ui.cc",
"webui/chromeos/certificate_manager_dialog_ui.h",
+ "webui/chromeos/cloud_upload/cloud_upload_dialog.cc",
+ "webui/chromeos/cloud_upload/cloud_upload_dialog.h",
+ "webui/chromeos/cloud_upload/cloud_upload_page_handler.cc",
+ "webui/chromeos/cloud_upload/cloud_upload_page_handler.h",
+ "webui/chromeos/cloud_upload/cloud_upload_ui.cc",
+ "webui/chromeos/cloud_upload/cloud_upload_ui.h",
"webui/chromeos/connectivity_diagnostics_dialog.cc",
"webui/chromeos/connectivity_diagnostics_dialog.h",
"webui/chromeos/crostini_installer/crostini_installer_dialog.cc",
@@ -2757,6 +2793,12 @@ static_library("ui") {
"webui/chromeos/login/welcome_screen_handler.h",
"webui/chromeos/login/wrong_hwid_screen_handler.cc",
"webui/chromeos/login/wrong_hwid_screen_handler.h",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.cc",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.cc",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.cc",
+ "webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h",
"webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc",
"webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h",
"webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc",
@@ -2773,6 +2815,8 @@ static_library("ui") {
"webui/chromeos/network_logs_message_handler.h",
"webui/chromeos/network_ui.cc",
"webui/chromeos/network_ui.h",
+ "webui/chromeos/notification_tester/notification_tester_handler.cc",
+ "webui/chromeos/notification_tester/notification_tester_handler.h",
"webui/chromeos/notification_tester/notification_tester_ui.cc",
"webui/chromeos/notification_tester/notification_tester_ui.h",
"webui/chromeos/onc_import_message_handler.cc",
@@ -2811,8 +2855,6 @@ static_library("ui") {
"webui/chromeos/system_web_dialog_delegate.h",
"webui/chromeos/user_image_source.cc",
"webui/chromeos/user_image_source.h",
- "webui/chromeos/video_source.cc",
- "webui/chromeos/video_source.h",
"webui/chromeos/vm/vm_ui.cc",
"webui/chromeos/vm/vm_ui.h",
"webui/extensions/ash/kiosk_apps_handler.cc",
@@ -2841,21 +2883,18 @@ static_library("ui") {
"webui/nearby_share/nearby_share_dialog_ui.h",
"webui/nearby_share/shared_resources.cc",
"webui/nearby_share/shared_resources.h",
- "webui/policy/status_provider/device_active_directory_policy_status_provider.cc",
- "webui/policy/status_provider/device_active_directory_policy_status_provider.h",
- "webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.cc",
- "webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h",
- "webui/policy/status_provider/device_local_account_policy_status_provider.cc",
- "webui/policy/status_provider/device_local_account_policy_status_provider.h",
- "webui/policy/status_provider/user_active_directory_policy_status_provider.cc",
- "webui/policy/status_provider/user_active_directory_policy_status_provider.h",
- "webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.cc",
- "webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h",
"webui/settings/ash/app_management/app_management_uma.h",
"webui/settings/ash/calculator/size_calculator.cc",
"webui/settings/ash/calculator/size_calculator.h",
"webui/settings/ash/os_apps_page/app_notification_handler.cc",
"webui/settings/ash/os_apps_page/app_notification_handler.h",
+ "webui/settings/ash/search/per_session_settings_user_action_tracker.cc",
+ "webui/settings/ash/search/per_session_settings_user_action_tracker.h",
+ "webui/settings/ash/search/search_concept.h",
+ "webui/settings/ash/search/search_handler.cc",
+ "webui/settings/ash/search/search_handler.h",
+ "webui/settings/ash/search/search_tag_registry.cc",
+ "webui/settings/ash/search/search_tag_registry.h",
"webui/settings/chromeos/about_section.cc",
"webui/settings/chromeos/about_section.h",
"webui/settings/chromeos/accessibility_handler.cc",
@@ -2864,8 +2903,6 @@ static_library("ui") {
"webui/settings/chromeos/accessibility_section.h",
"webui/settings/chromeos/account_manager_handler.cc",
"webui/settings/chromeos/account_manager_handler.h",
- "webui/settings/chromeos/ambient_mode_handler.cc",
- "webui/settings/chromeos/ambient_mode_handler.h",
"webui/settings/chromeos/android_apps_handler.cc",
"webui/settings/chromeos/android_apps_handler.h",
"webui/settings/chromeos/apps_section.cc",
@@ -2904,8 +2941,12 @@ static_library("ui") {
"webui/settings/chromeos/device_section.h",
"webui/settings/chromeos/device_storage_handler.cc",
"webui/settings/chromeos/device_storage_handler.h",
+ "webui/settings/chromeos/device_storage_util.cc",
+ "webui/settings/chromeos/device_storage_util.h",
"webui/settings/chromeos/device_stylus_handler.cc",
"webui/settings/chromeos/device_stylus_handler.h",
+ "webui/settings/chromeos/fast_pair_saved_devices_handler.cc",
+ "webui/settings/chromeos/fast_pair_saved_devices_handler.h",
"webui/settings/chromeos/files_section.cc",
"webui/settings/chromeos/files_section.h",
"webui/settings/chromeos/fingerprint_handler.cc",
@@ -2963,19 +3004,14 @@ static_library("ui") {
"webui/settings/chromeos/pref_names.h",
"webui/settings/chromeos/printing_section.cc",
"webui/settings/chromeos/printing_section.h",
+ "webui/settings/chromeos/privacy_hub_handler.cc",
+ "webui/settings/chromeos/privacy_hub_handler.h",
"webui/settings/chromeos/privacy_section.cc",
"webui/settings/chromeos/privacy_section.h",
"webui/settings/chromeos/quick_unlock_handler.cc",
"webui/settings/chromeos/quick_unlock_handler.h",
"webui/settings/chromeos/reset_section.cc",
"webui/settings/chromeos/reset_section.h",
- "webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc",
- "webui/settings/chromeos/search/per_session_settings_user_action_tracker.h",
- "webui/settings/chromeos/search/search_concept.h",
- "webui/settings/chromeos/search/search_handler.cc",
- "webui/settings/chromeos/search/search_handler.h",
- "webui/settings/chromeos/search/search_tag_registry.cc",
- "webui/settings/chromeos/search/search_tag_registry.h",
"webui/settings/chromeos/search_section.cc",
"webui/settings/chromeos/search_section.h",
"webui/settings/chromeos/server_printer_url_util.cc",
@@ -3009,14 +3045,12 @@ static_library("ui") {
"//ash/app_list",
"//ash/assistant/model",
"//ash/assistant/util",
- "//ash/components/account_manager",
"//ash/components/arc",
"//ash/components/arc/video_accelerator:protected_native_pixmap_query_client",
- "//ash/components/audio",
- "//ash/components/cryptohome",
"//ash/components/disks",
"//ash/components/drivefs",
"//ash/components/drivefs/mojom:mojom",
+ "//ash/components/fwupd",
"//ash/components/login/auth",
"//ash/components/login/session",
"//ash/components/multidevice",
@@ -3027,7 +3061,6 @@ static_library("ui") {
"//ash/components/proximity_auth",
"//ash/components/settings",
"//ash/components/tether",
- "//ash/components/tpm",
"//ash/constants",
"//ash/keyboard/ui",
"//ash/public/cpp",
@@ -3035,6 +3068,7 @@ static_library("ui") {
"//ash/public/cpp/resources:ash_public_unscaled_resources",
"//ash/quick_pair/common",
"//ash/quick_pair/keyed_service",
+ "//ash/quick_pair/proto:fastpair_proto",
"//ash/quick_pair/repository",
"//ash/quick_pair/ui",
"//ash/services/cellular_setup",
@@ -3080,8 +3114,10 @@ static_library("ui") {
"//chrome/browser/ash",
"//chrome/browser/ash/crosapi",
"//chrome/browser/ash/crostini:crostini_installer_types_mojom",
+ "//chrome/browser/ash/system_web_apps",
"//chrome/browser/chromeos",
"//chrome/browser/chromeos/extensions/vpn_provider",
+ "//chrome/browser/chromeos/launcher_search:search_util",
"//chrome/browser/media/router/discovery/access_code:access_code_cast_feature",
"//chrome/browser/media/router/discovery/access_code:discovery_resources_proto",
"//chrome/browser/nearby_sharing:share_target",
@@ -3098,6 +3134,7 @@ static_library("ui") {
"//chrome/browser/resources:internet_config_dialog_resources",
"//chrome/browser/resources:internet_detail_dialog_resources",
"//chrome/browser/resources/chromeos:multidevice_setup_resources",
+ "//chrome/browser/resources/chromeos/cloud_upload:resources",
"//chrome/browser/ui/app_list/search/cros_action_history:cros_action_proto",
"//chrome/browser/ui/app_list/search/ranking:proto",
"//chrome/browser/ui/app_list/search/search_result_ranker:app_launch_event_logger_proto",
@@ -3107,64 +3144,72 @@ static_library("ui") {
"//chrome/browser/ui/quick_answers",
"//chrome/browser/ui/webui/chromeos/add_supervision:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/audio:mojo_bindings",
+ "//chrome/browser/ui/webui/chromeos/cloud_upload:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/crostini_upgrader:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/launcher_internals:mojo_bindings",
+ "//chrome/browser/ui/webui/chromeos/manage_mirrorsync:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/parent_access:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/parent_access:proto",
"//chrome/browser/ui/webui/chromeos/vm:mojo_bindings",
"//chrome/browser/ui/webui/nearby_share:mojom",
"//chrome/browser/ui/webui/nearby_share/public/mojom",
"//chrome/browser/ui/webui/settings/ash/os_apps_page/mojom",
- "//chrome/browser/ui/webui/settings/chromeos/search:mojo_bindings",
+ "//chrome/browser/ui/webui/settings/ash/search:mojo_bindings",
"//chrome/browser/web_applications",
+ "//chrome/browser/webshare:storage",
"//chrome/services/file_util/public/cpp",
+ "//chromeos/ash/components/account_manager",
"//chromeos/ash/components/assistant:buildflags",
+ "//chromeos/ash/components/audio",
+ "//chromeos/ash/components/cryptohome",
+ "//chromeos/ash/components/dbus",
+ "//chromeos/ash/components/dbus/audio",
+ "//chromeos/ash/components/dbus/cryptohome",
+ "//chromeos/ash/components/dbus/cryptohome:cryptohome_proto",
+ "//chromeos/ash/components/dbus/hermes",
+ "//chromeos/ash/components/dbus/human_presence",
"//chromeos/ash/components/dbus/kerberos:kerberos_proto",
"//chromeos/ash/components/dbus/os_install",
"//chromeos/ash/components/dbus/pciguard:pciguard",
+ "//chromeos/ash/components/dbus/session_manager",
+ "//chromeos/ash/components/dbus/shill",
"//chromeos/ash/components/dbus/spaced",
"//chromeos/ash/components/dbus/system_clock",
+ "//chromeos/ash/components/dbus/update_engine",
"//chromeos/ash/components/dbus/upstart",
+ "//chromeos/ash/components/dbus/userdataauth",
+ "//chromeos/ash/components/dbus/userdataauth:userdataauth_proto",
"//chromeos/ash/components/human_presence",
+ "//chromeos/ash/components/install_attributes",
+ "//chromeos/ash/components/local_search_service/public/cpp",
+ "//chromeos/ash/components/local_search_service/public/mojom",
+ "//chromeos/ash/components/network",
"//chromeos/ash/components/network/portal_detector",
"//chromeos/ash/components/oobe_quick_start",
+ "//chromeos/ash/components/string_matching",
"//chromeos/ash/resources",
"//chromeos/ash/services/assistant:lib",
- "//chromeos/components/local_search_service/public/cpp",
- "//chromeos/components/local_search_service/public/mojom",
+ "//chromeos/ash/services/assistant/public/cpp",
+ "//chromeos/ash/services/assistant/public/mojom",
+ "//chromeos/ash/services/assistant/public/proto",
+ "//chromeos/ash/services/auth_factor_config",
"//chromeos/components/onc",
"//chromeos/components/quick_answers",
"//chromeos/components/quick_answers/public/cpp:cpp",
"//chromeos/components/quick_answers/public/cpp:prefs",
"//chromeos/components/sharesheet:constants",
- "//chromeos/components/string_matching",
"//chromeos/constants",
"//chromeos/crosapi/cpp",
"//chromeos/crosapi/cpp:crosapi_constants",
- "//chromeos/dbus",
- "//chromeos/dbus/audio",
- "//chromeos/dbus/cryptohome",
- "//chromeos/dbus/cryptohome:cryptohome_proto",
- "//chromeos/dbus/hermes",
- "//chromeos/dbus/human_presence",
- "//chromeos/dbus/power",
- "//chromeos/dbus/session_manager",
"//chromeos/dbus/tpm_manager",
"//chromeos/dbus/tpm_manager:tpm_manager_proto",
- "//chromeos/dbus/update_engine",
- "//chromeos/dbus/userdataauth",
- "//chromeos/dbus/userdataauth:userdataauth_proto",
- "//chromeos/dbus/util",
"//chromeos/login/login_state",
- "//chromeos/network",
"//chromeos/printing",
- "//chromeos/services/assistant/public/cpp",
- "//chromeos/services/assistant/public/mojom",
- "//chromeos/services/assistant/public/proto",
"//chromeos/services/assistant/public/shared",
"//chromeos/services/bluetooth_config",
"//chromeos/services/bluetooth_config:in_process_bluetooth_config",
"//chromeos/services/bluetooth_config/public/mojom",
+ "//chromeos/services/network_config/public/cpp",
"//chromeos/services/network_config/public/mojom",
"//chromeos/services/network_health/public/mojom",
"//chromeos/system",
@@ -3172,6 +3217,7 @@ static_library("ui") {
"//chromeos/ui/frame",
"//chromeos/ui/vector_icons",
"//chromeos/ui/wm",
+ "//chromeos/version",
"//components/app_constants",
"//components/app_restore",
"//components/arc",
@@ -3261,6 +3307,8 @@ static_library("ui") {
"tabs/existing_window_sub_menu_model_chromeos.cc",
"tabs/existing_window_sub_menu_model_chromeos.h",
"views/extensions/print_job_confirmation_dialog.cc",
+ "views/extensions/request_file_system_dialog_view.cc",
+ "views/extensions/request_file_system_dialog_view.h",
"views/frame/browser_frame_header_chromeos.cc",
"views/frame/browser_frame_header_chromeos.h",
"views/frame/browser_non_client_frame_view_chromeos.cc",
@@ -3276,6 +3324,8 @@ static_library("ui") {
"views/platform_keys_certificate_selector_chromeos.h",
"views/tabs/tab_scrubber_chromeos.cc",
"views/tabs/tab_scrubber_chromeos.h",
+ "webui/certificate_provisioning_ui_handler.cc",
+ "webui/certificate_provisioning_ui_handler.h",
"webui/chromeos/chrome_url_disabled/chrome_url_disabled_ui.cc",
"webui/chromeos/chrome_url_disabled/chrome_url_disabled_ui.h",
"webui/version/version_handler_chromeos.cc",
@@ -3284,9 +3334,11 @@ static_library("ui") {
deps += [
"//chrome/app:generated_resources",
"//chromeos/components/security_token_pin",
+ "//chromeos/dbus/power",
"//chromeos/strings",
"//components/account_manager_core:account_manager_core",
"//ui/chromeos/styles:cros_styles_views",
+ "//ui/chromeos/styles:cros_tokens_color_mappings",
]
}
@@ -3304,10 +3356,6 @@ static_library("ui") {
"views/frame/immersive_mode_controller_chromeos.h",
"views/profiles/lacros_first_run_signed_in_flow_controller.cc",
"views/profiles/lacros_first_run_signed_in_flow_controller.h",
- "webui/policy/status_provider/device_policy_status_provider_lacros.cc",
- "webui/policy/status_provider/device_policy_status_provider_lacros.h",
- "webui/policy/status_provider/user_policy_status_provider_lacros.cc",
- "webui/policy/status_provider/user_policy_status_provider_lacros.h",
"webui/signin/profile_picker_lacros_sign_in_provider.cc",
"webui/signin/profile_picker_lacros_sign_in_provider.h",
"window_sizer/window_sizer_chromeos.cc",
@@ -3376,6 +3424,8 @@ static_library("ui") {
"views/privacy_sandbox/privacy_sandbox_notice_bubble.h",
"views/profiles/incognito_menu_view.cc",
"views/profiles/incognito_menu_view.h",
+ "views/profiles/profile_menu_coordinator.cc",
+ "views/profiles/profile_menu_coordinator.h",
"views/profiles/profile_menu_view_base.cc",
"views/profiles/profile_menu_view_base.h",
"views/profiles/signin_view_controller_delegate_views.cc",
@@ -3409,6 +3459,10 @@ static_library("ui") {
"views/web_apps/deprecated_apps_dialog_view.h",
"views/web_apps/force_installed_deprecated_apps_dialog_view.cc",
"views/web_apps/force_installed_deprecated_apps_dialog_view.h",
+ "webui/app_home/app_home_page_handler.cc",
+ "webui/app_home/app_home_page_handler.h",
+ "webui/app_home/app_home_ui.cc",
+ "webui/app_home/app_home_ui.h",
"webui/app_launcher_page_ui.cc",
"webui/app_launcher_page_ui.h",
"webui/app_settings/web_app_settings_navigation_throttle.cc",
@@ -3420,6 +3474,8 @@ static_library("ui") {
"webui/ntp/app_launcher_handler.cc",
"webui/ntp/app_launcher_handler.h",
]
+
+ deps += [ "//chrome/browser/ui/webui/app_home:mojo_bindings" ]
}
if (is_win || is_mac || is_fuchsia || is_linux || is_chromeos_lacros) {
@@ -3454,6 +3510,10 @@ static_library("ui") {
"views/profiles/profile_picker_view.cc",
"views/profiles/profile_picker_view.h",
"views/profiles/profile_picker_web_contents_host.h",
+ "webui/intro/intro_handler.cc",
+ "webui/intro/intro_handler.h",
+ "webui/intro/intro_ui.cc",
+ "webui/intro/intro_ui.h",
"webui/profile_helper.cc",
"webui/profile_helper.h",
"webui/settings/settings_default_browser_handler.cc",
@@ -3732,6 +3792,7 @@ static_library("ui") {
deps += [
"//chrome/browser/apps/app_shim",
+ "//chrome/updater:browser_sources",
"//components/remote_cocoa/app_shim",
"//components/remote_cocoa/browser",
"//extensions/components/native_app_window",
@@ -3747,10 +3808,7 @@ static_library("ui") {
weak_frameworks = [ "ScreenTime.framework" ]
if (enable_chromium_updater) {
- deps += [
- "//chrome/browser/updater:browser_updater_client",
- "//chrome/updater:browser_sources",
- ]
+ deps += [ "//chrome/browser/updater:browser_updater_client" ]
}
}
@@ -3796,10 +3854,12 @@ static_library("ui") {
"views/frame/native_browser_frame_factory_aura.cc",
"views/frame/system_menu_insertion_delegate_win.cc",
"views/frame/system_menu_insertion_delegate_win.h",
- "views/frame/windows_10_caption_button.cc",
- "views/frame/windows_10_caption_button.h",
- "views/frame/windows_10_tab_search_caption_button.cc",
- "views/frame/windows_10_tab_search_caption_button.h",
+ "views/frame/windows_caption_button.cc",
+ "views/frame/windows_caption_button.h",
+ "views/frame/windows_icon_painter.cc",
+ "views/frame/windows_icon_painter.h",
+ "views/frame/windows_tab_search_caption_button.cc",
+ "views/frame/windows_tab_search_caption_button.h",
"views/network_profile_bubble_view.cc",
"views/settings_reset_prompt_dialog.cc",
"views/settings_reset_prompt_dialog.h",
@@ -3823,8 +3883,6 @@ static_library("ui") {
"webui/conflicts/conflicts_handler.h",
"webui/conflicts/conflicts_ui.cc",
"webui/conflicts/conflicts_ui.h",
- "webui/policy/status_provider/updater_status_provider.cc",
- "webui/policy/status_provider/updater_status_provider.h",
"webui/sandbox/sandbox_handler.cc",
"webui/sandbox/sandbox_handler.h",
"webui/settings/chrome_cleanup_handler_win.cc",
@@ -3875,12 +3933,7 @@ static_library("ui") {
]
}
} else { # 'OS!="win"
- # The Cast Linux build sets toolkit_views to false, but many files in this
- # target include views-related files unconditionally, causing `gn check`
- # to fail on this variant. Since this target is only referenced (but not
- # compiled) on this variant, it's okay to add this "incorrect" dependency
- # to Cast Linux builds so that `gn check` passes.
- if (toolkit_views || is_castos) {
+ if (toolkit_views) {
public_deps += [
"//ui/views",
"//ui/views/controls/webview",
@@ -3907,6 +3960,10 @@ static_library("ui") {
"views/window_sizer_linux.cc",
"views/window_sizer_linux.h",
]
+ deps += [
+ "//ui/linux:linux_ui",
+ "//ui/linux:linux_ui_factory",
+ ]
}
if (is_linux || is_chromeos_lacros || is_fuchsia) {
@@ -3925,7 +3982,6 @@ static_library("ui") {
"//ui/base/ime",
"//ui/events:dom_keycode_converter",
"//ui/platform_window",
- "//ui/views/linux_ui:linux_ui_factory",
]
if (use_dbus) {
@@ -3975,20 +4031,27 @@ static_library("ui") {
]
}
- if (is_linux || is_chromeos) { # Both desktop Linux and ChromeOS.
+ if (enable_webui_certificate_viewer) {
sources += [
"certificate_dialogs.cc",
"certificate_dialogs.h",
- "process_singleton_dialog_linux.h",
"webui/certificate_viewer_ui.cc",
"webui/certificate_viewer_ui.h",
"webui/certificate_viewer_webui.cc",
"webui/certificate_viewer_webui.h",
+ ]
+ deps += [ "//third_party/boringssl" ]
+ if (use_nss_certs) {
+ configs += [ "//build/config/linux/nss" ]
+ }
+ }
+
+ if (is_linux || is_chromeos) {
+ sources += [
+ "process_singleton_dialog_linux.h",
"webui/webui_js_error/webui_js_error_ui.cc",
"webui/webui_js_error/webui_js_error_ui.h",
]
- deps += [ "//third_party/boringssl" ]
- configs += [ "//build/config/linux/nss" ]
if (use_aura) {
deps += [ "//third_party/fontconfig" ]
}
@@ -4041,9 +4104,7 @@ static_library("ui") {
"qrcode_generator/qrcode_generator_bubble_controller.cc",
"qrcode_generator/qrcode_generator_bubble_controller.h",
"qrcode_generator/qrcode_generator_bubble_view.h",
- "send_tab_to_self/send_tab_to_self_bubble_controller.cc",
- "send_tab_to_self/send_tab_to_self_bubble_controller.h",
- "send_tab_to_self/send_tab_to_self_bubble_view.h",
+ "send_tab_to_self/send_tab_to_self_bubble.h",
"send_tab_to_self/send_tab_to_self_toolbar_icon_controller.cc",
"send_tab_to_self/send_tab_to_self_toolbar_icon_controller.h",
"send_tab_to_self/send_tab_to_self_toolbar_icon_controller_delegate.h",
@@ -4051,6 +4112,14 @@ static_library("ui") {
"sharing_hub/screenshot/screenshot_captured_bubble_controller.h",
"sharing_hub/sharing_hub_bubble_controller.h",
"sharing_hub/sharing_hub_bubble_view.h",
+ "side_panel/customize_chrome/customize_chrome_side_panel_controller_utils.h",
+ "side_panel/customize_chrome/customize_chrome_tab_helper.cc",
+ "side_panel/customize_chrome/customize_chrome_tab_helper.h",
+ "views/send_tab_to_self/send_tab_to_self_bubble.cc",
+ "views/send_tab_to_self/send_tab_to_self_bubble_controller.cc",
+ "views/send_tab_to_self/send_tab_to_self_bubble_controller.h",
+ "views/send_tab_to_self/send_tab_to_self_bubble_view.cc",
+ "views/send_tab_to_self/send_tab_to_self_bubble_view.h",
# This test header is included because it contains forward declarations
# needed for "friend" statements for use in tests.
@@ -4066,6 +4135,7 @@ static_library("ui") {
"side_search/side_search_tab_contents_helper.h",
"side_search/side_search_utils.cc",
"side_search/side_search_utils.h",
+ "side_search/unified_side_search_helper.h",
"sync/one_click_signin_links_delegate.h",
"sync/one_click_signin_links_delegate_impl.cc",
"sync/one_click_signin_links_delegate_impl.h",
@@ -4167,11 +4237,19 @@ static_library("ui") {
"views/autofill/save_update_address_profile_icon_view.h",
"views/autofill/update_address_profile_view.cc",
"views/autofill/update_address_profile_view.h",
+ "views/autofill_assistant/password_change/apc_scrim_manager_impl.cc",
+ "views/autofill_assistant/password_change/apc_scrim_manager_impl.h",
"views/autofill_assistant/password_change/assistant_onboarding_view.cc",
"views/autofill_assistant/password_change/assistant_onboarding_view.h",
"views/autofill_assistant/password_change/assistant_side_panel_coordinator_impl.cc",
"views/autofill_assistant/password_change/assistant_side_panel_coordinator_impl.h",
+ "views/autofill_assistant/password_change/password_change_animated_icon.cc",
+ "views/autofill_assistant/password_change/password_change_animated_icon.h",
+ "views/autofill_assistant/password_change/password_change_animated_progress_bar.cc",
+ "views/autofill_assistant/password_change/password_change_animated_progress_bar.h",
"views/autofill_assistant/password_change/password_change_run_display.cc",
+ "views/autofill_assistant/password_change/password_change_run_progress.cc",
+ "views/autofill_assistant/password_change/password_change_run_progress.h",
"views/autofill_assistant/password_change/password_change_run_view.cc",
"views/autofill_assistant/password_change/password_change_run_view.h",
"views/bookmarks/bookmark_bar_view.cc",
@@ -4233,6 +4311,8 @@ static_library("ui") {
"views/chrome_web_dialog_view.h",
"views/collected_cookies_views.cc",
"views/collected_cookies_views.h",
+ "views/color_provider_browser_helper.cc",
+ "views/color_provider_browser_helper.h",
"views/commander_frontend_views.cc",
"views/commander_frontend_views.h",
"views/commerce/ntp_discount_consent_dialog_view.cc",
@@ -4288,8 +4368,6 @@ static_library("ui") {
"views/exclusive_access_bubble_views.cc",
"views/exclusive_access_bubble_views.h",
"views/exclusive_access_bubble_views_context.h",
- "views/extensions/blocked_action_dialog_view.cc",
- "views/extensions/blocked_action_dialog_view.h",
"views/extensions/chooser_dialog_view.cc",
"views/extensions/chooser_dialog_view.h",
"views/extensions/expandable_container_view.cc",
@@ -4322,6 +4400,8 @@ static_library("ui") {
"views/extensions/extensions_request_access_button_hover_card.h",
"views/extensions/extensions_request_access_dialog_view.cc",
"views/extensions/extensions_request_access_dialog_view.h",
+ "views/extensions/extensions_tabbed_menu_coordinator.cc",
+ "views/extensions/extensions_tabbed_menu_coordinator.h",
"views/extensions/extensions_tabbed_menu_view.cc",
"views/extensions/extensions_tabbed_menu_view.h",
"views/extensions/extensions_toolbar_button.cc",
@@ -4330,8 +4410,12 @@ static_library("ui") {
"views/extensions/extensions_toolbar_container.h",
"views/extensions/extensions_toolbar_controls.cc",
"views/extensions/extensions_toolbar_controls.h",
+ "views/extensions/reload_page_dialog_view.cc",
+ "views/extensions/reload_page_dialog_view.h",
"views/extensions/site_settings_expand_button.cc",
"views/extensions/site_settings_expand_button.h",
+ "views/file_system_access/file_system_access_dangerous_file_dialog_view.cc",
+ "views/file_system_access/file_system_access_dangerous_file_dialog_view.h",
"views/file_system_access/file_system_access_icon_view.cc",
"views/file_system_access/file_system_access_icon_view.h",
"views/file_system_access/file_system_access_permission_view.cc",
@@ -4379,6 +4463,8 @@ static_library("ui") {
"views/frame/native_browser_frame.h",
"views/frame/native_browser_frame_factory.cc",
"views/frame/native_browser_frame_factory.h",
+ "views/frame/picture_in_picture_browser_frame_view.cc",
+ "views/frame/picture_in_picture_browser_frame_view.h",
"views/frame/system_menu_model_builder.cc",
"views/frame/system_menu_model_builder.h",
"views/frame/system_menu_model_delegate.cc",
@@ -4426,6 +4512,8 @@ static_library("ui") {
"views/importer/import_lock_dialog_view.h",
"views/incognito_clear_browsing_data_dialog.cc",
"views/incognito_clear_browsing_data_dialog.h",
+ "views/incognito_clear_browsing_data_dialog_coordinator.cc",
+ "views/incognito_clear_browsing_data_dialog_coordinator.h",
"views/infobars/alternate_nav_infobar_view.cc",
"views/infobars/alternate_nav_infobar_view.h",
"views/infobars/confirm_infobar.cc",
@@ -4467,13 +4555,6 @@ static_library("ui") {
"views/location_bar/omnibox_chip_button.cc",
"views/location_bar/omnibox_chip_button.h",
"views/location_bar/omnibox_chip_theme.h",
- "views/location_bar/permission_chip.cc",
- "views/location_bar/permission_chip.h",
- "views/location_bar/permission_chip_delegate.h",
- "views/location_bar/permission_quiet_chip.cc",
- "views/location_bar/permission_quiet_chip.h",
- "views/location_bar/permission_request_chip.cc",
- "views/location_bar/permission_request_chip.h",
"views/location_bar/selected_keyword_view.cc",
"views/location_bar/selected_keyword_view.h",
"views/location_bar/star_view.cc",
@@ -4487,6 +4568,8 @@ static_library("ui") {
"views/md_text_button_with_down_arrow.h",
"views/media_router/cast_dialog_access_code_cast_button.cc",
"views/media_router/cast_dialog_access_code_cast_button.h",
+ "views/media_router/cast_dialog_coordinator.cc",
+ "views/media_router/cast_dialog_coordinator.h",
"views/media_router/cast_dialog_helper.cc",
"views/media_router/cast_dialog_helper.h",
"views/media_router/cast_dialog_metrics.cc",
@@ -4575,6 +4658,10 @@ static_library("ui") {
"views/page_action/pwa_install_view.h",
"views/page_action/zoom_view.cc",
"views/page_action/zoom_view.h",
+ "views/page_info/about_this_site_side_panel_coordinator.cc",
+ "views/page_info/about_this_site_side_panel_coordinator.h",
+ "views/page_info/about_this_site_side_panel_view.cc",
+ "views/page_info/about_this_site_side_panel_view.h",
"views/page_info/accuracy_tip_bubble_view.cc",
"views/page_info/accuracy_tip_bubble_view.h",
"views/page_info/chosen_object_view.cc",
@@ -4588,6 +4675,8 @@ static_library("ui") {
"views/page_info/page_info_bubble_view.h",
"views/page_info/page_info_bubble_view_base.cc",
"views/page_info/page_info_bubble_view_base.h",
+ "views/page_info/page_info_cookies_content_view.cc",
+ "views/page_info/page_info_cookies_content_view.h",
"views/page_info/page_info_history_controller.cc",
"views/page_info/page_info_history_controller.h",
"views/page_info/page_info_hover_button.cc",
@@ -4646,10 +4735,6 @@ static_library("ui") {
"views/passwords/views_utils.h",
"views/payments/contact_info_editor_view_controller.cc",
"views/payments/contact_info_editor_view_controller.h",
- "views/payments/credit_card_editor_view_controller.cc",
- "views/payments/credit_card_editor_view_controller.h",
- "views/payments/cvc_unmask_view_controller.cc",
- "views/payments/cvc_unmask_view_controller.h",
"views/payments/editor_view_controller.cc",
"views/payments/editor_view_controller.h",
"views/payments/error_message_view_controller.cc",
@@ -4695,12 +4780,26 @@ static_library("ui") {
"views/payments/validation_delegate.h",
"views/payments/view_stack.cc",
"views/payments/view_stack.h",
- "views/permission_bubble/chooser_bubble_ui.cc",
- "views/permission_bubble/permission_prompt_bubble_view.cc",
- "views/permission_bubble/permission_prompt_bubble_view.h",
- "views/permission_bubble/permission_prompt_impl.cc",
- "views/permission_bubble/permission_prompt_impl.h",
- "views/permission_bubble/permission_prompt_style.h",
+ "views/permissions/chooser_bubble_ui.cc",
+ "views/permissions/permission_chip.cc",
+ "views/permissions/permission_chip.h",
+ "views/permissions/permission_chip_delegate.h",
+ "views/permissions/permission_prompt_bubble.cc",
+ "views/permissions/permission_prompt_bubble.h",
+ "views/permissions/permission_prompt_bubble_view.cc",
+ "views/permissions/permission_prompt_bubble_view.h",
+ "views/permissions/permission_prompt_chip.cc",
+ "views/permissions/permission_prompt_chip.h",
+ "views/permissions/permission_prompt_desktop.cc",
+ "views/permissions/permission_prompt_desktop.h",
+ "views/permissions/permission_prompt_factory.cc",
+ "views/permissions/permission_prompt_quiet_icon.cc",
+ "views/permissions/permission_prompt_quiet_icon.h",
+ "views/permissions/permission_prompt_style.h",
+ "views/permissions/permission_quiet_chip.cc",
+ "views/permissions/permission_quiet_chip.h",
+ "views/permissions/permission_request_chip.cc",
+ "views/permissions/permission_request_chip.h",
"views/profiles/avatar_toolbar_button.cc",
"views/profiles/avatar_toolbar_button.h",
"views/profiles/avatar_toolbar_button_delegate.cc",
@@ -4727,6 +4826,8 @@ static_library("ui") {
"views/safe_browsing/password_reuse_modal_warning_dialog.h",
"views/safe_browsing/prompt_for_scanning_modal_dialog.cc",
"views/safe_browsing/prompt_for_scanning_modal_dialog.h",
+ "views/safe_browsing/tailored_security_desktop_dialog.cc",
+ "views/safe_browsing/tailored_security_desktop_dialog.h",
"views/safe_browsing/tailored_security_unconsented_modal.cc",
"views/safe_browsing/tailored_security_unconsented_modal.h",
"views/send_tab_to_self/manage_account_devices_link_view.cc",
@@ -4757,18 +4858,21 @@ static_library("ui") {
"views/sharing_hub/sharing_hub_bubble_action_button.h",
"views/sharing_hub/sharing_hub_bubble_util.cc",
"views/sharing_hub/sharing_hub_bubble_util.h",
- "views/sharing_hub/sharing_hub_bubble_view_impl.cc",
- "views/sharing_hub/sharing_hub_bubble_view_impl.h",
"views/sharing_hub/sharing_hub_icon_view.cc",
"views/sharing_hub/sharing_hub_icon_view.h",
"views/shopping_bubble/shopping_prompt_impl.cc",
"views/shopping_bubble/shopping_prompt_impl.h",
"views/side_panel/bookmarks/bookmarks_side_panel_coordinator.cc",
"views/side_panel/bookmarks/bookmarks_side_panel_coordinator.h",
+ "views/side_panel/customize_chrome/customize_chrome_side_panel_controller.cc",
+ "views/side_panel/customize_chrome/customize_chrome_side_panel_controller.h",
+ "views/side_panel/customize_chrome/customize_chrome_side_panel_controller_utils.cc",
"views/side_panel/feed/feed_side_panel_coordinator.cc",
"views/side_panel/feed/feed_side_panel_coordinator.h",
"views/side_panel/history_clusters/history_clusters_side_panel_coordinator.cc",
"views/side_panel/history_clusters/history_clusters_side_panel_coordinator.h",
+ "views/side_panel/read_anything/read_anything_button_view.cc",
+ "views/side_panel/read_anything/read_anything_button_view.h",
"views/side_panel/read_anything/read_anything_constants.h",
"views/side_panel/read_anything/read_anything_container_view.cc",
"views/side_panel/read_anything/read_anything_container_view.h",
@@ -4776,6 +4880,8 @@ static_library("ui") {
"views/side_panel/read_anything/read_anything_controller.h",
"views/side_panel/read_anything/read_anything_coordinator.cc",
"views/side_panel/read_anything/read_anything_coordinator.h",
+ "views/side_panel/read_anything/read_anything_font_combobox.cc",
+ "views/side_panel/read_anything/read_anything_font_combobox.h",
"views/side_panel/read_anything/read_anything_model.cc",
"views/side_panel/read_anything/read_anything_model.h",
"views/side_panel/read_anything/read_anything_toolbar_view.cc",
@@ -4798,8 +4904,11 @@ static_library("ui") {
"views/side_panel/side_panel_registry.cc",
"views/side_panel/side_panel_registry.h",
"views/side_panel/side_panel_registry_observer.h",
+ "views/side_panel/side_panel_resize_area.cc",
+ "views/side_panel/side_panel_resize_area.h",
"views/side_panel/side_panel_util.cc",
"views/side_panel/side_panel_util.h",
+ "views/side_panel/side_panel_view_state_observer.h",
"views/side_panel/side_panel_web_ui_view.cc",
"views/side_panel/side_panel_web_ui_view.h",
"views/side_panel/user_note/user_note_ui_coordinator.cc",
@@ -4812,6 +4921,17 @@ static_library("ui") {
"views/side_search/side_search_browser_controller.h",
"views/side_search/side_search_icon_view.cc",
"views/side_search/side_search_icon_view.h",
+ "views/side_search/side_search_views_utils.cc",
+ "views/side_search/side_search_views_utils.h",
+ "views/side_search/unified_side_search_controller.cc",
+ "views/side_search/unified_side_search_controller.h",
+ "views/side_search/unified_side_search_helper.cc",
+ "views/site_data/page_specific_site_data_dialog.cc",
+ "views/site_data/page_specific_site_data_dialog.h",
+ "views/site_data/page_specific_site_data_dialog_controller.cc",
+ "views/site_data/page_specific_site_data_dialog_controller.h",
+ "views/site_data/site_data_row_view.cc",
+ "views/site_data/site_data_row_view.h",
"views/ssl_client_certificate_selector.cc",
"views/ssl_client_certificate_selector.h",
"views/status_bubble_views.cc",
@@ -4850,8 +4970,10 @@ static_library("ui") {
"views/tabs/tab.h",
"views/tabs/tab_close_button.cc",
"views/tabs/tab_close_button.h",
- "views/tabs/tab_container.cc",
"views/tabs/tab_container.h",
+ "views/tabs/tab_container_controller.h",
+ "views/tabs/tab_container_impl.cc",
+ "views/tabs/tab_container_impl.h",
"views/tabs/tab_drag_context.h",
"views/tabs/tab_drag_controller.cc",
"views/tabs/tab_drag_controller.h",
@@ -4898,6 +5020,8 @@ static_library("ui") {
"views/tabs/tab_width_constraints.h",
"views/tabs/window_finder.cc",
"views/tabs/window_finder.h",
+ "views/tabs/z_orderable_tab_container_element.cc",
+ "views/tabs/z_orderable_tab_container_element.h",
"views/task_manager_view.cc",
"views/task_manager_view.h",
"views/theme_copying_widget.cc",
@@ -5045,7 +5169,6 @@ static_library("ui") {
deps += [
"side_search:side_search_tab_data_proto",
- "side_search:side_search_window_data_proto",
"//base",
"//chrome/browser/ui/views",
"//components/commerce/core:public",
@@ -5117,7 +5240,6 @@ static_library("ui") {
}
if (is_fuchsia) {
sources += [
- "views/certificate_viewer_fuchsia.cc",
"views/chrome_views_delegate_fuchsia.cc",
"views/frame/browser_desktop_window_tree_host.h",
"views/frame/browser_desktop_window_tree_host_fuchsia.cc",
@@ -5222,6 +5344,8 @@ static_library("ui") {
"views/frame/opaque_browser_frame_view_layout.h",
"views/frame/opaque_browser_frame_view_layout_delegate.cc",
"views/frame/opaque_browser_frame_view_layout_delegate.h",
+ "views/sharing_hub/sharing_hub_bubble_view_impl.cc",
+ "views/sharing_hub/sharing_hub_bubble_view_impl.h",
]
deps += [ "//ui/views/window/vector_icons" ]
}
@@ -5243,6 +5367,10 @@ static_library("ui") {
"views/lens/lens_side_panel_helper.cc",
"views/lens/lens_side_panel_view.cc",
"views/lens/lens_side_panel_view.h",
+ "views/side_panel/lens/lens_side_panel_coordinator.cc",
+ "views/side_panel/lens/lens_side_panel_coordinator.h",
+ "views/side_panel/lens/lens_unified_side_panel_view.cc",
+ "views/side_panel/lens/lens_unified_side_panel_view.h",
]
deps += [ "//chrome/browser/ui/media_router/internal/vector_icons" ]
}
@@ -5376,8 +5504,8 @@ static_library("ui") {
"views/extensions/media_galleries_dialog_views.h",
"views/extensions/media_gallery_checkbox_view.cc",
"views/extensions/media_gallery_checkbox_view.h",
- "views/extensions/settings_overridden_dialog_view.cc",
- "views/extensions/settings_overridden_dialog_view.h",
+ "views/extensions/settings_overridden_dialog.cc",
+ "views/extensions/settings_overridden_dialog.h",
"views/javascript_app_modal_event_blocker.h",
"web_applications/app_browser_controller.cc",
"web_applications/app_browser_controller.h",
@@ -5387,9 +5515,6 @@ static_library("ui") {
"web_applications/share_target_utils.h",
"web_applications/sub_apps_service_impl.cc",
"web_applications/sub_apps_service_impl.h",
- "web_applications/system_web_app_delegate_ui_impl.cc",
- "web_applications/system_web_app_ui_utils.cc",
- "web_applications/system_web_app_ui_utils.h",
"web_applications/web_app_browser_controller.cc",
"web_applications/web_app_browser_controller.h",
"web_applications/web_app_dialog_manager.cc",
@@ -5410,6 +5535,8 @@ static_library("ui") {
"web_applications/web_app_metrics_factory.h",
"web_applications/web_app_metrics_tab_helper.cc",
"web_applications/web_app_metrics_tab_helper.h",
+ "web_applications/web_app_tabbed_utils.cc",
+ "web_applications/web_app_tabbed_utils.h",
"web_applications/web_app_ui_manager_impl.cc",
"web_applications/web_app_ui_manager_impl.h",
"web_applications/web_app_ui_utils.cc",
@@ -5421,6 +5548,12 @@ static_library("ui") {
"webui/extensions/extension_icon_source.h",
]
+ if (is_chromeos_ash) {
+ deps += [ "//chrome/browser/ui/ash/system_web_apps" ]
+ allow_circular_includes_from +=
+ [ "//chrome/browser/ui/ash/system_web_apps" ]
+ }
+
if (is_mac) {
sources += [ "views/javascript_app_modal_event_blocker_mac.h" ]
} else {
@@ -5454,10 +5587,6 @@ static_library("ui") {
"hung_plugin_tab_helper.cc",
"hung_plugin_tab_helper.h",
]
- deps += [
- "//ppapi/c",
- "//ppapi/proxy:ipc",
- ]
}
if (enable_basic_printing) {
@@ -5614,12 +5743,6 @@ static_library("test_support") {
"find_bar/find_bar_host_unittest_util.h",
"login/login_handler_test_utils.cc",
"login/login_handler_test_utils.h",
- "passwords/settings/password_ui_view_mock.cc",
- "passwords/settings/password_ui_view_mock.h",
- "toolbar/test_toolbar_action_view_controller.cc",
- "toolbar/test_toolbar_action_view_controller.h",
- "toolbar/test_toolbar_actions_bar_bubble_delegate.cc",
- "toolbar/test_toolbar_actions_bar_bubble_delegate.h",
]
public_deps = [ ":ui" ]
deps = [
@@ -5687,14 +5810,20 @@ static_library("test_support") {
if (!is_android) {
sources += [
+ "autofill_assistant/password_change/mock_apc_scrim_manager.cc",
+ "autofill_assistant/password_change/mock_apc_scrim_manager.h",
"autofill_assistant/password_change/mock_assistant_display_delegate.cc",
"autofill_assistant/password_change/mock_assistant_display_delegate.h",
"autofill_assistant/password_change/mock_assistant_onboarding_controller.cc",
"autofill_assistant/password_change/mock_assistant_onboarding_controller.h",
"autofill_assistant/password_change/mock_assistant_onboarding_prompt.cc",
"autofill_assistant/password_change/mock_assistant_onboarding_prompt.h",
+ "autofill_assistant/password_change/mock_assistant_side_panel_coordinator.cc",
+ "autofill_assistant/password_change/mock_assistant_side_panel_coordinator.h",
"autofill_assistant/password_change/mock_password_change_run_controller.cc",
"autofill_assistant/password_change/mock_password_change_run_controller.h",
+ "autofill_assistant/password_change/mock_password_change_run_display.cc",
+ "autofill_assistant/password_change/mock_password_change_run_display.h",
"exclusive_access/exclusive_access_test.cc",
"exclusive_access/exclusive_access_test.h",
"exclusive_access/fullscreen_controller_state_test.cc",
@@ -5725,6 +5854,7 @@ static_library("test_support") {
]
deps += [
"//chrome/test:test_support_ui",
+ "//components/autofill_assistant/browser/public/password_change/proto:proto",
"//components/media_message_center:media_message_center",
"//components/media_router/browser:browser",
"//components/signin/core/browser",
@@ -5757,12 +5887,18 @@ static_library("test_support") {
]
deps += [
"//ash/public/cpp",
- "//chromeos/dbus",
+ "//chromeos/ash/components/dbus",
"//chromeos/ui/base",
]
}
if (enable_extensions) {
+ sources += [
+ "toolbar/test_toolbar_action_view_controller.cc",
+ "toolbar/test_toolbar_action_view_controller.h",
+ "toolbar/test_toolbar_actions_bar_bubble_delegate.cc",
+ "toolbar/test_toolbar_actions_bar_bubble_delegate.h",
+ ]
deps += [ "//extensions/browser" ]
}
}
diff --git a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
index 7a8f3befd96..b86e1c435d4 100644
--- a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
@@ -58,7 +58,7 @@ android_resources("java_resources") {
]
}
-android_library("javatests") {
+android_library("unit_device_javatests") {
testonly = true
resources_package = "org.chromium.chrome.browser.ui.appmenu.test"
@@ -78,7 +78,7 @@ android_library("javatests") {
"//chrome/browser/flags:java",
"//chrome/browser/ui/android/appmenu:java",
"//chrome/browser/ui/android/appmenu/test:test_support_java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_integration_test_support",
"//components/browser_ui/widget/android:java",
"//components/browser_ui/widget/android:test_support_java",
"//content/public/test/android:content_java_test_support",
@@ -99,30 +99,22 @@ android_resources("test_java_resources") {
testonly = true
sources = [
- "test/java/res/drawable/test_ic_arrow_downward_black_24dp.xml",
- "test/java/res/drawable/test_ic_arrow_forward_black_24dp.xml",
- "test/java/res/drawable/test_ic_info_outline_black_24dp.xml",
- "test/java/res/drawable/test_ic_more_vert_black_24dp.xml",
- "test/java/res/drawable/test_ic_refresh_black_24dp.xml",
- "test/java/res/drawable/test_ic_star_border_black_24dp.xml",
- "test/java/res/drawable/test_ic_vintage_filter.xml",
"test/java/res/layout/test_app_menu_activity_layout.xml",
"test/java/res/layout/test_menu_footer.xml",
"test/java/res/layout/test_menu_header.xml",
"test/java/res/menu/test_menu.xml",
]
- deps = [ ":java_resources" ]
+ deps = [
+ ":java_resources",
+ "//components/browser_ui/widget/android:java_test_resources",
+ ]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
+robolectric_library("junit") {
sources = [ "java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuPopupPositionTest.java" ]
deps = [
":java",
"//base:base_junit_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
diff --git a/chromium/chrome/browser/ui/android/autofill/internal/BUILD.gn b/chromium/chrome/browser/ui/android/autofill/internal/BUILD.gn
index 8223699ec21..49543b2d321 100644
--- a/chromium/chrome/browser/ui/android/autofill/internal/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/autofill/internal/BUILD.gn
@@ -53,10 +53,7 @@ generate_jni("jni_headers") {
]
}
-android_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/ui/autofill/AuthenticatorSelectionDialogBridgeTest.java",
"java/src/org/chromium/chrome/browser/ui/autofill/AuthenticatorSelectionDialogTest.java",
diff --git a/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn b/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
index 6f28d07724e..f303b9e4038 100644
--- a/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
@@ -22,16 +22,12 @@ android_library("java") {
resources_package = "org.chromium.chrome.browser.ui.default_browser_promo"
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
+robolectric_library("junit") {
sources = [ "java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoUtilsTest.java" ]
deps = [
":java",
"//base:base_java",
"//base:base_junit_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
diff --git a/chromium/chrome/browser/ui/android/fast_checkout/BUILD.gn b/chromium/chrome/browser/ui/android/fast_checkout/BUILD.gn
new file mode 100644
index 00000000000..906ddeeae79
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/fast_checkout/BUILD.gn
@@ -0,0 +1,50 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/android/rules.gni")
+
+android_library("java") {
+ deps = [
+ "//base:jni_java",
+ "//components/autofill/android:autofill_payments_java_resources",
+ "//components/autofill/android:main_autofill_java",
+ "//components/browser_ui/bottomsheet/android:java",
+ "//components/payments/content/android:java_resources",
+ "//url:gurl_java",
+ ]
+ sources = [
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutComponent.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/data/FastCheckoutAutofillProfile.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/data/FastCheckoutCreditCard.java",
+ ]
+ resources_package = "org.chromium.chrome.browser.ui.fast_checkout"
+}
+
+generate_jni("jni_headers") {
+ sources = [
+ "internal/java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutBridge.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/data/FastCheckoutAutofillProfile.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/data/FastCheckoutCreditCard.java",
+ ]
+}
+
+robolectric_library("junit") {
+ testonly = true
+
+ sources = [ "junit/java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutControllerTest.java" ]
+ deps = [
+ ":java",
+ "//base:base_junit_test_support",
+ "//chrome/browser/ui/android/fast_checkout/internal:java",
+ "//components/autofill/android:main_autofill_java",
+ "//components/autofill_assistant/android:public_java",
+ "//components/browser_ui/bottomsheet/android:java",
+ "//third_party/androidx:androidx_recyclerview_recyclerview_java",
+ "//third_party/hamcrest:hamcrest_library_java",
+ "//third_party/junit:junit",
+ "//third_party/mockito:mockito_java",
+ "//ui/android:ui_java_test_support",
+ "//ui/android:ui_no_recycler_view_java",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/android/fast_checkout/internal/BUILD.gn b/chromium/chrome/browser/ui/android/fast_checkout/internal/BUILD.gn
new file mode 100644
index 00000000000..5d29064f14f
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/fast_checkout/internal/BUILD.gn
@@ -0,0 +1,51 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/android/rules.gni")
+import("//build/config/locales.gni")
+import("//chrome/common/features.gni")
+import("//tools/grit/grit_rule.gni")
+
+android_library("java") {
+ sources = [
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutBridge.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutCoordinator.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutMediator.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutModel.java",
+ "java/src/org/chromium/chrome/browser/ui/fast_checkout/FastCheckoutSheetContent.java",
+ ]
+ deps = [
+ ":java_resources",
+ "//base:base_java",
+ "//base:jni_java",
+ "//build/android:build_java",
+ "//chrome/browser/ui/android/fast_checkout:java",
+ "//chrome/browser/ui/android/strings:ui_strings_grd",
+ "//components/autofill_assistant/android:public_java",
+ "//components/browser_ui/bottomsheet/android:java",
+ "//components/browser_ui/strings/android:browser_ui_strings_grd",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//ui/android:ui_no_recycler_view_java",
+ ]
+ annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
+ resources_package = "org.chromium.chrome.browser.ui.fast_checkout"
+}
+
+android_resources("java_resources") {
+ deps = [
+ ":java_strings_grd",
+ "//ui/android:ui_java_resources",
+ ]
+ custom_package = "org.chromium.chrome.browser.ui.fast_checkout"
+}
+
+java_strings_grd("java_strings_grd") {
+ defines = chrome_grit_defines
+ grd_file = "java/strings/android_fast_checkout_strings.grd"
+ outputs =
+ [ "values/android_fast_checkout_strings.xml" ] +
+ process_file_template(
+ android_bundle_locales_as_resources,
+ [ "values-{{source_name_part}}/android_fast_checkout_strings.xml" ])
+}
diff --git a/chromium/chrome/browser/ui/android/fast_checkout/internal/java/strings/android_fast_checkout_strings.grd b/chromium/chrome/browser/ui/android/fast_checkout/internal/java/strings/android_fast_checkout_strings.grd
new file mode 100644
index 00000000000..a3e83afa5f6
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/fast_checkout/internal/java/strings/android_fast_checkout_strings.grd
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2022 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file. -->
+
+<grit current_release="1" latest_public_release="0" output_all_resource_defines="false">
+ <outputs>
+ <output filename="values-af/android_fast_checkout_strings.xml" lang="af" type="android" />
+ <output filename="values-am/android_fast_checkout_strings.xml" lang="am" type="android" />
+ <output filename="values-ar/android_fast_checkout_strings.xml" lang="ar" type="android" />
+ <output filename="values-as/android_fast_checkout_strings.xml" lang="as" type="android" />
+ <output filename="values-az/android_fast_checkout_strings.xml" lang="az" type="android" />
+ <output filename="values-be/android_fast_checkout_strings.xml" lang="be" type="android" />
+ <output filename="values-bg/android_fast_checkout_strings.xml" lang="bg" type="android" />
+ <output filename="values-bn/android_fast_checkout_strings.xml" lang="bn" type="android" />
+ <output filename="values-bs/android_fast_checkout_strings.xml" lang="bs" type="android" />
+ <output filename="values-ca/android_fast_checkout_strings.xml" lang="ca" type="android" />
+ <output filename="values-cs/android_fast_checkout_strings.xml" lang="cs" type="android" />
+ <output filename="values-da/android_fast_checkout_strings.xml" lang="da" type="android" />
+ <output filename="values-de/android_fast_checkout_strings.xml" lang="de" type="android" />
+ <output filename="values-el/android_fast_checkout_strings.xml" lang="el" type="android" />
+ <output filename="values/android_fast_checkout_strings.xml" lang="en" type="android" />
+ <output filename="values-en-rGB/android_fast_checkout_strings.xml" lang="en-GB" type="android" />
+ <output filename="values-es/android_fast_checkout_strings.xml" lang="es" type="android" />
+ <output filename="values-es-rUS/android_fast_checkout_strings.xml" lang="es-419" type="android" />
+ <output filename="values-et/android_fast_checkout_strings.xml" lang="et" type="android" />
+ <output filename="values-eu/android_fast_checkout_strings.xml" lang="eu" type="android" />
+ <output filename="values-fa/android_fast_checkout_strings.xml" lang="fa" type="android" />
+ <output filename="values-fi/android_fast_checkout_strings.xml" lang="fi" type="android" />
+ <output filename="values-tl/android_fast_checkout_strings.xml" lang="fil" type="android" />
+ <output filename="values-fr/android_fast_checkout_strings.xml" lang="fr" type="android" />
+ <output filename="values-fr-rCA/android_fast_checkout_strings.xml" lang="fr-CA" type="android" />
+ <output filename="values-gl/android_fast_checkout_strings.xml" lang="gl" type="android" />
+ <output filename="values-gu/android_fast_checkout_strings.xml" lang="gu" type="android" />
+ <output filename="values-hi/android_fast_checkout_strings.xml" lang="hi" type="android" />
+ <output filename="values-hr/android_fast_checkout_strings.xml" lang="hr" type="android" />
+ <output filename="values-hu/android_fast_checkout_strings.xml" lang="hu" type="android" />
+ <output filename="values-hy/android_fast_checkout_strings.xml" lang="hy" type="android" />
+ <output filename="values-in/android_fast_checkout_strings.xml" lang="id" type="android" />
+ <output filename="values-is/android_fast_checkout_strings.xml" lang="is" type="android" />
+ <output filename="values-it/android_fast_checkout_strings.xml" lang="it" type="android" />
+ <output filename="values-iw/android_fast_checkout_strings.xml" lang="iw" type="android" />
+ <output filename="values-ja/android_fast_checkout_strings.xml" lang="ja" type="android" />
+ <output filename="values-ka/android_fast_checkout_strings.xml" lang="ka" type="android" />
+ <output filename="values-kk/android_fast_checkout_strings.xml" lang="kk" type="android" />
+ <output filename="values-km/android_fast_checkout_strings.xml" lang="km" type="android" />
+ <output filename="values-kn/android_fast_checkout_strings.xml" lang="kn" type="android" />
+ <output filename="values-ko/android_fast_checkout_strings.xml" lang="ko" type="android" />
+ <output filename="values-ky/android_fast_checkout_strings.xml" lang="ky" type="android" />
+ <output filename="values-lo/android_fast_checkout_strings.xml" lang="lo" type="android" />
+ <output filename="values-lt/android_fast_checkout_strings.xml" lang="lt" type="android" />
+ <output filename="values-lv/android_fast_checkout_strings.xml" lang="lv" type="android" />
+ <output filename="values-mk/android_fast_checkout_strings.xml" lang="mk" type="android" />
+ <output filename="values-ml/android_fast_checkout_strings.xml" lang="ml" type="android" />
+ <output filename="values-mn/android_fast_checkout_strings.xml" lang="mn" type="android" />
+ <output filename="values-mr/android_fast_checkout_strings.xml" lang="mr" type="android" />
+ <output filename="values-ms/android_fast_checkout_strings.xml" lang="ms" type="android" />
+ <output filename="values-my/android_fast_checkout_strings.xml" lang="my" type="android" />
+ <output filename="values-ne/android_fast_checkout_strings.xml" lang="ne" type="android" />
+ <output filename="values-nl/android_fast_checkout_strings.xml" lang="nl" type="android" />
+ <output filename="values-nb/android_fast_checkout_strings.xml" lang="no" type="android" />
+ <output filename="values-or/android_fast_checkout_strings.xml" lang="or" type="android" />
+ <output filename="values-pa/android_fast_checkout_strings.xml" lang="pa" type="android" />
+ <output filename="values-pl/android_fast_checkout_strings.xml" lang="pl" type="android" />
+ <output filename="values-pt-rBR/android_fast_checkout_strings.xml" lang="pt-BR" type="android" />
+ <output filename="values-pt-rPT/android_fast_checkout_strings.xml" lang="pt-PT" type="android" />
+ <output filename="values-ro/android_fast_checkout_strings.xml" lang="ro" type="android" />
+ <output filename="values-ru/android_fast_checkout_strings.xml" lang="ru" type="android" />
+ <output filename="values-si/android_fast_checkout_strings.xml" lang="si" type="android" />
+ <output filename="values-sk/android_fast_checkout_strings.xml" lang="sk" type="android" />
+ <output filename="values-sl/android_fast_checkout_strings.xml" lang="sl" type="android" />
+ <output filename="values-sq/android_fast_checkout_strings.xml" lang="sq" type="android" />
+ <output filename="values-sr/android_fast_checkout_strings.xml" lang="sr" type="android" />
+ <output filename="values-b+sr+Latn/android_fast_checkout_strings.xml" lang="sr-Latn" type="android" />
+ <output filename="values-sv/android_fast_checkout_strings.xml" lang="sv" type="android" />
+ <output filename="values-sw/android_fast_checkout_strings.xml" lang="sw" type="android" />
+ <output filename="values-ta/android_fast_checkout_strings.xml" lang="ta" type="android" />
+ <output filename="values-te/android_fast_checkout_strings.xml" lang="te" type="android" />
+ <output filename="values-th/android_fast_checkout_strings.xml" lang="th" type="android" />
+ <output filename="values-tr/android_fast_checkout_strings.xml" lang="tr" type="android" />
+ <output filename="values-uk/android_fast_checkout_strings.xml" lang="uk" type="android" />
+ <output filename="values-ur/android_fast_checkout_strings.xml" lang="ur" type="android" />
+ <output filename="values-uz/android_fast_checkout_strings.xml" lang="uz" type="android" />
+ <output filename="values-vi/android_fast_checkout_strings.xml" lang="vi" type="android" />
+ <output filename="values-zh-rCN/android_fast_checkout_strings.xml" lang="zh-CN" type="android" />
+ <output filename="values-zh-rHK/android_fast_checkout_strings.xml" lang="zh-HK" type="android" />
+ <output filename="values-zh-rTW/android_fast_checkout_strings.xml" lang="zh-TW" type="android" />
+ <output filename="values-zu/android_fast_checkout_strings.xml" lang="zu" type="android" />
+ <!-- Pseudolocales -->
+ <output filename="values-ar-rXB/android_fast_checkout_strings.xml" lang="ar-XB" type="android" />
+ <output filename="values-en-rXA/android_fast_checkout_strings.xml" lang="en-XA" type="android" />
+ </outputs>
+ <translations>
+ <file path="translations/android_fast_checkout_strings_af.xtb" lang="af"/>
+ <file path="translations/android_fast_checkout_strings_am.xtb" lang="am"/>
+ <file path="translations/android_fast_checkout_strings_ar.xtb" lang="ar"/>
+ <file path="translations/android_fast_checkout_strings_as.xtb" lang="as"/>
+ <file path="translations/android_fast_checkout_strings_az.xtb" lang="az"/>
+ <file path="translations/android_fast_checkout_strings_be.xtb" lang="be"/>
+ <file path="translations/android_fast_checkout_strings_bg.xtb" lang="bg"/>
+ <file path="translations/android_fast_checkout_strings_bn.xtb" lang="bn"/>
+ <file path="translations/android_fast_checkout_strings_bs.xtb" lang="bs"/>
+ <file path="translations/android_fast_checkout_strings_ca.xtb" lang="ca"/>
+ <file path="translations/android_fast_checkout_strings_cs.xtb" lang="cs"/>
+ <file path="translations/android_fast_checkout_strings_cy.xtb" lang="cy"/>
+ <file path="translations/android_fast_checkout_strings_da.xtb" lang="da"/>
+ <file path="translations/android_fast_checkout_strings_de.xtb" lang="de"/>
+ <file path="translations/android_fast_checkout_strings_el.xtb" lang="el"/>
+ <file path="translations/android_fast_checkout_strings_en-GB.xtb" lang="en-GB"/>
+ <file path="translations/android_fast_checkout_strings_es.xtb" lang="es"/>
+ <file path="translations/android_fast_checkout_strings_es-419.xtb" lang="es-419"/>
+ <file path="translations/android_fast_checkout_strings_et.xtb" lang="et"/>
+ <file path="translations/android_fast_checkout_strings_eu.xtb" lang="eu"/>
+ <file path="translations/android_fast_checkout_strings_fa.xtb" lang="fa"/>
+ <file path="translations/android_fast_checkout_strings_fi.xtb" lang="fi"/>
+ <file path="translations/android_fast_checkout_strings_fil.xtb" lang="fil"/>
+ <file path="translations/android_fast_checkout_strings_fr.xtb" lang="fr"/>
+ <file path="translations/android_fast_checkout_strings_fr-CA.xtb" lang="fr-CA"/>
+ <file path="translations/android_fast_checkout_strings_gl.xtb" lang="gl"/>
+ <file path="translations/android_fast_checkout_strings_gu.xtb" lang="gu"/>
+ <file path="translations/android_fast_checkout_strings_hi.xtb" lang="hi"/>
+ <file path="translations/android_fast_checkout_strings_hr.xtb" lang="hr"/>
+ <file path="translations/android_fast_checkout_strings_hu.xtb" lang="hu"/>
+ <file path="translations/android_fast_checkout_strings_hy.xtb" lang="hy"/>
+ <file path="translations/android_fast_checkout_strings_id.xtb" lang="id"/>
+ <file path="translations/android_fast_checkout_strings_is.xtb" lang="is"/>
+ <file path="translations/android_fast_checkout_strings_it.xtb" lang="it"/>
+ <file path="translations/android_fast_checkout_strings_iw.xtb" lang="iw"/>
+ <file path="translations/android_fast_checkout_strings_ja.xtb" lang="ja"/>
+ <file path="translations/android_fast_checkout_strings_ka.xtb" lang="ka"/>
+ <file path="translations/android_fast_checkout_strings_kk.xtb" lang="kk"/>
+ <file path="translations/android_fast_checkout_strings_km.xtb" lang="km"/>
+ <file path="translations/android_fast_checkout_strings_kn.xtb" lang="kn"/>
+ <file path="translations/android_fast_checkout_strings_ko.xtb" lang="ko"/>
+ <file path="translations/android_fast_checkout_strings_ky.xtb" lang="ky"/>
+ <file path="translations/android_fast_checkout_strings_lo.xtb" lang="lo"/>
+ <file path="translations/android_fast_checkout_strings_lt.xtb" lang="lt"/>
+ <file path="translations/android_fast_checkout_strings_lv.xtb" lang="lv"/>
+ <file path="translations/android_fast_checkout_strings_mk.xtb" lang="mk"/>
+ <file path="translations/android_fast_checkout_strings_ml.xtb" lang="ml"/>
+ <file path="translations/android_fast_checkout_strings_mn.xtb" lang="mn"/>
+ <file path="translations/android_fast_checkout_strings_mr.xtb" lang="mr"/>
+ <file path="translations/android_fast_checkout_strings_ms.xtb" lang="ms"/>
+ <file path="translations/android_fast_checkout_strings_my.xtb" lang="my"/>
+ <file path="translations/android_fast_checkout_strings_ne.xtb" lang="ne"/>
+ <file path="translations/android_fast_checkout_strings_nl.xtb" lang="nl"/>
+ <file path="translations/android_fast_checkout_strings_no.xtb" lang="no"/>
+ <file path="translations/android_fast_checkout_strings_or.xtb" lang="or"/>
+ <file path="translations/android_fast_checkout_strings_pa.xtb" lang="pa"/>
+ <file path="translations/android_fast_checkout_strings_pl.xtb" lang="pl"/>
+ <file path="translations/android_fast_checkout_strings_pt-BR.xtb" lang="pt-BR"/>
+ <file path="translations/android_fast_checkout_strings_pt-PT.xtb" lang="pt-PT"/>
+ <file path="translations/android_fast_checkout_strings_ro.xtb" lang="ro"/>
+ <file path="translations/android_fast_checkout_strings_ru.xtb" lang="ru"/>
+ <file path="translations/android_fast_checkout_strings_si.xtb" lang="si"/>
+ <file path="translations/android_fast_checkout_strings_sk.xtb" lang="sk"/>
+ <file path="translations/android_fast_checkout_strings_sl.xtb" lang="sl"/>
+ <file path="translations/android_fast_checkout_strings_sq.xtb" lang="sq"/>
+ <file path="translations/android_fast_checkout_strings_sr.xtb" lang="sr"/>
+ <file path="translations/android_fast_checkout_strings_sr-Latn.xtb" lang="sr-Latn"/>
+ <file path="translations/android_fast_checkout_strings_sv.xtb" lang="sv"/>
+ <file path="translations/android_fast_checkout_strings_sw.xtb" lang="sw"/>
+ <file path="translations/android_fast_checkout_strings_ta.xtb" lang="ta"/>
+ <file path="translations/android_fast_checkout_strings_te.xtb" lang="te"/>
+ <file path="translations/android_fast_checkout_strings_th.xtb" lang="th"/>
+ <file path="translations/android_fast_checkout_strings_tr.xtb" lang="tr"/>
+ <file path="translations/android_fast_checkout_strings_uk.xtb" lang="uk"/>
+ <file path="translations/android_fast_checkout_strings_ur.xtb" lang="ur"/>
+ <file path="translations/android_fast_checkout_strings_uz.xtb" lang="uz"/>
+ <file path="translations/android_fast_checkout_strings_vi.xtb" lang="vi"/>
+ <file path="translations/android_fast_checkout_strings_zh-CN.xtb" lang="zh-CN"/>
+ <file path="translations/android_fast_checkout_strings_zh-HK.xtb" lang="zh-HK"/>
+ <file path="translations/android_fast_checkout_strings_zh-TW.xtb" lang="zh-TW"/>
+ <file path="translations/android_fast_checkout_strings_zu.xtb" lang="zu"/>
+ </translations>
+ <release allow_pseudo="false" seq="1">
+ <messages fallback_to_english="true">
+ <!-- Fast Checkout -->
+ <message name="IDS_FAST_CHECKOUT_CONTENT_DESCRIPTION" desc="Accessibility string read when the Fast Checkout bottom sheet is opened. It describes the bottom sheet where a user can pick an address and payment option to fill during checkout flows">
+ List of addresses and payment options to be filled during checkout flows.
+ </message>
+ <message name="IDS_FAST_CHECKOUT_SHEET_HALF_HEIGHT" desc="Accessibility string read when the Fast Checkout bottom sheet showing a list of the user stored addresses and payment options is opened at half height. The sheet will occupy the bottom half the screen.">
+ List of addresses and payment options to be filled during checkout flows opened at half height.
+ </message>
+ <message name="IDS_FAST_CHECKOUT_SHEET_FULL_HEIGHT" desc="Accessibility string read when the Fast Checkout bottom sheet showing a list of the user stored addresses and payment options is opened at full height. The sheet will occupy the entire screen.">
+ List of addresses and payment options to be filled during checkout flows opened at full height.
+ </message>
+ <message name="IDS_FAST_CHECKOUT_SHEET_CLOSED" desc="Accessibility string read when the Fast Checkout bottom sheet showing a list of the user stored addresses and payment options is closed.">
+ List of addresses and payment options to be filled during checkout flows is closed.
+ </message>
+ </messages>
+ </release>
+</grit>
diff --git a/chromium/chrome/browser/ui/android/layouts/BUILD.gn b/chromium/chrome/browser/ui/android/layouts/BUILD.gn
index 76ea86beb3d..f7d4269c688 100644
--- a/chromium/chrome/browser/ui/android/layouts/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/layouts/BUILD.gn
@@ -52,11 +52,7 @@ generate_jni("layouts_jni_headers") {
]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
-
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/layouts/CompositorModelChangeProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/layouts/FilterLayoutStateObserverTest.java",
@@ -69,7 +65,6 @@ java_library("junit") {
"//base:base_java",
"//base:base_java_test_support",
"//base:base_junit_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
diff --git a/chromium/chrome/browser/ui/android/logo/BUILD.gn b/chromium/chrome/browser/ui/android/logo/BUILD.gn
index baac91089cd..c7b71a335ff 100644
--- a/chromium/chrome/browser/ui/android/logo/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/logo/BUILD.gn
@@ -55,32 +55,10 @@ android_resources("java_resources") {
deps = [ "//chrome/browser/ui/android/strings:ui_strings_grd" ]
}
-android_library("javatests") {
- testonly = true
- sources = [ "java/src/org/chromium/chrome/browser/logo/LogoViewTest.java" ]
-
- deps = [
- ":java",
- "//base:base_java_test_support",
- "//chrome/browser/search_engines/android:java",
- "//chrome/test/android:chrome_java_test_support",
- "//components/search_engines/android:java",
- "//content/public/android:content_full_java",
- "//content/public/test/android:content_java_test_support",
- "//third_party/androidx:androidx_test_runner_java",
- "//third_party/junit:junit",
- "//third_party/mockito:mockito_java",
- "//ui/android:ui_java_test_support",
- ]
-}
-
-android_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
-
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/logo/LogoLoadHelperUnitTest.java",
+ "java/src/org/chromium/chrome/browser/logo/LogoViewTest.java",
]
deps = [
@@ -96,9 +74,10 @@ android_library("junit") {
"//components/search_engines/android:java",
"//content/public/android:content_full_java",
"//content/public/test/android:content_java_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/androidx:androidx_test_core_java",
+ "//third_party/androidx:androidx_test_ext_junit_java",
"//third_party/junit:junit",
"//third_party/mockito:mockito_java",
+ "//ui/android:ui_java_test_support",
]
}
diff --git a/chromium/chrome/browser/ui/android/multiwindow/BUILD.gn b/chromium/chrome/browser/ui/android/multiwindow/BUILD.gn
index 00f5edf5f71..52bbfe158b3 100644
--- a/chromium/chrome/browser/ui/android/multiwindow/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/multiwindow/BUILD.gn
@@ -67,11 +67,7 @@ android_resources("java_resources") {
]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
-
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/multiwindow/MultiInstanceStateUnitTest.java",
"java/src/org/chromium/chrome/browser/multiwindow/UiUtilsUnitTest.java",
@@ -85,7 +81,6 @@ java_library("junit") {
"//chrome/browser/profiles/android:java",
"//chrome/browser/util:java",
"//components/favicon/android:java",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_test_core_java",
"//third_party/androidx:androidx_test_runner_java",
@@ -108,7 +103,7 @@ android_library("javatests") {
"//base:base_java_test_support",
"//chrome/browser/flags:java",
"//chrome/browser/preferences:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//components/browser_ui/modaldialog/android:java",
"//components/browser_ui/settings/android:java",
"//components/browser_ui/widget/android:java",
diff --git a/chromium/chrome/browser/ui/android/native_page/BUILD.gn b/chromium/chrome/browser/ui/android/native_page/BUILD.gn
index f5530991985..2153ef2b0bf 100644
--- a/chromium/chrome/browser/ui/android/native_page/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/native_page/BUILD.gn
@@ -21,11 +21,7 @@ android_library("java") {
]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
-
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/ui/native_page/NativePageTest.java",
]
@@ -33,7 +29,6 @@ java_library("junit") {
deps = [
":java",
"//base:base_junit_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
]
}
diff --git a/chromium/chrome/browser/ui/android/night_mode/BUILD.gn b/chromium/chrome/browser/ui/android/night_mode/BUILD.gn
index 4091efc4185..479f99492d0 100644
--- a/chromium/chrome/browser/ui/android/night_mode/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/night_mode/BUILD.gn
@@ -75,7 +75,7 @@ android_library("night_mode_java_test_support") {
]
}
-android_library("javatests") {
+android_library("unit_device_javatests") {
testonly = true
sources = [ "java/src/org/chromium/chrome/browser/night_mode/settings/ThemeSettingsFragmentTest.java" ]
@@ -85,14 +85,16 @@ android_library("javatests") {
":night_mode_java_test_support",
"//base:base_java",
"//base:base_java_test_support",
+ "//chrome/browser/feature_engagement:java",
"//chrome/browser/flags:java",
"//chrome/browser/preferences:java",
- "//chrome/browser/settings:java",
- "//chrome/browser/settings:test_support_java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/browser/profiles/android:java",
+ "//chrome/test/android:chrome_java_test_support_common",
+ "//components/browser_ui/settings/android:test_support_java",
"//components/browser_ui/site_settings/android:java",
"//components/browser_ui/widget/android:java",
"//components/content_settings/android:content_settings_enums_java",
+ "//components/feature_engagement/public:public_java",
"//content/public/android:content_full_java",
"//content/public/test/android:content_java_test_support",
"//third_party/androidx:androidx_test_runner_java",
@@ -104,10 +106,7 @@ android_library("javatests") {
resources_package = "org.chromium.chrome.browser.night_mode"
}
-android_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/night_mode/AutoDarkFeedbackSourceUnitTest.java",
"java/src/org/chromium/chrome/browser/night_mode/WebContentsDarkModeControllerUnitTest.java",
@@ -125,7 +124,7 @@ android_library("junit") {
"//chrome/browser/flags:java",
"//chrome/browser/preferences:java",
"//chrome/browser/profiles/android:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//components/browser_ui/settings/android:java",
"//components/browser_ui/site_settings/android:java",
"//components/content_settings/android:content_settings_enums_java",
@@ -137,7 +136,6 @@ android_library("junit") {
"//content/public/android:content_full_java",
"//content/public/test/android:content_java_test_support",
"//testing/android/junit:junit_test_support",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
diff --git a/chromium/chrome/browser/ui/android/omnibox/BUILD.gn b/chromium/chrome/browser/ui/android/omnibox/BUILD.gn
index 76ed0fe6a93..1063f68ee7d 100644
--- a/chromium/chrome/browser/ui/android/omnibox/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/omnibox/BUILD.gn
@@ -26,6 +26,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java",
"java/src/org/chromium/chrome/browser/omnibox/LocationBarTablet.java",
"java/src/org/chromium/chrome/browser/omnibox/NewTabPageDelegate.java",
+ "java/src/org/chromium/chrome/browser/omnibox/OmniboxFeatures.java",
"java/src/org/chromium/chrome/browser/omnibox/OmniboxFocusReason.java",
"java/src/org/chromium/chrome/browser/omnibox/OmniboxPrerender.java",
"java/src/org/chromium/chrome/browser/omnibox/OmniboxStub.java",
@@ -59,12 +60,13 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteDelegate.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediator.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManager.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownCommonProperties.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemProcessor.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfo.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListBuilder.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListManager.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/FaviconFetcher.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxPedalDelegate.java",
- "java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxQueryTileCoordinator.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionUiType.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdown.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdownAdapter.java",
@@ -93,6 +95,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/omnibox/suggestions/basic/BasicSuggestionProcessor.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/basic/SuggestionViewProperties.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/basic/SuggestionViewViewBinder.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionItemViewBuilder.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionProcessor.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionSelectionManager.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionView.java",
@@ -109,7 +112,6 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/omnibox/suggestions/header/HeaderView.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/header/HeaderViewBinder.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/header/HeaderViewProperties.java",
- "java/src/org/chromium/chrome/browser/omnibox/suggestions/mostvisited/ExploreIconProvider.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/mostvisited/MostVisitedTilesProcessor.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/pedal/PedalSuggestionProcessor.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/pedal/PedalSuggestionView.java",
@@ -140,6 +142,7 @@ android_library("java") {
"//base:jni_java",
"//build/android:build_java",
"//chrome/browser/android/lifecycle:java",
+ "//chrome/browser/back_press/android:java",
"//chrome/browser/browser_controls/android:java",
"//chrome/browser/commerce/merchant_viewer/android:java",
"//chrome/browser/device:java",
@@ -235,7 +238,7 @@ android_library("javatests") {
"//base:base_java",
"//base:base_java_test_support",
"//base/test:test_support_java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//content/public/test/android:content_java_test_support",
"//third_party/android_sdk:android_test_mock_java",
"//third_party/android_support_test_runner:runner_java",
@@ -325,7 +328,6 @@ android_resources("java_resources") {
"java/res/layout/omnibox_answer_suggestion.xml",
"java/res/layout/omnibox_basic_suggestion.xml",
"java/res/layout/omnibox_entity_suggestion.xml",
- "java/res/layout/omnibox_query_tiles_suggestion.xml",
"java/res/layout/omnibox_results_container.xml",
"java/res/layout/suggestions_tile_view.xml",
"java/res/layout/url_action_container.xml",
@@ -347,17 +349,46 @@ proto_java_library("partner_location_descriptor_proto_java") {
sources = [ "$proto_path/partner_location_descriptor.proto" ]
}
-android_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
+android_library("unit_device_javatests") {
testonly = true
+ sources = [
+ "java/src/org/chromium/chrome/browser/omnibox/status/StatusViewRenderTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/status/StatusViewTest.java",
+ ]
+ deps = [
+ ":java",
+ ":java_resources",
+ "//base:base_java_test_support",
+ "//chrome/browser/ui/android/toolbar:java",
+ "//chrome/test/android:chrome_java_test_support_common",
+ "//components/browser_ui/site_settings/android:java",
+ "//components/browser_ui/widget/android:java",
+ "//components/content_settings/android:content_settings_enums_java",
+ "//content/public/test/android:content_java_test_support",
+ "//third_party/android_deps:espresso_java",
+ "//third_party/android_sdk:android_test_base_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
+ "//third_party/androidx:androidx_core_core_java",
+ "//third_party/androidx:androidx_recyclerview_recyclerview_java",
+ "//third_party/androidx:androidx_test_core_java",
+ "//third_party/androidx:androidx_test_runner_java",
+ "//third_party/hamcrest:hamcrest_library_java",
+ "//third_party/junit:junit",
+ "//third_party/mockito:mockito_java",
+ "//ui/android:ui_java_test_support",
+ "//ui/android:ui_no_recycler_view_java",
+ "//url:gurl_java",
+ ]
+}
+robolectric_library("junit") {
sources = [
"java/src/org/chromium/chrome/browser/omnibox/AutocompleteEditTextTest.java",
"java/src/org/chromium/chrome/browser/omnibox/AutocompleteStateUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/KeyboardHideHelperUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/LocationBarMediatorTest.java",
"java/src/org/chromium/chrome/browser/omnibox/SearchEngineLogoUtilsUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/ShadowUrlBarData.java",
"java/src/org/chromium/chrome/browser/omnibox/SpannableAutocompleteEditTextModelUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarDataTest.java",
"java/src/org/chromium/chrome/browser/omnibox/UrlBarMediatorUnitTest.java",
@@ -366,16 +397,31 @@ android_library("junit") {
"java/src/org/chromium/chrome/browser/omnibox/geo/PlatformNetworksManagerTest.java",
"java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworksTest.java",
"java/src/org/chromium/chrome/browser/omnibox/geo/VisibleNetworksTrackerTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/status/StatusMediatorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/styles/OmniboxResourceProviderTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediatorUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManagerUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListBuilderUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListManagerUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/FaviconFetcherUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/answer/AnswerSuggestionProcessorUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/answer/AnswerTextNewLayoutUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/base/BaseSuggestionProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/BaseSuggestionViewBinderUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/BaseSuggestionViewProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/BaseSuggestionViewTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/SimpleHorizontalLayoutViewTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/SimpleVerticalLayoutViewTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/base/SuggestionSpannableUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/basic/BasicSuggestionProcessorUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionSelectionManagerUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/carousel/BaseCarouselSuggestionViewBinderUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/clipboard/ClipboardSuggestionProcessorUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/editurl/EditUrlSuggestionUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/entity/EntitySuggestionProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/header/HeaderViewBinderUnitTest.java",
+ "java/src/org/chromium/chrome/browser/omnibox/suggestions/mostvisited/MostVisitedTilesProcessorUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/tail/AlignmentManagerUnitTest.java",
"java/src/org/chromium/chrome/browser/omnibox/voice/AssistantVoiceSearchServiceUnitTest.java",
]
@@ -386,6 +432,7 @@ android_library("junit") {
"//base:base_junit_test_support",
"//build/android:build_java",
"//chrome/android:base_module_java",
+ "//chrome/browser/commerce/merchant_viewer/android:java",
"//chrome/browser/device:java",
"//chrome/browser/flags:java",
"//chrome/browser/gsa:java",
@@ -395,13 +442,16 @@ android_library("junit") {
"//chrome/browser/prefetch/android:java",
"//chrome/browser/privacy:java",
"//chrome/browser/profiles/android:java",
+ "//chrome/browser/search_engines/android:java",
+ "//chrome/browser/share:java",
"//chrome/browser/signin/services/android:java",
"//chrome/browser/tab:java",
+ "//chrome/browser/tabmodel:java",
"//chrome/browser/ui/android/favicon:java",
"//chrome/browser/ui/android/theme:java",
"//chrome/browser/ui/android/toolbar:java",
"//chrome/browser/util:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//components/browser_ui/site_settings/android:java",
"//components/browser_ui/styles/android:java",
"//components/browser_ui/theme/android:java_resources",
@@ -409,26 +459,35 @@ android_library("junit") {
"//components/content_settings/android:content_settings_enums_java",
"//components/embedder_support/android:util_java",
"//components/externalauth/android:java",
+ "//components/favicon/android:java",
+ "//components/image_fetcher:java",
"//components/omnibox/browser:browser_java",
+ "//components/omnibox/browser:junit_test_support",
+ "//components/permissions/android:java",
"//components/search_engines/android:java",
+ "//components/security_state/core:security_state_enums_java",
"//components/signin/public/android:java",
"//components/signin/public/android:signin_java_test_support",
"//content/public/android:content_java",
"//content/public/test/android:content_java_test_support",
"//testing/android/junit:junit_test_support",
"//third_party/android_deps:material_design_java",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_recyclerview_recyclerview_java",
"//third_party/androidx:androidx_test_core_java",
+ "//third_party/androidx:androidx_test_ext_junit_java",
"//third_party/androidx:androidx_test_runner_java",
+ "//third_party/hamcrest:hamcrest_core_java",
"//third_party/hamcrest:hamcrest_library_java",
"//third_party/junit",
+ "//third_party/metrics_proto:metrics_proto_java",
"//third_party/mockito:mockito_java",
+ "//ui/android:ui_java_test_support",
"//ui/android:ui_no_recycler_view_java",
"//ui/android:ui_recycler_view_java",
"//url:gurl_java",
+ "//url:gurl_junit_shadows",
"//url:gurl_junit_test_support",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
diff --git a/chromium/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn b/chromium/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn
index 0f24e9e2a3e..b47762d1c9f 100644
--- a/chromium/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn
@@ -21,8 +21,6 @@ android_library("java") {
}
android_library("javatests") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
testonly = true
sources = [
"java/src/org/chromium/chrome/browser/ui/quickactionsearchwidget/QuickActionSearchWidgetProviderDelegateTest.java",
@@ -40,7 +38,7 @@ android_library("javatests") {
"//chrome/browser/tab:java",
"//chrome/browser/tabmodel:java",
"//chrome/browser/ui/android/searchactivityutils:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_integration_test_support",
"//components/embedder_support/android:util_java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_support_test_runner:runner_java",
diff --git a/chromium/chrome/browser/ui/android/searchactivityutils/BUILD.gn b/chromium/chrome/browser/ui/android/searchactivityutils/BUILD.gn
index b4ac2dcfd49..d1a29b1196a 100644
--- a/chromium/chrome/browser/ui/android/searchactivityutils/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/searchactivityutils/BUILD.gn
@@ -27,7 +27,7 @@ android_library("constants_java") {
sources = [ "java/src/org/chromium/chrome/browser/ui/searchactivityutils/SearchActivityConstants.java" ]
}
-android_library("javatests") {
+android_library("unit_device_javatests") {
testonly = true
sources = [ "java/src/org/chromium/chrome/browser/ui/searchactivityutils/SearchActivityPreferencesManagerTest.java" ]
diff --git a/chromium/chrome/browser/ui/android/signin/BUILD.gn b/chromium/chrome/browser/ui/android/signin/BUILD.gn
index 8d5cb30a1dd..dc9e4e63a1a 100644
--- a/chromium/chrome/browser/ui/android/signin/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/signin/BUILD.gn
@@ -43,20 +43,21 @@ android_library("java") {
]
sources = [
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmImportSyncDataDialogCoordinator.java",
- "java/src/org/chromium/chrome/browser/ui/signin/ConfirmManagedSyncDataDialog.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/ConfirmManagedSyncDataDialogCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataStateMachine.java",
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataStateMachineDelegate.java",
"java/src/org/chromium/chrome/browser/ui/signin/ConsentTextTracker.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/FullScreenSyncPromoUtil.java",
"java/src/org/chromium/chrome/browser/ui/signin/GoogleActivityController.java",
"java/src/org/chromium/chrome/browser/ui/signin/PersonalizedSigninPromoView.java",
"java/src/org/chromium/chrome/browser/ui/signin/SignOutDialogCoordinator.java",
- "java/src/org/chromium/chrome/browser/ui/signin/SigninPromoController.java",
- "java/src/org/chromium/chrome/browser/ui/signin/SigninPromoUtil.java",
"java/src/org/chromium/chrome/browser/ui/signin/SigninScrollView.java",
"java/src/org/chromium/chrome/browser/ui/signin/SigninUtils.java",
"java/src/org/chromium/chrome/browser/ui/signin/SigninView.java",
"java/src/org/chromium/chrome/browser/ui/signin/SyncConsentActivityLauncher.java",
"java/src/org/chromium/chrome/browser/ui/signin/SyncConsentFragmentBase.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/SyncConsentView.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/SyncPromoController.java",
"java/src/org/chromium/chrome/browser/ui/signin/TangibleSyncCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetMediator.java",
@@ -83,17 +84,15 @@ android_library("java") {
android_resources("java_resources") {
sources = [
- "java/res/drawable-hdpi/chrome_sync_logo.png",
"java/res/drawable-hdpi/ic_account_child_20dp.png",
- "java/res/drawable-mdpi/chrome_sync_logo.png",
"java/res/drawable-mdpi/ic_account_child_20dp.png",
"java/res/drawable-night/sync_promo_illustration.xml",
- "java/res/drawable-xhdpi/chrome_sync_logo.png",
"java/res/drawable-xhdpi/ic_account_child_20dp.png",
- "java/res/drawable-xxhdpi/chrome_sync_logo.png",
"java/res/drawable-xxhdpi/ic_account_child_20dp.png",
- "java/res/drawable-xxxhdpi/chrome_sync_logo.png",
"java/res/drawable-xxxhdpi/ic_account_child_20dp.png",
+ "java/res/drawable/autofill_key.xml",
+ "java/res/drawable/chrome_sync_logo.xml",
+ "java/res/drawable/devices_icon.xml",
"java/res/drawable/ic_expand_more_in_circle_24dp.xml",
"java/res/drawable/sync_promo_illustration.xml",
"java/res/layout/account_picker_bottom_sheet_continue_button.xml",
@@ -123,6 +122,7 @@ android_resources("java_resources") {
"java/res/layout/signin_progress_bar_dialog.xml",
"java/res/layout/signin_view.xml",
"java/res/layout/signout_wipe_storage_dialog.xml",
+ "java/res/layout/sync_consent_view.xml",
"java/res/values-sw320dp/styles.xml",
"java/res/values/dimens.xml",
"java/res/values/styles.xml",
@@ -135,14 +135,11 @@ android_resources("java_resources") {
]
}
-android_library("junit") {
- bypass_platform_checks = true
- testonly = true
+robolectric_library("junit") {
sources = [
- "junit/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataStateMachineDelegateTest.java",
"junit/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataStateMachineTest.java",
- "junit/src/org/chromium/chrome/browser/ui/signin/SigninPromoControllerTest.java",
- "junit/src/org/chromium/chrome/browser/ui/signin/SigninPromoUtilLaunchSigninPromoTest.java",
+ "junit/src/org/chromium/chrome/browser/ui/signin/FullScreenSyncPromoTest.java",
+ "junit/src/org/chromium/chrome/browser/ui/signin/SyncPromoControllerTest.java",
"junit/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerMediatorTest.java",
"junit/src/org/chromium/chrome/browser/ui/signin/account_picker/WebSigninAccountPickerDelegateTest.java",
]
@@ -157,7 +154,7 @@ android_library("junit") {
"//chrome/browser/profiles/android:java",
"//chrome/browser/signin/services/android:java",
"//chrome/browser/tab:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//components/browser_ui/modaldialog/android:java",
"//components/browser_ui/test/android:test_support_java",
"//components/prefs/android:java",
@@ -166,7 +163,6 @@ android_library("junit") {
"//components/signin/public/android:signin_java_test_support",
"//components/user_prefs/android:java",
"//content/public/android:content_java",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/androidx:androidx_appcompat_appcompat_java",
"//third_party/androidx:androidx_fragment_fragment_java",
"//third_party/androidx:androidx_test_core_java",
@@ -179,14 +175,46 @@ android_library("junit") {
android_library("javatests") {
testonly = true
sources = [
+ "java/src/org/chromium/chrome/browser/ui/signin/SyncPromoControllerRenderTest.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetRenderTest.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetTest.java",
+ ]
+ deps = [
+ ":java",
+ "//base:base_java",
+ "//base:base_java_test_support",
+ "//chrome/android:chrome_java",
+ "//chrome/browser/flags:java",
+ "//chrome/browser/preferences:java",
+ "//chrome/browser/signin/services/android:java",
+ "//chrome/browser/ui/android/night_mode:night_mode_java_test_support",
+ "//chrome/test/android:chrome_java_integration_test_support",
+ "//components/browser_ui/bottomsheet/android:java",
+ "//components/signin/core/browser:signin_enums_java",
+ "//components/signin/public/android:java",
+ "//components/signin/public/android:signin_java_test_support",
+ "//content/public/test/android:content_java_test_support",
+ "//third_party/android_deps:espresso_java",
+ "//third_party/android_support_test_runner:runner_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_test_runner_java",
+ "//third_party/hamcrest:hamcrest_java",
+ "//third_party/junit",
+ "//third_party/mockito:mockito_java",
+ "//ui/android:ui_java_test_support",
+ ]
+}
+
+android_library("unit_device_javatests") {
+ testonly = true
+ sources = [
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmImportSyncDataDialogTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmManagedSyncDataDialogTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataIntegrationTest.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/ConfirmSyncDataStateMachineDelegateTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/SignOutDialogRenderTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/SignOutDialogTest.java",
- "java/src/org/chromium/chrome/browser/ui/signin/SigninPromoControllerRenderTest.java",
- "java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetRenderTest.java",
- "java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerBottomSheetTest.java",
+ "java/src/org/chromium/chrome/browser/ui/signin/TangibleSyncCoordinatorTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/account_picker/AccountPickerDialogTest.java",
"java/src/org/chromium/chrome/browser/ui/signin/fre/FreUMADialogTest.java",
]
@@ -194,15 +222,14 @@ android_library("javatests") {
":java",
"//base:base_java",
"//base:base_java_test_support",
- "//chrome/android:chrome_java",
"//chrome/browser/flags:java",
"//chrome/browser/preferences:java",
"//chrome/browser/profiles/android:java",
"//chrome/browser/signin/services/android:java",
"//chrome/browser/ui/android/night_mode:night_mode_java_test_support",
- "//chrome/test/android:chrome_java_test_support",
- "//components/browser_ui/bottomsheet/android:java",
+ "//chrome/test/android:chrome_java_integration_test_support",
"//components/browser_ui/modaldialog/android:java",
+ "//components/browser_ui/styles/android:java",
"//components/externalauth/android:java",
"//components/prefs/android:java",
"//components/signin/core/browser:signin_enums_java",
diff --git a/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
index cf38ec789fa..60c67124be2 100644
--- a/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -277,10 +277,6 @@ CHAR_LIMIT guidelines:
USB
</message>
- <message name="IDS_UNSUPPORTED" desc="Message displayed to the user when an attempted action is not supported.">
- Unsupported
- </message>
-
<!-- Sign-in, sync and personalization preferences -->
<message name="IDS_PREFS_SECTION_ACCOUNT_AND_GOOGLE_SERVICES" desc="Title for the group of account-related entries and google services in Settings. [CHAR_LIMIT=32]">
You and Google
@@ -553,7 +549,7 @@ CHAR_LIMIT guidelines:
Remove
</message>
<message name="IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_DIALOG_EDUCATION_TEXT" desc="Text explaining the benefit of enrolling a credit card as a virtual card. Also contains a link to learn more about virtual cards from IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_LEARN_MORE_LINK_LABEL.">
- A virtual card disguises your actual card to help protect you from potential fraud. <ph name="BEGIN_LINK1">&lt;link1&gt;</ph>Learn more about virtual cards<ph name="END_LINK1">&lt;/link1&gt;</ph>
+ A virtual card hides your actual card to help protect you from potential fraud. <ph name="BEGIN_LINK1">&lt;link1&gt;</ph>Learn more about virtual cards<ph name="END_LINK1">&lt;/link1&gt;</ph>
</message>
<message name="IDS_AUTOFILL_VIRTUAL_CARD_ENROLLMENT_DIALOG_CARD_CONTAINER_TITLE" desc="Text describing how the virtual card will be shown to the user in autofill suggestions.">
Virtual card
@@ -594,7 +590,7 @@ CHAR_LIMIT guidelines:
other {<ph name="CONTACT_PREVIEW">%1$s<ex>Jerry, 438-123-1922</ex></ph>\u2026 and <ph name="NUMBER_OF_ADDITIONAL_CONTACTS">%2$s<ex>2</ex></ph> more}}
</message>
- <!-- Password Settings -->
+ <!-- Password Manager -->
<message name="IDS_PASSWORD_SETTINGS_TITLE" desc="Title for the settings screen with saved passwords and the header for the list of saved passwords in that screen. [CHAR_LIMIT=32]">
Passwords
</message>
@@ -745,6 +741,12 @@ CHAR_LIMIT guidelines:
<message name="IDS_PASSWORD_SETTINGS_EXPORT_ERROR_DETAILS" desc="A short prefix to introduce a technical error message passed to the user from Android after exporting passwords through a temporary file fails. Both the prefix and the error message are shown in the body of an alert dialog.">
Details: <ph name="ERROR_DESCRIPTION">%1$s<ex>IOException: No space left on device</ex></ph>
</message>
+ <message name="IDS_UPM_ERROR_NOTIFICATION_TITLE" translateable="false" desc="The title of the UI surface telling the user that the new password manager backend has encountered an error.">
+ Unified password manager error
+ </message>
+ <message name="IDS_UPM_ERROR_NOTIFICATION_CONTENTS" translateable="false" desc="The contents of the UI surface shown when the new password manager backend encounters an error, prompting the user to file a bug.">
+ The unified password manager was automatically disabled. Please submit an issue via the bug app!
+ </message>
<!-- Lock Screen Fragment -->
<message name="IDS_LOCKSCREEN_DESCRIPTION_COPY" desc="When a user attempts to copy a password for a particular website into clipboard in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
@@ -806,22 +808,9 @@ CHAR_LIMIT guidelines:
<message name="IDS_CONTEXTUAL_SEARCH_TITLE" desc="Name for the Contextual Search feature, which allows users to search for a term in a web page by tapping on it.">
Touch to Search
</message>
- <message name="IDS_CONTEXTUAL_SEARCH_TAP_DESCRIPTION" desc="Description for Contextual Search preference">
- Learn about topics on websites without leaving the page. Touch to Search sends a word and its surrounding context to Google Search, returning definitions, pictures, search results, and other details.
-
-Tap any word to search. To refine your search, touch &amp; hold to select more or fewer words. To edit your search, open the panel, tap the icon to open in a new tab, and make your changes in the search box.
- </message>
<message name="IDS_CONTEXTUAL_SEARCH_DESCRIPTION" desc="Description for Contextual Search preference">
- Learn about topics on websites without leaving the page. Touch to Search sends a word and its surrounding context to Google Search, returning definitions, pictures, search results, and other details.
-
-Touch &amp; hold any word to search. To refine your search, select more or fewer words. To edit your search, open the panel, tap the icon to open in a new tab, and make your changes in the search box.
- </message>
- <message name="IDS_CONTEXTUAL_SEARCH_DESCRIPTION_REVISED" desc="Description for Contextual Search preference">
Learn about topics on websites without leaving the page. Select one or more words on the page to search for them.
</message>
- <message name="IDS_CONTEXTUAL_SEARCH_SHORT_DESCRIPTION" desc="A promo message shown to users with Touch to Search to explain the new behavior and provide an option to opt in or out">
- Touch to Search sends the selected word and the current page as context to Google Search. You can turn it off in <ph name="BEGIN_LINK">&lt;link&gt;</ph>Settings<ph name="END_LINK">&lt;/link&gt;</ph>.
- </message>
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_TITLE" desc="The title of the promo message for the contextual search.">
Include surrounding text in Google searches?
</message>
@@ -831,9 +820,6 @@ Touch &amp; hold any word to search. To refine your search, select more or fewer
<message name="IDS_CONTEXTUAL_SEARCH_INCLUDE_BUTTON" desc="A button to confirm and dismiss opt in promo">
Include
</message>
- <message name="IDS_CONTEXTUAL_SEARCH_ALLOW_BUTTON" desc="A button to confirm and dismiss opt out promo">
- Allow
- </message>
<message name="IDS_CONTEXTUAL_SEARCH_NO_THANKS_BUTTON" desc="A button to confirm and dismiss opt out promo">
No thanks
</message>
@@ -968,48 +954,84 @@ Based on your interaction with a site, like regularly signing in to an account,
Trust tokens improve privacy on the web and can’t be used to find out who you are.
</message>
- <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_1" desc="TOPICS API Bullet 1 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “What data is used:” is bold and serves as a label to help people skimming the page. * “Your browsing history”: The user’s browsing history is available beneath the “History” menu at Chrome’s top level. The Topics API estimates topics of interest based on sites in the user’s browsing history that are participating in the trials.">
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_TOPICS_1" desc="TOPICS API Bullet 1 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “What data is used:” is bold and serves as a label to help people skimming the page. * “Your browsing history”: The user’s browsing history is available beneath the “History” menu at Chrome’s top level. The Topics API estimates topics of interest based on sites in the user’s browsing history that are participating in the trials.">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>What data is used:<ph name="END_BOLD">&lt;/b&gt;</ph> Your browsing history, a record of sites you’ve visited using Chrome on this device.
</message>
- <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_2" desc="TOPICS API Bullet 2 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How we use this data:” is bold and serves as a label to help people skimming the page. * “estimate your interests”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”).">
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_TOPICS_2" desc="TOPICS API Bullet 2 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How we use this data:” is bold and serves as a label to help people skimming the page. * “estimate your interests”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”).">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>How we use this data:<ph name="END_BOLD">&lt;/b&gt;</ph> Chrome can estimate your interests. Later, a site you visit can ask Chrome to see your interests in order to personalize the ads you see.
</message>
- <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_3" desc="TOPICS API Bullet 3 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How you can manage your data:” is bold and serves as a label to help people skimming the page. * “To protect your privacy”: Today, most data is kept for long periods of time. This new Topics API doesn’t retain estimated topics for more than 3 weeks. The only reason for this feature is to protect the user’s privacy. * “auto”: isn’t strictly necessary, but it conveys that this feature is an ongoing part of the service. This isn’t describing, for example, a one-time deletion. * “older than 4 weeks”: We’re trying to convey a rolling delete. Imagine a user opens a browser for the very first time. As the user browses, Chrome will estimate up to 5 topics of interest in the first week. In the second week, Chrome will estimate up to 5 additional topics of interest. The same for the third week, for a total of 15 potential interests. In week 4, Chrome will automatically delete the 5 interests from week 1 so that there aren’t ever more than 15 topics associated with a user at any given time. * “interests can refresh”: If a user loves horror films and reads about them for months on end, the interest “Horror movies” might get deleted and refreshed in the same week, so that “Horror movies” doesn’t ever disappear from the user’s list of interests. * “Or you can…”: A user might love horror movies but can’t stand the idea of seeing ads about horror movies (because even the visuals will ruin the surprise of opening night). In this case, the user can remove “Horror movies” from the list of interests Chrome will consider. This removal remains in place indefinitely. Note that the user might still see ads about Horror movies from different ad networks or by other means than Chrome’s “Browser-based ad personalization” setting.">
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_TOPICS_3" desc="TOPICS API Bullet 3 of 3 that appear beneath the “Your interests as estimated by Chrome” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How you can manage your data:” is bold and serves as a label to help people skimming the page. * “To protect your privacy”: Today, most data is kept for long periods of time. This new Topics API doesn’t retain estimated topics for more than 3 weeks. The only reason for this feature is to protect the user’s privacy. * “auto”: isn’t strictly necessary, but it conveys that this feature is an ongoing part of the service. This isn’t describing, for example, a one-time deletion. * “older than 4 weeks”: We’re trying to convey a rolling delete. Imagine a user opens a browser for the very first time. As the user browses, Chrome will estimate up to 5 topics of interest in the first week. In the second week, Chrome will estimate up to 5 additional topics of interest. The same for the third week, for a total of 15 potential interests. In week 4, Chrome will automatically delete the 5 interests from week 1 so that there aren’t ever more than 15 topics associated with a user at any given time. * “interests can refresh”: If a user loves horror films and reads about them for months on end, the interest “Horror movies” might get deleted and refreshed in the same week, so that “Horror movies” doesn’t ever disappear from the user’s list of interests. * “Or you can…”: A user might love horror movies but can’t stand the idea of seeing ads about horror movies (because even the visuals will ruin the surprise of opening night). In this case, the user can remove “Horror movies” from the list of interests Chrome will consider. This removal remains in place indefinitely. Note that the user might still see ads about Horror movies from different ad networks or by other means than Chrome’s “Browser-based ad personalization” setting.">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>How you can manage your data:<ph name="END_BOLD">&lt;/b&gt;</ph> To protect your privacy, we auto-delete your interests that are older than 4 weeks. As you keep browsing, an interest might appear on the list again. Or you can remove interests you don’t want Chrome to consider.
</message>
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_FLEDGE_1" desc="FLEDGE APIBullet 1 of 3 that appear beneath the “Sites you visit that define your interests” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “What data is used:” is bold and serves as a label to help people skimming the page. * “Your browsing history”: The user’s browsing history is available beneath the “History” menu at Chrome’s top level. This content taken in isolation is somewhat misleading. With FLEDGE, a site can store information in Chrome about the user’s visit to their site. For example, the site might store “running_shoes_red_size_35” to indicate that the user showed interest in a particular shoe. We’re OK with the simplification in this bullet because 1) we explain it in the next bullet and 2) we want the user to understand that at the top level, both Topics &amp; Fledge are based on the same thing and that is the user’s browsing history.">
+ <ph name="BEGIN_BOLD">&lt;b&gt;</ph>What data is used:<ph name="END_BOLD">&lt;/b&gt;</ph> Your browsing history, a record of sites you’ve visited using Chrome on this device.
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_FLEDGE_2" desc="FLEDGE API Bullet 2 of 3 that appear beneath the “Sites you visit that define your interests” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How we use this data:” is bold and serves as a label to help people skimming the page.">
+ <ph name="BEGIN_BOLD">&lt;b&gt;</ph>How we use this data:<ph name="END_BOLD">&lt;/b&gt;</ph> Sites can store information with Chrome about your interests. For example, if you visit a site to buy shoes for a marathon, the site might define your interest as running marathons. Later, if you visit a different site to register for a race, that site can show you an ad for running shoes based on your interests.
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_DESCRIPTION_FLEDGE_3" desc="FLEDGE API Bullet 3 of 3 that appear beneath the “Sites you visit that define your interests” subtitle. We break the description into the 3 pieces users most care about: 1) what data, 2) why this data, 3) what can I do about it? * “How you can manage your data:” is bold and serves as a label to help people skimming the page. * “To protect your privacy”: Today, most data is kept for long periods of time. This new Topics API doesn’t retain estimated topics for more than 3 weeks. The only reason for this feature is to protect the user’s privacy. * “auto”: isn’t strictly necessary, but it conveys that this feature is an ongoing part of the service. This isn’t describing, for example, a one-time deletion. * “older than 4 weeks”: We’re trying to convey a rolling delete. Imagine a user opens a browser for the very first time. As the user browses, sites can store info with Chrome for up to 4 weeks. So in week 1, the user visits site A. When week 5 starts, site A is removed from the list of sites. * “a site you visit…”: If a user visits site A every week for months on end, that site will remain on the user’s list of sites for months on end. * “Or you can…”: Say a user strongly dislikes www.siteB.com. But that user might visit siteB.com as part of their job, or just to see how bad it really is. The user can stop siteB from defining interests for them. This block lasts indefinitely.">
+ <ph name="BEGIN_BOLD">&lt;b&gt;</ph>How you can manage your data:<ph name="END_BOLD">&lt;/b&gt;</ph> To protect your privacy, we auto-delete sites from the list that are older than 4 weeks. A site you visit again might appear on the list again. Or you can remove a site if you don’t want that site to ever define interests for you.
+ </message>
<message name="IDS_PRIVACY_SANDBOX_LEARN_MORE_TITLE" desc="Title of the settings page to explain ad personalization in the Privacy Sandbox.">
About ad personalization
</message>
<message name="IDS_PRIVACY_SANDBOX_ADD_INTEREST_BUTTON_DESCRIPTION" desc="Content description for button that adds an ad interest for the Topics API of the Privacy Sandbox.">
Add <ph name="INTEREST">%1$s<ex>Acting and Theater</ex></ph>
</message>
+ <message name="IDS_PRIVACY_SANDBOX_ADD_SITE_BUTTON_DESCRIPTION" desc="Content description for button that adds an ad interest for the FLEDGE API of the Privacy Sandbox.">
+ Add <ph name="SITE">%1$s<ex>example.com</ex></ph>
+ </message>
<message name="IDS_PRIVACY_SANDBOX_ADD_INTEREST_SNACKBAR" desc="Text on a snackbar after an ad personalization interest was added to the Topics API of the Privacy Sandbox.">
- Interest added
+ Chrome can consider this interest
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_ADD_SITE_SNACKBAR" desc="Text on a snackbar after an ad personalization interest was added to the FLEDGE API of the Privacy Sandbox.">
+ Site can define interests
</message>
<message name="IDS_PRIVACY_SANDBOX_REMOVE_INTEREST_BUTTON_DESCRIPTION" desc="Content description for button that removes an ad interest for the Topics API of the Privacy Sandbox.">
Remove <ph name="INTEREST">%1$s<ex>Acting and Theater</ex></ph>
</message>
+ <message name="IDS_PRIVACY_SANDBOX_REMOVE_SITE_BUTTON_DESCRIPTION" desc="Content description for button that removes an ad interest for the FLEDGE API of the Privacy Sandbox.">
+ Remove <ph name="DOMAIN">%1$s<ex>example.com</ex></ph>
+ </message>
<message name="IDS_PRIVACY_SANDBOX_REMOVE_INTEREST_SNACKBAR" desc="Text on a snackbar after an ad personalization interest was removed from the Topics API of the Privacy Sandbox.">
Interest removed
</message>
<message name="IDS_PRIVACY_SANDBOX_REMOVE_INTEREST_TITLE" desc="Title of the settings page to configure interests that were removed from ad personalization in the Privacy Sandbox.">
Interests you removed
</message>
+ <message name="IDS_PRIVACY_SANDBOX_REMOVE_SITE_SNACKBAR" desc="Text on a snackbar after an ad personalization interest was removed from the FLEDGE API of the Privacy Sandbox.">
+ Site removed
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_REMOVE_SITES_TITLE" desc="Title of the settings page to configure sites that were removed from ad personalization in the Privacy Sandbox.">
+ Sites you removed
+ </message>
<message name="IDS_PRIVACY_SANDBOX_REMOVE_INTEREST_DESCRIPTION" desc="A paragraph beneath the card title. The page title explains why things appear on this page. This string explains why the user might want to “un-remove” or “re-allow” an item from the list. If a user does choose “Allow” for an item, there won’t be any immediate change in the interface because the item simply becomes eligible again. So, for example, the user previously blocked the interest “Horror movies.” Today, they “allow” “Horror movies” because they’ve decided that as about horror movies are actually OK to see. It might take another week or longer, based on the user’s browsing history, for “Horror movies” to appear in the list of interests again as an active interest within the last 3 weeks. * “Allow”: This aligns with the button label titled “allow”. It wouldn’t make much sense if the user couldn’t see the Allow button on the card.">
Allow an interest or site if you think ads related to the item would be useful to you
</message>
<message name="IDS_PRIVACY_SANDBOX_AD_PERSONALIZATION_SUBTITLE" desc="Subtitle of page where the user controls thier Browser-based ad personalization settings.">
Browser-based ad personalization
</message>
- <message name="IDS_PRIVACY_SANDBOX_TOPIC_INTERESTS_SUBTITLE" desc="TOPICS API A sub title that describes the first of 2 ways a site can get info from Chrome in order to target ads to the user. Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. * “Your”: we need to convey a sense of ownership, even if the user didn’t explicitly choose the interests we’re talking about. Without the “your”, it could sound like Chrome is simply building a generic library of interests. * “estimated”: It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “by Chrome”: This is new behavior for a browser (Chrome) to take an active role in processing user data for the purposes of showing ads. It’s important to convey “chrome”, the actor in this case.">
+ <message name="IDS_PRIVACY_SANDBOX_TOPIC_INTERESTS_SUBTITLE" desc="TOPICS API A sub title that describes the first of 2 ways a site can get info from Chrome in order to target ads to the user. Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. * “Your”: we need to convey a sense of ownership, even if the user didn’t explicitly choose the interests we’re talking about. Without the “your”, it could sound like Chrome is simply building a generic library of interests. * “estimated”: It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “by Chrome”: This is new behavior for a browser (Chrome) to take an active role in processing user data for the purposes of showing ads. It’s important to convey “chrome”, the actor in this case.">
Your interests as estimated by Chrome
</message>
+ <message name="IDS_PRIVACY_SANDBOX_FLEDGE_INTERESTS_SUBTITLE" desc="FLEDGE API. A sub title that describes the second of 2 ways a site can get info from Chrome in order to target ads to the user.">
+ Sites you visit that define your interests
+ </message>
<message name="IDS_PRIVACY_SANDBOX_TOPIC_EMPTY_STATE" desc="Summary shown when no interests for ad personlization are available for the Topics API of the Privacy Sandbox.">
A list of interests will appear here as you browse the web
</message>
<message name="IDS_PRIVACY_SANDBOX_REMOVED_TOPICS_EMPTY_STATE" desc="Summary shown when no interests for ad personlization were removed from the Topics API of the Privacy Sandbox.">
Interests you removed will appear here
</message>
+ <message name="IDS_PRIVACY_SANDBOX_REMOVED_SITES_EMPTY_STATE" desc="Summary shown when no interests for ad personlization were removed from the FLEDGE API of the Privacy Sandbox.">
+ Sites you removed will appear here
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_FLEDGE_SUBTITLE" desc="FLEDGE API A sub title that describes the second of 2 ways a site can get info from Chrome in order to target ads to the user.">
+ Sites you visit that define your interests
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_FLEDGE_EMPTY_STATE" desc="Summary shown when no interests for ad personlization are available for the FLEDGE API of the Privacy Sandbox.">
+ A list of sites will appear here as you browse the web
+ </message>
<!-- Privacy Sandbox dialog. -->
<message name="IDS_PRIVACY_SANDBOX_DIALOG_NO_BUTTON" desc="A button that allows the user to decline joining the Privacy Sandbox trials. If the user chooses “No thanks” this consent page disappears and the flow is complete.">
@@ -1033,21 +1055,24 @@ Trust tokens improve privacy on the web and can’t be used to find out who you
<message name="IDS_PRIVACY_SANDBOX_CONSENT_HEADING_ONE" desc="1 of 2 subtitles on the page. We want to write for users who skim the page. That means that the page title, the sub titles, and the button label all work well together as a mini story: 1) Help us build a more private web How? 2) Limit sharing between sites 3) More control over the ads you see 4) Yes, I’ll try it">
Limited sharing between sites
</message>
- <message name="IDS_PRIVACY_SANDBOX_CONSENT_DESCRIPTION_ONE" desc="* “exploring” conveys that this is a work in progress. * “restrict” means to lessen. We don’t want to suggest that we’re “eliminating” cross-site tracking. * “cross-site tracking”: An example: a user visits site A and then site B. Based on how third-party cookies work today, when that user later visits site C, site C can be aware that the user visited sites A and B, and can even have some sense for what they did on those sites. * “stop ad spam and fraud”: This feature isn’t really related to restricting cross-site tracking but we combined these features in the same sentence / section for structural reasons.">
- We’re exploring ways to restrict cross-site tracking while enabling sites to stop ad spam and fraud.
+ <message name="IDS_PRIVACY_SANDBOX_CONSENT_DESCRIPTION_ONE" desc="The description beneath the “Limited sharing between sites” subtitle. * “exploring” conveys that this is a work in progress. * “restrict” means to lessen. We don’t want to suggest that we’re “eliminating” cross-site tracking. * “tracking”: An example: a user visits site A and then site B. Based on how third-party cookies work today, when that user later visits site C, site C can be aware that the user visited sites A and B, and can even have some sense for what they did on those sites. * “stop ad spam and fraud”: This feature isn’t really related to restricting cross-site tracking but we combined these features in the same sentence / section for structural reasons.">
+ We’re exploring ways to restrict tracking while enabling sites to stop ad spam and fraud.
</message>
<message name="IDS_PRIVACY_SANDBOX_CONSENT_HEADING_TWO" desc="2 of 2 subtitles on the page. We want to write for users who skim the page. That means that the page title, the sub titles, and the button label all work well together as a mini story: 1) Help us build a more private web How? 2) Limit sharing between sites 3) More control over the ads you see 4) Yes, I’ll try it">
More control over the ads you see
</message>
- <message name="IDS_PRIVACY_SANDBOX_CONSENT_DESCRIPTION_TWO" desc="A paragraph beneath the “More control over the ads you see” subtitle. * “During the trials”: The trials happens in addition to today’s current system based on third-party cookies. In other words, even by agreeing to or remaining in a trial,, the user’s core experience doesn’t change much. This is an experiment, and we need the user to understand as much. * “see and remove topics of interests”: we want to stress the element of control * “estimate topics”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “recent browsing history”: Later in the UI, we define this as “a record of sites you’ve visited using Chrome on this device.” By “recent”, we mean the last 3 weeks (also defined later in the UI).">
- During the trials, you can see and remove topics of interest sites use to show you ads. Chrome estimates your interests based on your recent browsing history.
+ <message name="IDS_PRIVACY_SANDBOX_CONSENT_DESCRIPTION_TWO" desc="A paragraph beneath the “More control over the ads you see” subtitle. * “see and remove topics of interests”: we want to stress the element of control * “estimate topics”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “recent browsing history”: Later in the UI, we define this as “a record of sites you’ve visited using Chrome on this device.” By “recent”, we mean the last 3 weeks (also defined later in the UI).">
+ You can see and remove topics of interest sites use to show you ads. Chrome estimates your interests based on your recent browsing history.
</message>
<message name="IDS_PRIVACY_SANDBOX_CONSENT_DROPDOWN_BUTTON" desc="Learn more link * Unfolds content within the page * The text that appears describes 2 ways in which a site can target ads: the “Topics API” and the “FLEDGE API”. You can see what those are at www.privacysanbox.com or they’re described for the user’s benefit in other text. * “ad personalization” can mean different things in different contexts. Here, we’re using it as a simple noun. In other words, it’s not the name of a control but a descriptive term used to describe the personalization of ads in the Chrome browser. This “ad personalization” shouldn’t be confused with the setting in the Google Account called “Ad personalization”.">
Learn more about ad personalization in Chrome
</message>
- <message name="IDS_PRIVACY_SANDBOX_CONSENT_DROPDOWN_HEADING" desc="TOPICS API A sub title that describes the first of 2 ways a site can get info from Chrome in order to target ads to the user. Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. * “Your”: we need to convey a sense of ownership, even if the user didn’t explicitly choose the interests we’re talking about. Without the “your”, it could sound like Chrome is simply building a generic library of interests. * “estimated”: It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “by Chrome”: This is new behavior for a browser (Chrome) to take an active role in processing user data for the purposes of showing ads. It’s important to convey “chrome”, the actor in this case.">
+ <message name="IDS_PRIVACY_SANDBOX_CONSENT_DROPDOWN_TOPICS_HEADING" desc="TOPICS API A sub title that describes the first of 2 ways a site can get info from Chrome in order to target ads to the user. Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. * “Your”: we need to convey a sense of ownership, even if the user didn’t explicitly choose the interests we’re talking about. Without the “your”, it could sound like Chrome is simply building a generic library of interests. * “estimated”: It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “by Chrome”: This is new behavior for a browser (Chrome) to take an active role in processing user data for the purposes of showing ads. It’s important to convey “chrome”, the actor in this case.">
Your interests as estimated by Chrome
</message>
+ <message name="IDS_PRIVACY_SANDBOX_CONSENT_DROPDOWN_FLEDGE_HEADING" desc="FLEDGE API. A sub title that describes the second of 2 ways a site can get info from Chrome in order to target ads to the user.">
+ Sites you visit that define your interests
+ </message>
<message name="IDS_PRIVACY_SANDBOX_CONSENT_DESCRIPTION_THREE" desc="A conclusion paragraph for the entire page. It sits beneath the “More control over the ads you see” subtitle but it’s no more associated with that topic than “Limit sharing between sites”. * “You can change your mind”: When writing a consent moment, we have a legal obligation to inform the user how they can “revoke their consent” or “opt out”. A friendlier way to say this is “change your mind”. * “in Chrome settings”: The URL is chrome://settings/privacySandbox. We don’t make it a live link because we need the users to stay in this moment until they make a choice. * “The trials run alongside…”: The trials happen in addition to today’s current system based on third-party cookies. In other words, even by accepting in this consent moment, the user’s core experience doesn’t change much. This is an experiment, and we need the user to understand as much.">
You can change your mind at any time in Chrome settings. The trials run alongside the current way ads get served, so you won’t see changes right away.
</message>
@@ -1066,8 +1091,8 @@ Trust tokens improve privacy on the web and can’t be used to find out who you
<message name="IDS_PRIVACY_SANDBOX_NOTICE_SHEET_TITLE" desc="CONTEXT: there are updates to the Chrome browser each month. Just after the user accepts the latest update, this message will appear. The title of the page. * “Help us” is intended to convey a sense of collaboration. Privacy Sandbox is an ongoing multi-year effort. There are sites participating to help us and we also need users to agree to these trials so that we can measure the effectiveness of the features we're building. * “build” is intended to convey that this is a process. The user is agreeing to an effort rather than a stable set of features. Something like “make” doesn't have the same nuance. * See www.privacysandbox.com for more context.">
Help us build a better web
</message>
- <message name="IDS_PRIVACY_SANDBOX_NOTICE_SHEET_DESCRIPTION" desc="* “During the trials”: The trials happen in addition to today’s current system (which is based on third-party cookies). In other words, even by agreeing to or remaining in a trial, the user’s core experience doesn’t change much. This is an experiment, and we need the user to understand as much. * “estimate your interests”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”).">
- During trials, Chrome is exploring ways to limit spam, fraud, and sharing between sites. Chrome also <ph name="BEGIN_LINK">&lt;link&gt;</ph>estimates your interests<ph name="END_LINK">&lt;/link&gt;</ph> that sites can use to show you ads. You can manage your interests in settings.
+ <message name="IDS_PRIVACY_SANDBOX_NOTICE_SHEET_DESCRIPTION" desc="* “Chrome is finding new ways”: “finding” is meant to convey a work in progress, like “build” in the title. The features are live and functional, but still in beta. So we want a verb that’s stronger than “exploring” but weaker than “launching”. * “reduce tracking”: This used to read “reduce cross-site tracking”, but we’ve dropped “cross-site” because it makes the idea unnecessarily complicated. * “estimate your interests”: Topics of interest include things like “Live comedy” and “Rock music”. Chrome estimates these interests based on the sites users visit. It’s an “estimation”, and we don’t want to suggest that we know with certainty the user’s interests. Avoid words like “guess”, “establish”, “define”, etc. (in place of “estimate”). * “Then” is an important keyword. It suggests some amount of time later. The first step is that interests are generated. Later (minutes or weeks), a different site might request interests.">
+ Chrome is finding new ways to reduce tracking and keep you even safer as you browse. Chrome also <ph name="BEGIN_LINK">&lt;link&gt;</ph>estimates your interests<ph name="END_LINK">&lt;/link&gt;</ph> and enables you to manage them. Then, sites you visit can ask Chrome for your interests to show you ads.
</message>
<!-- Secure DNS Settings. Used by //chrome/browser/privacy. -->
@@ -1225,143 +1250,143 @@ Your Google account may have other forms of browsing history like searches and a
<ph name="NUMBER_OF_ITEMS">%1$s<ex>3</ex></ph> items deleted
</message>
- <!-- Privacy Review -->
- <message name="IDS_PREFS_PRIVACY_REVIEW_TITLE" desc="The title of the privacy review menu item.">
+ <!-- Privacy Guide -->
+ <message name="IDS_PREFS_PRIVACY_GUIDE_TITLE" desc="The title of the privacy guide menu item.">
Privacy guide
</message>
- <message name="IDS_PREFS_PRIVACY_REVIEW_SUMMARY" desc="The summary of the privacy menu item.">
- Review privacy and security settings
+ <message name="IDS_PREFS_PRIVACY_GUIDE_SUMMARY" desc="The summary of the privacy menu item.">
+ Review key privacy and security controls
</message>
- <message name="IDS_PRIVACY_REVIEW_WELCOME_TITLE" desc="Title on the welcome page of the privacy review.">
- The most important privacy and security controls in one place
+ <message name="IDS_PRIVACY_GUIDE_WELCOME_TITLE" desc="Title on the welcome page of the privacy guide.">
+ A guide of your privacy choices
</message>
- <message name="IDS_PRIVACY_REVIEW_WELCOME_DESCRIPTION" desc="Description on the welcome page of the privacy review.">
- Chrome provides reasonable defaults, but you can customize it to best fit your browsing habit
+ <message name="IDS_PRIVACY_GUIDE_WELCOME_DESCRIPTION" desc="Description on the welcome page of the privacy guide.">
+ Take a guided tour of key privacy and security controls. For more options, go to individual settings.
</message>
- <message name="IDS_PRIVACY_REVIEW_START_BUTTON" desc="Text on the privacy review start button on the welcome screen.">
+ <message name="IDS_PRIVACY_GUIDE_START_BUTTON" desc="Text on the privacy guide start button on the welcome screen.">
Let’s go
</message>
- <message name="IDS_PRIVACY_REVIEW_WHAT_YOU_GET" desc="Section header text describing what the user gets out of the feature.">
- What you get
+ <message name="IDS_PRIVACY_GUIDE_WHEN_ON" desc="Header of a description text that describes the behavior of a particular feature. This description is shown to users alongside the feature itself." meaning="Privacy Guide - feature benefits">
+ When on
</message>
- <message name="IDS_PRIVACY_REVIEW_WHAT_YOU_SHARE" desc="Section header text describing what data the user shares when using the feature.">
- What you share with Google
+ <message name="IDS_PRIVACY_GUIDE_THINGS_TO_CONSIDER" desc="Header of a text column that describes things users should consider about a feature. This description is shown to users alongside the feature itself." meaning="Privacy Guide - feature considerations">
+ Things to consider
</message>
- <message name="IDS_PRIVACY_REVIEW_MSBB_ITEM_ONE" desc="First bullet point that describes the details of the MSBB toggle.">
+ <message name="IDS_PRIVACY_GUIDE_MSBB_ITEM_ONE" desc="First bullet point that describes the details of the MSBB toggle.">
You’ll browse faster because content is proactively loaded based on your current webpage visit
</message>
- <message name="IDS_PRIVACY_REVIEW_MSBB_ITEM_TWO" desc="Second bullet point that describes the details of the MSBB toggle.">
+ <message name="IDS_PRIVACY_GUIDE_MSBB_ITEM_TWO" desc="Second bullet point that describes the details of the MSBB toggle.">
You’ll get improved suggestions in the address bar
</message>
- <message name="IDS_PRIVACY_REVIEW_MSBB_ITEM_THREE" desc="Third bullet point that describes the details of the MSBB toggle.">
- URLs you visit are sent to Google
+ <message name="IDS_PRIVACY_GUIDE_MSBB_ITEM_THREE" desc="Third bullet point that describes the details of the MSBB toggle.">
+ URLs you visit are sent to Google to predict what sites you might visit next
</message>
- <message name="IDS_PRIVACY_REVIEW_MSBB_ITEM_FOUR" desc="Fourth bullet point that describes the details of the MSBB toggle.">
+ <message name="IDS_PRIVACY_GUIDE_MSBB_ITEM_FOUR" desc="Fourth bullet point that describes the details of the MSBB toggle.">
If you also share Chrome usage reports, those reports include the URLs you visit
</message>
- <message name="IDS_PRIVACY_REVIEW_SYNC_TOGGLE" desc="Title for the history sync toggle.">
+ <message name="IDS_PRIVACY_GUIDE_SYNC_TOGGLE" desc="Title for the history sync toggle.">
History sync
</message>
- <message name="IDS_PRIVACY_REVIEW_SYNC_ITEM_ONE" desc="First bullet point that describes the details of the history sync toggle.">
- You’ll have your history on all your synced devices, so you can continue what you were doing
+ <message name="IDS_PRIVACY_GUIDE_SYNC_ITEM_ONE" desc="First bullet point that describes the details of the history sync toggle.">
+ You’ll have your history on all your synced devices so you can continue what you were doing
</message>
- <message name="IDS_PRIVACY_REVIEW_SYNC_ITEM_TWO" desc="Second bullet point that describes the details of the history sync toggle.">
+ <message name="IDS_PRIVACY_GUIDE_SYNC_ITEM_TWO" desc="Second bullet point that describes the details of the history sync toggle.">
If Google is also your default search engine, you’ll see better, contextually relevant suggestions
</message>
- <message name="IDS_PRIVACY_REVIEW_SYNC_ITEM_THREE" desc="Third bullet point that describes the details of the history sync toggle.">
- The URLs you visit are saved to your Google account
+ <message name="IDS_PRIVACY_GUIDE_SYNC_ITEM_THREE" desc="Third bullet point that describes the details of the history sync toggle.">
+ The URLs you visit are saved to your Google Account
</message>
- <message name="IDS_PRIVACY_REVIEW_COOKIES_INTRO" desc="Text introducing the cookies control.">
+ <message name="IDS_PRIVACY_GUIDE_COOKIES_INTRO" desc="Text introducing the cookies control.">
Choose when to block third-party cookies
</message>
- <message name="IDS_PRIVACY_REVIEW_COOKIES_BLOCK_INCOGNITO_TITLE" desc="Title for the radio button for blocking third-party cookies in incognito.">
+ <message name="IDS_PRIVACY_GUIDE_COOKIES_BLOCK_INCOGNITO_TITLE" desc="Title for the radio button for blocking third-party cookies in incognito.">
Block while using incognito
</message>
- <message name="IDS_PRIVACY_REVIEW_COOKIES_BLOCK_INCOGNITO_DESCRIPTION" desc="Description for the radio button for blocking third-party cookies in incognito.">
+ <message name="IDS_PRIVACY_GUIDE_COOKIES_BLOCK_INCOGNITO_DESCRIPTION" desc="Description for the radio button for blocking third-party cookies in incognito.">
While in incognito, sites can’t use your cookies to see your browsing activity across different sites, for example, to personalize ads. Features on some sites may break.
</message>
- <message name="IDS_PRIVACY_REVIEW_COOKIES_BLOCK_ALWAYS_TITLE" desc="Title for the radio button for blocking third-party cookies always.">
+ <message name="IDS_PRIVACY_GUIDE_COOKIES_BLOCK_ALWAYS_TITLE" desc="Title for the radio button for blocking third-party cookies always.">
Block all the time
</message>
- <message name="IDS_PRIVACY_REVIEW_COOKIES_BLOCK_ALWAYS_DESCRIPTION" desc="Description for the radio button for blocking third-party cookies always.">
+ <message name="IDS_PRIVACY_GUIDE_COOKIES_BLOCK_ALWAYS_DESCRIPTION" desc="Description for the radio button for blocking third-party cookies always.">
Sites can only use your cookies to see your browsing activity only on their own site
</message>
- <message name="IDS_PRIVACY_REVIEW_SAFE_BROWSING_INTRO" desc="Text introducing the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SAFE_BROWSING_INTRO" desc="Text introducing the Safe Browsing control.">
Choose your Safe Browsing protection
</message>
- <message name="IDS_PRIVACY_REVIEW_SAFE_BROWSING_ENHANCED_TITLE" desc="Title for the radio button for the enhanced Safe Browsing.">
+ <message name="IDS_PRIVACY_GUIDE_SAFE_BROWSING_ENHANCED_TITLE" desc="Title for the radio button for the enhanced Safe Browsing.">
Enhanced protection
</message>
- <message name="IDS_PRIVACY_REVIEW_SAFE_BROWSING_ENHANCED_DESCRIPTION" desc="Description for the radio button for the enhanced Safe Browsing.">
+ <message name="IDS_PRIVACY_GUIDE_SAFE_BROWSING_ENHANCED_DESCRIPTION" desc="Description for the radio button for the enhanced Safe Browsing.">
Faster, proactive protection against dangerous websites, downloads, and extensions
</message>
- <message name="IDS_PRIVACY_REVIEW_SAFE_BROWSING_STANDARD_TITLE" desc="Title for the radio button for the standard Safe Browsing.">
+ <message name="IDS_PRIVACY_GUIDE_SAFE_BROWSING_STANDARD_TITLE" desc="Title for the radio button for the standard Safe Browsing.">
Standard protection
</message>
- <message name="IDS_PRIVACY_REVIEW_SAFE_BROWSING_STANDARD_DESCRIPTION" desc="Description for the radio button for the standard Safe Browsing.">
+ <message name="IDS_PRIVACY_GUIDE_SAFE_BROWSING_STANDARD_DESCRIPTION" desc="Description for the radio button for the standard Safe Browsing.">
Standard protection against websites, downloads, and extensions that are known to be dangerous
</message>
- <message name="IDS_PRIVACY_REVIEW_FINISH_BUTTON" desc="Text on the button to finish the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_FINISH_BUTTON" desc="Text on the button to finish the privacy guide">
Finish
</message>
- <message name="IDS_PRIVACY_REVIEW_DONE_TITLE" desc="Title on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_DONE_TITLE" desc="Title on the final page of the privacy guide">
Review complete!
</message>
- <message name="IDS_PRIVACY_REVIEW_DONE_DESCRIPTION" desc="Subtitle on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_DONE_DESCRIPTION" desc="Subtitle on the final page of the privacy guide">
Explore more settings below or finish now
</message>
- <message name="IDS_PRIVACY_REVIEW_PRIVACY_SANDBOX_HEADING" desc="Title for the Privacy Sandbox item on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_PRIVACY_SANDBOX_HEADING" desc="Title for the Privacy Sandbox item on the final page of the privacy guide">
Privacy Sandbox trial
</message>
- <message name="IDS_PRIVACY_REVIEW_PRIVACY_SANDBOX_DESCRIPTION" desc="Description for the Privacy Sandbox item on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_PRIVACY_SANDBOX_DESCRIPTION" desc="Description for the Privacy Sandbox item on the final page of the privacy guide">
See how Chrome plans to safeguard you from cross-site tracking while preserving the open web
</message>
- <message name="IDS_PRIVACY_REVIEW_WEB_APP_ACTIVITY_HEADING" desc="Title for the Web and App Activity item on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_WEB_APP_ACTIVITY_HEADING" desc="Title for the Web and App Activity item on the final page of the privacy guide">
Web &amp; App Activity
</message>
- <message name="IDS_PRIVACY_REVIEW_WEB_APP_ACTIVITY_DESCRIPTION" desc="Description for the Web and App Activity item on the final page of the privacy review">
+ <message name="IDS_PRIVACY_GUIDE_WEB_APP_ACTIVITY_DESCRIPTION" desc="Description for the Web and App Activity item on the final page of the privacy guide">
Choose whether to include Chrome history for more personalized experiences in Google services
</message>
- <message name="IDS_PRIVACY_REVIEW_EXPLANATION_CONTENT_DESCRIPTION" desc="The content description for the privacy review explanation bottom sheet. Read as accessibility string when tapping on the bottom sheet.">
+ <message name="IDS_PRIVACY_GUIDE_EXPLANATION_CONTENT_DESCRIPTION" desc="The content description for the privacy guide explanation bottom sheet. Read as accessibility string when tapping on the bottom sheet.">
Privacy guide explanation
</message>
- <message name="IDS_PRIVACY_REVIEW_EXPLANATION_OPENED_HALF" desc="The accessibility string read when the privacy review explanation bottom sheet is half opened.">
+ <message name="IDS_PRIVACY_GUIDE_EXPLANATION_OPENED_HALF" desc="The accessibility string read when the privacy guide explanation bottom sheet is half opened.">
Privacy guide explanation opened at half height
</message>
- <message name="IDS_PRIVACY_REVIEW_EXPLANATION_OPENED_FULL" desc="The accessibility string read when the privacy review explanation bottom sheet is fully opened.">
+ <message name="IDS_PRIVACY_GUIDE_EXPLANATION_OPENED_FULL" desc="The accessibility string read when the privacy guide explanation bottom sheet is fully opened.">
Privacy guide explanation opened at full height
</message>
- <message name="IDS_PRIVACY_REVIEW_EXPLANATION_CLOSED_DESCRIPTION" desc="The accessibility string read when the privacy review explanation bottom sheet is closed.">
+ <message name="IDS_PRIVACY_GUIDE_EXPLANATION_CLOSED_DESCRIPTION" desc="The accessibility string read when the privacy guide explanation bottom sheet is closed.">
Privacy guide explanation closed
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_STANDARD_ITEM_ONE" desc="First bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_STANDARD_ITEM_ONE" desc="First bullet point that describes the details of the Safe Browsing control.">
Detects and warns you about dangerous events when they happen
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_STANDARD_ITEM_TWO" desc="Second bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_STANDARD_ITEM_TWO" desc="Second bullet point that describes the details of the Safe Browsing control.">
Checks URLs with a list of unsafe sites stored in Chrome
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_STANDARD_ITEM_THREE" desc="Third bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_STANDARD_ITEM_THREE" desc="Third bullet point that describes the details of the Safe Browsing control.">
If a site tries to steal your password, or when you download a harmful file, Chrome may send URLs including bits of page content to Safe Browsing
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_ONE" desc="First bullet point that describes the details of the Safe Browsing control.">
- Warns you about dangerous events before they happen
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_ONE" desc="First bullet point that describes the details of the Safe Browsing control.">
+ Predicts and warns you about dangerous events before they happen
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_TWO" desc="Second bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_TWO" desc="Second bullet point that describes the details of the Safe Browsing control.">
Keeps you safe on Chrome and may be used to improve your security in other Google apps when you are signed in
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_THREE" desc="Third bullet point that describes the details of the Safe Browsing control.">
- Warns you if passwords are exposed in a data breach
- </message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_FOUR" desc="Fourth bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_THREE" desc="Third bullet point that describes the details of the Safe Browsing control.">
Improves security for you and everyone on the web
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_FIVE" desc="Fifth bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_FOUR" desc="Fourth bullet point that describes the details of the Safe Browsing control.">
+ Warns you if passwords are exposed in a data breach
+ </message>
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_FIVE" desc="Fifth bullet point that describes the details of the Safe Browsing control.">
Sends URLs to Safe Browsing to check them
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_SIX" desc="Sixth bullet point that describes the details of the Safe Browsing control.">
- Sends a small sample of pages, downloads, extension activity, and system information to help discover new threats
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_SIX" desc="Sixth bullet point that describes the details of the Safe Browsing control.">
+ Also sends a small sample of pages, downloads, extension activity, and system information to help discover new threats
</message>
- <message name="IDS_PRIVACY_REVIEW_SB_ENHANCED_ITEM_SEVEN" desc="Seventh bullet point that describes the details of the Safe Browsing control.">
+ <message name="IDS_PRIVACY_GUIDE_SB_ENHANCED_ITEM_SEVEN" desc="Seventh bullet point that describes the details of the Safe Browsing control.">
Temporarily links this data to your Google Account when you’re signed in, to protect you across Google apps
</message>
@@ -1422,6 +1447,9 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_SAFETY_CHECK_PASSWORDS_ERROR_QUOTA_LIMIT" desc="Text to display when the password check hits the daily quota limit.">
Chrome couldn’t check all passwords
</message>
+ <message name="IDS_SAFETY_CHECK_PASSWORDS_UPDATE_PLAY_SERVICES" desc="Text to display when the password check is unable to run because Google Play services version is not supported.">
+ Update Google Play services to check your passwords
+ </message>
<message name="IDS_SAFETY_CHECK_UPDATES_UPDATED" desc="Text to display when the updates check confirms that the latest version is already installed.">
Chrome is up to date
</message>
@@ -1562,7 +1590,7 @@ Your Google account may have other forms of browsing history like searches and a
Other languages
</message>
<message name="IDS_LANGUAGES_CONTENT_TITLE" desc="Title of Language settings section to add or remove preferred content languages. Content languages are selected by the user and tell Chrome what language the user prefers webpage content in. [CHAR_LIMIT=32]">
- Content languages
+ Preferred languages
</message>
<message name="IDS_LANGUAGES_CONTENT_DESCRIPTION" desc="Description of Content language on the Language settings screen. Appears above a list of one or more languages that the user selects to tell Chrome which languages they prefer webpage content in.">
To show content in your preferred languages, the sites you visit can see your preferences
@@ -1588,6 +1616,9 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_LANGUAGES_SRP_SUBTITLE" desc="Subtitle warning a user that the language of their keyboard will not change if they change the application language of Chrome on Android.">
Your keyboard won’t change
</message>
+ <message name="IDS_LANGUAGES_MORE_LANGUAGES" desc="Text used in a language picker to hide languages that a user is less likely to select. [CHAR_LIMIT=32]">
+ More languages
+ </message>
<message name="IDS_LANGUAGES_SRP_LOADING_TEXT" desc="Text to display while a language pack is being downloaded.">
Loading <ph name="LANG">%1$s<ex>Hindi</ex></ph>
</message>
@@ -1660,45 +1691,12 @@ Your Google account may have other forms of browsing history like searches and a
</message>
<!-- Download later -->
- <message name="IDS_DOWNLOAD_LATER_DIALOG_TITLE" desc="Title of the download later dialog that let the user to choose the time to download.">
- Download later instead?
- </message>
- <message name="IDS_DOWNLOAD_LATER_DIALOG_SUBTITLE" desc="Subtitle of the download later dialog that let the user to choose the time to download.">
- You'll see a notification when this file is ready
- </message>
- <message name="IDS_DOWNLOAD_LATER_DOWNLOAD_NOW_TEXT" desc="The text for the radio button to trigger the download now in download later dialog.">
- Now
- </message>
- <message name="IDS_DOWNLOAD_LATER_EDIT_LOCATION" desc="The text in the download later dialog that can be clicked to edit download location.">
- Your file will be saved to <ph name="BEGIN_BOLD">&lt;b&gt;</ph><ph name="DIRECTORY">%1$s<ex>Downloads</ex></ph><ph name="END_BOLD">&lt;/b&gt;</ph>. <ph name="BEGIN_LINK2">&lt;LINK2&gt;</ph>Edit<ph name="END_LINK2">&lt;/LINK2&gt;</ph>.
- </message>
<message name="IDS_DOWNLOAD_DATE_TIME_PICKER_NEXT_TEXT" desc="The text for the positive button of the download date time picker dialog.">
Next
</message>
- <message name="IDS_DOWNLOAD_LATER_ON_WIFI_TEXT" desc="The text for the radio button to trigger the download on WIFI in download later dialog.">
- On Wi-Fi
- </message>
- <message name="IDS_DOWNLOAD_LATER_PICK_TIME_TEXT" desc="The text for the radio button to select the download time in download later dialog.">
- Pick date &amp; time
- </message>
<message name="IDS_DOWNLOAD_LATER_PROMPT_ENABLED_TITLE" desc="A setting text to ask whether to show a dialog about when to download.">
Ask when to save files
</message>
- <message name="IDS_DOWNLOAD_LATER_SLOW_NETWORK_SUBTITLE" desc="A subtitle in the download later dialog to inform the user about slow network connection.">
- Your <ph name="CONNECTION_TYPE">%1$s<ex>2G</ex></ph> connection might slow down your download
- </message>
- <message name="IDS_DOWNLOAD_LATER_2G_CONNECTION" desc="2G connection type.">
- 2G
- </message>
- <message name="IDS_DOWNLOAD_LATER_BLUETOOTH_CONNECTION" desc="Bluetooth connection type.">
- Bluetooth
- </message>
- <message name="IDS_DOWNLOAD_LATER_LARGE_FILE_SUBTITLE" desc="A subtitle in the download later dialog to inform the user about large download file size.">
- This file is large (<ph name="FILE_SIZE">%1$s<ex>300MB</ex></ph>)
- </message>
- <message name="IDS_DOWNLOAD_LATER_DIALOG_POSITIVE_BUTTON_TEXT" desc="The text of positive button on the download later dialog.">
- Done
- </message>
<!-- Downloads location -->
<message name="IDS_DOWNLOADS_LOCATION_SELECTOR_TITLE" desc="Title of the preference that allows the user to select which of the folders they would like to make the default location to save their downloads.">
@@ -1842,8 +1840,27 @@ Your Google account may have other forms of browsing history like searches and a
Allow all sites
</message>
- <message name="IDS_POWERED_BY_CHROME_MESSAGE" desc="A message indicating that the current page is running in Chrome.">
- Powered by Chrome
+ <!-- Parent approval widget. TODO(crbug.com/1330900): enable translations once strings are finalized. -->
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_TITLE" desc="The title text displayed in the bottom sheet asking a parent to allow or not allow a website." translateable="false">
+ <ph name="CHILD_NAME">%1$s<ex>Alice</ex></ph> wants you to approve this website:
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_ALL_OF_DOMAIN" desc="The text which tells the parent that all of a particular domain will be allowed if they approve the request." translateable="false">
+ All pages of <ph name="DOMAIN">%1$s<ex>netflix.com</ex></ph>
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_APPROVE_BUTTON" desc="The text displayed on the button to approve a website." translateable="false">
+ Approve
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_DENY_BUTTON" desc="The text displayed on the button to not approve a website." translateable="false">
+ Don’t approve
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_CONTENT_DESCRIPTION" desc="The content description for the bottom sheet allowing a parent to approve or deny a request to view a website." translateable="false">
+ Option to approve or not approve a website
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_FULL_HEIGHT" desc="Accessibility string read when the parent website approval bottom sheet is opened at full height." translateable="false">
+ Option to approve or not approve a website opened at full height
+ </message>
+ <message name="IDS_PARENT_WEBSITE_APPROVAL_CLOSED" desc="Accessibility string read when the parent website approval bottom sheet is closed." translateable="false">
+ Option to approve or not approve a website closed
</message>
<!-- Sync strings in account management dialog -->
@@ -2244,6 +2261,16 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Download will start at <ph name="time">%1$s<ex>8:30PM</ex></ph>.
</message>
+ <message name="IDS_INCOGNITO_DOWNLOAD_MESSAGE_TITLE" desc="Download title displayed in a prompt message when the user downloads a file in Incognito mode.">
+ Download file?
+ </message>
+ <message name="IDS_INCOGNITO_DOWNLOAD_MESSAGE_DETAIL" desc="Download message text displayed in a prompt message when the user downloads a file in Incognito mode.">
+ Anyone using this device can see downloaded files
+ </message>
+ <message name="IDS_INCOGNITO_DOWNLOAD_MESSAGE_BUTTON" desc="Download primary button text displayed in a prompt message when the user downloads a file in Incognito mode.">
+ Download
+ </message>
+
<message name="IDS_MENU_TRANSLATE" desc="Menu item for triggering a page translation. The word 'Translate' should match the translation in TC ID 1613971242435858090. [CHAR_LIMIT=27]">
Translate…
</message>
@@ -2289,6 +2316,15 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_PASSWORD_FILLING_REAUTH_PROMPT_TITLE" desc="The title of the authentication dialog displayed before the password manager fills a saved password into a website.">
Verify it’s you
</message>
+ <message name="IDS_PASSWORD_MANAGER_OUTDATED_GMS_DIALOG_DESCRIPTION" desc="Description text of the dialog appearing when the Google Play Services needs to be updated to use the Google Password Manager. Dialog suggests to update the Google Play Services.">
+ To manage your passwords, update Google Play services
+ </message>
+ <message name="IDS_PASSWORD_MANAGER_OUTDATED_GMS_POSITIVE_BUTTON" desc="Label for the positive ('update') button of the dialog appearing when the Google Play Services needs to be updated to use the Google Password Manager. Clicking on this button opens the Google Play services page in the Google Play Store.">
+ Update
+ </message>
+ <message name="IDS_PASSWORD_MANAGER_OUTDATED_GMS_NEGATIVE_BUTTON" desc="Label for the negative ('not now') button of the dialog appearing when the Google Play Services needs to be updated to use the Google Password Manager. Clicking on this button dismisses the dialog without further actions.">
+ Not now
+ </message>
<!-- Runtime permission strings -->
<message name="IDS_MISSING_STORAGE_PERMISSION_DOWNLOAD_EDUCATION_TEXT" desc="Text shown educating the user that Chrome is missing the Android storage permission, which is required to download files.">
@@ -2443,12 +2479,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_IPH_PWA_INSTALL_AVAILABLE_TEXT" desc="The in-product-help message for PWAs that can be installed to the device.">
Install this app
</message>
- <message name="IDS_IPH_BUBBLE_ADD_TO_HOME_SCREEN" desc="The in-product-help text bubble message encouraging users to add a commonly visited webpage to the home screen.">
- To get here quicker, add this page to your Home screen
- </message>
- <message name="IDS_IPH_BUBBLE_ADD_TO_HOME_SCREEN_ACCESSIBILITY" desc="The in-product-help text bubble message encouraging users to add a commonly visited webpage to the home screen. Used when a screen reader is turned. 'More options' should match TC ID 8110367050267853536.">
- To get here quicker, add this page to your Home screen from the More options button
- </message>
<message name="IDS_IPH_MESSAGE_ADD_TO_HOME_SCREEN_TITLE" desc="The title of in-product-help message encouraging users to add a commonly visited webpage to the home screen.">
Add to Home screen
</message>
@@ -2755,6 +2785,20 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
See other tabs
</message>
+ <!-- Incognito reauthentication promo card -->
+ <message name ="IDS_INCOGNITO_REAUTH_PROMO_TITLE" desc="The title of the incognito re-auth promo card.">
+ Lock Incognito tabs when you leave Chrome
+ </message>
+ <message name ="IDS_INCOGNITO_REAUTH_PROMO_DESCRIPTION" desc="The description of the incognito re-auth promo card.">
+ Use screen lock to see open Incognito tabs
+ </message>
+ <message name ="IDS_INCOGNITO_REAUTH_LOCK_ACTION_TEXT" desc="The label of the button which upon click would turn on the corresponding Chrome level Incognito lock setting after a re-authentication.">
+ Turn on Incognito lock
+ </message>
+ <message name ="IDS_INCOGNITO_REAUTH_SNACKBAR_TEXT" desc="The label of the snackbar notification which appears after the incognito re-authentication is turned on from the promo card shown inside the Incognito grid tab switcher.">
+ Incognito tabs will be locked when you leave Chrome
+ </message>
+
<!-- Autofill/Wallet integration prompt -->
<message name="IDS_CARD_UNMASK_INPUT_HINT" desc="Hint text for an input field containing the user's credit card CVC (card verification code).">
CVC
@@ -2857,6 +2901,18 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SIGNIN_TITLE" desc="Title for the screen that asks users to sign-in and turn on Sync. [CHAR_LIMIT=27]">
Turn on sync?
</message>
+ <message name="IDS_SYNC_CONSENT_TITLE" desc="This string appears as a heading on a full-page screen that asks users if they want to turn on sync. 'Sync' is short for 'synchronization'. The tone should be informative and inviting. [CHAR_LIMIT=35]">
+ Turn on sync
+ </message>
+ <message name="IDS_SYNC_CONSENT_TITLE_VARIATION" desc="This string appears as a heading on a full-page screen that asks users if they want to turn on sync. 'Sync' is short for 'synchronization'. [CHAR_LIMIT=20]">
+ Sync
+ </message>
+ <message name="IDS_SYNC_CONSENT_SUBTITLE" desc="This string appears as a subheading on a full-page screen that asks users if they want to turn on sync. This string explains to users that they can back up their Chrome data and use it on all their computers, phones, and other devices; a user's Chrome data includes their bookmarks, passwords, history, settings, and more. The word 'stuff' can be translated as 'data' or similar if there is no natural translation of 'stuff'. Maintain the level of formality that your language generally uses in the Chrome app. The tone should be informative and inviting. [CHAR_LIMIT=100]">
+ Back up your stuff and use it on any device
+ </message>
+ <message name="IDS_SYNC_CONSENT_SUBTITLE_VARIATION" desc="This string appears as a subheading on a full-page screen that asks users if they want to turn on sync. This string explains to users that they can get their Chrome data on all their computers, phones, and other devices; a user's Chrome data includes their bookmarks, passwords, history, settings, and more. Maintain the level of formality that your language generally uses in the Chrome app. The tone should be informative and inviting. [CHAR_LIMIT=100]">
+ Sync your data on all devices
+ </message>
<message name="IDS_SIGNIN_SYNC_TITLE" desc="Title of Sync feature for the screen that asks users to sign-in and turn on Sync.">
Sync your passwords, history &amp; more on all devices
</message>
@@ -2866,6 +2922,18 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SIGNIN_DETAILS_DESCRIPTION" desc="Message with a link to customize Sync settings. Shown on the screen that asks the user to turn on Sync.">
You can always choose what to sync in <ph name="BEGIN_LINK1">&lt;LINK1&gt;</ph>settings<ph name="END_LINK1">&lt;/LINK1&gt;</ph>.
</message>
+ <message name="IDS_SYNC_CONSENT_DETAILS_DESCRIPTION" desc="This string appears in the footer on a full-page screen that asks users if they want to turn on sync. 'Sync' is short for 'synchronization'. The first sentence informs the user where they can go to change their mind or to customize what Chrome data types they choose to sync (a user's Chrome data includes their bookmarks, passwords, history, settings, and more). The second sentence informs the user that if they choose to sync, then their history may be used to personalize Search and other services. Translate 'history' according to https://localization.google.com/glossary/termset?gid=27517723&amp;tsid=59c3162. [CHAR_LIMIT=200].">
+ You can always choose what to sync in <ph name="BEGIN_LINK1">&lt;LINK1&gt;</ph>settings<ph name="END_LINK1">&lt;/LINK1&gt;</ph>. Google may personalize Search and other services based on your history.
+ </message>
+ <message name="IDS_SYNC_CONSENT_BOOKMARKS_TEXT" desc="This string appears as an item in a list of sync data types on a full-page screen that asks users if they want to turn on sync. Translate 'bookmarks' according to https://localization.google.com/glossary/termset?gid=27517723&amp;tsid=59c31bb. [CHAR_LIMIT=25]">
+ Bookmarks
+ </message>
+ <message name="IDS_SYNC_CONSENT_AUTOFILL_TEXT" desc="This string appears as an item in a list of sync data types on a full-page screen that asks users if they want to turn on sync. Translate 'autofill' according to https://localization.google.com/glossary/termset?gid=27517723&amp;tsid=77d3626. [CHAR_LIMIT=25]">
+ Autofill
+ </message>
+ <message name="IDS_SYNC_CONSENT_HISTORY_TEXT" desc="This string appears as an item in a list of sync data types on a full-page screen that asks users if they want to turn on sync. Translate 'history' according to https://localization.google.com/glossary/termset?gid=27517723&amp;tsid=59c3162. Translate 'and more' so that it conveys that there are additional similar items that are not listed. [CHAR_LIMIT=30]">
+ History and more
+ </message>
<message name="IDS_SIGNIN_ACCEPT_BUTTON" desc="Text for the confirmation button in the sign-in screen. By clicking this button users signs in and turns on Sync. [CHAR_LIMIT=20]">
Yes, I'm in
</message>
@@ -2882,10 +2950,10 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Sign in to Chrome, closed.
</message>
<message name="IDS_SIGNIN_ACCOUNT_PICKER_BOTTOM_SHEET_SUBTITLE" desc="The subtitle for the account picker bottom sheet that tells the user what happens if the button 'Continue as John Doe' is clicked">
- Sign in to this site and Chrome with your Google Account. You can turn on sync later.
+ Sign in to this site and Chrome
</message>
<message name="IDS_SIGNIN_ACCOUNT_PICKER_BOTTOM_SHEET_SUBTITLE_FOR_SEND_TAB_TO_SELF" desc="The subtitle for the account picker bottom sheet that tells the user what happens if the button 'Continue as John Doe' is clicked, when send-tab-to-self triggered the UI.">
- You can send tabs between devices that are signed in with the same Google Account
+ To send this tab to another device, sign in to Chrome on both devices
</message>
<message name="IDS_SIGNIN_ACCOUNT_PICKER_BOTTOM_SHEET_SIGNIN_TITLE" desc="The title of the account picker bottom sheet tells that the user is in the process of signing in with their Google Account">
Signing in...
@@ -3648,7 +3716,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Try again
</message>
<message name="IDS_IPH_PRICE_TRACKING_MENU_ITEM" desc="In-product-help text that describes that a user can track the price of a product in the overflow menu.">
- Track price here
+ Track price
</message>
<message name="IDS_IPH_PRICE_TRACKING_MENU_ITEM_ACCESSIBILITY" is_accessibility_with_no_ui="true" desc="In-product-help accessibility text that describes that a user can track the price of a product in the overflow menu.">
Track price from the More options button
@@ -3797,6 +3865,17 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Take survey
</message>
+ <!-- Request Desktop Site -->
+ <message name="IDS_RDS_GLOBAL_DEFAULT_ON_MESSAGE_TITLE" desc="Title of the message shown when the desktop site global setting is default-enabled on premium tablets.">
+ Desktop sites requested by default
+ </message>
+ <message name="IDS_RDS_GLOBAL_DEFAULT_ON_MESSAGE_BUTTON" desc="Text on the button reflecting an opt-out of the default setting update.">
+ Update settings
+ </message>
+ <message name="IDS_RDS_GLOBAL_OPT_IN_MESSAGE_TITLE" desc="Title of the message shown for the user to opt in to the desktop site global setting based on device conditions.">
+ Request desktop sites by default?
+ </message>
+
<!-- Accessibility -->
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_MENU_UPDATE" desc="Content description for the menu button when it is covered by the update icon that is displayed when a newer version of Chrome is available.">
@@ -3887,15 +3966,18 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_OMNIBOX_SHOWING_SUGGESTIONS_FOR_WEBSITE" desc="Whenever the User is visiting a Website, when they click the Omnibox, we will announce this message, if we have suggestions to show.">
Showing suggestions for <ph name="WEBSITE_TITLE">%1$s<ex>Crater Lake National Park (U.S. National Park Service)</ex></ph>
</message>
- <message name="IDS_ACCESSIBILITY_OMNIBOX_MOST_VISITED_TILE" desc="When the user focuses a Frequently Visited URL tile suggestion, the tile will be crome://announced according to the following pattern">
- <ph name="WEBSITE_TITLE">%1$s<ex>Crater Lake National Park (U.S. National Park Service)</ex></ph>: <ph name="WEBSITE_URL">%2$s<ex>https://www.nps.gov/crla</ex></ph>
- </message>
<message name="IDS_ACCESSIBILITY_OMNIBOX_PEDAL" desc="Announce focused Chrome Action Button on the Omnibox Suggestions List. List of known Action buttons is defined here: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/omnibox/omnibox_pedal_implementations.cc">
Chrome action button: <ph name="ACTION">%s<ex>clear browsing data</ex></ph>
</message>
<message name="IDS_ACCESSIBILITY_OMNIBOX_SUGGESTED_ITEMS" desc="Announcement about the presence and volume of suggestions below the Omnibox.">
<ph name="SUGGESTIONS_COUNT">%d<ex>12</ex></ph> suggested items in list below.
</message>
+ <message name="IDS_ACCESSIBILITY_OMNIBOX_MOST_VISITED_TILE_SEARCH" desc="Announces that interacting with a Tile executes a specific search query.">
+ Search: <ph name="SEARCH_QUERY">%s<ex>Weather in San Francisco</ex></ph>
+ </message>
+ <message name="IDS_ACCESSIBILITY_OMNIBOX_MOST_VISITED_TILE_NAVIGATE" desc="Announces that interacting with a Tile takes the user to specific website.">
+ Navigate: <ph name="WEBSITE_TITLE">%1$s<ex>Crater Lake National Park (U.S. National Park Service)</ex></ph>: <ph name="WEBSITE_URL">%2$s<ex>https://www.nps.gov/crla</ex></ph>
+ </message>
<message name="IDS_ACCESSIBILITY_SHARE_SELECTED_ITEMS" desc="Content description for the button to share selected items. [ICU Syntax]">
{NUM_SELECTED, plural,
@@ -4200,6 +4282,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_TWA_RUNNING_IN_CHROME" desc="Message on a snackbar indicating that the current Activity may use Chrome data (the rest of the app may not be).">
Running in Chrome
</message>
+ <message name="IDS_TWA_RUNNING_IN_CHROME_TEMPLATE" desc="Message template that used to indicating that the current Activity may use Chrome data (the rest of the app may not be). [CHAR_LIMIT=32]">
+ Running in <ph name="APP_NAME">%1$s<ex>Chromium</ex></ph>
+ </message>
<message name="IDS_TWA_RUNNING_IN_CHROME_V2" desc="Updated message on a snackbar indicating that the current Activity may use Chrome data (the rest of the app may not be).">
You'll see your <ph name="SITE_NAME">%1$s<ex>www.youtube.com</ex></ph> sign-in status, browsing data, and site data in Chrome
</message>
@@ -4495,6 +4580,12 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_IPH_TRANSLATE_MENU_BUTTON_ACCESSIBILITY_TEXT" desc="The in-product-help accessibility text after a successful navigation prompting user to translate current page.">
Translate this page to any language from the More options button
</message>
+ <message name="IDS_IPH_TRANSLATE_MESSAGE_DISMISSED_TEXT" desc="The in-product-help message after the prompt for the user to translate the current page has disappeared, in order to show the user how to bring the translate prompt back.">
+ Translate pages here
+ </message>
+ <message name="IDS_IPH_TRANSLATE_MESSAGE_DISMISSED_ACCESSIBILITY_TEXT" desc="The in-product-help message spoken by screen readers after the prompt for the user to translate the current page has disappeared, in order to show the user how to bring the translate prompt back.">
+ Translate pages from the More Options button
+ </message>
<message name="IDS_IPH_SHARED_HIGHLIGHTING_BUILDER" desc="The in-product-help message to notify the user that the share action can preemptively share a link-to-text.">
New: share a link that scrolls to this text
</message>
@@ -4592,21 +4683,15 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SEND_TAB_TO_SELF_WHEN_SIGNED_IN_UNAVAILABLE" desc="Instructions for the user to enable the feature when it's currently unavailable.">
You can send tabs between devices that are signed in with the same Google Account
</message>
+ <message name="IDS_SEND_TAB_TO_SELF_ANDROID_NO_TARGET_DEVICE_LABEL" desc="Text shown when a user with no available target devices attempts to use send-tab-to-self.">
+ To send this tab to another device, sign in to Chrome there
+ </message>
<!-- Sharing -->
<message name="IDS_SHARING_SENDING_NOTIFICATION_TITLE" desc="Title text displayed in a sharing sending notification.">
Sharing to <ph name="DEVICE_NAME">%1$s<ex>Pixel 3</ex></ph>
</message>
- <message name="IDS_SHARING_NO_DEVICES_AVAILABLE_TITLE" desc="Text to show when no device targets are available for sharing.">
- Turn on sync to share across devices
- </message>
- <message name="IDS_SHARING_NO_DEVICES_AVAILABLE_TEXT" desc="Text to show when no device targets are available for sharing.">
- To share something from your phone to another device, turn on sync in Chrome settings on both devices
- </message>
- <message name="IDS_SHARING_CHROME_SETTINGS" desc="Text shown in a button when user has turned off sync.">
- Go to Chrome settings
- </message>
<!-- Sharing Hub -->
<message name="IDS_SHARING_HUB_NO_DEVICES_AVAILABLE_TEXT" desc="Text to show when no device targets are available for sharing.">
@@ -4698,9 +4783,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SHARED_CLIPBOARD_NOTIFICATION_TEXT" desc="Content text displayed in a shared clipboard notification.">
Copied to your clipboard
</message>
- <message name="IDS_SHARED_CLIPBOARD_SHARE_ACTIVITY_TITLE" desc="Title of the Shared Clipboard Share activity that will appear in the Android share dialog.">
- Send text to Your Devices
- </message>
<!-- Sms Fetcher -->
<message name="IDS_SMS_FETCHER_NOTIFICATION_TITLE" desc="Title text shown when the Android Chrome receives a ONE_TIME_CODE from an incoming SMS and ask users for permission to submit the code to their linked Desktop Chrome">
@@ -4967,12 +5049,12 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Connect with QR Code?
</message>
- <message name="IDS_CABLEV2_QR_BODY_PHONE" desc="The body text on a screen that confirms that the user wants to connect to a computer that displayed a QR code. This message is specific to phones and won't appear on tablets.">
- You can use this phone to sign in on the computer that’s displaying this QR code.
+ <message name="IDS_CABLEV2_QR_BODY_PHONE" desc="The body text on a screen that confirms that the user wants to connect to a device that displayed a QR code. This message is specific to phones and won't appear on tablets. The device displaying the QR code might be a computer, laptop, phone, table, or even TV.">
+ You can use this phone to sign in on the device that’s displaying this QR code.
</message>
- <message name="IDS_CABLEV2_QR_BODY_TABLET" desc="The body text on a screen that confirms that the user wants to connect to a computer that displayed a QR code. This message is specific to tablets and won't appear on phones.">
- You can use this tablet to sign in on the computer that’s displaying this QR code.
+ <message name="IDS_CABLEV2_QR_BODY_TABLET" desc="The body text on a screen that confirms that the user wants to connect to a device that displayed a QR code. This message is specific to tablets and won't appear on phones. The device displaying the QR code might be a computer, laptop, phone, table, or even TV.">
+ You can use this tablet to sign in on the device that’s displaying this QR code.
</message>
<message name="IDS_CABLEV2_QR_REMEMBER" desc="The label of a checkbox that appears on a screen confirming that the user wants to connect to a computer from which they just scanned a QR code. If the computer is 'remembered' then it'll be able to connect to the phone automatically in the future. The 'computer' is a laptop, desktop, or (eventually) another phone or tablet.">
@@ -5470,17 +5552,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Google Assistant provides a better voice experience for searching the web and engaging with sites you have open. Google Assistant will receive the URL and contents of sites you use with it.
</message>
- <!-- Continuous Search Navigation strings -->
- <message name="IDS_CSN_AD_LABEL" desc="Label for identifying an ad in search results." translateable="false">
- Ad
- </message>
- <message name="IDS_CSN_PROVIDER_LABEL" desc="Label that shows the source of a list of clickalbe URLs. This should have a new line character in the middle." translateable="false">
- Results from\n<ph name="PROVIDER">%1$s</ph>
- </message>
- <message name="IDS_CSN_ACCESSIBILITY_RESULTS_FROM_GOOGLE" desc="Content description for the Google search results button.">
- Search results from Google.
- </message>
-
<!-- WebID Account Selection strings -->
<message name="IDS_ACCOUNT_SELECTION_SHEET_TITLE_AUTO" desc="Header for sign in sheet. Sheet is shown to inform user of sign in. Sign in occurs automatically. (User can cancel)." translateable="false">
Signing in to <ph name="SITE_ETLD_PLUS_ONE">%1$s<ex>rp.example</ex></ph> with <ph name="IDENTITY_PROVIDER_ETLD_PLUS_ONE">%2$s<ex>idp.com</ex></ph>
@@ -5620,6 +5691,11 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_PASSWORD_EDIT_DIALOG_UNSYNCED_FOOTER" desc="Footer for a dialog which allows users to see and edit passwords while saving/updating a new credential. Displayed for users who are not syncing passwords.">
Passwords are saved to Password Manager on this device
</message>
+
+ <!-- Price tracking strings -->
+ <message name="IDS_PRICE_DROP_SPOTTED_IPH" desc="This text appears in the IPH when a user opens a new tab page and an item in any of their open tabs has a price drop.">
+ Price drop spotted
+ </message>
</messages>
</release>
</grit>
diff --git a/chromium/chrome/browser/ui/android/toolbar/BUILD.gn b/chromium/chrome/browser/ui/android/toolbar/BUILD.gn
index c7293ed364f..56e3c249e07 100644
--- a/chromium/chrome/browser/ui/android/toolbar/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/toolbar/BUILD.gn
@@ -11,6 +11,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/toolbar/ButtonData.java",
"java/src/org/chromium/chrome/browser/toolbar/ButtonDataImpl.java",
"java/src/org/chromium/chrome/browser/toolbar/ButtonDataProvider.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ConstraintsChecker.java",
"java/src/org/chromium/chrome/browser/toolbar/ControlContainer.java",
"java/src/org/chromium/chrome/browser/toolbar/HomeButton.java",
"java/src/org/chromium/chrome/browser/toolbar/IncognitoToggleTabLayout.java",
@@ -65,6 +66,13 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonViewBinder.java",
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuItemState.java",
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuUiState.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonConstants.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonMediator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonView.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonViewBinder.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/ShrinkTransition.java",
"java/src/org/chromium/chrome/browser/toolbar/top/ActionModeController.java",
"java/src/org/chromium/chrome/browser/toolbar/top/CaptureReadinessResult.java",
"java/src/org/chromium/chrome/browser/toolbar/top/HomeButtonCoordinator.java",
@@ -74,7 +82,6 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/toolbar/top/NavigationPopup.java",
"java/src/org/chromium/chrome/browser/toolbar/top/OptionalBrowsingModeButtonController.java",
"java/src/org/chromium/chrome/browser/toolbar/top/ResourceFactory.java",
- "java/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceHomeButtonIPHController.java",
"java/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceTabSwitcherActionMenuCoordinator.java",
"java/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarCoordinator.java",
"java/src/org/chromium/chrome/browser/toolbar/top/StartSurfaceToolbarMediator.java",
@@ -107,6 +114,7 @@ android_library("java") {
"//base:base_java",
"//base:jni_java",
"//build/android:build_java",
+ "//cc:cc_java",
"//chrome/android/features/start_surface:public_java",
"//chrome/browser/android/lifecycle:java",
"//chrome/browser/back_press/android:java",
@@ -247,6 +255,7 @@ android_resources("java_resources") {
"java/res/layout/control_container.xml",
"java/res/layout/menu_button.xml",
"java/res/layout/navigation_popup_item.xml",
+ "java/res/layout/optional_button_layout.xml",
"java/res/layout/radio_button_group_adaptive_toolbar_preference.xml",
"java/res/layout/start_top_toolbar.xml",
"java/res/layout/tab_switcher_toolbar.xml",
@@ -269,26 +278,29 @@ android_resources("java_resources") {
]
}
-android_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
- testonly = true
-
+robolectric_library("junit") {
sources = [
+ "java/src/org/chromium/chrome/browser/toolbar/ConstraintsCheckerTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBarTest.java",
"java/src/org/chromium/chrome/browser/toolbar/VoiceToolbarButtonControllerUnitTest.java",
"java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveButtonActionMenuCoordinatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarButtonControllerTest.java",
"java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeaturesTest.java",
"java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarStatePredictorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/adaptive/OptionalNewTabButtonControllerUnitTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressMediatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonCoordinatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonMediatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/menu_button/MenuButtonTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonCoordinatorTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/optional_button/OptionalButtonViewTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/HomeButtonCoordinatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/OptionalBrowsingModeButtonControllerTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/ToggleTabStackButtonCoordinatorTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/ToolbarControlContainerTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/ToolbarSnapshotStateTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTabletUnitTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarInteractabilityManagerTest.java",
"java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarOverlayMediatorTest.java",
]
@@ -298,6 +310,7 @@ android_library("junit") {
"//base:base_java",
"//base:base_java_test_support",
"//base:base_junit_test_support",
+ "//cc:cc_java",
"//chrome/browser/android/lifecycle:java",
"//chrome/browser/browser_controls/android:java",
"//chrome/browser/feature_engagement:java",
@@ -313,8 +326,10 @@ android_library("junit") {
"//chrome/browser/ui/android/theme:java",
"//chrome/browser/ui/android/toolbar:java_resources",
"//chrome/browser/user_education:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_unit_test_support",
"//components/browser_ui/settings/android:java",
+ "//components/browser_ui/styles/android:java",
+ "//components/browser_ui/theme/android:java_resources",
"//components/browser_ui/widget/android:java",
"//components/feature_engagement:feature_engagement_java",
"//components/search_engines/android:java",
@@ -322,53 +337,18 @@ android_library("junit") {
"//content/public/android:content_full_java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_deps:guava_android_java",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
+ "//third_party/androidx:androidx_fragment_fragment_testing_java",
"//third_party/androidx:androidx_test_core_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/hamcrest:hamcrest_library_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//ui/android:ui_java",
- "//url:gurl_java",
- "//url:gurl_junit_test_support",
- ]
-}
-
-android_library("javatests") {
- testonly = true
- sources = [
- "java/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBarTest.java",
- "java/src/org/chromium/chrome/browser/toolbar/adaptive/settings/AdaptiveToolbarPreferenceFragmentTest.java",
- "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressMediatorTest.java",
- ]
-
- deps = [
- ":java",
- ":java_resources",
- "//base:base_java",
- "//base:base_java_test_support",
- "//chrome/browser/flags:java",
- "//chrome/browser/preferences:java",
- "//chrome/browser/settings:test_support_java",
- "//chrome/browser/tab:java",
- "//chrome/browser/ui/android/omnibox:java_resources",
- "//chrome/browser/ui/android/toolbar:java",
- "//chrome/test/android:chrome_java_test_support",
- "//components/browser_ui/settings/android:java",
- "//components/browser_ui/styles/android:java",
- "//components/browser_ui/widget/android:java",
- "//content/public/android:content_java",
- "//content/public/test/android:content_java_test_support",
- "//third_party/androidx:androidx_test_runner_java",
- "//third_party/hamcrest:hamcrest_library_java",
- "//third_party/junit",
- "//third_party/mockito:mockito_java",
- "//ui/android:ui_java",
"//ui/android:ui_java_test_support",
"//url:gurl_java",
+ "//url:gurl_junit_test_support",
]
-
- resources_package = "org.chromium.chrome.browser.toolbar"
}
diff --git a/chromium/chrome/browser/ui/android/webid/BUILD.gn b/chromium/chrome/browser/ui/android/webid/BUILD.gn
index 7db653b2253..a1eba546082 100644
--- a/chromium/chrome/browser/ui/android/webid/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/webid/BUILD.gn
@@ -13,6 +13,8 @@ android_library("public_java") {
"//url:gurl_java",
]
+ srcjar_deps = [ ":java_enums_srcjar" ]
+
sources = [
"java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionComponent.java",
"java/src/org/chromium/chrome/browser/ui/android/webid/data/Account.java",
@@ -29,3 +31,7 @@ generate_jni("jni_headers") {
"java/src/org/chromium/chrome/browser/ui/android/webid/data/IdentityProviderMetadata.java",
]
}
+
+java_cpp_enum("java_enums_srcjar") {
+ sources = [ "//content/public/browser/identity_request_dialog_controller.h" ]
+}
diff --git a/chromium/chrome/browser/ui/android/webid/internal/BUILD.gn b/chromium/chrome/browser/ui/android/webid/internal/BUILD.gn
index 8747b28633a..4dbe88ec4d2 100644
--- a/chromium/chrome/browser/ui/android/webid/internal/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/webid/internal/BUILD.gn
@@ -65,13 +65,11 @@ android_resources("java_resources") {
]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
-
- testonly = true
-
- sources = [ "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionControllerTest.java" ]
+robolectric_library("junit") {
+ sources = [
+ "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionControllerTest.java",
+ "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionViewTest.java",
+ ]
deps = [
":java",
@@ -85,11 +83,14 @@ java_library("junit") {
"//components/favicon/android:java",
"//components/image_fetcher:java",
"//components/url_formatter/android:url_formatter_java",
- "//third_party/android_deps:robolectric_all_java",
"//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_recyclerview_recyclerview_java",
+ "//third_party/androidx:androidx_test_core_java",
+ "//third_party/androidx:androidx_test_ext_junit_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//ui/android:ui_full_java",
+ "//ui/android:ui_java_test_support",
"//url:gurl_java",
"//url:gurl_junit_shadows",
"//url:gurl_junit_test_support",
@@ -99,10 +100,7 @@ java_library("junit") {
android_library("javatests") {
testonly = true
- sources = [
- "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionIntegrationTest.java",
- "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionViewTest.java",
- ]
+ sources = [ "java/src/org/chromium/chrome/browser/ui/android/webid/AccountSelectionIntegrationTest.java" ]
deps = [
":java",
@@ -115,7 +113,7 @@ android_library("javatests") {
"//chrome/browser/flags:java",
"//chrome/browser/tab:java",
"//chrome/browser/ui/android/webid:public_java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_integration_test_support",
"//components/browser_ui/bottomsheet/android:java",
"//components/browser_ui/bottomsheet/android/test:java",
"//content/public/test/android:content_java_test_support",
diff --git a/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
index 4224d6fbd66..0bd7bb2242b 100644
--- a/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
+++ b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
@@ -60,12 +60,12 @@ source_set("test_support") {
"//base/test:test_support",
"//chrome/browser",
"//chrome/browser/ash",
+ "//chrome/browser/ash/system_web_apps/test_support:test_support_ui",
"//chrome/browser/chromeos:test_support",
"//chrome/browser/extensions",
"//chrome/browser/ui",
- "//chrome/browser/web_applications:browser_tests_base",
"//chrome/test:test_support_ui",
- "//chromeos/dbus/session_manager",
+ "//chromeos/ash/components/dbus/session_manager",
"//components/session_manager/core",
"//ui/views",
]
diff --git a/chromium/chrome/browser/ui/ash/system_web_apps/BUILD.gn b/chromium/chrome/browser/ui/ash/system_web_apps/BUILD.gn
new file mode 100644
index 00000000000..11f738a7bc0
--- /dev/null
+++ b/chromium/chrome/browser/ui/ash/system_web_apps/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//chrome/browser/buildflags.gni")
+
+assert(is_chromeos_ash)
+
+source_set("system_web_apps") {
+ sources = [
+ "system_web_app_delegate_ui_impl.cc",
+ "system_web_app_ui_utils.cc",
+ "system_web_app_ui_utils.h",
+ ]
+
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+
+ deps = [
+ "//base",
+ "//chrome/browser/ash/system_web_apps",
+ "//chrome/browser/ash/system_web_apps/types",
+ "//chrome/browser/profiles:profile",
+ "//chrome/browser/web_applications",
+ "//chrome/common",
+ "//components/services/app_service/public/mojom",
+ "//content/public/browser",
+ "//ui/base",
+ "//ui/display",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/color/BUILD.gn b/chromium/chrome/browser/ui/color/BUILD.gn
index 99e5a81eeab..be4803fdbc2 100644
--- a/chromium/chrome/browser/ui/color/BUILD.gn
+++ b/chromium/chrome/browser/ui/color/BUILD.gn
@@ -65,7 +65,7 @@ source_set("mixers") {
}
}
-if (!is_ios && !is_android && !is_castos) {
+if (!is_ios && !is_android) {
executable("dump_colors") {
testonly = true
diff --git a/chromium/chrome/browser/ui/messages/android/BUILD.gn b/chromium/chrome/browser/ui/messages/android/BUILD.gn
index d7e310efb47..b104ee30c86 100644
--- a/chromium/chrome/browser/ui/messages/android/BUILD.gn
+++ b/chromium/chrome/browser/ui/messages/android/BUILD.gn
@@ -59,12 +59,7 @@ generate_jni("jni_headers") {
sources = [ "java/src/org/chromium/chrome/browser/ui/messages/infobar/SimpleConfirmInfoBarBuilder.java" ]
}
-java_library("junit") {
- # Skip platform checks since Robolectric depends on requires_android targets.
- bypass_platform_checks = true
-
- testonly = true
-
+robolectric_library("junit") {
sources = [ "java/src/org/chromium/chrome/browser/ui/messages/snackbar/SnackbarCollectionUnitTest.java" ]
deps = [
@@ -75,7 +70,7 @@ java_library("junit") {
]
}
-android_library("javatests") {
+android_library("unit_device_javatests") {
testonly = true
resources_package = "org.chromium.chrome.browser.ui.messages.test"
@@ -87,7 +82,7 @@ android_library("javatests") {
"//base:base_java",
"//base:base_java_test_support",
"//chrome/browser/util:java",
- "//chrome/test/android:chrome_java_test_support",
+ "//chrome/test/android:chrome_java_integration_test_support",
"//content/public/android:content_java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_support_test_runner:rules_java",
diff --git a/chromium/chrome/browser/ui/side_search/BUILD.gn b/chromium/chrome/browser/ui/side_search/BUILD.gn
index 2495de1df55..576b84d8ad5 100644
--- a/chromium/chrome/browser/ui/side_search/BUILD.gn
+++ b/chromium/chrome/browser/ui/side_search/BUILD.gn
@@ -4,10 +4,6 @@
import("//third_party/protobuf/proto_library.gni")
-proto_library("side_search_window_data_proto") {
- sources = [ "side_search_window_data.proto" ]
-}
-
proto_library("side_search_tab_data_proto") {
sources = [ "side_search_tab_data.proto" ]
}
diff --git a/chromium/chrome/browser/ui/web_applications/BUILD.gn b/chromium/chrome/browser/ui/web_applications/BUILD.gn
new file mode 100644
index 00000000000..5d2724f8f3f
--- /dev/null
+++ b/chromium/chrome/browser/ui/web_applications/BUILD.gn
@@ -0,0 +1,131 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//chrome/browser/buildflags.gni")
+
+source_set("unit_tests") {
+ testonly = true
+
+ sources = [
+ "app_browser_controller_unittest.cc",
+ "share_target_utils_unittest.cc",
+ "web_app_launch_manager_unittest.cc",
+ "web_app_launch_utils_unittest.cc",
+ ]
+
+ if (is_chromeos_ash) {
+ sources += [ "file_stream_data_pipe_getter_unittest.cc" ]
+ }
+
+ deps = [
+ "//chrome/browser",
+ "//chrome/browser/ui",
+ "//chrome/browser/web_applications",
+ "//chrome/browser/web_applications:web_applications_unit_tests",
+ "//components/services/app_service/public/cpp:intents",
+ "//content/test:test_support",
+ "//storage/browser:test_support",
+ ]
+}
+
+source_set("browser_tests") {
+ testonly = true
+
+ sources = [
+ "create_shortcut_browsertest.cc",
+ "pwa_mixed_content_browsertest.cc",
+ "sub_apps_service_impl_browsertest.cc",
+ "web_app_badging_browsertest.cc",
+ "web_app_browsertest.cc",
+ "web_app_dark_mode_browsertest.cc",
+ "web_app_engagement_browsertest.cc",
+ "web_app_file_handling_browsertest.cc",
+ "web_app_launch_handler_browsertest.cc",
+ "web_app_link_capturing_browsertest.cc",
+ "web_app_metrics_browsertest.cc",
+ "web_app_navigate_browsertest.cc",
+ "web_app_protocol_handling_browsertest.cc",
+ "web_app_ui_manager_impl_browsertest.cc",
+ "web_app_uninstall_browsertest.cc",
+ "web_app_url_handling_browsertest.cc",
+ "web_app_window_controls_overlay_browsertest.cc",
+ ]
+
+ if (!is_chromeos_lacros) {
+ sources += [
+ # Test not valid on Lacros as WebApps is only enabled in the main
+ # profile which can never be deleted.
+ "web_app_profile_deletion_browsertest.cc",
+ ]
+ }
+
+ if (is_chromeos_ash) {
+ sources += [
+ "app_browser_controller_browsertest.cc",
+ "web_app_guest_session_browsertest_chromeos.cc",
+ ]
+ }
+
+ defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
+
+ deps = [
+ "//chrome/app:command_ids",
+ "//chrome/browser:browser_themes",
+ "//chrome/browser:theme_properties",
+ "//chrome/browser/browsing_data:constants",
+ "//chrome/browser/devtools",
+ "//chrome/browser/web_applications:web_applications_test_support",
+ "//chrome/test:test_support",
+ "//chrome/test:test_support_ui",
+ "//components/embedder_support",
+ "//components/page_load_metrics/browser:test_support",
+ "//components/services/app_service/public/cpp:protocol_handling",
+ "//components/site_engagement/content",
+ "//components/webapps/browser",
+ ]
+
+ if (is_chromeos_ash) {
+ deps += [
+ "//chrome/browser/ash/system_web_apps/test_support",
+ "//chrome/browser/ui/ash/system_web_apps",
+ ]
+ }
+}
+
+# On Lacros, these browser tests require Ash to be running.
+source_set("app_service_browser_tests") {
+ testonly = true
+
+ sources = [ "launch_web_app_browsertest.cc" ]
+
+ if (is_chromeos) {
+ sources += [
+ "share_to_target_browsertest.cc",
+ "web_share_target_browsertest.cc",
+ ]
+ }
+
+ if (is_chromeos_lacros) {
+ sources += [ "lacros_web_app_browsertest.cc" ]
+ }
+
+ defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
+
+ deps = [
+ "//chrome/app:command_ids",
+ "//chrome/browser/web_applications",
+ "//chrome/browser/web_applications:web_applications_test_support",
+ "//chrome/test:test_support",
+ "//chrome/test:test_support_ui",
+ "//components/services/app_service/public/cpp:intents",
+ ]
+
+ if (is_chromeos_lacros) {
+ deps += [
+ "//chrome/test:lacros_test_support_ui",
+ "//chromeos/lacros",
+ "//chromeos/lacros:test_support",
+ ]
+ }
+}
diff --git a/chromium/chrome/browser/ui/webui/BUILD.gn b/chromium/chrome/browser/ui/webui/BUILD.gn
index 2f2ac276d6b..d8d8de838d5 100644
--- a/chromium/chrome/browser/ui/webui/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/BUILD.gn
@@ -55,11 +55,13 @@ source_set("configs") {
"//ash/webui/file_manager:file_manager_untrusted_ui",
"//ash/webui/help_app_ui",
"//ash/webui/os_feedback_ui",
+ "//ash/webui/shortcut_customization_ui",
"//chrome/browser/ash",
]
if (!is_official_build) {
deps += [
"//ash/webui/demo_mode_app_ui",
+ "//ash/webui/facial_ml_app_ui",
"//ash/webui/sample_system_web_app_ui",
]
}
diff --git a/chromium/chrome/browser/ui/webui/DEPS b/chromium/chrome/browser/ui/webui/DEPS
index fa8286d2400..e40bda8b4cd 100644
--- a/chromium/chrome/browser/ui/webui/DEPS
+++ b/chromium/chrome/browser/ui/webui/DEPS
@@ -1,20 +1,6 @@
include_rules = [
- "+ash/components/account_manager",
- "+ash/components/audio",
- "+ash/webui/os_feedback_ui",
- "+components/app_constants",
"+components/browser_ui/share/android",
- "+components/services/app_service/public",
- "+device/bluetooth",
"+extensions/strings/grit/extensions_strings.h",
-
- # Generated files
- "+js2webui/chrome/test/data",
-
- # Other libraries.
- "+third_party/angle", # For ANGLE version.
- "+third_party/brotli", # For compressed resources.
- "+third_party/zlib/zlib.h", # For compression level constants.
]
specific_include_rules = {
diff --git a/chromium/chrome/browser/ui/webui/OWNERS b/chromium/chrome/browser/ui/webui/OWNERS
index acfb748e059..39b8fd02560 100644
--- a/chromium/chrome/browser/ui/webui/OWNERS
+++ b/chromium/chrome/browser/ui/webui/OWNERS
@@ -8,8 +8,6 @@ per-file devtools_ui*=caseq@chromium.org
per-file inspect_ui*=dgozman@chromium.org
per-file inspect_ui*=caseq@chromium.org
-per-file history_ui*=calamity@chromium.org
-
per-file memory_internals_ui*=erikchen@chromium.org
per-file net_export_ui.*=file://net/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/about_ui.cc b/chromium/chrome/browser/ui/webui/about_ui.cc
index f1be7001f5e..d6138afa814 100644
--- a/chromium/chrome/browser/ui/webui/about_ui.cc
+++ b/chromium/chrome/browser/ui/webui/about_ui.cc
@@ -686,11 +686,21 @@ void AboutUIHTMLSource::StartDataRequest(
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
} else if (source_name_ == chrome::kChromeUIOSCreditsHost) {
- ChromeOSCreditsHandler::Start(path, std::move(callback));
- return;
+ if (path == kCreditsCssPath) {
+ response = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
+ IDR_ABOUT_UI_CREDITS_CSS);
+ } else {
+ ChromeOSCreditsHandler::Start(path, std::move(callback));
+ return;
+ }
} else if (source_name_ == chrome::kChromeUICrostiniCreditsHost) {
- CrostiniCreditsHandler::Start(profile(), path, std::move(callback));
- return;
+ if (path == kCreditsCssPath) {
+ response = ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
+ IDR_ABOUT_UI_CREDITS_CSS);
+ } else {
+ CrostiniCreditsHandler::Start(profile(), path, std::move(callback));
+ return;
+ }
} else if (source_name_ == chrome::kChromeUIBorealisCreditsHost) {
HandleBorealisCredits(profile(), std::move(callback));
return;
@@ -720,7 +730,8 @@ void AboutUIHTMLSource::FinishDataRequest(
base::RefCountedString::TakeString(std::move(html_copy)));
}
-std::string AboutUIHTMLSource::GetMimeType(const std::string& path) {
+std::string AboutUIHTMLSource::GetMimeType(const GURL& url) {
+ const base::StringPiece path = url.path_piece().substr(1);
if (path == kCreditsJsPath ||
#if BUILDFLAG(IS_CHROMEOS_ASH)
path == kKeyboardUtilsPath ||
diff --git a/chromium/chrome/browser/ui/webui/about_ui.h b/chromium/chrome/browser/ui/webui/about_ui.h
index b159d18de89..4bdfbc6a002 100644
--- a/chromium/chrome/browser/ui/webui/about_ui.h
+++ b/chromium/chrome/browser/ui/webui/about_ui.h
@@ -32,7 +32,7 @@ class AboutUIHTMLSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool ShouldAddContentSecurityPolicy() override;
std::string GetAccessControlAllowOriginForOrigin(
const std::string& origin) override;
diff --git a/chromium/chrome/browser/ui/webui/about_ui_unittest.cc b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
index a802b46fa0e..2dc25abbba8 100644
--- a/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
@@ -24,7 +24,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/scoped_browser_locale.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "chromeos/system/statistics_provider.h"
#include "content/public/browser/browser_task_traits.h"
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast.mojom b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast.mojom
index 9a7e3a00f2f..4b7138e6fcb 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast.mojom
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast.mojom
@@ -29,7 +29,8 @@ enum AddSinkResultCode {
SERVER_ERROR,
SINK_CREATION_ERROR,
CHANNEL_OPEN_ERROR,
- PROFILE_SYNC_ERROR
+ PROFILE_SYNC_ERROR,
+ INTERNAL_MEDIA_ROUTER_ERROR
};
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.cc
index 9eb6b79b9d7..1159b3b3db0 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.cc
@@ -34,6 +34,11 @@ void SetCurrentDialog(std::unique_ptr<AccessCodeCastDialog> dialog) {
// The corner radius for system dialogs.
constexpr int kSystemDialogCornerRadiusDp = 12;
+// The default width, height without footnote, height with footnote for the dialog container.
+const int kDialogWidthDefault = 448;
+const int kDialogHeightDefault = 295;
+const int kDialogHeightFootnote = 330;
+
AccessCodeCastDialog::AccessCodeCastDialog(
const CastModeSet& cast_mode_set,
std::unique_ptr<MediaRouteStarter> media_route_starter)
@@ -156,14 +161,10 @@ void AccessCodeCastDialog::GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const {}
void AccessCodeCastDialog::GetDialogSize(gfx::Size* size) const {
- const int kDefaultWidth = 448;
- const int kDefaultHeight = 271;
- const int kRememberDevicesHeight = 310;
- base::TimeDelta duration_pref = GetAccessCodeDeviceDurationPref(
- context_->GetPrefs());
+ base::TimeDelta duration_pref = GetAccessCodeDeviceDurationPref(context_);
bool rememberDevices = duration_pref != base::Seconds(0);
- size->SetSize(kDefaultWidth,
- rememberDevices ? kRememberDevicesHeight : kDefaultHeight);
+ size->SetSize(kDialogWidthDefault,
+ rememberDevices ? kDialogHeightFootnote : kDialogHeightDefault);
}
std::string AccessCodeCastDialog::GetDialogArgs() const {
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog_browsertest.cc
new file mode 100644
index 00000000000..d10275e2c31
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog_browsertest.cc
@@ -0,0 +1,60 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/media/router/discovery/access_code/access_code_cast_feature.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "chrome/browser/ui/webui/access_code_cast/access_code_cast_dialog.h"
+#include "chrome/test/base/chrome_test_utils.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/test/browser_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media_router {
+
+class AccessCodeCastDialogBrowserTest : public DialogBrowserTest {
+ public:
+ AccessCodeCastDialogBrowserTest() = default;
+ AccessCodeCastDialogBrowserTest(const AccessCodeCastDialogBrowserTest&) =
+ delete;
+ AccessCodeCastDialogBrowserTest& operator=(
+ const AccessCodeCastDialogBrowserTest&) = delete;
+ ~AccessCodeCastDialogBrowserTest() override = default;
+
+ // DialogBrowserTest:
+ void ShowUi(const std::string& name) override {
+ content::WebContentsAddedObserver observer;
+
+ // Enable AccessCodeCast.
+ browser()->profile()->GetPrefs()->SetBoolean(
+ media_router::prefs::kAccessCodeCastEnabled, true);
+
+ // Show the dialog.
+ CastModeSet tab_mode = {MediaCastMode::TAB_MIRROR};
+ content::WebContents* web_contents =
+ chrome_test_utils::GetActiveWebContents(this);
+ std::unique_ptr<MediaRouteStarter> starter =
+ std::make_unique<MediaRouteStarter>(tab_mode, web_contents, nullptr);
+ AccessCodeCastDialog::Show(
+ tab_mode, std::move(starter),
+ AccessCodeCastDialogOpenLocation::kBrowserCastMenu);
+ content::WebContents* dialog_contents = observer.GetWebContents();
+ EXPECT_TRUE(content::WaitForLoadStop(dialog_contents));
+ }
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
+};
+
+IN_PROC_BROWSER_TEST_F(AccessCodeCastDialogBrowserTest, InvokeUi_default) {
+#if BUILDFLAG(IS_LINUX)
+ GTEST_SKIP() << "Flaky on linux due to dialog closing early, b/235882005";
+#else
+ // ShowAndVerifyUi();
+ GTEST_SKIP() << "Disabling test while investigating failures, b/242863470";
+#endif
+}
+
+} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.cc
index 0249584141c..fdaed23dfdd 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.cc
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.cc
@@ -60,6 +60,8 @@ const char* AddSinkResultCodeToStringHelper(AddSinkResultCode value) {
return "CHANNEL_OPEN_ERROR";
case AddSinkResultCode::PROFILE_SYNC_ERROR:
return "PROFILE_SYNC_ERROR";
+ case AddSinkResultCode::INTERNAL_MEDIA_ROUTER_ERROR:
+ return "INTERNAL_MEDIA_ROUTER_ERROR";
default:
return nullptr;
}
@@ -120,9 +122,13 @@ AccessCodeCastHandler::AccessCodeCastHandler(
cast_mode_set_(cast_mode_set),
media_route_starter_(std::move(media_route_starter)) {
if (media_route_starter_) {
+ DCHECK(media_route_starter_->GetProfile())
+ << "The MediaRouteStarter does not have a valid profile!";
// Ensure we don't use an off-the-record profile.
access_code_sink_service_ = AccessCodeCastSinkServiceFactory::GetForProfile(
media_route_starter_->GetProfile()->GetOriginalProfile());
+ DCHECK(access_code_sink_service_)
+ << "AccessCodeSinkService was not properly created!";
Init();
}
}
@@ -147,8 +153,6 @@ AccessCodeCastHandler::~AccessCodeCastHandler() {
}
void AccessCodeCastHandler::Init() {
- DCHECK(access_code_sink_service_)
- << "AccessCodeSinkService was not properly created!";
DCHECK(media_route_starter_) << "Must have MediaRouterService!";
media_route_starter_->SetLoggerComponent(kLoggerComponent);
media_route_starter_->AddMediaSinkWithCastModesObserver(this);
@@ -165,10 +169,10 @@ void AccessCodeCastHandler::AddSink(
return;
}
AddSinkCallback callback_with_default_invoker =
- mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(callback),
- AddSinkResultCode::UNKNOWN_ERROR);
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ std::move(callback), AddSinkResultCode::UNKNOWN_ERROR);
add_sink_callback_ = std::move(base::BindOnce(&AddSinkMetricsCallback))
- .Then(std::move(callback_with_default_invoker));
+ .Then(std::move(callback_with_default_invoker));
access_code_sink_service_->DiscoverSink(
access_code, base::BindOnce(&AccessCodeCastHandler::OnSinkAddedResult,
weak_ptr_factory_.GetWeakPtr()));
@@ -197,11 +201,6 @@ void AccessCodeCastHandler::CheckForDiscoveryCompletion() {
return;
}
- // Sink has been completely added so caller can be alerted.
- if (base::FeatureList::IsEnabled(features::kAccessCodeCastRememberDevices)) {
- access_code_sink_service_->StoreSinkAndSetExpirationTimer(sink_id_.value());
- }
-
std::move(add_sink_callback_).Run(AddSinkResultCode::OK);
}
@@ -287,6 +286,18 @@ void AccessCodeCastHandler::CastToSink(CastToSinkCallback callback) {
current_route_request_ = absl::make_optional(*params->request);
+ if (HasActiveRoute(sink_id_.value())) {
+ GetMediaRouter()->GetLogger()->LogInfo(
+ mojom::LogCategory::kUi, kLoggerComponent,
+ "There already exists a route for the given sink id. No new route can "
+ "be created. Checking to see if this is a saved device -- otherwise we "
+ "wil remove it from the media router.",
+ sink_id_.value(), "", "");
+ access_code_sink_service_->CheckMediaSinkForExpiration(sink_id_.value());
+ std::move(callback).Run(RouteRequestResultCode::ROUTE_ALREADY_EXISTS);
+ return;
+ }
+
params->route_result_callbacks.push_back(base::BindOnce(
&AccessCodeCastHandler::OnRouteResponse, weak_ptr_factory_.GetWeakPtr(),
cast_mode, params->request->id, *sink_id_, std::move(callback)));
@@ -315,17 +326,14 @@ void AccessCodeCastHandler::OnRouteResponse(MediaCastMode cast_mode,
const MediaRoute* route = result.route();
if (!route) {
- DCHECK(result.result_code() != RouteRequestResult::OK)
+ DCHECK(result.result_code() != mojom::RouteRequestResultCode::OK)
<< "No route but OK response";
// The provider will handle sending an issue for a failed route request.
GetMediaRouter()->GetLogger()->LogError(
mojom::LogCategory::kUi, kLoggerComponent,
"MediaRouteResponse returned error: " + result.error(), sink_id, "",
"");
- std::move(dialog_callback)
- .Run(mojo::EnumTraits<
- RouteRequestResultCode,
- RouteRequestResult::ResultCode>::ToMojom(result.result_code()));
+ std::move(dialog_callback).Run(result.result_code());
return;
}
@@ -333,4 +341,17 @@ void AccessCodeCastHandler::OnRouteResponse(MediaCastMode cast_mode,
std::move(dialog_callback).Run(RouteRequestResultCode::OK);
}
+bool AccessCodeCastHandler::HasActiveRoute(const MediaSink::Id& sink_id) {
+ if (!GetMediaRouter())
+ return false;
+ auto routes = GetMediaRouter()->GetCurrentRoutes();
+ auto route_it = std::find_if(routes.begin(), routes.end(),
+ [&sink_id](const MediaRoute& route) {
+ return route.media_sink_id() == sink_id;
+ });
+ if (route_it == routes.end())
+ return false;
+ return true;
+}
+
} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.h b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.h
index 6fa9a84552f..1d86437655b 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.h
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler.h
@@ -65,6 +65,7 @@ class AccessCodeCastHandler : public access_code_cast::mojom::PageHandler,
FRIEND_TEST_ALL_PREFIXES(AccessCodeCastHandlerTest, DesktopMirroring);
FRIEND_TEST_ALL_PREFIXES(AccessCodeCastHandlerTest, DesktopMirroringError);
FRIEND_TEST_ALL_PREFIXES(AccessCodeCastHandlerTest, OnSinkAddedResult);
+ FRIEND_TEST_ALL_PREFIXES(AccessCodeCastHandlerTest, RouteAlreadyExists);
// Constructor that is used for testing.
AccessCodeCastHandler(
@@ -110,6 +111,9 @@ class AccessCodeCastHandler : public access_code_cast::mojom::PageHandler,
// been satisfied. If so, alerts the dialog.
void CheckForDiscoveryCompletion();
+ // Checks to see that if route already exists for the given media sink id.
+ bool HasActiveRoute(const MediaSink::Id& sink_id);
+
mojo::Remote<access_code_cast::mojom::Page> page_;
mojo::Receiver<access_code_cast::mojom::PageHandler> receiver_;
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_browsertest.cc
new file mode 100644
index 00000000000..e62f725210e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_browsertest.cc
@@ -0,0 +1,124 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/media_router/access_code_cast/access_code_cast_integration_browsertest.h"
+
+#if BUILDFLAG(IS_WIN)
+#include "base/win/windows_version.h"
+#endif
+#include "chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h"
+#include "components/sessions/content/session_tab_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media_router {
+
+class AccessCodeCastHandlerBrowserTest
+ : public AccessCodeCastIntegrationBrowserTest {};
+
+// TODO(b/235275754): Add a case for when the network is connected and we
+// surface a server error.
+IN_PROC_BROWSER_TEST_F(AccessCodeCastHandlerBrowserTest,
+ ExpectNetworkErrorWhenNoNetwork) {
+#if BUILDFLAG(IS_WIN)
+ // TODO(b/235896651): This test sometimes timesout on win10.
+ if (base::win::GetVersion() >= base::win::Version::WIN10)
+ GTEST_SKIP() << "This test is flaky on win10";
+#endif
+
+ EnableAccessCodeCasting();
+
+ // This tests that if the network is not present (we are not connected to the
+ // internet), we will see a server error in the access code dialog box.
+ SetUpPrimaryAccountWithHostedDomain(signin::ConsentLevel::kSync,
+ browser()->profile());
+
+ auto* dialog_contents = ShowDialog();
+ SetAccessCode("abcdef", dialog_contents);
+ PressSubmit(dialog_contents);
+
+ // This error code corresponds to
+ // ErrorMessage.NETWORK::AddSinkResultCode.SERVER_ERROR
+ EXPECT_EQ(3, WaitForAddSinkErrorCode(dialog_contents));
+ CloseDialog(dialog_contents);
+}
+
+IN_PROC_BROWSER_TEST_F(AccessCodeCastHandlerBrowserTest,
+ ReturnSuccessfulResponse) {
+#if BUILDFLAG(IS_WIN)
+ // TODO(b/235896651): This test sometimes timesout on win10.
+ if (base::win::GetVersion() >= base::win::Version::WIN10)
+ GTEST_SKIP() << "This test is flaky on win10";
+#endif
+
+ const char kEndpointResponseSuccess[] =
+ R"({
+ "device": {
+ "displayName": "test_device",
+ "id": "1234",
+ "deviceCapabilities": {
+ "videoOut": true,
+ "videoIn": true,
+ "audioOut": true,
+ "audioIn": true,
+ "devMode": true
+ },
+ "networkInfo": {
+ "hostName": "GoogleNet",
+ "port": "666",
+ "ipV4Address": "192.0.2.146",
+ "ipV6Address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
+ }
+ }
+ })";
+
+ // Mock a successful fetch from our server.
+ SetEndpointFetcherMockResponse(kEndpointResponseSuccess, net::HTTP_OK,
+ net::OK);
+
+ // Simulate a successful opening of the channel.
+ SetMockOpenChannelCallbackResponse(true);
+
+ EnableAccessCodeCasting();
+
+ SetUpPrimaryAccountWithHostedDomain(signin::ConsentLevel::kSync,
+ browser()->profile());
+
+ auto* dialog_contents = ShowDialog();
+ SetAccessCode("abcdef", dialog_contents);
+ ExpectStartRouteCallFromTabMirroring(
+ "cast:<1234>",
+ MediaSource::ForTab(
+ sessions::SessionTabHelper::IdForTab(web_contents()).id())
+ .id(),
+ web_contents());
+
+ PressSubmitAndWaitForClose(dialog_contents);
+}
+
+IN_PROC_BROWSER_TEST_F(AccessCodeCastHandlerBrowserTest,
+ ExpectGenericErrorWhenNoSync) {
+#if BUILDFLAG(IS_WIN)
+ // TODO(b/235896651): This test sometimes timesout on win10.
+ if (base::win::GetVersion() >= base::win::Version::WIN10)
+ GTEST_SKIP() << "This test is flaky on win10";
+#endif
+
+ EnableAccessCodeCasting();
+
+ // This tests that an account that does not have Sync enabled will throw a
+ // generic error.
+ SetUpPrimaryAccountWithHostedDomain(signin::ConsentLevel::kSignin,
+ browser()->profile());
+
+ auto* dialog_contents = ShowDialog();
+ SetAccessCode("abcdef", dialog_contents);
+ PressSubmit(dialog_contents);
+
+ // This error code corresponds to
+ // ErrorMessage.GENERIC::AddSinkResultCode.PROFILE_SYNC_ERROR
+ EXPECT_EQ(1, WaitForAddSinkErrorCode(dialog_contents));
+ CloseDialog(dialog_contents);
+}
+
+} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_unittest.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_unittest.cc
index fc749d043d1..64721262e4e 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_handler_unittest.cc
@@ -72,27 +72,6 @@ class MockPage : public access_code_cast::mojom::Page {
} // namespace
-class MockAccessCodeCastSinkService : public AccessCodeCastSinkService {
- public:
- MockAccessCodeCastSinkService(
- Profile* profile,
- MediaRouter* media_router,
- CastMediaSinkServiceImpl* cast_media_sink_service_impl,
- DiscoveryNetworkMonitor* network_monitor)
- : AccessCodeCastSinkService(profile,
- media_router,
- cast_media_sink_service_impl,
- network_monitor,
- profile->GetPrefs()) {}
- ~MockAccessCodeCastSinkService() override = default;
-
- MOCK_METHOD(void,
- AddSinkToMediaRouter,
- (const MediaSinkInternal& sink,
- AddSinkResultCallback add_sink_callback),
- (override));
-};
-
class AccessCodeCastHandlerTest : public ChromeRenderViewHostTestHarness {
protected:
AccessCodeCastHandlerTest()
@@ -197,7 +176,7 @@ class AccessCodeCastHandlerTest : public ChromeRenderViewHostTestHarness {
return access_code_cast_sink_service_.get();
}
- void set_expected_cast_result(RouteRequestResult::ResultCode code) {
+ void set_expected_cast_result(mojom::RouteRequestResultCode code) {
result_code_ = code;
}
@@ -292,9 +271,6 @@ class AccessCodeCastHandlerTest : public ChromeRenderViewHostTestHarness {
}
});
- ON_CALL(*router(), GetCurrentRoutes())
- .WillByDefault(Return(std::vector<MediaRoute>()));
-
// Handler so MockMediaRouter will respond to requests to create a route.
// Will construct a RouteRequestResult based on the set result code and
// then call the handler's callback, which should call the page's callback.
@@ -306,7 +282,7 @@ class AccessCodeCastHandlerTest : public ChromeRenderViewHostTestHarness {
MediaRouteResponseCallback& callback,
base::TimeDelta timeout, bool incognito) {
std::unique_ptr<RouteRequestResult> result;
- if (result_code_ == RouteRequestResult::ResultCode::OK) {
+ if (result_code_ == mojom::RouteRequestResultCode::OK) {
MediaSource source(source_id);
MediaRoute route;
route.set_media_route_id(source_id + "->" + sink_id);
@@ -351,8 +327,8 @@ class AccessCodeCastHandlerTest : public ChromeRenderViewHostTestHarness {
mock_cast_media_sink_service_impl_;
std::unique_ptr<MockWebContentsPresentationManager> presentation_manager_;
std::vector<MediaSinksObserver*> media_sinks_observers_;
- RouteRequestResult::ResultCode result_code_ =
- RouteRequestResult::ResultCode::OK;
+ mojom::RouteRequestResultCode result_code_ =
+ mojom::RouteRequestResultCode::OK;
MediaSinkInternal cast_sink_1_;
MediaSinkInternal cast_sink_2_;
};
@@ -410,7 +386,7 @@ TEST_F(AccessCodeCastHandlerTest, OtherDevicesIgnored) {
// Demonstrates that desktop mirroring attempts call media router with the
// correct parameters, and that success is communicated to the dialog box.
TEST_F(AccessCodeCastHandlerTest, DesktopMirroring) {
- set_expected_cast_result(RouteRequestResult::ResultCode::OK);
+ set_expected_cast_result(mojom::RouteRequestResultCode::OK);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::OK));
StartDesktopMirroring(MediaSource::ForUnchosenDesktop(), mock_callback);
@@ -419,7 +395,7 @@ TEST_F(AccessCodeCastHandlerTest, DesktopMirroring) {
// Demonstrates that if casting does not start successfully that the error
// code is communicated to the dialog.
TEST_F(AccessCodeCastHandlerTest, DesktopMirroringError) {
- set_expected_cast_result(RouteRequestResult::ResultCode::ROUTE_NOT_FOUND);
+ set_expected_cast_result(mojom::RouteRequestResultCode::ROUTE_NOT_FOUND);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::ROUTE_NOT_FOUND));
StartDesktopMirroring(MediaSource::ForUnchosenDesktop(), mock_callback);
@@ -428,7 +404,7 @@ TEST_F(AccessCodeCastHandlerTest, DesktopMirroringError) {
// Demonstrates that tab mirroring attempts call media router with the
// correct parameters, and that success is communicated to the dialog box.
TEST_F(AccessCodeCastHandlerTest, TabMirroring) {
- set_expected_cast_result(RouteRequestResult::ResultCode::OK);
+ set_expected_cast_result(mojom::RouteRequestResultCode::OK);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::OK));
MediaSource media_source = MediaSource::ForTab(
@@ -439,7 +415,7 @@ TEST_F(AccessCodeCastHandlerTest, TabMirroring) {
// Demonstrates that if casting does not start successfully that the error
// code is communicated to the dialog.
TEST_F(AccessCodeCastHandlerTest, TabMirroringError) {
- set_expected_cast_result(RouteRequestResult::ResultCode::INVALID_ORIGIN);
+ set_expected_cast_result(mojom::RouteRequestResultCode::INVALID_ORIGIN);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::INVALID_ORIGIN));
MediaSource media_source = MediaSource::ForTab(
@@ -450,7 +426,7 @@ TEST_F(AccessCodeCastHandlerTest, TabMirroringError) {
// Demonstrates that if a default presentation source is available,
// presentation casting will begin instead of tab casting.
TEST_F(AccessCodeCastHandlerTest, DefaultPresentation) {
- set_expected_cast_result(RouteRequestResult::ResultCode::OK);
+ set_expected_cast_result(mojom::RouteRequestResultCode::OK);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::OK));
@@ -464,7 +440,7 @@ TEST_F(AccessCodeCastHandlerTest, DefaultPresentation) {
// Demonstrates that if a presentation casting does not start successfully
// that the error is propagated to the dialog.
TEST_F(AccessCodeCastHandlerTest, DefaultPresentationError) {
- set_expected_cast_result(RouteRequestResult::ResultCode::INVALID_ORIGIN);
+ set_expected_cast_result(mojom::RouteRequestResultCode::INVALID_ORIGIN);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::INVALID_ORIGIN));
@@ -479,7 +455,7 @@ TEST_F(AccessCodeCastHandlerTest, DefaultPresentationError) {
// it will be used to start casting in preference to the default request and
// tab mirroring.
TEST_F(AccessCodeCastHandlerTest, StartPresentationContext) {
- set_expected_cast_result(RouteRequestResult::ResultCode::OK);
+ set_expected_cast_result(mojom::RouteRequestResultCode::OK);
MockCastToSinkCallback mock_callback;
EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::OK));
@@ -500,4 +476,26 @@ TEST_F(AccessCodeCastHandlerTest, StartPresentationContext) {
mock_callback);
}
+// Demonstrates that casting will not start if there already exists a route for
+// the given sink.
+TEST_F(AccessCodeCastHandlerTest, RouteAlreadyExists) {
+ MockCastToSinkCallback mock_callback;
+
+ MediaSinkInternal access_code_sink = CreateCastSink(1);
+ access_code_sink.cast_data().discovery_type =
+ CastDiscoveryType::kAccessCodeManualEntry;
+
+ CreateHandler({MediaCastMode::DESKTOP_MIRROR});
+ set_screen_capture_allowed_for_testing(true);
+ UpdateSinks({access_code_sink.sink()}, std::vector<url::Origin>());
+ handler()->set_sink_id_for_testing(access_code_sink.sink().id());
+
+ MediaRoute media_route_access = CreateRouteForTesting(access_code_sink.id());
+ std::vector<MediaRoute> route_list = {media_route_access};
+ ON_CALL(*router(), GetCurrentRoutes()).WillByDefault(Return(route_list));
+
+ EXPECT_CALL(mock_callback, Run(RouteRequestResultCode::ROUTE_ALREADY_EXISTS));
+ handler()->CastToSink(mock_callback.Get());
+}
+
} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_ui.cc b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_ui.cc
index ce5c5e2d8eb..4086f9a8325 100644
--- a/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_ui.cc
+++ b/chromium/chrome/browser/ui/webui/access_code_cast/access_code_cast_ui.cc
@@ -61,7 +61,7 @@ AccessCodeCastUI::AccessCodeCastUI(content::WebUI* web_ui)
Profile* const profile = Profile::FromWebUI(web_ui);
source->AddInteger("rememberedDeviceDuration",
- GetAccessCodeDeviceDurationPref(profile->GetPrefs()).InSeconds());
+ GetAccessCodeDeviceDurationPref(profile).InSeconds());
// Add a handler to provide pluralized strings.
auto plural_string_handler = std::make_unique<PluralStringHandler>();
diff --git a/chromium/chrome/browser/ui/webui/apc_internals/OWNERS b/chromium/chrome/browser/ui/webui/apc_internals/OWNERS
index 0472f1f0382..664cba0d3d2 100644
--- a/chromium/chrome/browser/ui/webui/apc_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/apc_internals/OWNERS
@@ -1,2 +1,3 @@
+brunobraga@google.com
jkeitel@google.com
vizcay@google.com
diff --git a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.cc b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.cc
index c69bc54202c..5a0e0b8fefc 100644
--- a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.cc
@@ -7,23 +7,42 @@
#include <string>
#include "base/bind.h"
+#include "base/callback_forward.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
+#include "base/containers/unique_ptr_adapters.h"
#include "base/metrics/field_trial_params.h"
+#include "base/ranges/algorithm.h"
+#include "base/strings/strcat.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/autofill_assistant/password_change/apc_client.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/password_manager/password_scripts_fetcher_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
+#include "chrome/browser/ui/ui_features.h"
+#include "chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h"
#include "components/autofill_assistant/browser/switches.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/password_manager/core/browser/password_scripts_fetcher.h"
#include "components/password_manager/core/common/password_manager_features.h"
+#include "components/url_formatter/url_formatter.h"
#include "components/variations/service/variations_service.h"
+#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
+#include "url/origin.h"
using password_manager::PasswordScriptsFetcher;
namespace {
+constexpr char kPasswordChangeIntentName[] = "password_change";
+constexpr char kBundleIdSeparator[] = "/";
+
// TODO(1311324): Reduce the level of code duplication between
// autofill_assistant::ClientAndroid and the helper method in
// chrome/browser/password_manager/password_scripts_fetcher_factory.cc.
@@ -36,11 +55,37 @@ std::string GetCountryCode() {
return base::ToUpperASCII(variations_service->GetLatestCountry());
}
+// Builds the bundle id that Autofill Assistant takes as a parameter based on
+// the user's `ldap`, the `url` of the page, and the `id` of the bundle.
+std::string CreateBundleId(const std::string& ldap,
+ const GURL& url,
+ unsigned id) {
+ const std::u16string formatted_url = url_formatter::FormatUrl(
+ url,
+ url_formatter::kFormatUrlOmitHTTP | url_formatter::kFormatUrlOmitHTTPS |
+ url_formatter::kFormatUrlOmitTrivialSubdomains |
+ url_formatter::kFormatUrlTrimAfterHost,
+ base::UnescapeRule::SPACES, /*new_parsed=*/nullptr,
+ /*prefix_end=*/nullptr, /*offset_for_adjustment=*/nullptr);
+ // Autofill Assistant expects the following format:
+ // `{LDAP}/{BUNDLE_ID}/{INTENT_NAME}/{DOMAIN}`.
+ return base::StrCat({ldap, kBundleIdSeparator, base::NumberToString(id),
+ kBundleIdSeparator, kPasswordChangeIntentName,
+ kBundleIdSeparator, base::UTF16ToUTF8(formatted_url)});
+}
+
} // namespace
+APCInternalsHandler::APCInternalsHandler() = default;
+
APCInternalsHandler::~APCInternalsHandler() = default;
void APCInternalsHandler::RegisterMessages() {
+ password_manager::PasswordManagerClient* password_manager_client =
+ ChromePasswordManagerClient::FromWebContents(web_ui()->GetWebContents());
+ profile_password_store_ = password_manager_client->GetProfilePasswordStore();
+ account_password_store_ = password_manager_client->GetAccountPasswordStore();
+
web_ui()->RegisterMessageCallback(
"loaded", base::BindRepeating(&APCInternalsHandler::OnLoaded,
base::Unretained(this)));
@@ -58,35 +103,42 @@ void APCInternalsHandler::RegisterMessages() {
"set-autofill-assistant-url",
base::BindRepeating(&APCInternalsHandler::OnSetAutofillAssistantUrl,
base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "launch-script",
+ base::BindRepeating(&APCInternalsHandler::GetLoginsAndTryLaunchScript,
+ base::Unretained(this)));
}
void APCInternalsHandler::OnLoaded(const base::Value::List& args) {
AllowJavascript();
// Provide information for initial page creation.
- FireWebUIListener("on-flags-information-received",
- base::Value(GetAPCRelatedFlags()));
+ FireWebUIListener("on-flags-information-received", GetAPCRelatedFlags());
FireWebUIListener("on-script-fetching-information-received",
- base::Value(GetPasswordScriptFetcherInformation()));
+ GetPasswordScriptFetcherInformation());
UpdateAutofillAssistantInformation();
+ OnRefreshScriptCacheRequested(base::Value::List());
}
void APCInternalsHandler::UpdateAutofillAssistantInformation() {
FireWebUIListener("on-autofill-assistant-information-received",
- base::Value(GetAutofillAssistantInformation()));
+ GetAutofillAssistantInformation());
}
void APCInternalsHandler::OnScriptCacheRequested(
const base::Value::List& args) {
FireWebUIListener("on-script-cache-received",
- base::Value(GetPasswordScriptFetcherCache()));
+ GetPasswordScriptFetcherCache());
}
void APCInternalsHandler::OnRefreshScriptCacheRequested(
const base::Value::List& args) {
if (PasswordScriptsFetcher* scripts_fetcher = GetPasswordScriptsFetcher();
scripts_fetcher) {
- scripts_fetcher->PrewarmCache();
+ scripts_fetcher->RefreshScriptsIfNecessary(
+ base::BindOnce(&APCInternalsHandler::OnScriptCacheRequested,
+ weak_ptr_factory_.GetWeakPtr(), base::Value::List()));
}
}
@@ -120,11 +172,14 @@ base::Value::List APCInternalsHandler::GetAPCRelatedFlags() const {
// base::FeatureList::IsEnabled) checks that there is only one memory address
// per feature.
const base::Feature* const apc_features[] = {
- &password_manager::features::kPasswordChange,
- &password_manager::features::kPasswordChangeInSettings,
- &password_manager::features::kPasswordScriptsFetching,
- &password_manager::features::kPasswordDomainCapabilitiesFetching,
- &password_manager::features::kForceEnablePasswordDomainCapabilities,
+ &password_manager::features::kPasswordChange,
+ &password_manager::features::kPasswordChangeInSettings,
+ &password_manager::features::kPasswordScriptsFetching,
+ &password_manager::features::kPasswordDomainCapabilitiesFetching,
+ &password_manager::features::kForceEnablePasswordDomainCapabilities,
+#if !BUILDFLAG(IS_ANDROID)
+ &features::kUnifiedSidePanel,
+#endif
};
base::Value::List relevant_features;
@@ -142,10 +197,10 @@ base::Value::List APCInternalsHandler::GetAPCRelatedFlags() const {
for (const auto& [param_name, param_state] : params)
feature_params.Set(param_name, param_state);
- feature_entry.Set("parameters", base::Value(std::move(feature_params)));
+ feature_entry.Set("parameters", std::move(feature_params));
}
}
- relevant_features.Append(base::Value(std::move(feature_entry)));
+ relevant_features.Append(std::move(feature_entry));
}
return relevant_features;
}
@@ -192,3 +247,75 @@ base::Value::Dict APCInternalsHandler::GetAutofillAssistantInformation() const {
}
return result;
}
+
+void APCInternalsHandler::GetLoginsAndTryLaunchScript(
+ const base::Value::List& args) {
+ if (!profile_password_store_)
+ return;
+
+ if (args.size() == 3 && base::ranges::all_of(args.cbegin(), args.cend(),
+ &base::Value::is_string)) {
+ GURL url = GURL(args.front().GetString());
+ url::Origin origin = url::Origin::Create(url);
+ password_manager::PasswordFormDigest digest(
+ password_manager::PasswordForm::Scheme::kHtml, origin.GetURL().spec(),
+ GURL());
+
+ // Check whether to pass debug parameters.
+ const std::string& ldap = args[1].GetString();
+ const std::string& bundle_id_input = args[2].GetString();
+ unsigned bundle_id_number = 0u;
+ if (!ldap.empty() &&
+ base::StringToUint(bundle_id_input, &bundle_id_number)) {
+ debug_run_information_ = ApcClient::DebugRunInformation{
+ .bundle_id = CreateBundleId(ldap, url, bundle_id_number),
+ .socket_id = ldap};
+ } else {
+ debug_run_information_.reset();
+ }
+
+ pending_logins_requests_.emplace_back(
+ std::make_unique<APCInternalsLoginsRequest>(
+ base::BindOnce(&APCInternalsHandler::LaunchScript,
+ base::Unretained(this)),
+ base::BindOnce(&APCInternalsHandler::OnLoginsRequestFinished,
+ base::Unretained(this))));
+
+ pending_logins_requests_.back()->IncreaseWaitCounter();
+ if (account_password_store_)
+ pending_logins_requests_.back()->IncreaseWaitCounter();
+
+ profile_password_store_->GetLogins(
+ digest, pending_logins_requests_.back()->GetWeakPtr());
+
+ if (account_password_store_)
+ account_password_store_->GetLogins(
+ digest, pending_logins_requests_.back()->GetWeakPtr());
+ }
+}
+
+void APCInternalsHandler::OnLoginsRequestFinished(
+ APCInternalsLoginsRequest* finished_request) {
+ base::EraseIf(pending_logins_requests_,
+ base::MatchesUniquePtr(finished_request));
+}
+
+void APCInternalsHandler::LaunchScript(const GURL& url,
+ const std::string& username) {
+#if !BUILDFLAG(IS_ANDROID)
+ NavigateParams params(Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext()),
+ url, ui::PageTransition::PAGE_TRANSITION_LINK);
+ params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ base::WeakPtr<content::NavigationHandle> navigation_handle =
+ Navigate(&params);
+
+ if (navigation_handle) {
+ ApcClient* apc_client = ApcClient::GetOrCreateForWebContents(
+ navigation_handle.get()->GetWebContents());
+ apc_client->Start(url, username,
+ /*skip_login=*/false,
+ /*callback=*/base::DoNothing(), debug_run_information_);
+ }
+#endif // !IS_ANDROID
+}
diff --git a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.h b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.h
index f5a9a47791f..dbb205a3aad 100644
--- a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.h
+++ b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_handler.h
@@ -5,15 +5,25 @@
#ifndef CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_HANDLER_H_
+#include "base/callback_forward.h"
+#include "base/memory/weak_ptr.h"
#include "base/values.h"
-#include "components/password_manager/core/browser/password_scripts_fetcher.h"
+#include "chrome/browser/autofill_assistant/password_change/apc_client.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
+
+class APCInternalsLoginsRequest;
+
+namespace password_manager {
+class PasswordScriptsFetcher;
+class PasswordStoreInterface;
+} // namespace password_manager
// Provides the WebUI message handling for chrome://apc-internals, the
// diagnostics page for Automated Password Change (APC) flows.
class APCInternalsHandler : public content::WebUIMessageHandler {
public:
- APCInternalsHandler() = default;
+ APCInternalsHandler();
APCInternalsHandler(const APCInternalsHandler&) = delete;
APCInternalsHandler& operator=(const APCInternalsHandler&) = delete;
@@ -43,11 +53,13 @@ class APCInternalsHandler : public content::WebUIMessageHandler {
// user-triggered DOM event.
void OnSetAutofillAssistantUrl(const base::Value::List& args);
+ void GetLoginsAndTryLaunchScript(const base::Value::List& args);
+
// Returns a raw pointer to the |PasswordScriptsFetcher| keyed service.
password_manager::PasswordScriptsFetcher* GetPasswordScriptsFetcher();
// Data gathering methods.
- // Gathers information on all APC-related feature and feature parameters.
+ // Gathers information on all APC-related features and feature parameters.
base::Value::List GetAPCRelatedFlags() const;
// Gathers information about the script fetcher, e.g. chosen engine,
@@ -60,6 +72,28 @@ class APCInternalsHandler : public content::WebUIMessageHandler {
// Gathers AutofillAssistant-related information, e.g. language, locale (can
// be different from general Chrome settings)
base::Value::Dict GetAutofillAssistantInformation() const;
+
+ // Launches APC script on `url` with login `username`.
+ void LaunchScript(const GURL& url, const std::string& username);
+
+ // Removes finished requests from `pending_logins_requests_`.
+ void OnLoginsRequestFinished(APCInternalsLoginsRequest* finished_request);
+
+ // Parameters for starting an APC script as a debug run.
+ absl::optional<ApcClient::DebugRunInformation> debug_run_information_;
+
+ // Queue for pending requests fetching logins from password store.
+ std::vector<std::unique_ptr<APCInternalsLoginsRequest>>
+ pending_logins_requests_;
+
+ // Profile password store.
+ raw_ptr<password_manager::PasswordStoreInterface> profile_password_store_;
+
+ // Represents all Gaia-account-scoped password stores.
+ raw_ptr<password_manager::PasswordStoreInterface> account_password_store_;
+
+ // A factory for weak pointers to the handler.
+ base::WeakPtrFactory<APCInternalsHandler> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.cc b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.cc
new file mode 100644
index 00000000000..234dcaf87e8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.cc
@@ -0,0 +1,44 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "components/password_manager/core/browser/password_form.h"
+
+APCInternalsLoginsRequest::APCInternalsLoginsRequest(
+ base::OnceCallback<void(const GURL& url, const std::string& username)>
+ on_success_callback,
+ base::OnceCallback<void(APCInternalsLoginsRequest*)>
+ request_finished_callback)
+ : on_success_callback_(std::move(on_success_callback)),
+ request_finished_callback_(std::move(request_finished_callback)) {}
+
+APCInternalsLoginsRequest::~APCInternalsLoginsRequest() = default;
+
+void APCInternalsLoginsRequest::OnGetPasswordStoreResults(
+ std::vector<std::unique_ptr<password_manager::PasswordForm>> results) {
+ for (auto& password_form : results)
+ results_.push_back(std::move(password_form));
+
+ if (--wait_counter_ > 0)
+ return;
+
+ if (!results_.empty()) {
+ GURL url = results_.front()->url;
+ std::string username = base::UTF16ToUTF8(results_.front()->username_value);
+ std::move(on_success_callback_).Run(url, username);
+ }
+
+ std::move(request_finished_callback_).Run(this);
+}
+
+void APCInternalsLoginsRequest::IncreaseWaitCounter() {
+ wait_counter_++;
+}
+
+base::WeakPtr<APCInternalsLoginsRequest>
+APCInternalsLoginsRequest::GetWeakPtr() {
+ return weak_ptr_factory_.GetWeakPtr();
+}
diff --git a/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h
new file mode 100644
index 00000000000..f9e54da5e83
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/apc_internals/apc_internals_logins_request.h
@@ -0,0 +1,54 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_LOGINS_REQUEST_H_
+#define CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_LOGINS_REQUEST_H_
+
+#include "components/password_manager/core/browser/password_store_consumer.h"
+#include "url/gurl.h"
+
+// Helper class for fetching logins from password store.
+class APCInternalsLoginsRequest
+ : public password_manager::PasswordStoreConsumer {
+ public:
+ explicit APCInternalsLoginsRequest(
+ base::OnceCallback<void(const GURL& url, const std::string& username)>
+ on_success_callback,
+ base::OnceCallback<void(APCInternalsLoginsRequest*)>
+ request_finished_callback);
+
+ ~APCInternalsLoginsRequest() override;
+
+ // Called by PasswordStoreInterface::GetLogins on completion.
+ void OnGetPasswordStoreResults(
+ std::vector<std::unique_ptr<password_manager::PasswordForm>> results)
+ override;
+
+ // Increase `wait_counter_` by 1.
+ void IncreaseWaitCounter();
+
+ base::WeakPtr<APCInternalsLoginsRequest> GetWeakPtr();
+
+ private:
+ // Callback for when all password stores are finished retrieving logins and
+ // there is at least one login. Used for launching a script.
+ base::OnceCallback<void(const GURL& url, const std::string& username)>
+ on_success_callback_;
+
+ // Callback for when all password stores are finished retrieving logins. Used
+ // for clearing requests queue (outside of this class).
+ base::OnceCallback<void(APCInternalsLoginsRequest*)>
+ request_finished_callback_;
+
+ // The number of password stores this class is still waiting for to complete
+ // retrieving logins.
+ int wait_counter_ = 0;
+
+ // Logins retrieved from all password stores.
+ std::vector<std::unique_ptr<password_manager::PasswordForm>> results_;
+
+ base::WeakPtrFactory<APCInternalsLoginsRequest> weak_ptr_factory_{this};
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_APC_INTERNALS_APC_INTERNALS_LOGINS_REQUEST_H_
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/BUILD.gn b/chromium/chrome/browser/ui/webui/app_home/BUILD.gn
index 3b218d5a1d3..88352e40c05 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/app_home/BUILD.gn
@@ -1,14 +1,11 @@
-# Copyright 2021 The Chromium Authors. All rights reserved.
+# Copyright 2022 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojo_bindings") {
- sources = [ "read_anything.mojom" ]
+ sources = [ "app_home.mojom" ]
webui_module_path = "/"
- public_deps = [
- "//mojo/public/mojom/base",
- "//url/mojom:url_mojom_gurl",
- ]
+ public_deps = [ "//url/mojom:url_mojom_gurl" ]
}
diff --git a/chromium/chrome/browser/ui/webui/app_home/DIR_METADATA b/chromium/chrome/browser/ui/webui/app_home/DIR_METADATA
new file mode 100644
index 00000000000..59e00971183
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/DIR_METADATA
@@ -0,0 +1 @@
+mixins: "//chrome/browser/web_applications/COMMON_METADATA" \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/app_home/OWNERS b/chromium/chrome/browser/ui/webui/app_home/OWNERS
new file mode 100644
index 00000000000..a74f1031167
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/OWNERS
@@ -0,0 +1,4 @@
+file://chrome/browser/web_applications/OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home.mojom b/chromium/chrome/browser/ui/webui/app_home/app_home.mojom
new file mode 100644
index 00000000000..20f0a96b141
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home.mojom
@@ -0,0 +1,35 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module app_home.mojom;
+
+import "url/mojom/url.mojom";
+
+struct AppInfo {
+ // The app id.
+ string id;
+ // The first url to load when app start launching.
+ url.mojom.Url start_url;
+ // The app's name.
+ string name;
+ // The app's icon url showing on `chrome://apps`.
+ url.mojom.Url icon_url;
+};
+
+interface PageHandlerFactory {
+ CreatePageHandler(pending_remote<Page> page,
+ pending_receiver<PageHandler> handler);
+};
+
+interface PageHandler {
+ // Get all apps' information that defined in `AppInfo`.
+ GetApps() => (array<AppInfo> app_list);
+};
+
+// The `Page` interface is used for sending mojom action messsage
+// from backend to frontend.
+// TODO(crbug.com/1350406): Currently there's no place needs to
+// send message to frontend page, so we just left an empty interface class
+// here now, but in the feature, we will add needed APIs here.
+interface Page {}; \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.cc b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.cc
new file mode 100644
index 00000000000..ffbf204d1e6
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.cc
@@ -0,0 +1,121 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#include "chrome/browser/ui/webui/app_home/app_home_page_handler.h"
+
+#include "chrome/browser/apps/app_service/app_icon/app_icon_source.h"
+#include "chrome/browser/extensions/extension_ui_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
+#include "chrome/browser/web_applications/web_app.h"
+#include "chrome/browser/web_applications/web_app_provider.h"
+#include "chrome/browser/web_applications/web_app_registrar.h"
+#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
+#include "content/public/browser/web_ui.h"
+#include "extensions/browser/extension_registry.h"
+#include "url/gurl.h"
+
+using content::WebUI;
+using extensions::Extension;
+using extensions::ExtensionRegistry;
+using extensions::ExtensionSet;
+
+namespace webapps {
+
+namespace {
+
+const int kWebAppLargeIconSize = 128;
+
+// The Youtube app is incorrectly hardcoded to be a 'bookmark app'. However, it
+// is a platform app.
+// TODO(crbug.com/1065748): Remove this hack once the youtube app is fixed.
+bool IsYoutubeExtension(const std::string& extension_id) {
+ return extension_id == extension_misc::kYoutubeAppId;
+}
+} // namespace
+
+AppHomePageHandler::~AppHomePageHandler() = default;
+
+AppHomePageHandler::AppHomePageHandler(
+ content::WebUI* web_ui,
+ Profile* profile,
+ mojo::PendingReceiver<app_home::mojom::PageHandler> receiver,
+ mojo::PendingRemote<app_home::mojom::Page> page)
+ : web_ui_(web_ui),
+ profile_(profile),
+ receiver_(this, std::move(receiver)),
+ page_(std::move(page)) {}
+
+app_home::mojom::AppInfoPtr AppHomePageHandler::CreateAppInfoPtrFromWebApp(
+ const web_app::AppId& app_id) {
+ auto& registrar =
+ web_app::WebAppProvider::GetForWebApps(profile_)->registrar();
+
+ auto app_info = app_home::mojom::AppInfo::New();
+
+ app_info->id = app_id;
+
+ GURL start_url = registrar.GetAppStartUrl(app_id);
+ app_info->start_url = start_url;
+
+ std::string name = registrar.GetAppShortName(app_id);
+ app_info->name = name;
+
+ app_info->icon_url =
+ apps::AppIconSource::GetIconURL(app_id, kWebAppLargeIconSize);
+
+ return app_info;
+}
+
+app_home::mojom::AppInfoPtr AppHomePageHandler::CreateAppInfoPtrFromExtension(
+ const Extension* extension) {
+ auto app_info = app_home::mojom::AppInfo::New();
+
+ app_info->id = extension->id();
+
+ GURL start_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension);
+ app_info->start_url = start_url;
+
+ app_info->name = extension->name();
+
+ app_info->icon_url = extensions::ExtensionIconSource::GetIconURL(
+ extension, extension_misc::EXTENSION_ICON_LARGE,
+ ExtensionIconSet::MATCH_BIGGER, false /*grayscale*/);
+
+ return app_info;
+}
+
+void AppHomePageHandler::FillWebAppInfoList(
+ std::vector<app_home::mojom::AppInfoPtr>* result) {
+ web_app::WebAppRegistrar& registrar =
+ web_app::WebAppProvider::GetForWebApps(profile_)->registrar();
+
+ for (const web_app::AppId& web_app_id : registrar.GetAppIds()) {
+ if (IsYoutubeExtension(web_app_id))
+ continue;
+ result->emplace_back(CreateAppInfoPtrFromWebApp(web_app_id));
+ }
+}
+
+void AppHomePageHandler::FillExtensionInfoList(
+ std::vector<app_home::mojom::AppInfoPtr>* result) {
+ ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
+ std::unique_ptr<ExtensionSet> extension_apps =
+ registry->GenerateInstalledExtensionsSet(ExtensionRegistry::ENABLED |
+ ExtensionRegistry::DISABLED |
+ ExtensionRegistry::TERMINATED);
+ for (const auto& extension : *extension_apps) {
+ if (extensions::ui_util::ShouldDisplayInNewTabPage(extension.get(),
+ profile_))
+ result->emplace_back(CreateAppInfoPtrFromExtension(extension.get()));
+ }
+}
+
+void AppHomePageHandler::GetApps(GetAppsCallback callback) {
+ std::vector<app_home::mojom::AppInfoPtr> result;
+ FillWebAppInfoList(&result);
+ FillExtensionInfoList(&result);
+ std::move(callback).Run(std::move(result));
+}
+
+} // namespace webapps
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.h b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.h
new file mode 100644
index 00000000000..312667fb1e8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler.h
@@ -0,0 +1,63 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_PAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_PAGE_HANDLER_H_
+
+#include "base/memory/raw_ptr.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/app_home/app_home.mojom.h"
+#include "chrome/browser/web_applications/web_app_id.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
+
+namespace content {
+class WebUI;
+} // namespace content
+
+namespace extensions {
+class Extension;
+} // namespace extensions
+
+namespace webapps {
+
+class AppHomePageHandler : public app_home::mojom::PageHandler {
+ public:
+ AppHomePageHandler(
+ content::WebUI*,
+ Profile* profile,
+ mojo::PendingReceiver<app_home::mojom::PageHandler> receiver,
+ mojo::PendingRemote<app_home::mojom::Page> page);
+
+ AppHomePageHandler(const AppHomePageHandler&) = delete;
+ AppHomePageHandler& operator=(const AppHomePageHandler&) = delete;
+
+ ~AppHomePageHandler() override;
+
+ // app_home::mojom::PageHandler:
+ void GetApps(GetAppsCallback callback) override;
+
+ private:
+ void FillWebAppInfoList(std::vector<app_home::mojom::AppInfoPtr>* result);
+ void FillExtensionInfoList(std::vector<app_home::mojom::AppInfoPtr>* result);
+ app_home::mojom::AppInfoPtr CreateAppInfoPtrFromWebApp(
+ const web_app::AppId& app_id);
+ app_home::mojom::AppInfoPtr CreateAppInfoPtrFromExtension(
+ const extensions::Extension* extension);
+
+ raw_ptr<content::WebUI> web_ui_;
+
+ raw_ptr<Profile> profile_;
+
+ mojo::Receiver<app_home::mojom::PageHandler> receiver_;
+
+ mojo::Remote<app_home::mojom::Page> page_;
+
+ // Used for passing callbacks.
+ base::WeakPtrFactory<AppHomePageHandler> weak_ptr_factory_{this};
+};
+
+} // namespace webapps
+
+#endif // CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler_test.cc b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler_test.cc
new file mode 100644
index 00000000000..2762c67f940
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home_page_handler_test.cc
@@ -0,0 +1,128 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/app_home/app_home_page_handler.h"
+
+#include <vector>
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/webui/app_home/app_home.mojom.h"
+#include "chrome/browser/ui/webui/app_home/mock_app_home_page.h"
+#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
+#include "chrome/browser/web_applications/test/web_app_test.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using web_app::AppId;
+using GetAppsCallback =
+ base::OnceCallback<void(std::vector<app_home::mojom::AppInfoPtr>)>;
+
+namespace webapps {
+
+namespace {
+
+constexpr char kTestAppUrl[] = "https://www.example.com/";
+constexpr char kTestManifestUrl[] = "https://www.example.com/manifest.json";
+const std::u16string kTestAppName = u"Test App";
+
+class TestAppHomePageHandler : public AppHomePageHandler {
+ public:
+ TestAppHomePageHandler(content::WebUI* web_ui,
+ Profile* profile,
+ mojo::PendingRemote<app_home::mojom::Page> page)
+ : AppHomePageHandler(
+ web_ui,
+ profile,
+ mojo::PendingReceiver<app_home::mojom::PageHandler>(),
+ std::move(page)) {}
+
+ TestAppHomePageHandler(const TestAppHomePageHandler&) = delete;
+ TestAppHomePageHandler& operator=(const TestAppHomePageHandler&) = delete;
+
+ ~TestAppHomePageHandler() override = default;
+};
+
+std::unique_ptr<WebAppInstallInfo> BuildWebAppInfo() {
+ auto app_info = std::make_unique<WebAppInstallInfo>();
+ app_info->start_url = GURL(kTestAppUrl);
+ app_info->scope = GURL(kTestAppUrl);
+ app_info->title = kTestAppName;
+ app_info->manifest_url = GURL(kTestManifestUrl);
+
+ return app_info;
+}
+
+GetAppsCallback WrapGetAppsCallback(
+ std::vector<app_home::mojom::AppInfoPtr>* out,
+ base::OnceClosure quit_closure) {
+ return base::BindOnce(
+ [](base::OnceClosure quit_closure,
+ std::vector<app_home::mojom::AppInfoPtr>* out,
+ std::vector<app_home::mojom::AppInfoPtr> result) {
+ *out = std::move(result);
+ std::move(quit_closure).Run();
+ },
+ std::move(quit_closure), out);
+}
+
+} // namespace
+
+class AppHomePageHandlerTest : public WebAppTest {
+ public:
+ AppHomePageHandlerTest() = default;
+
+ AppHomePageHandlerTest(const AppHomePageHandlerTest&) = delete;
+ AppHomePageHandlerTest& operator=(const AppHomePageHandlerTest&) = delete;
+
+ ~AppHomePageHandlerTest() override = default;
+
+ void SetUp() override {
+ WebAppTest::SetUp();
+ web_app::test::AwaitStartWebAppProviderAndSubsystems(profile());
+ }
+
+ protected:
+ std::unique_ptr<TestAppHomePageHandler> GetAppHomePageHandler(
+ content::TestWebUI* test_web_ui) {
+ return std::make_unique<TestAppHomePageHandler>(test_web_ui, profile(),
+ page_.BindAndGetRemote());
+ }
+
+ AppId InstallWebApp() {
+ AppId installed_app_id =
+ web_app::test::InstallWebApp(profile(), BuildWebAppInfo());
+
+ return installed_app_id;
+ }
+
+ std::unique_ptr<content::TestWebUI> CreateTestWebUI() {
+ auto test_web_ui = std::make_unique<content::TestWebUI>();
+ test_web_ui->set_web_contents(web_contents());
+ return test_web_ui;
+ }
+
+ testing::StrictMock<MockAppHomePage> page_;
+};
+
+TEST_F(AppHomePageHandlerTest, GetApps) {
+ AppId installed_app_id = InstallWebApp();
+
+ std::unique_ptr<content::TestWebUI> test_web_ui = CreateTestWebUI();
+
+ std::unique_ptr<TestAppHomePageHandler> page_handler =
+ GetAppHomePageHandler(test_web_ui.get());
+
+ std::vector<app_home::mojom::AppInfoPtr> app_infos;
+ base::RunLoop run_loop;
+ page_handler->GetApps(
+ WrapGetAppsCallback(&app_infos, run_loop.QuitClosure()));
+ run_loop.Run();
+
+ ASSERT_EQ(1u, app_infos.size());
+ EXPECT_EQ(kTestAppUrl, app_infos[0]->start_url);
+ EXPECT_EQ(kTestAppName, base::UTF8ToUTF16(app_infos[0]->name));
+}
+} // namespace webapps
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home_ui.cc b/chromium/chrome/browser/ui/webui/app_home/app_home_ui.cc
new file mode 100644
index 00000000000..90cfc06ebc2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home_ui.cc
@@ -0,0 +1,43 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/app_home/app_home_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/app_home/app_home.mojom.h"
+#include "chrome/browser/ui/webui/app_home/app_home_page_handler.h"
+#include "chrome/common/webui_url_constants.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+namespace webapps {
+
+AppHomeUI::AppHomeUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIAppLauncherPageHost);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, source);
+}
+
+void AppHomeUI::BindInterface(
+ mojo::PendingReceiver<app_home::mojom::PageHandlerFactory> receiver) {
+ page_factory_receiver_.reset();
+
+ page_factory_receiver_.Bind(std::move(receiver));
+}
+
+void AppHomeUI::CreatePageHandler(
+ mojo::PendingRemote<app_home::mojom::Page> page,
+ mojo::PendingReceiver<app_home::mojom::PageHandler> receiver) {
+ DCHECK(page);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ page_handler_ = std::make_unique<AppHomePageHandler>(
+ web_ui(), profile, std::move(receiver), std::move(page));
+}
+
+WEB_UI_CONTROLLER_TYPE_IMPL(AppHomeUI)
+
+AppHomeUI::~AppHomeUI() = default;
+
+} // namespace webapps
diff --git a/chromium/chrome/browser/ui/webui/app_home/app_home_ui.h b/chromium/chrome/browser/ui/webui/app_home/app_home_ui.h
new file mode 100644
index 00000000000..3bd696e44e1
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/app_home_ui.h
@@ -0,0 +1,48 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_UI_H_
+
+#include "chrome/browser/ui/webui/app_home/app_home.mojom.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "ui/webui/mojo_web_ui_controller.h"
+
+namespace webapps {
+class AppHomePageHandler;
+} // namespace webapps
+
+namespace webapps {
+
+// The WebUI controller for chrome://apps.
+class AppHomeUI : public ui::MojoWebUIController,
+ public app_home::mojom::PageHandlerFactory {
+ public:
+ explicit AppHomeUI(content::WebUI* web_ui);
+ AppHomeUI(const AppHomeUI&) = delete;
+ AppHomeUI& operator=(const AppHomeUI&) = delete;
+ ~AppHomeUI() override;
+
+ void BindInterface(
+ mojo::PendingReceiver<app_home::mojom::PageHandlerFactory> receiver);
+
+ private:
+ // app_home::mojom::PageHandlerFactory:
+ void CreatePageHandler(
+ mojo::PendingRemote<app_home::mojom::Page> page,
+ mojo::PendingReceiver<app_home::mojom::PageHandler> receiver) override;
+
+ std::unique_ptr<AppHomePageHandler> page_handler_;
+
+ mojo::Receiver<app_home::mojom::PageHandlerFactory> page_factory_receiver_{
+ this};
+
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+} // namespace webapps
+
+#endif // CHROME_BROWSER_UI_WEBUI_APP_HOME_APP_HOME_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.cc b/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.cc
new file mode 100644
index 00000000000..039aa466fe7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.cc
@@ -0,0 +1,18 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/app_home/mock_app_home_page.h"
+
+namespace webapps {
+
+MockAppHomePage::MockAppHomePage() = default;
+
+MockAppHomePage::~MockAppHomePage() = default;
+
+mojo::PendingRemote<app_home::mojom::Page> MockAppHomePage::BindAndGetRemote() {
+ DCHECK(!receiver_.is_bound());
+ return receiver_.BindNewPipeAndPassRemote();
+}
+
+} // namespace webapps
diff --git a/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.h b/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.h
new file mode 100644
index 00000000000..b1ab46aebfd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/app_home/mock_app_home_page.h
@@ -0,0 +1,26 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_APP_HOME_MOCK_APP_HOME_PAGE_H_
+#define CHROME_BROWSER_UI_WEBUI_APP_HOME_MOCK_APP_HOME_PAGE_H_
+
+#include "chrome/browser/ui/webui/app_home/app_home.mojom.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+
+namespace webapps {
+
+class MockAppHomePage : public app_home::mojom::Page {
+ public:
+ MockAppHomePage();
+ ~MockAppHomePage() override;
+
+ mojo::PendingRemote<app_home::mojom::Page> BindAndGetRemote();
+
+ mojo::Receiver<app_home::mojom::Page> receiver_{this};
+};
+
+} // namespace webapps
+
+#endif // CHROME_BROWSER_UI_WEBUI_APP_HOME_MOCK_APP_HOME_PAGE_H_
diff --git a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
index a418a3352ff..b87ac3eb247 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
+++ b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
@@ -132,9 +132,9 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui)
bool is_swipe_tracking_from_scroll_events_enabled = false;
#if BUILDFLAG(IS_MAC)
- // On Mac OS X 10.7+, horizontal scrolling can be treated as a back or
- // forward gesture. Pass through a flag that indicates whether or not that
- // feature is enabled.
+ // On the Mac, horizontal scrolling can be treated as a back or forward
+ // gesture. Pass through a flag that indicates whether or not that feature is
+ // enabled.
is_swipe_tracking_from_scroll_events_enabled =
platform_util::IsSwipeTrackingFromScrollEventsEnabled();
#endif
diff --git a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
index 33bc72f90d0..fe59c24327e 100644
--- a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
@@ -11,6 +11,7 @@
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/i18n/message_formatter.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
@@ -24,9 +25,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/app_constants/constants.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
+#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/cpp/intent_filter.h"
#include "components/services/app_service/public/cpp/intent_filter_util.h"
#include "components/services/app_service/public/cpp/intent_util.h"
+#include "components/services/app_service/public/cpp/permission.h"
#include "components/services/app_service/public/cpp/preferred_apps_list_handle.h"
#include "components/services/app_service/public/cpp/types_util.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
@@ -39,6 +42,7 @@
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
+#include "third_party/blink/public/common/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/events/event_constants.h"
@@ -267,8 +271,13 @@ void AppManagementPageHandler::SetPinned(const std::string& app_id,
void AppManagementPageHandler::SetPermission(const std::string& app_id,
apps::PermissionPtr permission) {
- apps::AppServiceProxyFactory::GetForProfile(profile_)->SetPermission(
- app_id, apps::ConvertPermissionToMojomPermission(permission));
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->SetPermission(
+ app_id, std::move(permission));
+ } else {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->SetPermission(
+ app_id, apps::ConvertPermissionToMojomPermission(permission));
+ }
}
void AppManagementPageHandler::SetResizeLocked(const std::string& app_id,
@@ -283,9 +292,15 @@ void AppManagementPageHandler::SetResizeLocked(const std::string& app_id,
}
void AppManagementPageHandler::Uninstall(const std::string& app_id) {
- apps::AppServiceProxyFactory::GetForProfile(profile_)->Uninstall(
- app_id, apps::mojom::UninstallSource::kAppManagement,
- delegate_.GetUninstallAnchorWindow());
+ if (base::FeatureList::IsEnabled(apps::kAppServiceUninstallWithoutMojom)) {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->Uninstall(
+ app_id, apps::UninstallSource::kAppManagement,
+ delegate_.GetUninstallAnchorWindow());
+ } else {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->Uninstall(
+ app_id, apps::mojom::UninstallSource::kAppManagement,
+ delegate_.GetUninstallAnchorWindow());
+ }
}
void AppManagementPageHandler::OpenNativeSettings(const std::string& app_id) {
@@ -353,8 +368,17 @@ void AppManagementPageHandler::SetRunOnOsLoginMode(
void AppManagementPageHandler::SetFileHandlingEnabled(const std::string& app_id,
bool enabled) {
- web_app::PersistFileHandlersUserChoice(profile_, app_id, enabled,
- base::DoNothing());
+ auto permission = std::make_unique<apps::Permission>(
+ apps::PermissionType::kFileHandling,
+ std::make_unique<apps::PermissionValue>(enabled),
+ /*is_managed=*/false);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->SetPermission(
+ app_id, std::move(permission));
+ } else {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->SetPermission(
+ app_id, apps::ConvertPermissionToMojomPermission(permission));
+ }
}
void AppManagementPageHandler::ShowDefaultAppAssociationsUi() {
@@ -441,55 +465,87 @@ app_management::mojom::AppPtr AppManagementPageHandler::CreateUIAppPtr(
std::move(run_on_os_login.value()));
}
- if (update.AppType() == apps::AppType::kWeb) {
+ if (update.AppType() == apps::AppType::kWeb ||
+ update.AppType() == apps::AppType::kSystemWeb) {
std::string file_handling_types;
std::string file_handling_types_label;
bool fh_enabled = false;
-// Speculative fix for crbug.com/1315958
-#if !BUILDFLAG(IS_CHROMEOS)
- auto* provider =
- web_app::WebAppProvider::GetForLocalAppsUnchecked(profile_);
- fh_enabled =
- !provider->registrar().IsAppFileHandlerPermissionBlocked(app->id);
- if (provider->os_integration_manager().IsFileHandlingAPIAvailable(
- app->id) &&
- !provider->registrar().IsSystemApp(app->id) &&
- !provider->registrar().GetAppFileHandlers(app->id)->empty()) {
- auto [file_handling_types16, count] =
- web_app::GetFileTypeAssociationsHandledByWebAppForDisplay(profile_,
- app->id);
- file_handling_types = base::UTF16ToUTF8(file_handling_types16);
-
- const std::vector<std::string> all_extensions =
- web_app::GetFileTypeAssociationsHandledByWebAppForDisplayAsList(
- profile_, app->id);
- std::vector<std::string> truncated_extensions = all_extensions;
- // Only show at most 4 extensions.
- truncated_extensions.resize(4);
- file_handling_types_label =
- base::UTF16ToUTF8(base::i18n::MessageFormatter::FormatWithNamedArgs(
- l10n_util::GetStringUTF16(IDS_APP_MANAGEMENT_FILE_HANDLING_TYPES),
- "FILE_TYPE_COUNT", static_cast<int>(all_extensions.size()),
- "FILE_TYPE1", truncated_extensions[0], "FILE_TYPE2",
- truncated_extensions[1], "FILE_TYPE3", truncated_extensions[2],
- "FILE_TYPE4", truncated_extensions[3], "OVERFLOW_COUNT",
- static_cast<int>(all_extensions.size()) -
- static_cast<int>(truncated_extensions.size()),
- "LINK", "#"));
+ const bool is_system_web_app =
+ update.InstallReason() == apps::InstallReason::kSystem;
+ if (!is_system_web_app &&
+ base::FeatureList::IsEnabled(blink::features::kFileHandlingAPI)) {
+ apps::IntentFilters filters = update.IntentFilters();
+ if (!filters.empty()) {
+ std::set<std::string> file_extensions;
+ // Mime types are ignored.
+ std::set<std::string> mime_types;
+ for (auto& filter : filters) {
+ bool is_potential_file_handler_action = base::ranges::any_of(
+ filter->conditions.begin(), filter->conditions.end(),
+ [](const std::unique_ptr<apps::Condition>& condition) {
+ if (condition->condition_type != apps::ConditionType::kAction)
+ return false;
+
+ if (condition->condition_values.size() != 1U)
+ return false;
+
+ return condition->condition_values[0]->value ==
+ apps_util::kIntentActionPotentialFileHandler;
+ });
+ if (is_potential_file_handler_action) {
+ filter->GetMimeTypesAndExtensions(mime_types, file_extensions);
+ break;
+ }
+ }
+
+ for (const auto& permission : update.Permissions()) {
+ if (permission->permission_type ==
+ apps::PermissionType::kFileHandling) {
+ fh_enabled = permission->IsPermissionEnabled();
+ break;
+ }
+ }
+
+ std::vector<std::u16string> extensions_for_display =
+ web_app::TransformFileExtensionsForDisplay(file_extensions);
+ file_handling_types = base::UTF16ToUTF8(
+ base::JoinString(extensions_for_display,
+ l10n_util::GetStringUTF16(
+ IDS_WEB_APP_FILE_HANDLING_LIST_SEPARATOR)));
+
+ std::vector<std::u16string> truncated_extensions =
+ extensions_for_display;
+ // Only show at most 4 extensions.
+ truncated_extensions.resize(4);
+ file_handling_types_label =
+ base::UTF16ToUTF8(base::i18n::MessageFormatter::FormatWithNamedArgs(
+ l10n_util::GetStringUTF16(
+ IDS_APP_MANAGEMENT_FILE_HANDLING_TYPES),
+ "FILE_TYPE_COUNT",
+ static_cast<int>(extensions_for_display.size()), "FILE_TYPE1",
+ truncated_extensions[0], "FILE_TYPE2", truncated_extensions[1],
+ "FILE_TYPE3", truncated_extensions[2], "FILE_TYPE4",
+ truncated_extensions[3], "OVERFLOW_COUNT",
+ static_cast<int>(extensions_for_display.size()) -
+ static_cast<int>(truncated_extensions.size()),
+ "LINK", "#"));
+ }
+
+ absl::optional<GURL> learn_more_url;
+ if (!CanShowDefaultAppAssociationsUi())
+ learn_more_url = GURL(kFileHandlingLearnMore);
+ // TODO(crbug/1252505): add file handling policy support.
+ app->file_handling_state = app_management::mojom::FileHandlingState::New(
+ fh_enabled, /*is_managed=*/false, file_handling_types,
+ file_handling_types_label, learn_more_url);
}
+ }
- app->hide_window_mode = provider->registrar().IsIsolated(app->id);
+#if !BUILDFLAG(IS_CHROMEOS)
+ auto* provider = web_app::WebAppProvider::GetForLocalAppsUnchecked(profile_);
+ app->hide_window_mode = provider->registrar().IsIsolated(app->id);
#endif
- absl::optional<GURL> learn_more_url;
- if (!CanShowDefaultAppAssociationsUi())
- learn_more_url = GURL(kFileHandlingLearnMore);
- // TODO(crbug/1252505): add file handling policy support.
- app->file_handling_state = app_management::mojom::FileHandlingState::New(
- fh_enabled, /*is_managed=*/false, file_handling_types,
- file_handling_types_label, learn_more_url);
- }
-
app->publisher_id = update.PublisherId();
return app;
@@ -503,12 +559,22 @@ void AppManagementPageHandler::OpenStorePage(const std::string& app_id) {
if (update.InstallSource() == apps::InstallSource::kPlayStore) {
GURL url("https://play.google.com/store/apps/details?id=" +
update.PublisherId());
- proxy->LaunchAppWithUrl(arc::kPlayStoreAppId, ui::EF_NONE, url,
- apps::mojom::LaunchSource::kFromChromeInternal);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ proxy->LaunchAppWithUrl(arc::kPlayStoreAppId, ui::EF_NONE, url,
+ apps::LaunchSource::kFromChromeInternal);
+ } else {
+ proxy->LaunchAppWithUrl(arc::kPlayStoreAppId, ui::EF_NONE, url,
+ apps::mojom::LaunchSource::kFromChromeInternal);
+ }
} else if (update.InstallSource() == apps::InstallSource::kChromeWebStore) {
GURL url("https://chrome.google.com/webstore/detail/" + update.AppId());
- proxy->LaunchAppWithUrl(extensions::kWebStoreAppId, ui::EF_NONE, url,
- apps::mojom::LaunchSource::kFromChromeInternal);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ proxy->LaunchAppWithUrl(extensions::kWebStoreAppId, ui::EF_NONE, url,
+ apps::LaunchSource::kFromChromeInternal);
+ } else {
+ proxy->LaunchAppWithUrl(extensions::kWebStoreAppId, ui::EF_NONE, url,
+ apps::mojom::LaunchSource::kFromChromeInternal);
+ }
}
});
#endif
diff --git a/chromium/chrome/browser/ui/webui/app_service_internals/app_service_internals_browsertest.cc b/chromium/chrome/browser/ui/webui/app_service_internals/app_service_internals_browsertest.cc
index 0e0bc19f062..8ad68143f93 100644
--- a/chromium/chrome/browser/ui/webui/app_service_internals/app_service_internals_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/app_service_internals/app_service_internals_browsertest.cc
@@ -18,7 +18,7 @@ IN_PROC_BROWSER_TEST_F(AppServiceInternalsBrowserTest, LoadsWebUiPage) {
// app visible.
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url =
- embedded_test_server()->GetURL("/web_apps/site_a/basic.html");
+ embedded_test_server()->GetURL("/web_apps/standalone/basic.html");
web_app::InstallWebAppFromPage(browser(), app_url);
content::WebContents* web_contents =
diff --git a/chromium/chrome/browser/ui/webui/app_settings/web_app_settings_navigation_throttle.cc b/chromium/chrome/browser/ui/webui/app_settings/web_app_settings_navigation_throttle.cc
index 25b062fb646..59c703a5ea7 100644
--- a/chromium/chrome/browser/ui/webui/app_settings/web_app_settings_navigation_throttle.cc
+++ b/chromium/chrome/browser/ui/webui/app_settings/web_app_settings_navigation_throttle.cc
@@ -21,9 +21,6 @@ bool g_disable_throttle_for_testing_ = false;
std::unique_ptr<content::NavigationThrottle>
WebAppSettingsNavigationThrottle::MaybeCreateThrottleFor(
content::NavigationHandle* handle) {
- // Check web app settings feature is enabled.
- if (!base::FeatureList::IsEnabled(features::kDesktopPWAsWebAppSettingsPage))
- return nullptr;
// Check the current url scheme is chrome://
if (!handle->GetURL().SchemeIs(content::kChromeUIScheme))
return nullptr;
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui_browsertest.cc
index ab02ab3d81f..aa51623af77 100644
--- a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui_browsertest.cc
@@ -46,7 +46,7 @@ IN_PROC_BROWSER_TEST_F(AutofillInternalsWebUIBrowserTest, ResetCache) {
// Wait for reset-fake-button to become visible
constexpr char kGetResetButtonDisplayStyle[] =
"document.getElementById('reset-cache-fake-button').style.display";
- while ("inline-block" != EvalJs(kGetResetButtonDisplayStyle))
+ while ("inline" != EvalJs(kGetResetButtonDisplayStyle))
SpinRunLoop();
// Trigger reset button.
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc
index 056541903e6..889c1159a29 100644
--- a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc
@@ -13,6 +13,7 @@
#include "components/autofill/core/browser/logging/log_router.h"
#include "components/embedder_support/user_agent_utils.h"
#include "components/grit/dev_ui_components_resources.h"
+#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/version_info/version_info.h"
#include "components/version_ui/version_handler_helper.h"
#include "components/version_ui/version_ui_constants.h"
@@ -91,12 +92,18 @@ InternalsUIHandler::~InternalsUIHandler() {
}
void InternalsUIHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"loaded", base::BindRepeating(&InternalsUIHandler::OnLoaded,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"resetCache", base::BindRepeating(&InternalsUIHandler::OnResetCache,
base::Unretained(this)));
+#if BUILDFLAG(IS_ANDROID)
+ web_ui()->RegisterMessageCallback(
+ "resetUpmEviction",
+ base::BindRepeating(&InternalsUIHandler::OnResetUpmEviction,
+ base::Unretained(this)));
+#endif
}
void InternalsUIHandler::OnJavascriptAllowed() {
@@ -107,7 +114,7 @@ void InternalsUIHandler::OnJavascriptDisallowed() {
EndSubscription();
}
-void InternalsUIHandler::OnLoaded(const base::ListValue* args) {
+void InternalsUIHandler::OnLoaded(const base::Value::List& args) {
AllowJavascript();
FireWebUIListener(call_on_load_, base::Value());
// This is only available in contents, because the iOS BrowsingDataRemover
@@ -118,9 +125,17 @@ void InternalsUIHandler::OnLoaded(const base::ListValue* args) {
"notify-about-incognito",
base::Value(Profile::FromWebUI(web_ui())->IsIncognitoProfile()));
FireWebUIListener("notify-about-variations", version_ui::GetVariationsList());
+
+#if BUILDFLAG(IS_ANDROID)
+ auto* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ FireWebUIListener("enable-reset-upm-eviction-button",
+ base::Value(prefs->GetBoolean(
+ password_manager::prefs::
+ kUnenrolledFromGoogleMobileServicesDueToErrors)));
+#endif
}
-void InternalsUIHandler::OnResetCache(const base::ListValue* args) {
+void InternalsUIHandler::OnResetCache(const base::Value::List& args) {
if (!autofill_cache_resetter_) {
content::BrowserContext* browser_context = Profile::FromWebUI(web_ui());
autofill_cache_resetter_.emplace(browser_context);
@@ -133,6 +148,16 @@ void InternalsUIHandler::OnResetCacheDone(const std::string& message) {
FireWebUIListener("notify-reset-done", base::Value(message));
}
+#if BUILDFLAG(IS_ANDROID)
+void InternalsUIHandler::OnResetUpmEviction(const base::Value::List& args) {
+ auto* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ prefs->SetBoolean(
+ password_manager::prefs::kUnenrolledFromGoogleMobileServicesDueToErrors,
+ false);
+ FireWebUIListener("enable-reset-upm-eviction-button", base::Value(false));
+}
+#endif
+
void InternalsUIHandler::StartSubscription() {
LogRouter* log_router =
get_log_router_function_.Run(Profile::FromWebUI(web_ui()));
@@ -140,10 +165,7 @@ void InternalsUIHandler::StartSubscription() {
return;
registered_with_log_router_ = true;
-
- const auto& past_logs = log_router->RegisterReceiver(this);
- for (const auto& entry : past_logs)
- LogEntry(entry);
+ log_router->RegisterReceiver(this);
}
void InternalsUIHandler::EndSubscription() {
@@ -156,8 +178,8 @@ void InternalsUIHandler::EndSubscription() {
log_router->UnregisterReceiver(this);
}
-void InternalsUIHandler::LogEntry(const base::Value& entry) {
- if (!registered_with_log_router_ || entry.is_none())
+void InternalsUIHandler::LogEntry(const base::Value::Dict& entry) {
+ if (!registered_with_log_router_)
return;
FireWebUIListener("add-structured-log", entry);
}
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.h b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.h
index a94e0d1a055..ae019503ca6 100644
--- a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.h
@@ -78,14 +78,15 @@ class InternalsUIHandler : public content::WebUIMessageHandler,
void OnJavascriptDisallowed() override;
// LogReceiver implementation.
- void LogEntry(const base::Value& entry) override;
+ void LogEntry(const base::Value::Dict& entry) override;
void StartSubscription();
void EndSubscription();
// JavaScript call handler.
- void OnLoaded(const base::ListValue* args);
- void OnResetCache(const base::ListValue* args);
+ void OnLoaded(const base::Value::List& args);
+ void OnResetCache(const base::Value::List& args);
+ void OnResetUpmEviction(const base::Value::List& args);
void OnResetCacheDone(const std::string& message);
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui_browsertest.cc
index bd9a0758584..d3dca59791f 100644
--- a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui_browsertest.cc
@@ -102,44 +102,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest,
ASSERT_TRUE(RunJavascriptTest("testLogEmpty"));
}
-// Test that if two tabs with the internals page are open, the second displays
-// the same logs. In particular, this checks that both the second tab gets the
-// logs created before the second tab was opened, and also that the second tab
-// waits with displaying until the internals page is ready (trying to display
-// the old logs just on construction time would fail).
-IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest,
- LogEntry_MultipleTabsIdentical) {
- // First, open one tab with the internals page, and log something.
- autofill::LogRouter* log_router =
- password_manager::PasswordManagerLogRouterFactory::GetForBrowserContext(
- browser()->profile());
- ASSERT_TRUE(log_router);
- log_router->ProcessLog("<script> text for testing");
- ASSERT_TRUE(RunJavascriptTest("testLogText"));
- // Now open a second tab with the internals page, but do not log anything.
- OpenInternalsPage(WindowOpenDisposition::NEW_FOREGROUND_TAB);
- // The previously logged text should have made it to the page.
- ASSERT_TRUE(RunJavascriptTest("testLogText"));
-}
-
-// Test that in the presence of more internals pages, reload does not cause
-// flushing the logs.
-IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest,
- LogEntry_NotFlushedOnReloadIfMultiple) {
- // Open one more tab with the internals page.
- OpenInternalsPage(WindowOpenDisposition::NEW_FOREGROUND_TAB);
- // Now log something.
- autofill::LogRouter* log_router =
- password_manager::PasswordManagerLogRouterFactory::GetForBrowserContext(
- browser()->profile());
- ASSERT_TRUE(log_router);
- log_router->ProcessLog("<script> text for testing");
- // Reload.
- OpenInternalsPage(WindowOpenDisposition::CURRENT_TAB);
- // The text should still be there.
- ASSERT_TRUE(RunJavascriptTest("testLogText"));
-}
-
// Test that navigation away from the internals page works OK.
IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest,
LogEntry_NavigateAway) {
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc
index 98a699fa6cb..6f128a8253b 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc
@@ -17,12 +17,12 @@ BookmarksMessageHandler::BookmarksMessageHandler() {}
BookmarksMessageHandler::~BookmarksMessageHandler() {}
void BookmarksMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getIncognitoAvailability",
base::BindRepeating(
&BookmarksMessageHandler::HandleGetIncognitoAvailability,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getCanEditBookmarks",
base::BindRepeating(&BookmarksMessageHandler::HandleGetCanEditBookmarks,
base::Unretained(this)));
@@ -51,9 +51,9 @@ int BookmarksMessageHandler::GetIncognitoAvailability() {
}
void BookmarksMessageHandler::HandleGetIncognitoAvailability(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
+ const base::Value& callback_id = args[0];
AllowJavascript();
@@ -72,9 +72,9 @@ bool BookmarksMessageHandler::CanEditBookmarks() {
}
void BookmarksMessageHandler::HandleGetCanEditBookmarks(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
+ const base::Value& callback_id = args[0];
AllowJavascript();
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.h b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.h
index 5819ecea75d..ec77cf64a6d 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.h
@@ -8,10 +8,6 @@
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-}
-
class BookmarksMessageHandler : public content::WebUIMessageHandler {
public:
BookmarksMessageHandler();
@@ -23,11 +19,11 @@ class BookmarksMessageHandler : public content::WebUIMessageHandler {
private:
int GetIncognitoAvailability();
- void HandleGetIncognitoAvailability(const base::ListValue* args);
+ void HandleGetIncognitoAvailability(const base::Value::List& args);
void UpdateIncognitoAvailability();
bool CanEditBookmarks();
- void HandleGetCanEditBookmarks(const base::ListValue* args);
+ void HandleGetCanEditBookmarks(const base::Value::List& args);
void UpdateCanEditBookmarks();
// content::WebUIMessageHandler:
diff --git a/chromium/chrome/browser/ui/webui/browser_command/DEPS b/chromium/chrome/browser/ui/webui/browser_command/DEPS
new file mode 100644
index 00000000000..40885822102
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/browser_command/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ # Browser command relies on the tutorial ID defined here.
+ "+chrome/browser/ui/views/user_education/browser_user_education_service.h",
+]
diff --git a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.cc b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.cc
index e85f606521a..b9825e39810 100644
--- a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.cc
+++ b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.cc
@@ -11,13 +11,22 @@
#include "chrome/browser/new_tab_page/promos/promo_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/tabs/tab_group_model.h"
+#include "chrome/browser/ui/user_education/user_education_service.h"
+#include "chrome/browser/ui/user_education/user_education_service_factory.h"
+#include "chrome/browser/ui/views/user_education/browser_user_education_service.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/webui_url_constants.h"
#include "components/safe_browsing/content/browser/web_ui/safe_browsing_ui.h"
#include "components/safe_browsing/core/common/safe_browsing_policy_handler.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
+#include "components/user_education/common/tutorial_identifier.h"
+#include "components/user_education/common/tutorial_service.h"
+#include "ui/base/interaction/element_identifier.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
@@ -72,12 +81,17 @@ void BrowserCommandHandler::CanExecuteCommand(
can_execute = true;
break;
case Command::kOpenPrivacyGuide:
- can_execute = base::FeatureList::IsEnabled(features::kPrivacyGuide) &&
- !chrome::enterprise_util::IsBrowserManaged(profile_) &&
+ can_execute = !chrome::enterprise_util::IsBrowserManaged(profile_) &&
!profile_->IsChild();
break;
- default:
- NOTREACHED() << "Unspecified behavior for command " << command_id;
+ case Command::kStartTabGroupTutorial:
+ can_execute = !!GetTutorialService() && BrowserSupportsTabGroups();
+ break;
+ case Command::kOpenPasswordManager:
+ can_execute = true;
+ break;
+ case Command::kNoOpCommand:
+ can_execute = true;
break;
}
std::move(callback).Run(can_execute);
@@ -132,12 +146,68 @@ void BrowserCommandHandler::ExecuteCommandWithDisposition(
base::RecordAction(
base::UserMetricsAction("NewTabPage_Promos_PrivacyGuide"));
break;
+ case Command::kStartTabGroupTutorial:
+ StartTabGroupTutorial();
+ break;
+ case Command::kOpenPasswordManager:
+ NavigateToURL(
+ GURL(chrome::GetSettingsUrl(chrome::kPasswordManagerSubPage)),
+ disposition);
+ break;
+ case Command::kNoOpCommand:
+ // Nothing to do.
+ break;
default:
NOTREACHED() << "Unspecified behavior for command " << id;
break;
}
}
+user_education::TutorialService* BrowserCommandHandler::GetTutorialService() {
+ auto* service = UserEducationServiceFactory::GetForProfile(profile_);
+ return service ? &service->tutorial_service() : nullptr;
+}
+
+ui::ElementContext BrowserCommandHandler::GetUiElementContext() {
+ return chrome::FindBrowserWithProfile(profile_)
+ ->window()
+ ->GetElementContext();
+}
+
+bool BrowserCommandHandler::BrowserSupportsTabGroups() {
+ Browser* browser = chrome::FindBrowserWithProfile(profile_);
+ return browser->tab_strip_model()->SupportsTabGroups();
+}
+
+bool BrowserCommandHandler::BrowserHasTabGroups() {
+ Browser* browser = chrome::FindBrowserWithProfile(profile_);
+ return !browser->tab_strip_model()->group_model()->ListTabGroups().empty();
+}
+
+void BrowserCommandHandler::StartTabGroupTutorial() {
+ user_education::TutorialService* tutorial_service = GetTutorialService();
+
+ // Should never happen since we return false in CanExecuteCommand(), but
+ // avoid a browser crash anyway.
+ if (!tutorial_service)
+ return;
+
+ const ui::ElementContext context = GetUiElementContext();
+ if (!context)
+ return;
+
+ if (!BrowserSupportsTabGroups()) {
+ return;
+ }
+
+ user_education::TutorialIdentifier tutorial_id =
+ BrowserHasTabGroups() ? kTabGroupWithExistingGroupTutorialId
+ : kTabGroupTutorialId;
+
+ bool started_tutorial = tutorial_service->StartTutorial(tutorial_id, context);
+ tutorial_service->LogStartedFromWhatsNewPage(tutorial_id, started_tutorial);
+}
+
void BrowserCommandHandler::OpenFeedbackForm() {
chrome::ShowFeedbackPage(feedback_settings_.url, profile_,
feedback_settings_.source,
diff --git a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.h b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.h
index a4336233085..d202842c861 100644
--- a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.h
+++ b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler.h
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
+#include "ui/base/interaction/element_tracker.h"
#include "ui/base/window_open_disposition.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
#include "url/gurl.h"
@@ -19,6 +20,10 @@
class CommandUpdater;
class Profile;
+namespace user_education {
+class TutorialService;
+}
+
// Struct containing the information needed to customize/configure the feedback
// form. Used to populate arguments passed to chrome::ShowFeedbackPage().
struct FeedbackCommandSettings {
@@ -66,10 +71,17 @@ class BrowserCommandHandler : public CommandUpdaterDelegate,
virtual CommandUpdater* GetCommandUpdater();
+ virtual bool BrowserSupportsTabGroups();
+
+ virtual bool BrowserHasTabGroups();
+
private:
virtual void NavigateToURL(const GURL& url,
WindowOpenDisposition disposition);
virtual void OpenFeedbackForm();
+ virtual user_education::TutorialService* GetTutorialService();
+ virtual ui::ElementContext GetUiElementContext();
+ void StartTabGroupTutorial();
FeedbackCommandSettings feedback_settings_;
raw_ptr<Profile> profile_;
diff --git a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler_unittest.cc b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler_unittest.cc
index 0bbfc031fcc..2d5d95e7925 100644
--- a/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/browser_command/browser_command_handler_unittest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/browser_features.h"
#include "chrome/browser/command_updater_impl.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/views/user_education/browser_user_education_service.h"
#include "chrome/browser/ui/webui/browser_command/browser_command_handler.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/webui_url_constants.h"
@@ -19,9 +20,14 @@
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
+#include "components/user_education/common/help_bubble_factory_registry.h"
+#include "components/user_education/common/tutorial_identifier.h"
+#include "components/user_education/common/tutorial_registry.h"
+#include "components/user_education/common/tutorial_service.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/interaction/element_tracker.h"
#include "ui/base/window_open_disposition.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
@@ -38,8 +44,13 @@ std::vector<Command> supported_commands = {
Command::kOpenSafeBrowsingEnhancedProtectionSettings,
Command::kOpenFeedbackForm,
Command::kOpenPrivacyGuide,
+ Command::kStartTabGroupTutorial,
+ Command::kOpenPasswordManager,
+ Command::kNoOpCommand,
};
+const ui::ElementContext kTestContext1(1);
+
class TestCommandHandler : public BrowserCommandHandler {
public:
explicit TestCommandHandler(Profile* profile)
@@ -55,9 +66,15 @@ class TestCommandHandler : public BrowserCommandHandler {
void OpenFeedbackForm() override {
// The functionality of opening the feedback form is removed, as it cannot
- // be executed in a unittes.
+ // be executed in a unittest.
+ }
+
+ user_education::TutorialService* GetTutorialService() override {
+ return tutorial_service_;
}
+ ui::ElementContext GetUiElementContext() override { return kTestContext1; }
+
CommandUpdater* GetCommandUpdater() override {
if (command_updater_)
return command_updater_.get();
@@ -70,7 +87,69 @@ class TestCommandHandler : public BrowserCommandHandler {
EnableSupportedCommands();
}
+ void SetTutorialService(user_education::TutorialService* service) {
+ tutorial_service_ = service;
+ }
+
+ void SetBrowserSupportsTabGroups(bool is_supported) {
+ tab_groups_feature_supported_ = is_supported;
+ }
+
+ void SetBrowserHasTabGroups(bool has_tab_groups) {
+ has_tab_groups_ = has_tab_groups;
+ }
+
+ protected:
+ bool BrowserSupportsTabGroups() override {
+ return tab_groups_feature_supported_;
+ }
+
+ bool BrowserHasTabGroups() override { return has_tab_groups_; }
+
+ private:
+ user_education::TutorialService* tutorial_service_;
std::unique_ptr<CommandUpdater> command_updater_;
+
+ bool tab_groups_feature_supported_ = true;
+ bool has_tab_groups_ = false;
+};
+
+class TestTutorialService : public user_education::TutorialService {
+ public:
+ TestTutorialService(
+ user_education::TutorialRegistry* tutorial_registry,
+ user_education::HelpBubbleFactoryRegistry* help_bubble_factory_registry)
+ : user_education::TutorialService(tutorial_registry,
+ help_bubble_factory_registry) {}
+ ~TestTutorialService() override = default;
+ std::u16string GetBodyIconAltText(bool is_last_step) const override {
+ return std::u16string();
+ }
+
+ bool StartTutorial(
+ user_education::TutorialIdentifier id,
+ ui::ElementContext context,
+ base::OnceClosure completed_callback = base::DoNothing(),
+ base::OnceClosure aborted_callback = base::DoNothing()) override {
+ return true;
+ }
+};
+
+class MockTutorialService : public TestTutorialService {
+ public:
+ MockTutorialService(
+ user_education::TutorialRegistry* tutorial_registry,
+ user_education::HelpBubbleFactoryRegistry* help_bubble_factory_registry)
+ : TestTutorialService(tutorial_registry, help_bubble_factory_registry) {}
+ ~MockTutorialService() override = default;
+
+ MOCK_METHOD4(StartTutorial,
+ bool(user_education::TutorialIdentifier,
+ ui::ElementContext,
+ base::OnceClosure,
+ base::OnceClosure));
+ MOCK_METHOD2(LogStartedFromWhatsNewPage,
+ void(user_education::TutorialIdentifier, bool));
};
class MockCommandHandler : public TestCommandHandler {
@@ -322,18 +401,9 @@ TEST_F(BrowserCommandHandlerTest, OpenFeedbackFormCommand) {
}
TEST_F(BrowserCommandHandlerTest, CanExecuteCommand_OpenPrivacyGuide) {
- // Showing the Privacy Guide promo is not allowed if the experimental
- // flag is disabled.
- base::test::ScopedFeatureList feature_list;
- feature_list.InitAndDisableFeature(features::kPrivacyGuide);
- EXPECT_FALSE(CanExecuteCommand(Command::kOpenPrivacyGuide));
-
- // Once the flag is enabled, it is allowed.
- feature_list.Reset();
- feature_list.InitAndEnableFeature(features::kPrivacyGuide);
EXPECT_TRUE(CanExecuteCommand(Command::kOpenPrivacyGuide));
- // If the browser is managed, it is again not allowed.
+ // Showing the Privacy Guide promo is not allowed if the browser is managed.
{
TestingProfile::Builder builder;
builder.OverridePolicyConnectorIsManagedForTesting(true);
@@ -362,3 +432,64 @@ TEST_F(BrowserCommandHandlerTest, OpenPrivacyGuideCommand) {
DispositionFromClick(*info)));
EXPECT_TRUE(ExecuteCommand(Command::kOpenPrivacyGuide, std::move(info)));
}
+
+TEST_F(BrowserCommandHandlerTest, StartTabGroupTutorialCommand) {
+ // Command cannot be executed if the tutorial service doesn't exist.
+ command_handler_->SetTutorialService(nullptr);
+ EXPECT_FALSE(CanExecuteCommand(Command::kStartTabGroupTutorial));
+
+ // Create mock service so the command can be executed.
+ auto bubble_factory_registry =
+ std::make_unique<user_education::HelpBubbleFactoryRegistry>();
+ user_education::TutorialRegistry registry;
+ MockTutorialService service(&registry, bubble_factory_registry.get());
+ command_handler_->SetTutorialService(&service);
+
+ // If the browsers Tab Strip does not support tutorials, dont run the command.
+ command_handler_->SetBrowserSupportsTabGroups(false);
+ EXPECT_FALSE(CanExecuteCommand(Command::kStartTabGroupTutorial));
+
+ // If the browser supports tab groups and has a tutorial service it should
+ // allow running commands.
+ command_handler_->SetBrowserSupportsTabGroups(true);
+ EXPECT_TRUE(CanExecuteCommand(Command::kStartTabGroupTutorial));
+
+ // The StartTabGroupTutorial command should start the tab group tutorial. if
+ // there are no tab groups in the tabstrip
+ command_handler_->SetBrowserHasTabGroups(false);
+ ClickInfoPtr info = ClickInfo::New();
+ EXPECT_CALL(service, StartTutorial(kTabGroupTutorialId, kTestContext1,
+ testing::_, testing::_))
+ .WillOnce(testing::Return(true));
+ EXPECT_CALL(service, LogStartedFromWhatsNewPage(kTabGroupTutorialId, true));
+ EXPECT_TRUE(ExecuteCommand(Command::kStartTabGroupTutorial, std::move(info)));
+
+ // The StartTabGroupTutorial command should start the "existing tab groups"
+ // tab group tutorial. if there are tab groups in the tabstrip
+ {
+ command_handler_->SetBrowserHasTabGroups(true);
+ ClickInfoPtr info = ClickInfo::New();
+ EXPECT_CALL(service, StartTutorial(kTabGroupWithExistingGroupTutorialId,
+ kTestContext1, testing::_, testing::_))
+ .WillOnce(testing::Return(true));
+ EXPECT_CALL(service, LogStartedFromWhatsNewPage(
+ kTabGroupWithExistingGroupTutorialId, true));
+ EXPECT_TRUE(
+ ExecuteCommand(Command::kStartTabGroupTutorial, std::move(info)));
+ }
+}
+
+TEST_F(BrowserCommandHandlerTest, OpenPasswordManagerCommand) {
+ // By default, opening the password manager is allowed.
+ EXPECT_TRUE(CanExecuteCommand(Command::kOpenPasswordManager));
+ ClickInfoPtr info = ClickInfo::New();
+ info->middle_button = true;
+ info->meta_key = true;
+ // The OpenPassswordManager command opens a new settings window with the
+ // password manager and the correct disposition.
+ EXPECT_CALL(*command_handler_,
+ NavigateToURL(
+ GURL(chrome::GetSettingsUrl(chrome::kPasswordManagerSubPage)),
+ DispositionFromClick(*info)));
+ EXPECT_TRUE(ExecuteCommand(Command::kOpenPasswordManager, std::move(info)));
+}
diff --git a/chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc b/chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc
index 0dea7c6baf8..61802046753 100644
--- a/chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc
+++ b/chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc
@@ -241,14 +241,14 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
//
// If it fails, the JavaScript promise is rejected. If it succeeds, the
// JavaScript promise is not resolved, because we close the tab anyways.
- void HandleLaunchAlternativeBrowserAndCloseTab(const base::ListValue* args);
+ void HandleLaunchAlternativeBrowserAndCloseTab(const base::Value::List& args);
void OnLaunchFinished(base::TimeTicks start,
std::string callback_id,
bool success);
// Navigates to the New Tab Page.
- void HandleGotoNewTabPage(const base::ListValue* args);
+ void HandleGotoNewTabPage(const base::Value::List& args);
// Resolves a promise with a JSON object with all the LBS rulesets, formatted
// like this:
@@ -261,7 +261,7 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
// "ieem": { "sitelist": [...], "greylist": [...] },
// "external": { "sitelist": [...], "greylist": [...] }
// }
- void HandleGetAllRulesets(const base::ListValue* args);
+ void HandleGetAllRulesets(const base::Value::List& args);
// Resolves a promise with a JSON object describing the decision for a URL
// (stay/go) + reason. The result is formatted like this:
@@ -271,7 +271,7 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
// "reason": ("globally_disabled"|"protocol"|"sitelist"|...),
// "matching_rule": (string|undefined)
// }
- void HandleGetDecision(const base::ListValue* args);
+ void HandleGetDecision(const base::Value::List& args);
// Resolves a promise with the time of the last policy fetch and next policy
// fetch, as JS timestamps.
@@ -280,7 +280,7 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
// "last_fetch": 123456789,
// "next_fetch": 234567890
// }
- void HandleGetTimestamps(const base::ListValue* args);
+ void HandleGetTimestamps(const base::Value::List& args);
// Resolves a promise with the configured sitelist XML download URLs. The keys
// are the name of the pref associated with the sitelist.
@@ -292,14 +292,14 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
// "external_greylist_url": null
// }
// }
- void HandleGetRulesetSources(const base::ListValue* args);
+ void HandleGetRulesetSources(const base::Value::List& args);
// Immediately re-download and apply XML rules.
- void HandleRefreshXml(const base::ListValue* args);
+ void HandleRefreshXml(const base::Value::List& args);
// Resolves a promise with the boolean value describing whether the feature
// is enabled or not which is configured by BrowserSwitcherEnabled key
- void HandleIsBrowserSwitchEnabled(const base::ListValue* args);
+ void HandleIsBrowserSwitchEnabled(const base::Value::List& args);
base::CallbackListSubscription prefs_subscription_;
@@ -313,35 +313,35 @@ BrowserSwitchHandler::BrowserSwitchHandler() {}
BrowserSwitchHandler::~BrowserSwitchHandler() = default;
void BrowserSwitchHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"launchAlternativeBrowserAndCloseTab",
base::BindRepeating(
&BrowserSwitchHandler::HandleLaunchAlternativeBrowserAndCloseTab,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"gotoNewTabPage",
base::BindRepeating(&BrowserSwitchHandler::HandleGotoNewTabPage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getAllRulesets",
base::BindRepeating(&BrowserSwitchHandler::HandleGetAllRulesets,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getDecision",
base::BindRepeating(&BrowserSwitchHandler::HandleGetDecision,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getTimestamps",
base::BindRepeating(&BrowserSwitchHandler::HandleGetTimestamps,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getRulesetSources",
base::BindRepeating(&BrowserSwitchHandler::HandleGetRulesetSources,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"refreshXml", base::BindRepeating(&BrowserSwitchHandler::HandleRefreshXml,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"isBrowserSwitcherEnabled",
base::BindRepeating(&BrowserSwitchHandler::HandleIsBrowserSwitchEnabled,
base::Unretained(this)));
@@ -378,12 +378,11 @@ void BrowserSwitchHandler::SendDataChangedEvent() {
}
void BrowserSwitchHandler::HandleLaunchAlternativeBrowserAndCloseTab(
- const base::ListValue* args) {
- DCHECK(args);
+ const base::Value::List& args) {
AllowJavascript();
- std::string callback_id = args->GetListDeprecated()[0].GetString();
- std::string url_spec = args->GetListDeprecated()[1].GetString();
+ std::string callback_id = args[0].GetString();
+ std::string url_spec = args[1].GetString();
GURL url(url_spec);
auto* service = GetBrowserSwitcherService(web_ui());
@@ -392,7 +391,7 @@ void BrowserSwitchHandler::HandleLaunchAlternativeBrowserAndCloseTab(
// This URL shouldn't open in an alternative browser. Abort launch, because
// something weird is going on (e.g. race condition from a new sitelist
// being loaded).
- RejectJavascriptCallback(args->GetListDeprecated()[0], base::Value());
+ RejectJavascriptCallback(args[0], base::Value());
return;
}
@@ -427,49 +426,47 @@ void BrowserSwitchHandler::OnLaunchFinished(base::TimeTicks start,
}
}
-void BrowserSwitchHandler::HandleGotoNewTabPage(const base::ListValue* args) {
+void BrowserSwitchHandler::HandleGotoNewTabPage(const base::Value::List& args) {
GotoNewTabPage(web_ui()->GetWebContents());
}
-void BrowserSwitchHandler::HandleGetAllRulesets(const base::ListValue* args) {
- DCHECK(args);
+void BrowserSwitchHandler::HandleGetAllRulesets(const base::Value::List& args) {
AllowJavascript();
auto* service = GetBrowserSwitcherService(web_ui());
- base::Value retval(base::Value::Type::DICTIONARY);
+ base::Value::Dict retval;
auto gpo_dict = RuleSetToDict(service->prefs().GetRules());
- retval.SetKey("gpo", std::move(gpo_dict));
+ retval.Set("gpo", std::move(gpo_dict));
auto ieem_dict = RuleSetToDict(*service->sitelist()->GetIeemSitelist());
- retval.SetKey("ieem", std::move(ieem_dict));
+ retval.Set("ieem", std::move(ieem_dict));
auto external_sitelist_dict =
RuleSetToDict(*service->sitelist()->GetExternalSitelist());
- retval.SetKey("external_sitelist", std::move(external_sitelist_dict));
+ retval.Set("external_sitelist", std::move(external_sitelist_dict));
auto external_greylist_dict =
RuleSetToDict(*service->sitelist()->GetExternalGreylist());
- retval.SetKey("external_greylist", std::move(external_greylist_dict));
+ retval.Set("external_greylist", std::move(external_greylist_dict));
- ResolveJavascriptCallback(args->GetListDeprecated()[0], retval);
+ ResolveJavascriptCallback(args[0], retval);
}
-void BrowserSwitchHandler::HandleGetDecision(const base::ListValue* args) {
- DCHECK(args);
+void BrowserSwitchHandler::HandleGetDecision(const base::Value::List& args) {
AllowJavascript();
- GURL url = GURL(args->GetListDeprecated()[1].GetString());
+ GURL url = GURL(args[1].GetString());
if (!url.is_valid()) {
- RejectJavascriptCallback(args->GetListDeprecated()[0], base::Value());
+ RejectJavascriptCallback(args[0], base::Value());
return;
}
auto* service = GetBrowserSwitcherService(web_ui());
browser_switcher::Decision decision = service->sitelist()->GetDecision(url);
- base::DictionaryValue retval;
+ base::Value::Dict retval;
base::StringPiece action_name =
(decision.action == browser_switcher::kStay) ? "stay" : "go";
- retval.Set("action", std::make_unique<base::Value>(action_name));
+ retval.Set("action", action_name);
base::StringPiece reason_name;
switch (decision.reason) {
@@ -489,72 +486,65 @@ void BrowserSwitchHandler::HandleGetDecision(const base::ListValue* args) {
reason_name = "default";
break;
}
- retval.Set("reason", std::make_unique<base::Value>(reason_name));
+ retval.Set("reason", reason_name);
if (decision.matching_rule) {
- retval.Set("matching_rule", std::make_unique<base::Value>(
- decision.matching_rule->ToString()));
+ retval.Set("matching_rule", decision.matching_rule->ToString());
}
- ResolveJavascriptCallback(args->GetListDeprecated()[0], retval);
+ ResolveJavascriptCallback(args[0], retval);
}
-void BrowserSwitchHandler::HandleGetTimestamps(const base::ListValue* args) {
- DCHECK(args);
+void BrowserSwitchHandler::HandleGetTimestamps(const base::Value::List& args) {
AllowJavascript();
auto* service = GetBrowserSwitcherService(web_ui());
auto* downloader = service->sitelist_downloader();
if (!downloader) {
- ResolveJavascriptCallback(args->GetListDeprecated()[0], base::Value());
+ ResolveJavascriptCallback(args[0], base::Value());
return;
}
- base::DictionaryValue retval;
- retval.Set("last_fetch", std::make_unique<base::Value>(
- downloader->last_refresh_time().ToJsTime()));
- retval.Set("next_fetch", std::make_unique<base::Value>(
- downloader->next_refresh_time().ToJsTime()));
+ base::Value::Dict retval;
+ retval.Set("last_fetch", downloader->last_refresh_time().ToJsTime());
+ retval.Set("next_fetch", downloader->next_refresh_time().ToJsTime());
- ResolveJavascriptCallback(args->GetListDeprecated()[0], retval);
+ ResolveJavascriptCallback(args[0], retval);
}
void BrowserSwitchHandler::HandleGetRulesetSources(
- const base::ListValue* args) {
- DCHECK(args);
+ const base::Value::List& args) {
AllowJavascript();
auto* service = GetBrowserSwitcherService(web_ui());
std::vector<browser_switcher::RulesetSource> sources =
service->GetRulesetSources();
- base::DictionaryValue retval;
+ base::Value::Dict retval;
for (const auto& source : sources) {
base::Value val;
if (source.url.is_valid())
val = base::Value(source.url.spec());
- // |pref_name| is something like "browser_switcher.blah", so this will be in
- // a nested object.
- retval.SetKey(source.pref_name, std::move(val));
+ // |pref_name| is something like "browser_switcher.blah"; however path
+ // expansion is not expected on it as the JavaScript expects to see
+ // "browser_switcher.blah" as a key in the object, not a nested hierarchy.
+ retval.Set(source.pref_name, std::move(val));
}
- ResolveJavascriptCallback(args->GetListDeprecated()[0], retval);
+ ResolveJavascriptCallback(args[0], retval);
}
-void BrowserSwitchHandler::HandleRefreshXml(const base::ListValue* args) {
- DCHECK(args);
+void BrowserSwitchHandler::HandleRefreshXml(const base::Value::List& args) {
auto* service = GetBrowserSwitcherService(web_ui());
service->StartDownload(base::TimeDelta());
}
void BrowserSwitchHandler::HandleIsBrowserSwitchEnabled(
- const base::ListValue* args) {
- DCHECK(args);
+ const base::Value::List& args) {
AllowJavascript();
auto* service = GetBrowserSwitcherService(web_ui());
- ResolveJavascriptCallback(args->GetListDeprecated()[0],
- base::Value(service->prefs().IsEnabled()));
+ ResolveJavascriptCallback(args[0], base::Value(service->prefs().IsEnabled()));
}
BrowserSwitchUI::BrowserSwitchUI(content::WebUI* web_ui)
diff --git a/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.cc
index e1cf322f036..23de99f6d8f 100644
--- a/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.cc
@@ -55,6 +55,7 @@ void BrowsingTopicsInternalsPageHandler::GetBrowsingTopicsConfiguration(
}
void BrowsingTopicsInternalsPageHandler::GetBrowsingTopicsState(
+ bool calculate_now,
browsing_topics::mojom::PageHandler::GetBrowsingTopicsStateCallback
callback) {
browsing_topics::BrowsingTopicsService* browsing_topics_service =
@@ -69,8 +70,8 @@ void BrowsingTopicsInternalsPageHandler::GetBrowsingTopicsState(
return;
}
- std::move(callback).Run(
- browsing_topics_service->GetBrowsingTopicsStateForWebUi());
+ browsing_topics_service->GetBrowsingTopicsStateForWebUi(calculate_now,
+ std::move(callback));
}
void BrowsingTopicsInternalsPageHandler::GetModelInfo(
diff --git a/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.h b/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.h
index 376d2a03b4c..9368e971657 100644
--- a/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/browsing_topics/browsing_topics_internals_page_handler.h
@@ -35,6 +35,7 @@ class BrowsingTopicsInternalsPageHandler
browsing_topics::mojom::PageHandler::
GetBrowsingTopicsConfigurationCallback callback) override;
void GetBrowsingTopicsState(
+ bool calculate_now,
browsing_topics::mojom::PageHandler::GetBrowsingTopicsStateCallback
callback) override;
void GetModelInfo(browsing_topics::mojom::PageHandler::GetModelInfoCallback
diff --git a/chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc
index 3ffe3003f6d..d4854e0d0a7 100644
--- a/chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc
@@ -81,7 +81,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CERTIFICATE_MANAGER_CONFIRM_PASSWORD},
{"certificateImportErrorFormat",
IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_ERROR_FORMAT},
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
{"certificateProvisioningListHeader",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_LIST_HEADER},
{"certificateProvisioningRefresh",
@@ -103,7 +103,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
{"certificateProvisioningLastUnsuccessfulStatus",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_LAST_UNSUCCESSFUL_STATUS},
{"certificateProvisioningPublicKey", IDS_CERT_DETAILS_SUBJECT_KEY},
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS)
// For A11y.
{"menu", IDS_MENU},
};
diff --git a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
index b5911204ba3..85ce27377ec 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
@@ -11,93 +11,113 @@
#include "base/containers/span.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_common.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_scheduler_user_service.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_worker.h"
-#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.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/common/net/x509_certificate_model.h"
#include "chrome/common/net/x509_certificate_model_nss.h"
#include "chrome/grit/generated_resources.h"
#include "components/policy/core/browser/cloud/message_util.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
-#include "components/user_manager/user.h"
-#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
-namespace chromeos {
-namespace cert_provisioning {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/lacros/lacros_service.h"
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/crosapi/cert_provisioning_ash.h"
+#include "chrome/browser/ash/crosapi/crosapi_ash.h"
+#include "chrome/browser/ash/crosapi/crosapi_manager.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#endif // #if BUILDFLAG(IS_CHROMEOS_ASH)
+
+using crosapi::mojom::CertProvisioningProcessState;
+
+namespace chromeos::cert_provisioning {
namespace {
-// Returns the per-user CertProvisioningScheduler for |user_profile|, if it has
-// any.
-ash::cert_provisioning::CertProvisioningScheduler*
-GetCertProvisioningSchedulerForUser(Profile* user_profile) {
- ash::cert_provisioning::CertProvisioningSchedulerUserService* user_service =
- ash::cert_provisioning::CertProvisioningSchedulerUserServiceFactory::
- GetForProfile(user_profile);
- if (!user_service)
+crosapi::mojom::CertProvisioning* GetCertProvisioningInterface(
+ Profile* profile) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ chromeos::LacrosService* service = chromeos::LacrosService::Get();
+ if (!profile->IsMainProfile() || !service ||
+ !service->IsAvailable<crosapi::mojom::CertProvisioning>()) {
return nullptr;
- return user_service->scheduler();
-}
+ }
+ return service->GetRemote<crosapi::mojom::CertProvisioning>().get();
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
-// Returns the per-device CertProvisioningScheduler, if it exists. No
-// affiliation check is done here.
-ash::cert_provisioning::CertProvisioningScheduler*
-GetCertProvisioningSchedulerForDevice() {
- policy::BrowserPolicyConnectorAsh* connector =
- g_browser_process->platform_part()->browser_policy_connector_ash();
- return connector->GetDeviceCertProvisioningScheduler();
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ if (!ash::ProfileHelper::IsPrimaryProfile(profile)) {
+ return nullptr;
+ }
+ return crosapi::CrosapiManager::Get()->crosapi_ash()->cert_provisioning_ash();
+#endif // #if BUILDFLAG(IS_CHROMEOS_ASH)
}
// Returns localized representation for the state of a certificate provisioning
// process.
-std::u16string GetProvisioningProcessStatus(
- ash::cert_provisioning::CertProvisioningWorkerState state) {
- using CertProvisioningWorkerState =
- ash::cert_provisioning::CertProvisioningWorkerState;
+std::u16string StateToText(CertProvisioningProcessState state) {
switch (state) {
- case CertProvisioningWorkerState ::kInitState:
+ case CertProvisioningProcessState ::kInitState:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR);
- case CertProvisioningWorkerState ::kKeypairGenerated:
+ case CertProvisioningProcessState ::kKeypairGenerated:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING);
- case CertProvisioningWorkerState::kStartCsrResponseReceived:
+ case CertProvisioningProcessState::kStartCsrResponseReceived:
// Intentional fall-through.
- case CertProvisioningWorkerState::kVaChallengeFinished:
+ case CertProvisioningProcessState::kVaChallengeFinished:
// Intentional fall-through.
- case CertProvisioningWorkerState::kKeyRegistered:
+ case CertProvisioningProcessState::kKeyRegistered:
// Intentional fall-through.
- case CertProvisioningWorkerState::kKeypairMarked:
+ case CertProvisioningProcessState::kKeypairMarked:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR);
- case CertProvisioningWorkerState::kSignCsrFinished:
+ case CertProvisioningProcessState::kSignCsrFinished:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING);
- case CertProvisioningWorkerState::kFinishCsrResponseReceived:
+ case CertProvisioningProcessState::kFinishCsrResponseReceived:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_WAITING_FOR_CA);
- case CertProvisioningWorkerState::kSucceeded:
+ case CertProvisioningProcessState::kSucceeded:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_SUCCESS);
- case CertProvisioningWorkerState::kFailed:
+ case CertProvisioningProcessState::kFailed:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE);
- case CertProvisioningWorkerState::kInconsistentDataError:
+ case CertProvisioningProcessState::kInconsistentDataError:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING);
- case CertProvisioningWorkerState::kCanceled:
+ case CertProvisioningProcessState::kCanceled:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_CANCELED);
}
NOTREACHED();
}
+// Returns the status message of the process.
+// The status message is expanded by the failure message if the process failed
+// and the error message is non-empty.
+std::u16string MakeStatusMessage(
+ bool did_fail,
+ CertProvisioningProcessState state,
+ const absl::optional<std::string>& failure_message) {
+ if (!did_fail) {
+ return StateToText(state);
+ }
+ std::u16string status_message =
+ StateToText(CertProvisioningProcessState::kFailed);
+ if (failure_message.has_value()) {
+ status_message += base::UTF8ToUTF16(": " + failure_message.value());
+ }
+ return status_message;
+}
+
// Returns a localized representation of the last update time as a delay (e.g.
// "5 minutes ago".
std::u16string GetTimeSinceLastUpdate(base::Time last_update_time) {
@@ -110,70 +130,19 @@ std::u16string GetTimeSinceLastUpdate(base::Time last_update_time) {
}
std::u16string GetMessageFromBackendError(
- const absl::optional<ash::cert_provisioning::BackendServerError>&
- call_info) {
- if (!call_info.has_value())
+ const crosapi::mojom::CertProvisioningBackendServerErrorPtr& call_info) {
+ if (!call_info)
return std::u16string();
std::u16string time_u16 =
base::UTF8ToUTF16(base::TimeFormatHTTP(call_info->time));
+ // FormatDeviceManagementStatus will return "Unknown error" if the value after
+ // cast is not actually an existing enum value.
+ auto status =
+ static_cast<policy::DeviceManagementStatus>(call_info->status_code);
return l10n_util::GetStringFUTF16(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_DMSERVER_ERROR_MESSAGE,
- policy::FormatDeviceManagementStatus(call_info->status), time_u16);
-}
-
-base::Value CreateProvisioningProcessEntry(
- const std::string& cert_profile_id,
- const std::string& cert_profile_name,
- bool is_device_wide,
- ash::cert_provisioning::CertProvisioningWorkerState state,
- base::Time time_since_last_update,
- const std::string& public_key_spki_der,
- const absl::optional<ash::cert_provisioning::BackendServerError>&
- last_unsuccessful_attempt) {
- base::Value entry(base::Value::Type::DICTIONARY);
- entry.SetStringKey("certProfileId", cert_profile_id);
- entry.SetStringKey("certProfileName", cert_profile_name);
- entry.SetBoolKey("isDeviceWide", is_device_wide);
- entry.SetStringKey("status", GetProvisioningProcessStatus(state));
- entry.SetIntKey("stateId", static_cast<int>(state));
- entry.SetStringKey("timeSinceLastUpdate",
- GetTimeSinceLastUpdate(time_since_last_update));
- entry.SetStringKey("lastUnsuccessfulMessage",
- GetMessageFromBackendError(last_unsuccessful_attempt));
-
- auto spki_der_bytes = base::as_bytes(base::make_span(public_key_spki_der));
- entry.SetStringKey(
- "publicKey",
- x509_certificate_model::ProcessRawSubjectPublicKeyInfo(spki_der_bytes));
-
- return entry;
-}
-
-// Collects information about certificate provisioning processes from
-// |cert_provisioning_scheduler| and appends them to |list_to_append_to|.
-void CollectProvisioningProcesses(
- base::Value* list_to_append_to,
- ash::cert_provisioning::CertProvisioningScheduler*
- cert_provisioning_scheduler,
- bool is_device_wide) {
- for (const auto& worker_entry : cert_provisioning_scheduler->GetWorkers()) {
- ash::cert_provisioning::CertProvisioningWorker* worker =
- worker_entry.second.get();
- list_to_append_to->Append(CreateProvisioningProcessEntry(
- worker_entry.first, worker->GetCertProfile().name, is_device_wide,
- worker->GetState(), worker->GetLastUpdateTime(), worker->GetPublicKey(),
- worker->GetLastBackendServerError()));
- }
- for (const auto& failed_worker_entry :
- cert_provisioning_scheduler->GetFailedCertProfileIds()) {
- const ash::cert_provisioning::FailedWorkerInfo& worker =
- failed_worker_entry.second;
- list_to_append_to->Append(CreateProvisioningProcessEntry(
- failed_worker_entry.first, worker.cert_profile_name, is_device_wide,
- ash::cert_provisioning::CertProvisioningWorkerState::kFailed,
- worker.last_update_time, worker.public_key, absl::nullopt));
- }
+ policy::FormatDeviceManagementStatus(status), time_u16);
}
} // namespace
@@ -182,44 +151,38 @@ void CollectProvisioningProcesses(
std::unique_ptr<CertificateProvisioningUiHandler>
CertificateProvisioningUiHandler::CreateForProfile(Profile* user_profile) {
return std::make_unique<CertificateProvisioningUiHandler>(
- user_profile, GetCertProvisioningSchedulerForUser(user_profile),
- GetCertProvisioningSchedulerForDevice());
+ GetCertProvisioningInterface(user_profile));
}
CertificateProvisioningUiHandler::CertificateProvisioningUiHandler(
- Profile* user_profile,
- ash::cert_provisioning::CertProvisioningScheduler* scheduler_for_user,
- ash::cert_provisioning::CertProvisioningScheduler* scheduler_for_device)
- : scheduler_for_user_(scheduler_for_user),
- scheduler_for_device_(ShouldUseDeviceWideProcesses(user_profile)
- ? scheduler_for_device
- : nullptr) {
- if (scheduler_for_user_)
- observed_schedulers_.AddObservation(scheduler_for_user_);
- if (scheduler_for_device_)
- observed_schedulers_.AddObservation(scheduler_for_device_);
+ crosapi::mojom::CertProvisioning* cert_provisioning_interface)
+ : cert_provisioning_interface_(cert_provisioning_interface) {
+ if (cert_provisioning_interface_) {
+ cert_provisioning_interface->AddObserver(
+ receiver_.BindNewPipeAndPassRemote());
+ }
}
CertificateProvisioningUiHandler::~CertificateProvisioningUiHandler() = default;
void CertificateProvisioningUiHandler::RegisterMessages() {
// Passing base::Unretained(this) to
- // web_ui()->RegisterDeprecatedMessageCallback is fine because in chrome Web
+ // web_ui()->RegisterMessageCallback is fine because in chrome Web
// UI, web_ui() has acquired ownership of |this| and maintains the life time
// of |this| accordingly.
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"refreshCertificateProvisioningProcessses",
base::BindRepeating(&CertificateProvisioningUiHandler::
HandleRefreshCertificateProvisioningProcesses,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"triggerCertificateProvisioningProcessUpdate",
base::BindRepeating(&CertificateProvisioningUiHandler::
HandleTriggerCertificateProvisioningProcessUpdate,
base::Unretained(this)));
}
-void CertificateProvisioningUiHandler::OnVisibleStateChanged() {
+void CertificateProvisioningUiHandler::OnStateChanged() {
// If Javascript is not allowed yet, the UI will request a refresh during its
// first message to the handler.
if (!IsJavascriptAllowed())
@@ -236,61 +199,62 @@ CertificateProvisioningUiHandler::ReadAndResetUiRefreshCountForTesting() {
}
void CertificateProvisioningUiHandler::
- HandleRefreshCertificateProvisioningProcesses(const base::ListValue* args) {
- CHECK_EQ(0U, args->GetListDeprecated().size());
+ HandleRefreshCertificateProvisioningProcesses(
+ const base::Value::List& args) {
+ CHECK_EQ(0U, args.size());
AllowJavascript();
RefreshCertificateProvisioningProcesses();
}
void CertificateProvisioningUiHandler::
HandleTriggerCertificateProvisioningProcessUpdate(
- const base::ListValue* args) {
- CHECK_EQ(2U, args->GetListDeprecated().size());
- if (!args->is_list())
- return;
- const base::Value& cert_profile_id = args->GetListDeprecated()[0];
- if (!cert_profile_id.is_string())
- return;
- const base::Value& device_wide = args->GetListDeprecated()[1];
- if (!device_wide.is_bool())
- return;
-
- if (device_wide.GetBool() && !scheduler_for_device_)
- return;
-
- ash::cert_provisioning::CertProvisioningScheduler* scheduler =
- device_wide.GetBool() ? scheduler_for_device_ : scheduler_for_user_;
- if (!scheduler)
+ const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
+ const base::Value& cert_profile_id = args[0];
+ if (!cert_profile_id.is_string()) {
return;
+ }
- scheduler->UpdateOneCert(cert_profile_id.GetString());
+ if (cert_provisioning_interface_) {
+ cert_provisioning_interface_->UpdateOneProcess(cert_profile_id.GetString());
+ }
}
void CertificateProvisioningUiHandler::
RefreshCertificateProvisioningProcesses() {
- base::ListValue all_processes;
- if (scheduler_for_user_) {
- CollectProvisioningProcesses(&all_processes, scheduler_for_user_,
- /*is_device_wide=*/false);
+ if (cert_provisioning_interface_) {
+ cert_provisioning_interface_->GetStatus(
+ base::BindOnce(&CertificateProvisioningUiHandler::GotStatus,
+ weak_ptr_factory_.GetWeakPtr()));
}
+}
- if (scheduler_for_device_) {
- CollectProvisioningProcesses(&all_processes, scheduler_for_device_,
- /*is_device_wide=*/true);
+void CertificateProvisioningUiHandler::GotStatus(
+ std::vector<crosapi::mojom::CertProvisioningProcessStatusPtr> status) {
+ base::Value::List all_processes;
+
+ for (auto& process : status) {
+ base::Value::Dict entry;
+ entry.Set("certProfileId", std::move(process->cert_profile_id));
+ entry.Set("certProfileName", std::move(process->cert_profile_name));
+ entry.Set("isDeviceWide", process->is_device_wide);
+ entry.Set("timeSinceLastUpdate",
+ GetTimeSinceLastUpdate(process->last_update_time));
+ entry.Set("lastUnsuccessfulMessage",
+ GetMessageFromBackendError(process->last_backend_server_error));
+ entry.Set("stateId", static_cast<int>(process->state));
+ entry.Set("status", MakeStatusMessage(process->did_fail, process->state,
+ process->failure_message));
+ entry.Set("publicKey",
+ x509_certificate_model::ProcessRawSubjectPublicKeyInfo(
+ process->public_key));
+
+ all_processes.Append(std::move(entry));
}
++ui_refresh_count_for_testing_;
FireWebUIListener("certificate-provisioning-processes-changed",
- std::move(all_processes));
-}
-
-// static
-bool CertificateProvisioningUiHandler::ShouldUseDeviceWideProcesses(
- Profile* user_profile) {
- const user_manager::User* user =
- ash::ProfileHelper::Get()->GetUserByProfile(user_profile);
- return user && user->IsAffiliated();
+ all_processes);
}
-} // namespace cert_provisioning
-} // namespace chromeos
+} // namespace chromeos::cert_provisioning
diff --git a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
index 756acb3e6ee..958f56a1558 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
@@ -7,11 +7,12 @@
#include <utility>
+#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_multi_source_observation.h"
#include "base/values.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_scheduler.h"
+#include "chromeos/crosapi/mojom/cert_provisioning.mojom.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "mojo/public/cpp/bindings/receiver.h"
class Profile;
@@ -20,28 +21,22 @@ namespace cert_provisioning {
class CertificateProvisioningUiHandler
: public content::WebUIMessageHandler,
- public ash::cert_provisioning::CertProvisioningSchedulerObserver {
+ public crosapi::mojom::CertProvisioningObserver {
public:
- // Creates a CertificateProvisioningUiHandler for |user_profile|, which uses:
- // (*) The CertProvisioningScheduler associated with |user_profile|, if any.
- // (*) The device-wide CertProvisioningScheduler, if it exists and the
- // |user_profile| is affiliated.
+ // Creates a CertificateProvisioningUiHandler for |profile|.
+ // If the |profile| should be able to see and control cert provisioning
+ // processes, CertificateProvisioningUiHandler will be created with a correct
+ // |cert_provisioning_interface|. Otherwise |cert_provisioning_interface| will
+ // be nullptr and the related UI elements will show and do nothing.
static std::unique_ptr<CertificateProvisioningUiHandler> CreateForProfile(
- Profile* user_profile);
-
- // The constructed CertificateProvisioningUiHandler will use
- // |scheduler_for_user| to list certificate provisioning processes that belong
- // to the user, and |scheduler_for_device|, to list certificatge provisioning
- // processes that are device-wide. Both can be nullptr. Note: Intended to be
- // called directly for testing. Use CreateForProfile in production code
- // instead.
- // |user_profile| is used to determine if the current user is affiliated and
- // decide if |scheduler_for_device| should be used based on that. This pattern
- // is useful for unit-testing the affiliation detection logic.
- CertificateProvisioningUiHandler(
- Profile* user_profile,
- ash::cert_provisioning::CertProvisioningScheduler* scheduler_for_user,
- ash::cert_provisioning::CertProvisioningScheduler* scheduler_for_device);
+ Profile* profile);
+
+ // |cert_provisioning_interface| is the mojo interface to communicate with the
+ // cert provisioning component, can be nullptr.
+ // The constructor is public for testing, prefer using CreateForProfile when
+ // possible.
+ explicit CertificateProvisioningUiHandler(
+ crosapi::mojom::CertProvisioning* cert_provisioning_interface);
CertificateProvisioningUiHandler(
const CertificateProvisioningUiHandler& other) = delete;
@@ -50,11 +45,11 @@ class CertificateProvisioningUiHandler
~CertificateProvisioningUiHandler() override;
- // content::WebUIMessageHandler.
+ // content::WebUIMessageHandler
void RegisterMessages() override;
- // CertProvisioningSchedulerObserver:
- void OnVisibleStateChanged() override;
+ // crosapi::mojom::CertProvisioningObserver
+ void OnStateChanged() override;
// For testing: Reads the count of UI refreshes sent to the WebUI (since
// instantiation or the last call to this function) and resets it to 0.
@@ -65,7 +60,7 @@ class CertificateProvisioningUiHandler
// the UI when it loads.
// |args| is expected to be empty.
void HandleRefreshCertificateProvisioningProcesses(
- const base::ListValue* args);
+ const base::Value::List& args);
// Trigger an update / refresh on a certificate provisioning process.
// |args| is expected to contain two arguments:
@@ -74,37 +69,25 @@ class CertificateProvisioningUiHandler
// index 1 is a boolean specifying whether the process is a user-specific
// (false) or a device-wide (true) certificate provisioning process.
void HandleTriggerCertificateProvisioningProcessUpdate(
- const base::ListValue* args);
+ const base::Value::List& args);
// Send the list of certificate provisioning processes to the UI.
void RefreshCertificateProvisioningProcesses();
- // Called when the |hold_back_updates_timer_| expires.
- void OnHoldBackUpdatesTimerExpired();
-
- // Returns true if device-wide certificate provisioning processes should be
- // displayed, i.e. if the |user_profile| is affiliated.
- static bool ShouldUseDeviceWideProcesses(Profile* user_profile);
+ // Called when the status of cert provisioning processes is received.
+ void GotStatus(
+ std::vector<crosapi::mojom::CertProvisioningProcessStatusPtr> status);
- // The user-specific CertProvisioningScheduler. Can be nullptr.
- // Unowned.
- ash::cert_provisioning::CertProvisioningScheduler* const scheduler_for_user_;
-
- // The device-wide CertProvisioningScheduler. Can be nullptr.
- // Unowned.
- ash::cert_provisioning::CertProvisioningScheduler* const
- scheduler_for_device_;
+ // The interface to communicate with the cert provisioning component.
+ // Can be null (e.g. for non-primary / non-main profiles), in which case this
+ // part of the UI should show and do nothing.
+ const raw_ptr<crosapi::mojom::CertProvisioning> cert_provisioning_interface_;
+ // Receives mojo messages about cert provisioning updates.
+ mojo::Receiver<crosapi::mojom::CertProvisioningObserver> receiver_{this};
// Keeps track of the count of UI refreshes sent to the WebUI.
unsigned int ui_refresh_count_for_testing_ = 0;
- // Keeps track of the CertProvisioningSchedulers that this UI handler
- // observes.
- base::ScopedMultiSourceObservation<
- ash::cert_provisioning::CertProvisioningScheduler,
- ash::cert_provisioning::CertProvisioningSchedulerObserver>
- observed_schedulers_{this};
-
base::WeakPtrFactory<CertificateProvisioningUiHandler> weak_ptr_factory_{
this};
};
diff --git a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc
index 027e8554af0..e17f35942e1 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc
@@ -12,21 +12,21 @@
#include "base/base64.h"
#include "base/bind.h"
+#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/test/gmock_callback_support.h"
#include "base/test/values_test_util.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_common.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_scheduler.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_test_helpers.h"
-#include "chrome/browser/ash/cert_provisioning/cert_provisioning_worker.h"
-#include "chrome/browser/ash/cert_provisioning/mock_cert_provisioning_scheduler.h"
-#include "chrome/browser/ash/cert_provisioning/mock_cert_provisioning_worker.h"
#include "chrome/grit/generated_resources.h"
+#include "chrome/test/base/testing_profile.h"
+#include "chromeos/crosapi/mojom/cert_provisioning.mojom.h"
+#include "components/policy/core/browser/cloud/message_util.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "content/public/test/test_web_ui_listener_observer.h"
#include "crypto/nss_util.h"
-#include "testing/gmock/include/gmock/gmock.h"
+#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/l10n/l10n_util.h"
@@ -36,11 +36,9 @@ namespace cert_provisioning {
namespace {
-using ::testing::Return;
-using ::testing::ReturnPointee;
-using ::testing::ReturnRef;
-using ::testing::SaveArg;
-using ::testing::StrictMock;
+using ::base::test::RunOnceCallback;
+using ::testing::ElementsAre;
+using ::testing::Invoke;
using ::testing::UnorderedElementsAre;
// Extracted from a X.509 certificate using the command:
@@ -81,27 +79,11 @@ BA 48 53 4A E2 1C 42 24 EB E5 CD 46 E0 4E 9B 2B
01 00 01)";
// Test values for creating CertProfile for MockCertProvisioningWorker.
-constexpr char kCertProfileVersion[] = "cert_profile_version_1";
-constexpr base::TimeDelta kCertProfileRenewalPeriod = base::Seconds(0);
constexpr char kDeviceCertProfileId[] = "device_cert_profile_1";
constexpr char kDeviceCertProfileName[] = "Device Certificate Profile 1";
constexpr char kUserCertProfileId[] = "user_cert_profile_1";
constexpr char kUserCertProfileName[] = "User Certificate Profile 1";
-void SetupMockCertProvisioningWorker(
- ash::cert_provisioning::MockCertProvisioningWorker* worker,
- ash::cert_provisioning::CertProvisioningWorkerState state,
- const std::string* public_key,
- ash::cert_provisioning::CertProfile& cert_profile,
- absl::optional<ash::cert_provisioning::BackendServerError>& backend_error) {
- EXPECT_CALL(*worker, GetState).WillRepeatedly(Return(state));
- EXPECT_CALL(*worker, GetLastUpdateTime).WillRepeatedly(Return(base::Time()));
- EXPECT_CALL(*worker, GetPublicKey).WillRepeatedly(ReturnPointee(public_key));
- ON_CALL(*worker, GetCertProfile).WillByDefault(ReturnRef(cert_profile));
- ON_CALL(*worker, GetLastBackendServerError)
- .WillByDefault(ReturnRef(backend_error));
-}
-
// Recursively visits all strings in |value| and replaces placeholders such as
// "$0" with the corresponding message from |messages|.
void FormatDictRecurse(base::Value* value,
@@ -147,52 +129,45 @@ base::Value GetByProfileId(const base::Value& all_processes,
return base::Value();
}
-class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
+class FakeMojoCertProvisioning : public crosapi::mojom::CertProvisioning {
public:
- explicit CertificateProvisioningUiHandlerTestBase(bool user_is_affiliated)
- : profile_helper_for_testing_(user_is_affiliated) {
- base::Base64Decode(kDerEncodedSpkiBase64, &der_encoded_spki_);
-
- web_contents_ =
- content::WebContents::Create(content::WebContents::CreateParams(
- profile_helper_for_testing_.GetProfile()));
- web_ui_.set_web_contents(web_contents_.get());
+ void AddObserver(mojo::PendingRemote<crosapi::mojom::CertProvisioningObserver>
+ observer) override {
+ observer_ = mojo::Remote<crosapi::mojom::CertProvisioningObserver>(
+ std::move(observer));
+ }
- EXPECT_CALL(scheduler_for_user_, GetWorkers)
- .WillRepeatedly(ReturnRef(user_workers_));
- EXPECT_CALL(scheduler_for_user_, GetFailedCertProfileIds)
- .WillRepeatedly(ReturnRef(user_failed_workers_));
- EXPECT_CALL(scheduler_for_user_, AddObserver(_))
- .WillOnce(SaveArg<0>(&scheduler_observer_for_user_));
- EXPECT_CALL(scheduler_for_user_, RemoveObserver(_)).Times(1);
-
- if (user_is_affiliated) {
- EXPECT_CALL(scheduler_for_device_, GetWorkers)
- .WillRepeatedly(ReturnRef(device_workers_));
- EXPECT_CALL(scheduler_for_device_, GetFailedCertProfileIds)
- .WillRepeatedly(ReturnRef(device_failed_workers_));
- EXPECT_CALL(scheduler_for_device_, AddObserver(_))
- .WillOnce(SaveArg<0>(&scheduler_observer_for_device_));
- EXPECT_CALL(scheduler_for_device_, RemoveObserver(_)).Times(1);
+ void GetStatus(GetStatusCallback callback) override {
+ std::vector<crosapi::mojom::CertProvisioningProcessStatusPtr> result;
+ for (auto& process : status_) {
+ result.push_back(process->Clone());
}
-
- auto handler = std::make_unique<CertificateProvisioningUiHandler>(
- GetProfile(), &scheduler_for_user_, &scheduler_for_device_);
- handler_ = handler.get();
- web_ui_.AddMessageHandler(std::move(handler));
+ std::move(callback).Run(std::move(result));
}
- ~CertificateProvisioningUiHandlerTestBase() override {}
+ void UpdateOneProcess(const std::string& cert_profile_id) override {}
- CertificateProvisioningUiHandlerTestBase(
- const CertificateProvisioningUiHandlerTestBase& other) = delete;
- CertificateProvisioningUiHandlerTestBase& operator=(
- const CertificateProvisioningUiHandlerTestBase& other) = delete;
+ mojo::Remote<crosapi::mojom::CertProvisioningObserver> observer_;
+ std::vector<crosapi::mojom::CertProvisioningProcessStatusPtr> status_;
+};
+class CertificateProvisioningUiHandlerTest : public ::testing::Test {
+ public:
void SetUp() override {
// Required for public key (SubjectPublicKeyInfo) formatting that is being
// done in the UI handler.
crypto::EnsureNSSInit();
+
+ testing_profile_ = TestingProfile::Builder().Build();
+
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(testing_profile_.get()));
+ web_ui_.set_web_contents(web_contents_.get());
+
+ auto handler = std::make_unique<CertificateProvisioningUiHandler>(
+ &mojo_cert_provisioning_);
+ handler_ = handler.get();
+ web_ui_.AddMessageHandler(std::move(handler));
}
// Use in ASSERT_NO_FATAL_FAILURE.
@@ -223,9 +198,9 @@ class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
content::TestWebUIListenerObserver result_waiter(
&web_ui_, "certificate-provisioning-processes-changed");
- base::ListValue args;
+ base::Value::List args;
web_ui_.HandleReceivedMessage("refreshCertificateProvisioningProcessses",
- &args);
+ args);
result_waiter.Wait();
ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
@@ -233,54 +208,19 @@ class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
}
protected:
- Profile* GetProfile() { return profile_helper_for_testing_.GetProfile(); }
-
- std::string der_encoded_spki_;
-
content::BrowserTaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
- ash::cert_provisioning::ProfileHelperForTesting profile_helper_for_testing_;
-
- ash::cert_provisioning::WorkerMap user_workers_;
- base::flat_map<ash::cert_provisioning::CertProfileId,
- ash::cert_provisioning::FailedWorkerInfo>
- user_failed_workers_;
- StrictMock<ash::cert_provisioning::MockCertProvisioningScheduler>
- scheduler_for_user_;
- ash::cert_provisioning::CertProvisioningSchedulerObserver*
- scheduler_observer_for_user_ = nullptr;
-
- ash::cert_provisioning::WorkerMap device_workers_;
- base::flat_map<ash::cert_provisioning::CertProfileId,
- ash::cert_provisioning::FailedWorkerInfo>
- device_failed_workers_;
- StrictMock<ash::cert_provisioning::MockCertProvisioningScheduler>
- scheduler_for_device_;
- ash::cert_provisioning::CertProvisioningSchedulerObserver*
- scheduler_observer_for_device_ = nullptr;
+
+ // TestingProfileManager testing_profile_manager_;
+ std::unique_ptr<TestingProfile> testing_profile_;
content::TestWebUI web_ui_;
std::unique_ptr<content::WebContents> web_contents_;
// Owned by |web_ui_|.
- CertificateProvisioningUiHandler* handler_;
-};
+ raw_ptr<CertificateProvisioningUiHandler> handler_ = nullptr;
-class CertificateProvisioningUiHandlerTest
- : public CertificateProvisioningUiHandlerTestBase {
- public:
- CertificateProvisioningUiHandlerTest()
- : CertificateProvisioningUiHandlerTestBase(/*user_is_affiilated=*/false) {
- }
- ~CertificateProvisioningUiHandlerTest() override = default;
-};
-
-class CertificateProvisioningUiHandlerAffiliatedTest
- : public CertificateProvisioningUiHandlerTestBase {
- public:
- CertificateProvisioningUiHandlerAffiliatedTest()
- : CertificateProvisioningUiHandlerTestBase(/*user_is_affiilated=*/true) {}
- ~CertificateProvisioningUiHandlerAffiliatedTest() override = default;
+ FakeMojoCertProvisioning mojo_cert_provisioning_;
};
TEST_F(CertificateProvisioningUiHandlerTest, NoProcesses) {
@@ -290,38 +230,24 @@ TEST_F(CertificateProvisioningUiHandlerTest, NoProcesses) {
EXPECT_TRUE(all_processes.GetListDeprecated().empty());
}
-TEST_F(CertificateProvisioningUiHandlerTest, HasProcesses) {
- ash::cert_provisioning::CertProfile user_cert_profile(
- kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
- /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
- absl::optional<ash::cert_provisioning::BackendServerError> backend_error =
- absl::nullopt;
- auto user_cert_worker =
- std::make_unique<ash::cert_provisioning::MockCertProvisioningWorker>();
- SetupMockCertProvisioningWorker(
- user_cert_worker.get(),
- ash::cert_provisioning::CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_, user_cert_profile, backend_error);
- user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
-
- ash::cert_provisioning::CertProfile device_cert_profile(
- kDeviceCertProfileId, kDeviceCertProfileName, kCertProfileVersion,
- /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
- auto device_cert_worker =
- std::make_unique<ash::cert_provisioning::MockCertProvisioningWorker>();
- SetupMockCertProvisioningWorker(
- device_cert_worker.get(),
- ash::cert_provisioning::CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_, device_cert_profile, backend_error);
- device_workers_[kDeviceCertProfileId] = std::move(device_cert_worker);
-
- // Only the user worker is expected to be displayed in the UI, because the
- // user is not affiliated.
+TEST_F(CertificateProvisioningUiHandlerTest, HasOneProcess) {
+ auto process_0 = crosapi::mojom::CertProvisioningProcessStatus::New();
+ process_0->cert_profile_id = kUserCertProfileId;
+ process_0->cert_profile_name = kUserCertProfileName;
+ process_0->public_key = base::Base64Decode(kDerEncodedSpkiBase64).value();
+ process_0->last_update_time = base::Time();
+ process_0->state =
+ crosapi::mojom::CertProvisioningProcessState::kKeypairGenerated;
+ process_0->did_fail = false;
+ process_0->is_device_wide = false;
+ process_0->last_backend_server_error = nullptr;
+ mojo_cert_provisioning_.status_.push_back(std::move(process_0));
+
base::Value all_processes;
std::vector<std::string> profile_ids;
ASSERT_NO_FATAL_FAILURE(
RefreshCertProvisioningProcesses(&all_processes, &profile_ids));
- ASSERT_THAT(profile_ids, UnorderedElementsAre(kUserCertProfileId));
+ ASSERT_THAT(profile_ids, ElementsAre(kUserCertProfileId));
EXPECT_EQ(
GetByProfileId(all_processes, kUserCertProfileId),
FormatJsonDict(
@@ -340,32 +266,39 @@ TEST_F(CertificateProvisioningUiHandlerTest, HasProcesses) {
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
}
-TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
- ash::cert_provisioning::CertProfile user_cert_profile(
- kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
- /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
- auto user_cert_worker =
- std::make_unique<ash::cert_provisioning::MockCertProvisioningWorker>();
- absl::optional<ash::cert_provisioning::BackendServerError> backend_error{};
- SetupMockCertProvisioningWorker(
- user_cert_worker.get(),
- ash::cert_provisioning::CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_, user_cert_profile, backend_error);
- user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
-
- ash::cert_provisioning::CertProfile device_cert_profile(
- kDeviceCertProfileId, kDeviceCertProfileName, kCertProfileVersion,
- /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
- auto device_cert_worker =
- std::make_unique<ash::cert_provisioning::MockCertProvisioningWorker>();
- SetupMockCertProvisioningWorker(
- device_cert_worker.get(),
- ash::cert_provisioning::CertProvisioningWorkerState::kFailed,
- &der_encoded_spki_, device_cert_profile, backend_error);
- device_workers_[kDeviceCertProfileId] = std::move(device_cert_worker);
-
- // Both user and device-wide workers are expected to be displayed in the UI,
- // because the user is affiliated.
+TEST_F(CertificateProvisioningUiHandlerTest, HasTwoProcesses) {
+ {
+ auto process_0 = crosapi::mojom::CertProvisioningProcessStatus::New();
+ process_0->cert_profile_id = kUserCertProfileId;
+ process_0->cert_profile_name = kUserCertProfileName;
+ process_0->public_key = base::Base64Decode(kDerEncodedSpkiBase64).value();
+ process_0->last_update_time = base::Time();
+ process_0->state =
+ crosapi::mojom::CertProvisioningProcessState::kKeypairGenerated;
+ process_0->did_fail = false;
+ process_0->is_device_wide = false;
+ process_0->last_backend_server_error = nullptr;
+ mojo_cert_provisioning_.status_.push_back(std::move(process_0));
+ }
+
+ {
+ auto process_1 = crosapi::mojom::CertProvisioningProcessStatus::New();
+ process_1->cert_profile_id = kDeviceCertProfileId;
+ process_1->cert_profile_name = kDeviceCertProfileName;
+ process_1->public_key = base::Base64Decode(kDerEncodedSpkiBase64).value();
+ process_1->last_update_time = base::Time();
+ process_1->state =
+ crosapi::mojom::CertProvisioningProcessState::kKeyRegistered;
+ process_1->did_fail = true;
+ process_1->is_device_wide = true;
+ base::Time time1;
+ EXPECT_TRUE(base::Time::FromString("15 May 2010 10:00:00 GMT", &time1));
+ process_1->last_backend_server_error =
+ crosapi::mojom::CertProvisioningBackendServerError::New(
+ time1, policy::DM_STATUS_REQUEST_INVALID);
+ mojo_cert_provisioning_.status_.push_back(std::move(process_1));
+ }
+
base::Value all_processes;
std::vector<std::string> profile_ids;
ASSERT_NO_FATAL_FAILURE(
@@ -389,6 +322,16 @@ TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
{kUserCertProfileId, kUserCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
+
+ std::string last_unsuccessful_message =
+ base::UTF16ToUTF8(l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_DMSERVER_ERROR_MESSAGE,
+ policy::FormatDeviceManagementStatus(
+ policy::DM_STATUS_REQUEST_INVALID),
+ u"Sat, 15 May 2010 10:00:00 GMT"));
+
+ // The second process failed, stateId should contain the state before failure,
+ // status should contain a failure text.
EXPECT_EQ(
GetByProfileId(all_processes, kDeviceCertProfileId),
FormatJsonDict(
@@ -397,14 +340,15 @@ TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
"certProfileName": "$1",
"isDeviceWide": true,
"publicKey": "$2",
- "stateId": 10,
+ "stateId": 4,
"status": "$3",
"timeSinceLastUpdate": "",
- "lastUnsuccessfulMessage": ""
+ "lastUnsuccessfulMessage": "$4"
})",
{kDeviceCertProfileId, kDeviceCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
- IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE)}));
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE),
+ last_unsuccessful_message}));
}
TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
@@ -415,36 +359,34 @@ TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
// considered allowed by the UI handler.
ASSERT_NO_FATAL_FAILURE(
RefreshCertProvisioningProcesses(&all_processes, &profile_ids));
- ASSERT_THAT(profile_ids, UnorderedElementsAre());
+ ASSERT_THAT(profile_ids, ElementsAre());
EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
- ash::cert_provisioning::CertProfile user_cert_profile(
- kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
- /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
- absl::optional<ash::cert_provisioning::BackendServerError> backend_error =
- absl::nullopt;
- auto user_cert_worker =
- std::make_unique<ash::cert_provisioning::MockCertProvisioningWorker>();
- SetupMockCertProvisioningWorker(
- user_cert_worker.get(),
- ash::cert_provisioning::CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_, user_cert_profile, backend_error);
- user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
-
- // The user worker triggers an update
+ {
+ auto process_0 = crosapi::mojom::CertProvisioningProcessStatus::New();
+ process_0->cert_profile_id = kUserCertProfileId;
+ process_0->cert_profile_name = kUserCertProfileName;
+ process_0->public_key = base::Base64Decode(kDerEncodedSpkiBase64).value();
+ process_0->last_update_time = base::Time();
+ process_0->state =
+ crosapi::mojom::CertProvisioningProcessState::kKeypairGenerated;
+ process_0->did_fail = false;
+ process_0->is_device_wide = false;
+ process_0->last_backend_server_error = nullptr;
+ mojo_cert_provisioning_.status_.push_back(std::move(process_0));
+ }
+
+ // The mojo service triggers an update.
content::TestWebUIListenerObserver result_waiter_1(
&web_ui_, "certificate-provisioning-processes-changed");
+ mojo_cert_provisioning_.observer_->OnStateChanged();
- scheduler_observer_for_user_->OnVisibleStateChanged();
-
- EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
result_waiter_1.Wait();
+ EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
+
ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
result_waiter_1.args(), &all_processes, &profile_ids));
-
- // Only the user worker is expected to be displayed in the UI, because the
- // user is not affiliated.
- ASSERT_THAT(profile_ids, UnorderedElementsAre(kUserCertProfileId));
+ ASSERT_THAT(profile_ids, ElementsAre(kUserCertProfileId));
EXPECT_EQ(
GetByProfileId(all_processes, kUserCertProfileId),
@@ -465,10 +407,10 @@ TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
content::TestWebUIListenerObserver result_waiter_2(
&web_ui_, "certificate-provisioning-processes-changed");
- scheduler_observer_for_user_->OnVisibleStateChanged();
+ mojo_cert_provisioning_.observer_->OnStateChanged();
- EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
result_waiter_2.Wait();
+ EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
base::Value all_processes_2;
ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
diff --git a/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc b/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
index dd638f33dbc..79b49b9d0dc 100644
--- a/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
@@ -30,6 +30,7 @@ content::WebUIDataSource* GetWebUIDataSource(const std::string& host) {
{"details", IDS_CERT_INFO_DETAILS_TAB_LABEL},
{"close", IDS_CLOSE},
{"export", IDS_CERT_DETAILS_EXPORT_CERTIFICATE},
+ {"exportA11yLabel", IDS_CERT_DETAILS_EXPORT_CERTIFICATE_A11Y_LABEL},
{"issuedTo", IDS_CERT_INFO_SUBJECT_GROUP},
{"issuedBy", IDS_CERT_INFO_ISSUER_GROUP},
{"cn", IDS_CERT_INFO_COMMON_NAME_LABEL},
@@ -44,6 +45,7 @@ content::WebUIDataSource* GetWebUIDataSource(const std::string& host) {
{"hierarchy", IDS_CERT_DETAILS_CERTIFICATE_HIERARCHY_LABEL},
{"certFields", IDS_CERT_DETAILS_CERTIFICATE_FIELDS_LABEL},
{"certFieldVal", IDS_CERT_DETAILS_CERTIFICATE_FIELD_VALUE_LABEL},
+ {"certError", IDS_CERT_DUMP_ERROR},
};
html_source->AddLocalizedStrings(kStrings);
diff --git a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc
index ee1720978e9..f0f5e32b2ef 100644
--- a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc
@@ -23,16 +23,21 @@
#include "chrome/browser/ui/certificate_dialogs.h"
#include "chrome/browser/ui/webui/certificate_viewer_ui.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
-#include "chrome/common/net/x509_certificate_model_nss.h"
+#include "chrome/common/net/x509_certificate_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/web_contents.h"
-#include "net/cert/x509_util_nss.h"
+#include "net/cert/x509_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h"
+#if BUILDFLAG(USE_NSS_CERTS)
+#include "chrome/common/net/x509_certificate_model_nss.h"
+#include "net/cert/x509_util_nss.h"
+#endif
+
using content::WebContents;
using content::WebUIMessageHandler;
@@ -60,57 +65,56 @@ class CertNodeBuilder {
CertNodeBuilder& Payload(base::StringPiece payload);
// Adds |child| in the list keyed "children". Can be called multiple times.
- CertNodeBuilder& Child(std::unique_ptr<base::DictionaryValue> child);
+ CertNodeBuilder& Child(base::Value::Dict child);
// Similar to Child, but if the argument is null, then this does not add
// anything.
- CertNodeBuilder& ChildIfNotNull(std::unique_ptr<base::DictionaryValue> child);
+ CertNodeBuilder& ChildIfNotNullopt(absl::optional<base::Value::Dict> child);
- // Creates a DictionaryValue representation of the collected information. Only
- // call this once.
- std::unique_ptr<base::DictionaryValue> Build();
+ // Creates a base::Value::Dict representation of the collected information.
+ // Only call this once.
+ base::Value::Dict Build();
private:
- base::DictionaryValue node_;
- base::ListValue children_;
+ base::Value::Dict node_;
+ base::Value::List children_;
// |built_| is false until Build() is called. Once it is |true|, |node_| and
// |children_| are no longer valid for use.
bool built_ = false;
};
CertNodeBuilder::CertNodeBuilder(base::StringPiece label) {
- node_.SetStringKey("label", label);
+ node_.Set("label", label);
}
CertNodeBuilder::CertNodeBuilder(int label_id)
: CertNodeBuilder(l10n_util::GetStringUTF8(label_id)) {}
CertNodeBuilder& CertNodeBuilder::Payload(base::StringPiece payload) {
- DCHECK(!node_.FindPath("payload.val"));
- node_.SetStringPath("payload.val", payload);
+ DCHECK(!node_.FindByDottedPath("payload.val"));
+ node_.SetByDottedPath("payload.val", payload);
return *this;
}
-CertNodeBuilder& CertNodeBuilder::Child(
- std::unique_ptr<base::DictionaryValue> child) {
- children_.Append(base::Value::FromUniquePtrValue(std::move(child)));
+CertNodeBuilder& CertNodeBuilder::Child(base::Value::Dict child) {
+ children_.Append(std::move(child));
return *this;
}
-CertNodeBuilder& CertNodeBuilder::ChildIfNotNull(
- std::unique_ptr<base::DictionaryValue> child) {
+CertNodeBuilder& CertNodeBuilder::ChildIfNotNullopt(
+ absl::optional<base::Value::Dict> child) {
if (child)
- return Child(std::move(child));
+ return Child(std::move(*child));
return *this;
}
-std::unique_ptr<base::DictionaryValue> CertNodeBuilder::Build() {
+base::Value::Dict CertNodeBuilder::Build() {
DCHECK(!built_);
- if (!children_.GetListDeprecated().empty()) {
- node_.SetKey("children", std::move(children_));
+ if (!children_.empty()) {
+ node_.Set("children", std::move(children_));
}
built_ = true;
- return std::make_unique<base::DictionaryValue>(std::move(node_));
+ return std::move(node_);
}
} // namespace
@@ -119,25 +123,64 @@ std::unique_ptr<base::DictionaryValue> CertNodeBuilder::Build() {
void ShowCertificateViewer(WebContents* web_contents,
gfx::NativeWindow parent,
net::X509Certificate* cert) {
+ std::vector<std::string> nicknames;
+#if BUILDFLAG(USE_NSS_CERTS)
net::ScopedCERTCertificateList nss_certs =
net::x509_util::CreateCERTCertificateListFromX509Certificate(cert);
- if (nss_certs.empty())
- return;
+ // If any of the certs could not be parsed by NSS, |nss_certs| will be an
+ // empty list and |nicknames| will not be populated, which is fine as a
+ // fallback.
+ for (const auto& nss_cert : nss_certs) {
+ nicknames.push_back(x509_certificate_model::GetRawNickname(nss_cert.get()));
+ }
+#endif
- CertificateViewerDialog::ShowConstrained(std::move(nss_certs), web_contents,
- parent);
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> cert_buffers;
+ cert_buffers.push_back(bssl::UpRef(cert->cert_buffer()));
+ for (const auto& intermediate : cert->intermediate_buffers()) {
+ cert_buffers.push_back(bssl::UpRef(intermediate));
+ }
+ CertificateViewerDialog::ShowConstrained(
+ std::move(cert_buffers), std::move(nicknames), web_contents, parent);
+}
+
+#if !(BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC))
+void ShowCertificateViewerForClientAuth(content::WebContents* web_contents,
+ gfx::NativeWindow parent,
+ net::X509Certificate* cert) {
+ ShowCertificateViewer(web_contents, parent, cert);
}
+#endif
////////////////////////////////////////////////////////////////////////////////
// CertificateViewerDialog
+#if BUILDFLAG(USE_NSS_CERTS)
// static
CertificateViewerDialog* CertificateViewerDialog::ShowConstrained(
- net::ScopedCERTCertificateList certs,
+ net::ScopedCERTCertificateList nss_certs,
WebContents* web_contents,
gfx::NativeWindow parent) {
+ std::vector<std::string> nicknames;
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> cert_buffers;
+ for (const auto& cert : nss_certs) {
+ nicknames.push_back(x509_certificate_model::GetRawNickname(cert.get()));
+ cert_buffers.push_back(net::x509_util::CreateCryptoBuffer(
+ base::make_span(cert->derCert.data, cert->derCert.len)));
+ }
+ return ShowConstrained(std::move(cert_buffers), std::move(nicknames),
+ web_contents, parent);
+}
+#endif
+
+// static
+CertificateViewerDialog* CertificateViewerDialog::ShowConstrained(
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> certs,
+ std::vector<std::string> cert_nicknames,
+ content::WebContents* web_contents,
+ gfx::NativeWindow parent) {
CertificateViewerDialog* dialog_ptr =
- new CertificateViewerDialog(std::move(certs));
+ new CertificateViewerDialog(std::move(certs), std::move(cert_nicknames));
auto dialog = base::WrapUnique(dialog_ptr);
// TODO(bshe): UI tweaks needed for Aura HTML Dialog, such as adding padding
@@ -160,13 +203,17 @@ gfx::NativeWindow CertificateViewerDialog::GetNativeWebContentsModalDialog() {
}
CertificateViewerDialog::CertificateViewerDialog(
- net::ScopedCERTCertificateList certs)
- : nss_certs_(std::move(certs)) {
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> certs,
+ std::vector<std::string> cert_nicknames) {
+ for (size_t i = 0; i < certs.size(); ++i) {
+ std::string nickname;
+ if (i < cert_nicknames.size())
+ nickname = std::move(cert_nicknames[i]);
+ certs_.emplace_back(std::move(certs[i]), std::move(nickname));
+ }
// Construct the dialog title from the certificate.
title_ = l10n_util::GetStringFUTF16(
- IDS_CERT_INFO_DIALOG_TITLE,
- base::UTF8ToUTF16(
- x509_certificate_model::GetTitle(nss_certs_.front().get())));
+ IDS_CERT_INFO_DIALOG_TITLE, base::UTF8ToUTF16(certs_.front().GetTitle()));
}
CertificateViewerDialog::~CertificateViewerDialog() = default;
@@ -186,8 +233,7 @@ GURL CertificateViewerDialog::GetDialogContentURL() const {
void CertificateViewerDialog::GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const {
handlers->push_back(new CertificateViewerDialogHandler(
- const_cast<CertificateViewerDialog*>(this),
- net::x509_util::DupCERTCertificateList(nss_certs_)));
+ const_cast<CertificateViewerDialog*>(this), &certs_));
}
void CertificateViewerDialog::GetDialogSize(gfx::Size* size) const {
@@ -196,84 +242,92 @@ void CertificateViewerDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(kDefaultWidth, kDefaultHeight);
}
+std::string HandleOptionalOrError(
+ const x509_certificate_model::OptionalStringOrError& s) {
+ if (absl::holds_alternative<x509_certificate_model::Error>(s))
+ return l10n_util::GetStringUTF8(IDS_CERT_DUMP_ERROR);
+ else if (absl::holds_alternative<x509_certificate_model::NotPresent>(s))
+ return l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT);
+ return absl::get<std::string>(s);
+}
+
std::string CertificateViewerDialog::GetDialogArgs() const {
std::string data;
// Certificate information. The keys in this dictionary's general key
// correspond to the IDs in the Html page.
- base::DictionaryValue cert_info;
- CERTCertificate* cert_hnd = nss_certs_.front().get();
+ base::Value::Dict cert_info;
+ const x509_certificate_model::X509CertificateModel& model = certs_.front();
- // Standard certificate details.
- const std::string alternative_text =
- l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT);
- cert_info.SetStringPath(
+ cert_info.Set("isError", !model.is_valid());
+ cert_info.SetByDottedPath(
"general.title",
- l10n_util::GetStringFUTF8(
- IDS_CERT_INFO_DIALOG_TITLE,
- base::UTF8ToUTF16(x509_certificate_model::GetTitle(cert_hnd))));
-
- // Issued to information.
- cert_info.SetStringPath(
- "general.issued-cn",
- x509_certificate_model::GetSubjectCommonName(cert_hnd, alternative_text));
- cert_info.SetStringPath(
- "general.issued-o",
- x509_certificate_model::GetSubjectOrgName(cert_hnd, alternative_text));
- cert_info.SetStringPath("general.issued-ou",
- x509_certificate_model::GetSubjectOrgUnitName(
- cert_hnd, alternative_text));
-
- // Issuer information.
- cert_info.SetStringPath(
- "general.issuer-cn",
- x509_certificate_model::GetIssuerCommonName(cert_hnd, alternative_text));
- cert_info.SetStringPath(
- "general.issuer-o",
- x509_certificate_model::GetIssuerOrgName(cert_hnd, alternative_text));
- cert_info.SetStringPath(
- "general.issuer-ou",
- x509_certificate_model::GetIssuerOrgUnitName(cert_hnd, alternative_text));
-
- // Validity period.
- base::Time issued, expires;
- std::string issued_str, expires_str;
- if (x509_certificate_model::GetTimes(cert_hnd, &issued, &expires)) {
- issued_str = base::UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(issued));
- expires_str = base::UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(expires));
- } else {
- issued_str = alternative_text;
- expires_str = alternative_text;
+ l10n_util::GetStringFUTF8(IDS_CERT_INFO_DIALOG_TITLE,
+ base::UTF8ToUTF16(model.GetTitle())));
+
+ if (model.is_valid()) {
+ // Standard certificate details.
+ const std::string alternative_text =
+ l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT);
+
+ // Issued to information.
+ cert_info.SetByDottedPath(
+ "general.issued-cn",
+ HandleOptionalOrError(model.GetSubjectCommonName()));
+ cert_info.SetByDottedPath("general.issued-o",
+ HandleOptionalOrError(model.GetSubjectOrgName()));
+ cert_info.SetByDottedPath(
+ "general.issued-ou",
+ HandleOptionalOrError(model.GetSubjectOrgUnitName()));
+
+ // Issuer information.
+ cert_info.SetByDottedPath(
+ "general.issuer-cn",
+ HandleOptionalOrError(model.GetIssuerCommonName()));
+ cert_info.SetByDottedPath("general.issuer-o",
+ HandleOptionalOrError(model.GetIssuerOrgName()));
+ cert_info.SetByDottedPath(
+ "general.issuer-ou",
+ HandleOptionalOrError(model.GetIssuerOrgUnitName()));
+
+ // Validity period.
+ base::Time issued, expires;
+ std::string issued_str, expires_str;
+ if (model.GetTimes(&issued, &expires)) {
+ issued_str =
+ base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(issued));
+ expires_str =
+ base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(expires));
+ } else {
+ issued_str = alternative_text;
+ expires_str = alternative_text;
+ }
+ cert_info.SetByDottedPath("general.issue-date", issued_str);
+ cert_info.SetByDottedPath("general.expiry-date", expires_str);
}
- cert_info.SetStringPath("general.issue-date", issued_str);
- cert_info.SetStringPath("general.expiry-date", expires_str);
- cert_info.SetStringPath("general.sha256",
- x509_certificate_model::HashCertSHA256(cert_hnd));
- cert_info.SetStringPath("general.sha1",
- x509_certificate_model::HashCertSHA1(cert_hnd));
+ cert_info.SetByDottedPath("general.sha256",
+ model.HashCertSHA256WithSeparators());
+ cert_info.SetByDottedPath("general.sha1", model.HashCertSHA1WithSeparators());
// Certificate hierarchy is constructed from bottom up.
- base::Value children;
+ base::Value::List children;
int index = 0;
- for (const auto& cert : nss_certs_) {
- base::Value cert_node(base::Value::Type::DICTIONARY);
- cert_node.SetKey("label",
- base::Value(x509_certificate_model::GetTitle(cert.get())));
- cert_node.SetPath({"payload", "index"}, base::Value(index));
+ for (const auto& cert : certs_) {
+ base::Value::Dict cert_node;
+ cert_node.Set("label", base::Value(cert.GetTitle()));
+ cert_node.SetByDottedPath("payload.index", base::Value(index));
// Add the child from the previous iteration.
- if (!children.is_none())
- cert_node.SetKey("children", std::move(children));
+ if (!children.empty())
+ cert_node.Set("children", std::move(children));
// Add this node to the children list for the next iteration.
- children = base::Value(base::Value::Type::LIST);
+ children = base::Value::List();
children.Append(std::move(cert_node));
++index;
}
// Set the last node as the top of the certificate hierarchy.
- cert_info.SetKey("hierarchy", std::move(children));
+ cert_info.Set("hierarchy", std::move(children));
base::JSONWriter::Write(cert_info, &data);
@@ -302,19 +356,19 @@ bool CertificateViewerDialog::ShouldShowDialogTitle() const {
CertificateViewerDialogHandler::CertificateViewerDialogHandler(
CertificateViewerDialog* dialog,
- net::ScopedCERTCertificateList cert_chain)
- : dialog_(dialog), cert_chain_(std::move(cert_chain)) {}
+ const std::vector<x509_certificate_model::X509CertificateModel>* certs)
+ : dialog_(dialog), certs_(certs) {}
CertificateViewerDialogHandler::~CertificateViewerDialogHandler() {
}
void CertificateViewerDialogHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"exportCertificate",
base::BindRepeating(
&CertificateViewerDialogHandler::HandleExportCertificate,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestCertificateFields",
base::BindRepeating(
&CertificateViewerDialogHandler::HandleRequestCertificateFields,
@@ -322,139 +376,121 @@ void CertificateViewerDialogHandler::RegisterMessages() {
}
void CertificateViewerDialogHandler::HandleExportCertificate(
- const base::ListValue* args) {
- int cert_index = GetCertificateIndex(args->GetListDeprecated()[0].GetInt());
+ const base::Value::List& args) {
+ int cert_index = GetCertificateIndex(args[0].GetInt());
if (cert_index < 0)
return;
gfx::NativeWindow window =
- platform_util::GetTopLevel(dialog_->GetNativeWebContentsModalDialog());
- ShowCertExportDialog(web_ui()->GetWebContents(),
- window,
- cert_chain_.begin() + cert_index,
- cert_chain_.end());
+ platform_util::GetTopLevel(platform_util::GetViewForWindow(
+ dialog_->GetNativeWebContentsModalDialog()));
+
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> export_certs;
+ for (const auto& cert : base::make_span(*certs_).subspan(cert_index)) {
+ export_certs.push_back(bssl::UpRef(cert.cert_buffer()));
+ }
+ ShowCertExportDialog(web_ui()->GetWebContents(), window,
+ std::move(export_certs),
+ (*certs_)[cert_index].GetTitle());
}
void CertificateViewerDialogHandler::HandleRequestCertificateFields(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
- int cert_index = GetCertificateIndex(args->GetListDeprecated()[1].GetInt());
+ const base::Value& callback_id = args[0];
+ int cert_index = GetCertificateIndex(args[1].GetInt());
if (cert_index < 0)
return;
- CERTCertificate* cert = cert_chain_[cert_index].get();
+ const x509_certificate_model::X509CertificateModel& model =
+ (*certs_)[cert_index];
- CertNodeBuilder version_node(IDS_CERT_DETAILS_VERSION);
- std::string version = x509_certificate_model::GetVersion(cert);
- if (!version.empty()) {
- version_node.Payload(l10n_util::GetStringFUTF8(
- IDS_CERT_DETAILS_VERSION_FORMAT, base::UTF8ToUTF16(version)));
- }
+ CertNodeBuilder contents_builder(IDS_CERT_DETAILS_CERTIFICATE);
- CertNodeBuilder issued_node_builder(IDS_CERT_DETAILS_NOT_BEFORE);
- CertNodeBuilder expires_node_builder(IDS_CERT_DETAILS_NOT_AFTER);
- base::Time issued, expires;
- if (x509_certificate_model::GetTimes(cert, &issued, &expires)) {
- issued_node_builder.Payload(base::UTF16ToUTF8(
- base::TimeFormatShortDateAndTimeWithTimeZone(issued)));
- expires_node_builder.Payload(base::UTF16ToUTF8(
- base::TimeFormatShortDateAndTimeWithTimeZone(expires)));
- }
+ if (model.is_valid()) {
+ CertNodeBuilder issued_node_builder(IDS_CERT_DETAILS_NOT_BEFORE);
+ CertNodeBuilder expires_node_builder(IDS_CERT_DETAILS_NOT_AFTER);
+ base::Time issued, expires;
+ if (model.GetTimes(&issued, &expires)) {
+ issued_node_builder.Payload(base::UTF16ToUTF8(
+ base::TimeFormatShortDateAndTimeWithTimeZone(issued)));
+ expires_node_builder.Payload(base::UTF16ToUTF8(
+ base::TimeFormatShortDateAndTimeWithTimeZone(expires)));
+ }
- x509_certificate_model::Extensions extensions;
- x509_certificate_model::GetExtensions(
- l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL),
- l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL),
- cert, &extensions);
-
- std::unique_ptr<base::DictionaryValue> details_extensions;
- if (!extensions.empty()) {
- CertNodeBuilder details_extensions_builder(IDS_CERT_DETAILS_EXTENSIONS);
- for (const x509_certificate_model::Extension& extension : extensions) {
- details_extensions_builder.Child(
- CertNodeBuilder(extension.name).Payload(extension.value).Build());
+ std::vector<x509_certificate_model::Extension> extensions =
+ model.GetExtensions(
+ l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL),
+ l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL));
+
+ absl::optional<base::Value::Dict> details_extensions;
+ if (!extensions.empty()) {
+ CertNodeBuilder details_extensions_builder(IDS_CERT_DETAILS_EXTENSIONS);
+ for (const x509_certificate_model::Extension& extension : extensions) {
+ details_extensions_builder.Child(
+ CertNodeBuilder(extension.name).Payload(extension.value).Build());
+ }
+ details_extensions = details_extensions_builder.Build();
}
- details_extensions = details_extensions_builder.Build();
- }
- base::ListValue root_list;
- root_list.Append(base::Value::FromUniquePtrValue(
- CertNodeBuilder(x509_certificate_model::GetTitle(cert))
- .Child(
- CertNodeBuilder(
- l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE))
- // Main certificate fields.
- .Child(version_node.Build())
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_SERIAL_NUMBER)
- .Payload(
- x509_certificate_model::GetSerialNumberHexified(
- cert, l10n_util::GetStringUTF8(
- IDS_CERT_INFO_FIELD_NOT_PRESENT)))
- .Build())
- .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)
- .Payload(x509_certificate_model::
- ProcessSecAlgorithmSignature(cert))
- .Build())
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_ISSUER)
- .Payload(x509_certificate_model::GetIssuerName(cert))
- .Build())
- // Validity period.
- .Child(CertNodeBuilder(IDS_CERT_DETAILS_VALIDITY)
- .Child(issued_node_builder.Build())
- .Child(expires_node_builder.Build())
- .Build())
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT)
- .Payload(x509_certificate_model::GetSubjectName(cert))
- .Build())
- // Subject key information.
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_INFO)
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_ALG)
- .Payload(
- x509_certificate_model::
- ProcessSecAlgorithmSubjectPublicKey(
- cert))
- .Build())
- .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY)
- .Payload(
- x509_certificate_model::
- ProcessSubjectPublicKeyInfo(cert))
- .Build())
- .Build())
- // Extensions.
- .ChildIfNotNull(std::move(details_extensions))
- .Child(
- CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)
- .Payload(x509_certificate_model::
- ProcessSecAlgorithmSignatureWrap(cert))
- .Build())
- .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE)
- .Payload(x509_certificate_model::
- ProcessRawBitsSignatureWrap(cert))
- .Build())
- .Child(
- CertNodeBuilder(IDS_CERT_INFO_FINGERPRINTS_GROUP)
- .Child(CertNodeBuilder(
- IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)
- .Payload(
- x509_certificate_model::HashCertSHA256(
- cert))
- .Build())
- .Child(
- CertNodeBuilder(
- IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)
- .Payload(x509_certificate_model::HashCertSHA1(
- cert))
- .Build())
- .Build())
- .Build())
- .Build()));
+ contents_builder
+ // Main certificate fields.
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_VERSION)
+ .Payload(l10n_util::GetStringFUTF8(
+ IDS_CERT_DETAILS_VERSION_FORMAT,
+ base::UTF8ToUTF16(model.GetVersion())))
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_SERIAL_NUMBER)
+ .Payload(model.GetSerialNumberHexified())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)
+ .Payload(model.ProcessSecAlgorithmSignature())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_ISSUER)
+ .Payload(HandleOptionalOrError(model.GetIssuerName()))
+ .Build())
+ // Validity period.
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_VALIDITY)
+ .Child(issued_node_builder.Build())
+ .Child(expires_node_builder.Build())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT)
+ .Payload(HandleOptionalOrError(model.GetSubjectName()))
+ .Build())
+ // Subject key information.
+ .Child(
+ CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_INFO)
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_ALG)
+ .Payload(model.ProcessSecAlgorithmSubjectPublicKey())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY)
+ .Payload(model.ProcessSubjectPublicKeyInfo())
+ .Build())
+ .Build())
+ // Extensions.
+ .ChildIfNotNullopt(std::move(details_extensions))
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)
+ .Payload(model.ProcessSecAlgorithmSignatureWrap())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE)
+ .Payload(model.ProcessRawBitsSignatureWrap())
+ .Build());
+ }
+ contents_builder.Child(
+ CertNodeBuilder(IDS_CERT_INFO_FINGERPRINTS_GROUP)
+ .Child(CertNodeBuilder(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)
+ .Payload(model.HashCertSHA256WithSeparators())
+ .Build())
+ .Child(CertNodeBuilder(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)
+ .Payload(model.HashCertSHA1WithSeparators())
+ .Build())
+ .Build());
+
+ base::Value::List root_list;
+ root_list.Append(CertNodeBuilder(model.GetTitle())
+ .Child(contents_builder.Build())
+ .Build());
// Send certificate information to javascript.
ResolveJavascriptCallback(callback_id, root_list);
}
@@ -462,7 +498,7 @@ void CertificateViewerDialogHandler::HandleRequestCertificateFields(
int CertificateViewerDialogHandler::GetCertificateIndex(
int requested_index) const {
int cert_index = requested_index;
- if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size()))
+ if (cert_index < 0 || static_cast<size_t>(cert_index) >= certs_->size())
return -1;
return cert_index;
}
diff --git a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.h b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.h
index 70cc1c95617..0f02919db7f 100644
--- a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.h
+++ b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.h
@@ -8,27 +8,41 @@
#include <string>
#include <vector>
+#include "base/memory/raw_ptr.h"
#include "base/values.h"
+#include "chrome/common/net/x509_certificate_model.h"
#include "content/public/browser/web_ui_message_handler.h"
-#include "net/cert/scoped_nss_types.h"
+#include "crypto/crypto_buildflags.h"
#include "net/cert/x509_certificate.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
+#if BUILDFLAG(USE_NSS_CERTS)
+#include "net/cert/scoped_nss_types.h"
+#endif
+
namespace content {
class WebContents;
}
class ConstrainedWebDialogDelegate;
-// Dialog for displaying detailed certificate information. This is used in linux
-// and chromeos builds to display detailed information in a floating dialog when
-// the user clicks on "Certificate Information" from the lock icon of a web site
-// or "View" from the Certificate Manager.
+// Dialog for displaying detailed certificate information. This is used on
+// desktop builds to display detailed information in a floating dialog when the
+// user clicks on "Certificate Information" from the lock icon of a web site or
+// "View" from the Certificate Manager.
class CertificateViewerDialog : public ui::WebDialogDelegate {
public:
+#if BUILDFLAG(USE_NSS_CERTS)
+ static CertificateViewerDialog* ShowConstrained(
+ net::ScopedCERTCertificateList nss_certs,
+ content::WebContents* web_contents,
+ gfx::NativeWindow parent);
+#endif
+
static CertificateViewerDialog* ShowConstrained(
- net::ScopedCERTCertificateList certs,
+ std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> certs,
+ std::vector<std::string> cert_nicknames,
content::WebContents* web_contents,
gfx::NativeWindow parent);
@@ -45,7 +59,8 @@ class CertificateViewerDialog : public ui::WebDialogDelegate {
// Construct a certificate viewer for the passed in certificate. A reference
// to the certificate pointer is added for the lifetime of the certificate
// viewer.
- explicit CertificateViewerDialog(net::ScopedCERTCertificateList certs);
+ CertificateViewerDialog(std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> certs,
+ std::vector<std::string> cert_nicknames);
// ui::WebDialogDelegate:
ui::ModalType GetDialogModalType() const override;
@@ -61,22 +76,22 @@ class CertificateViewerDialog : public ui::WebDialogDelegate {
bool* out_close_dialog) override;
bool ShouldShowDialogTitle() const override;
- // The certificate chain, as NSS cert objects.
- net::ScopedCERTCertificateList nss_certs_;
+ std::vector<x509_certificate_model::X509CertificateModel> certs_;
// The title of the certificate viewer dialog, Certificate Viewer: CN.
std::u16string title_;
- content::WebUI* webui_ = nullptr;
- ConstrainedWebDialogDelegate* delegate_ = nullptr;
+ raw_ptr<content::WebUI> webui_ = nullptr;
+ raw_ptr<ConstrainedWebDialogDelegate> delegate_ = nullptr;
};
// Dialog handler which handles calls from the JS WebUI code to view certificate
// details and export the certificate.
class CertificateViewerDialogHandler : public content::WebUIMessageHandler {
public:
- CertificateViewerDialogHandler(CertificateViewerDialog* dialog,
- net::ScopedCERTCertificateList cert_chain);
+ CertificateViewerDialogHandler(
+ CertificateViewerDialog* dialog,
+ const std::vector<x509_certificate_model::X509CertificateModel>* certs);
CertificateViewerDialogHandler(const CertificateViewerDialogHandler&) =
delete;
@@ -93,24 +108,24 @@ class CertificateViewerDialogHandler : public content::WebUIMessageHandler {
// chain.
//
// The input is an integer index to the certificate in the chain to export.
- void HandleExportCertificate(const base::ListValue* args);
+ void HandleExportCertificate(const base::Value::List& args);
// Gets the details for a specific certificate in the certificate chain.
// Responds with a tree structure containing the fields and values for certain
// nodes.
//
// The input is an integer index to the certificate in the chain to view.
- void HandleRequestCertificateFields(const base::ListValue* args);
+ void HandleRequestCertificateFields(const base::Value::List& args);
// Helper function to get the certificate index. Returns -1 if the index is
// out of range.
int GetCertificateIndex(int requested_index) const;
// The dialog.
- CertificateViewerDialog* dialog_;
+ raw_ptr<CertificateViewerDialog> dialog_;
- // The certificate chain.
- net::ScopedCERTCertificateList cert_chain_;
+ raw_ptr<const std::vector<x509_certificate_model::X509CertificateModel>>
+ certs_;
};
#endif // CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_WEBUI_H_
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.cc b/chromium/chrome/browser/ui/webui/certificates_handler.cc
index 0f2f0f5be6b..ae680f41f39 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.cc
@@ -17,6 +17,7 @@
#include "base/callback_helpers.h"
#include "base/files/file_util.h" // for FileAccessProvider
#include "base/i18n/string_compare.h"
+#include "base/memory/raw_ptr.h"
#include "base/posix/safe_strerror.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -91,19 +92,14 @@ struct DictionaryIdComparator {
bool operator()(const base::Value& a, const base::Value& b) const {
DCHECK(a.type() == base::Value::Type::DICTIONARY);
DCHECK(b.type() == base::Value::Type::DICTIONARY);
- const base::DictionaryValue* a_dict;
- bool a_is_dictionary = a.GetAsDictionary(&a_dict);
- DCHECK(a_is_dictionary);
- const base::DictionaryValue* b_dict;
- bool b_is_dictionary = b.GetAsDictionary(&b_dict);
- DCHECK(b_is_dictionary);
+ const base::Value::Dict& a_dict = a.GetDict();
+ const base::Value::Dict& b_dict = b.GetDict();
std::u16string a_str;
std::u16string b_str;
- const std::string* ptr =
- a_dict->GetDict().FindString(kCertificatesHandlerNameField);
+ const std::string* ptr = a_dict.FindString(kCertificatesHandlerNameField);
if (ptr)
a_str = base::UTF8ToUTF16(*ptr);
- ptr = b_dict->GetDict().FindString(kCertificatesHandlerNameField);
+ ptr = b_dict.FindString(kCertificatesHandlerNameField);
if (ptr)
b_str = base::UTF8ToUTF16(*ptr);
if (collator_ == nullptr)
@@ -136,7 +132,7 @@ struct CertEquals {
bool operator()(const scoped_refptr<net::X509Certificate> cert) const {
return net::x509_util::IsSameCertificate(cert_, cert.get());
}
- CERTCertificate* cert_;
+ raw_ptr<CERTCertificate> cert_;
};
// Determine if |data| could be a PFX Protocol Data Unit.
@@ -442,18 +438,17 @@ void CertificatesHandler::HandleGetCATrust(const base::Value::List& args) {
net::NSSCertDatabase::TrustBits trust_bits =
certificate_manager_model_->cert_db()->GetCertTrust(cert_info->cert(),
net::CA_CERT);
- std::unique_ptr<base::DictionaryValue> ca_trust_info(
- new base::DictionaryValue);
- ca_trust_info->GetDict().Set(
+ base::Value::Dict ca_trust_info;
+ ca_trust_info.Set(
kCertificatesHandlerSslField,
static_cast<bool>(trust_bits & net::NSSCertDatabase::TRUSTED_SSL));
- ca_trust_info->GetDict().Set(
+ ca_trust_info.Set(
kCertificatesHandlerEmailField,
static_cast<bool>(trust_bits & net::NSSCertDatabase::TRUSTED_EMAIL));
- ca_trust_info->GetDict().Set(
+ ca_trust_info.Set(
kCertificatesHandlerObjSignField,
static_cast<bool>(trust_bits & net::NSSCertDatabase::TRUSTED_OBJ_SIGN));
- ResolveCallback(*ca_trust_info);
+ ResolveCallback(ca_trust_info);
}
void CertificatesHandler::HandleEditCATrust(const base::Value::List& args) {
@@ -993,7 +988,13 @@ void CertificatesHandler::HandleDeleteCertificate(
return;
}
- bool result = certificate_manager_model_->Delete(cert_info->cert());
+ certificate_manager_model_->RemoveFromDatabase(
+ net::x509_util::DupCERTCertificate(cert_info->cert()),
+ base::BindOnce(&CertificatesHandler::OnCertificateDeleted,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void CertificatesHandler::OnCertificateDeleted(bool result) {
if (!result) {
// TODO(mattm): better error messages?
RejectCallbackWithError(
@@ -1063,18 +1064,16 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name,
certificate_manager_model_->FilterAndBuildOrgGroupingMap(type,
&org_grouping_map);
- base::ListValue nodes;
+ base::Value::List nodes;
for (auto& org_grouping_map_entry : org_grouping_map) {
// Populate first level (org name).
- base::DictionaryValue org_dict;
- org_dict.GetDict().Set(
- kCertificatesHandlerKeyField,
- base::Value(OrgNameToId(org_grouping_map_entry.first)));
- org_dict.GetDict().Set(kCertificatesHandlerNameField,
- base::Value(org_grouping_map_entry.first));
+ base::Value::Dict org_dict;
+ org_dict.Set(kCertificatesHandlerKeyField,
+ OrgNameToId(org_grouping_map_entry.first));
+ org_dict.Set(kCertificatesHandlerNameField, org_grouping_map_entry.first);
// Populate second level (certs).
- base::ListValue subnodes;
+ base::Value::List subnodes;
bool contains_policy_certs = false;
for (auto& org_cert : org_grouping_map_entry.second) {
// Move the CertInfo into |cert_info_id_map_|.
@@ -1082,27 +1081,24 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name,
std::string id =
base::NumberToString(cert_info_id_map_.Add(std::move(org_cert)));
- base::DictionaryValue cert_dict;
- cert_dict.GetDict().Set(kCertificatesHandlerKeyField, base::Value(id));
- cert_dict.GetDict().Set(kCertificatesHandlerNameField,
- base::Value(cert_info->name()));
- cert_dict.GetDict().Set(kCertificatesHandlerCanBeDeletedField,
- base::Value(CanDeleteCertificate(cert_info)));
- cert_dict.GetDict().Set(kCertificatesHandlerCanBeEditedField,
- base::Value(CanEditCertificate(cert_info)));
- cert_dict.GetDict().Set(kCertificatesHandlerUntrustedField,
- base::Value(cert_info->untrusted()));
- cert_dict.GetDict().Set(
- kCertificatesHandlerPolicyInstalledField,
- base::Value(cert_info->source() ==
- CertificateManagerModel::CertInfo::Source::kPolicy));
- cert_dict.GetDict().Set(kCertificatesHandlerWebTrustAnchorField,
- base::Value(cert_info->web_trust_anchor()));
+ base::Value::Dict cert_dict;
+ cert_dict.Set(kCertificatesHandlerKeyField, id);
+ cert_dict.Set(kCertificatesHandlerNameField, cert_info->name());
+ cert_dict.Set(kCertificatesHandlerCanBeDeletedField,
+ CanDeleteCertificate(cert_info));
+ cert_dict.Set(kCertificatesHandlerCanBeEditedField,
+ CanEditCertificate(cert_info));
+ cert_dict.Set(kCertificatesHandlerUntrustedField, cert_info->untrusted());
+ cert_dict.Set(kCertificatesHandlerPolicyInstalledField,
+ cert_info->source() ==
+ CertificateManagerModel::CertInfo::Source::kPolicy);
+ cert_dict.Set(kCertificatesHandlerWebTrustAnchorField,
+ cert_info->web_trust_anchor());
// TODO(hshi): This should be determined by testing for PKCS #11
// CKA_EXTRACTABLE attribute. We may need to use the NSS function
// PK11_ReadRawAttribute to do that.
- cert_dict.GetDict().Set(kCertificatesHandlerExtractableField,
- base::Value(!cert_info->hardware_backed()));
+ cert_dict.Set(kCertificatesHandlerExtractableField,
+ !cert_info->hardware_backed());
// TODO(mattm): Other columns.
subnodes.Append(std::move(cert_dict));
@@ -1110,31 +1106,27 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name,
cert_info->source() ==
CertificateManagerModel::CertInfo::Source::kPolicy;
}
- std::sort(subnodes.GetListDeprecated().begin(),
- subnodes.GetListDeprecated().end(), comparator);
+ std::sort(subnodes.begin(), subnodes.end(), comparator);
- org_dict.GetDict().Set(kCertificatesHandlerContainsPolicyCertsField,
- base::Value(contains_policy_certs));
- org_dict.GetDict().Set(kCertificatesHandlerSubnodesField,
- std::move(subnodes));
+ org_dict.Set(kCertificatesHandlerContainsPolicyCertsField,
+ contains_policy_certs);
+ org_dict.Set(kCertificatesHandlerSubnodesField, std::move(subnodes));
nodes.Append(std::move(org_dict));
}
- std::sort(nodes.GetListDeprecated().begin(), nodes.GetListDeprecated().end(),
- comparator);
+ std::sort(nodes.begin(), nodes.end(), comparator);
if (IsJavascriptAllowed()) {
- FireWebUIListener("certificates-changed", base::Value(tab_name),
- std::move(nodes));
+ FireWebUIListener("certificates-changed", base::Value(tab_name), nodes);
}
}
-void CertificatesHandler::ResolveCallback(const base::Value& response) {
+void CertificatesHandler::ResolveCallback(const base::ValueView response) {
DCHECK(!webui_callback_id_.empty());
ResolveJavascriptCallback(base::Value(webui_callback_id_), response);
webui_callback_id_.clear();
}
-void CertificatesHandler::RejectCallback(const base::Value& response) {
+void CertificatesHandler::RejectCallback(const base::ValueView response) {
DCHECK(!webui_callback_id_.empty());
RejectJavascriptCallback(base::Value(webui_callback_id_), response);
webui_callback_id_.clear();
@@ -1142,10 +1134,10 @@ void CertificatesHandler::RejectCallback(const base::Value& response) {
void CertificatesHandler::RejectCallbackWithError(const std::string& title,
const std::string& error) {
- std::unique_ptr<base::DictionaryValue> error_info(new base::DictionaryValue);
- error_info->GetDict().Set(kCertificatesHandlerErrorTitle, title);
- error_info->GetDict().Set(kCertificatesHandlerErrorDescription, error);
- RejectCallback(*error_info);
+ base::Value::Dict error_info;
+ error_info.Set(kCertificatesHandlerErrorTitle, title);
+ error_info.Set(kCertificatesHandlerErrorDescription, error);
+ RejectCallback(error_info);
}
void CertificatesHandler::RejectCallbackWithImportError(
@@ -1177,8 +1169,8 @@ void CertificatesHandler::RejectCallbackWithImportError(
error_info.Set(kCertificatesHandlerErrorTitle, title);
error_info.Set(kCertificatesHandlerErrorDescription, error);
error_info.Set(kCertificatesHandlerCertificateErrors,
- base::Value(std::move(cert_error_list)));
- RejectCallback(base::Value(std::move(error_info)));
+ std::move(cert_error_list));
+ RejectCallback(error_info);
}
gfx::NativeWindow CertificatesHandler::GetParentWindow() {
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.h b/chromium/chrome/browser/ui/webui/certificates_handler.h
index cfe6018a617..93bb4716107 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.h
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.h
@@ -166,6 +166,7 @@ class CertificatesHandler : public content::WebUIMessageHandler,
// Delete certificate and private key (if any).
void HandleDeleteCertificate(const base::Value::List& args);
+ void OnCertificateDeleted(bool result);
// Model initialization methods.
void OnCertificateManagerModelCreated(
@@ -178,8 +179,8 @@ class CertificatesHandler : public content::WebUIMessageHandler,
// Populate the given tab's tree.
void PopulateTree(const std::string& tab_name, net::CertType type);
- void ResolveCallback(const base::Value& response);
- void RejectCallback(const base::Value& response);
+ void ResolveCallback(const base::ValueView response);
+ void RejectCallback(const base::ValueView response);
// Reject the pending JS callback with a generic error.
void RejectCallbackWithError(const std::string& title,
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc b/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc
index a3535e4ce68..56c20719ae6 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/certificates_handler.h"
+#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
@@ -41,7 +42,7 @@ class CertificateHandlerTest : public ChromeRenderViewHostTestHarness {
protected:
content::TestWebUI web_ui_;
certificate_manager::CertificatesHandler cert_handler_;
- sync_preferences::TestingPrefServiceSyncable* pref_service_ = nullptr;
+ raw_ptr<sync_preferences::TestingPrefServiceSyncable> pref_service_ = nullptr;
};
#if BUILDFLAG(IS_CHROMEOS)
diff --git a/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_configs_chromeos.cc b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_configs_chromeos.cc
index 8deab0183e2..19cfa87876d 100644
--- a/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_configs_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_configs_chromeos.cc
@@ -22,7 +22,9 @@
#include "chrome/browser/ash/web_applications/terminal_ui.h"
#if !defined(OFFICIAL_BUILD)
-#include "ash/webui/sample_system_web_app_ui/untrusted_sample_system_web_app_ui.h"
+#include "ash/webui/demo_mode_app_ui/demo_mode_app_untrusted_ui.h"
+#include "ash/webui/sample_system_web_app_ui/sample_system_web_app_untrusted_ui.h"
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#endif // !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@@ -57,7 +59,10 @@ void RegisterAshChromeUntrustedWebUIConfigs() {
}
#if !defined(OFFICIAL_BUILD)
map.AddUntrustedWebUIConfig(
- std::make_unique<ash::UntrustedSampleSystemWebAppUIConfig>());
+ std::make_unique<ash::SampleSystemWebAppUntrustedUIConfig>());
+ map.AddUntrustedWebUIConfig(
+ std::make_unique<ash::DemoModeAppUntrustedUIConfig>(base::BindRepeating(
+ [] { return ash::DemoSession::Get()->DemoAppComponentPath(); })));
#endif // !defined(OFFICIAL_BUILD)
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc b/chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc
index 0ed25e92c31..e6ae33c9769 100644
--- a/chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc
@@ -220,7 +220,6 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://dino",
// TODO(crbug.com/1113446): Test failure due to excessive output.
// "chrome://discards",
- "chrome://domain-reliability-internals",
"chrome://download-internals",
"chrome://downloads",
"chrome://extensions",
@@ -316,8 +315,6 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://linux-proxy-config",
"chrome://multidevice-setup",
"chrome://network",
- // TODO(crbug.com/1329058): Eliminate chrome://oobe/login
- "chrome://oobe/login",
"chrome://os-credits",
"chrome://os-settings",
"chrome://power",
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_ui_configs_chromeos.cc b/chromium/chrome/browser/ui/webui/chrome_web_ui_configs_chromeos.cc
index e97fe32d45f..f3155a4d853 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_ui_configs_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_web_ui_configs_chromeos.cc
@@ -8,8 +8,10 @@
#include "content/public/browser/webui_config_map.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/webui/shortcut_customization_ui/shortcut_customization_app_ui.h"
+#include "chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h"
#if !defined(OFFICIAL_BUILD)
-#include "ash/webui/demo_mode_app_ui/demo_mode_app_ui.h"
+#include "ash/webui/facial_ml_app_ui/facial_ml_app_ui.h"
#include "ash/webui/sample_system_web_app_ui/sample_system_web_app_ui.h"
#endif // !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@@ -18,10 +20,12 @@ namespace {
#if BUILDFLAG(IS_CHROMEOS_ASH)
void RegisterAshChromeWebUIConfigs() {
// Add `WebUIConfig`s for Ash ChromeOS to the list here.
-#if !defined(OFFICIAL_BUILD)
auto& map = content::WebUIConfigMap::GetInstance();
+ map.AddWebUIConfig(std::make_unique<ash::ShortcutCustomizationAppUIConfig>());
+ map.AddWebUIConfig(std::make_unique<chromeos::NotificationTesterUIConfig>());
+#if !defined(OFFICIAL_BUILD)
+ map.AddWebUIConfig(std::make_unique<ash::FacialMLAppUIConfig>());
map.AddWebUIConfig(std::make_unique<ash::SampleSystemWebAppUIConfig>());
- map.AddWebUIConfig(std::make_unique<ash::DemoModeAppUIConfig>());
#endif // !defined(OFFICIAL_BUILD)
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 8b770c0965a..822f9cdc574 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/webui/about_ui.h"
#include "chrome/browser/ui/webui/apc_internals/apc_internals_ui.h"
@@ -38,13 +39,13 @@
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/crashes_ui.h"
#include "chrome/browser/ui/webui/device_log_ui.h"
-#include "chrome/browser/ui/webui/domain_reliability_internals_ui.h"
#include "chrome/browser/ui/webui/download_internals/download_internals_ui.h"
#include "chrome/browser/ui/webui/engagement/site_engagement_ui.h"
#include "chrome/browser/ui/webui/flags/flags_ui.h"
#include "chrome/browser/ui/webui/gcm_internals_ui.h"
#include "chrome/browser/ui/webui/internals/internals_ui.h"
#include "chrome/browser/ui/webui/interstitials/interstitial_ui.h"
+#include "chrome/browser/ui/webui/intro/intro_ui.h"
#include "chrome/browser/ui/webui/invalidations/invalidations_ui.h"
#include "chrome/browser/ui/webui/local_state/local_state_ui.h"
#include "chrome/browser/ui/webui/log_web_ui_url.h"
@@ -148,11 +149,13 @@
#include "chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h"
+#include "chrome/browser/ui/webui/password_manager/password_manager_ui.h"
#include "chrome/browser/ui/webui/privacy_sandbox/privacy_sandbox_dialog_ui.h"
#include "chrome/browser/ui/webui/profile_internals/profile_internals_ui.h"
#include "chrome/browser/ui/webui/settings/settings_ui.h"
#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h"
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h"
#include "chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h"
@@ -164,6 +167,7 @@
#include "chrome/browser/ui/webui/webui_gallery/webui_gallery_ui.h"
#include "chrome/browser/ui/webui/whats_new/whats_new_ui.h"
#include "chrome/browser/web_applications/web_app_provider.h"
+#include "components/password_manager/core/common/password_manager_features.h"
#include "media/base/media_switches.h"
#endif // BUILDFLAG(IS_ANDROID)
@@ -209,11 +213,10 @@
#include "ash/webui/scanning/url_constants.h"
#include "ash/webui/shimless_rma/shimless_rma.h"
#include "ash/webui/shimless_rma/url_constants.h"
-#include "ash/webui/shortcut_customization_ui/shortcut_customization_app_ui.h"
-#include "ash/webui/shortcut_customization_ui/url_constants.h"
#include "ash/webui/system_extensions_internals_ui/system_extensions_internals_ui.h"
#include "ash/webui/system_extensions_internals_ui/url_constants.h"
#include "base/system/sys_info.h"
+#include "build/config/chromebox_for_meetings/buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/ash/arc/arc_util.h"
#include "chrome/browser/ash/device_sync/device_sync_client_factory.h"
@@ -252,6 +255,7 @@
#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h"
#include "chrome/browser/ui/webui/chromeos/certificate_manager_dialog_ui.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h"
#include "chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.h"
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h"
#include "chrome/browser/ui/webui/chromeos/cryptohome_ui.h"
@@ -265,6 +269,7 @@
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/launcher_internals/launcher_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
#include "chrome/browser/ui/webui/chromeos/network_ui.h"
@@ -281,7 +286,6 @@
#include "chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.h"
#include "chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
-#include "chrome/common/chrome_switches.h"
#include "chromeos/services/network_health/public/mojom/network_diagnostics.mojom.h" // nogncheck
#include "chromeos/services/network_health/public/mojom/network_health.mojom.h" // nogncheck
#include "content/public/common/content_switches.h"
@@ -310,6 +314,7 @@
#endif
#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID)
+#include "chrome/browser/ui/webui/app_home/app_home_ui.h"
#include "chrome/browser/ui/webui/app_settings/web_app_settings_ui.h"
#include "chrome/browser/ui/webui/browser_switch/browser_switch_ui.h"
#include "chrome/browser/ui/webui/welcome/helpers.h"
@@ -344,7 +349,7 @@
#include "chrome/browser/ui/webui/connectors_internals/connectors_internals_ui.h"
#endif
-#if BUILDFLAG(USE_NSS_CERTS) && defined(USE_AURA)
+#if BUILDFLAG(ENABLE_WEBUI_CERTIFICATE_VIEWER)
#include "chrome/browser/ui/webui/certificate_viewer_ui.h"
#endif
@@ -751,8 +756,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<CrashesUI>;
if (url.host_piece() == chrome::kChromeUIDeviceLogHost)
return &NewWebUI<chromeos::DeviceLogUI>;
- if (url.host_piece() == chrome::kChromeUIDomainReliabilityInternalsHost)
- return &NewWebUI<DomainReliabilityInternalsUI>;
if (url.host_piece() == chrome::kChromeUIDownloadInternalsHost)
return &NewWebUI<DownloadInternalsUI>;
if (url.host_piece() == chrome::kChromeUIFlagsHost &&
@@ -821,7 +824,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIAppLauncherPageHost && profile &&
extensions::ExtensionSystem::Get(profile)->extension_service() &&
!profile->IsGuestSession()) {
- return &NewWebUI<AppLauncherPageUI>;
+ if (base::FeatureList::IsEnabled(features::kDesktopPWAsAppHomePage)) {
+ return &NewWebUI<webapps::AppHomeUI>;
+ } else {
+ return &NewWebUI<AppLauncherPageUI>;
+ }
}
#endif // !BUILDFLAG(IS_CHROMEOS)
if (profile->IsGuestSession() &&
@@ -838,6 +845,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
// Bookmarks are part of NTP on Android.
if (url.host_piece() == chrome::kChromeUIBookmarksHost)
return &NewWebUI<BookmarksUI>;
+ if (url.host_piece() == chrome::kChromeUIPasswordManagerHost &&
+ base::FeatureList::IsEnabled(
+ password_manager::features::kPasswordManagerRedesign))
+ return &NewWebUI<PasswordManagerUI>;
if (url.host_piece() == chrome::kChromeUICommanderHost)
return &NewWebUI<CommanderUI>;
// Downloads list on Android uses the built-in download manager.
@@ -860,6 +871,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<ReadingListUI>;
if (url.host_piece() == chrome::kChromeUIBookmarksSidePanelHost)
return &NewWebUI<BookmarksSidePanelUI>;
+ if (url.host_piece() == chrome::kChromeUICustomizeChromeSidePanelHost)
+ return &NewWebUI<CustomizeChromeUI>;
if (base::FeatureList::IsEnabled(features::kSidePanelJourneys)) {
if (url.host_piece() == chrome::kChromeUIHistoryClustersSidePanelHost)
return &NewWebUI<HistoryClustersSidePanelUI>;
@@ -887,7 +900,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (!base::FeatureList::IsEnabled(features::kAccessCodeCastUI)) {
return nullptr;
}
- if (!media_router::GetAccessCodeCastEnabledPref(profile->GetPrefs())) {
+ if (!media_router::GetAccessCodeCastEnabledPref(profile)) {
return nullptr;
}
return &NewWebUI<media_router::AccessCodeCastUI>;
@@ -929,13 +942,15 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::UrgentPasswordExpiryNotificationUI>;
}
if (url.host_piece() == chrome::kChromeUILockScreenStartReauthHost) {
- if (!ash::features::IsSamlReauthenticationOnLockscreenEnabled()) {
+ if (!ash::features::IsSamlReauthenticationOnLockscreenEnabled() ||
+ !ash::ProfileHelper::IsLockScreenProfile(profile)) {
return nullptr;
}
return &NewWebUI<chromeos::LockScreenStartReauthUI>;
}
if (url.host_piece() == chrome::kChromeUILockScreenNetworkHost) {
- if (!ash::features::IsSamlReauthenticationOnLockscreenEnabled()) {
+ if (!ash::features::IsSamlReauthenticationOnLockscreenEnabled() ||
+ !ash::ProfileHelper::IsLockScreenProfile(profile)) {
return nullptr;
}
return &NewWebUI<chromeos::LockScreenNetworkUI>;
@@ -947,8 +962,12 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewComponentUI<ash::file_manager::FileManagerUI,
ChromeFileManagerUIDelegate>;
}
- if (url.host_piece() == chrome::kChromeUINotificationTesterHost)
- return &NewWebUI<chromeos::NotificationTesterUI>;
+ if (url.host_piece() == chrome::kChromeUICloudUploadHost) {
+ if (!ash::features::IsUploadOfficeToCloudEnabled()) {
+ return nullptr;
+ }
+ return &NewWebUI<chromeos::cloud_upload::CloudUploadUI>;
+ }
if (url.host_piece() == chrome::kChromeUIAccountManagerErrorHost)
return &NewWebUI<chromeos::AccountManagerErrorUI>;
if (url.host_piece() == chrome::kChromeUIAccountMigrationWelcomeHost)
@@ -983,6 +1002,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewComponentUI<ash::HelpAppUI, ash::ChromeHelpAppUIDelegate>;
if (url.host_piece() == chrome::kChromeUIHumanPresenceInternalsHost)
return &NewWebUI<chromeos::HumanPresenceInternalsUI>;
+ if (url.host_piece() == chrome::kChromeUIManageMirrorSyncHost &&
+ ash::features::IsDriveFsMirroringEnabled()) {
+ return &NewWebUI<chromeos::ManageMirrorSyncUI>;
+ }
if (url.host_piece() == chrome::kChromeUIMobileSetupHost)
return &NewWebUI<chromeos::cellular_setup::MobileSetupUI>;
if (url.host_piece() == chrome::kChromeUIMultiDeviceInternalsHost)
@@ -992,13 +1015,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUINetworkHost)
return &NewWebUI<chromeos::NetworkUI>;
if (url.host_piece() == chrome::kChromeUIOobeHost) {
- // TODO(crbug.com/1329058): Eliminate chrome://oobe/login and fix OOBE tests
- // running inside the session.
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
- command_line->HasSwitch(::switches::kTestType);
- if (ash::ProfileHelper::IsSigninProfile(profile) ||
- (url.path() == "/login" && is_running_test)) {
+ if (ash::ProfileHelper::IsSigninProfile(profile)) {
return &NewWebUI<chromeos::OobeUI>;
}
return nullptr;
@@ -1021,10 +1038,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
if (url.host_piece() == ash::kChromeUIMediaAppHost)
return &NewComponentUI<ash::MediaAppUI, ChromeMediaAppUIDelegate>;
- if (features::IsShortcutCustomizationAppEnabled()) {
- if (url.host_piece() == ash::kChromeUIShortcutCustomizationAppHost)
- return &NewWebUI<ash::ShortcutCustomizationAppUI>;
- }
if (ash::features::IsFirmwareUpdaterAppEnabled()) {
if (url.host_piece() == ash::kChromeUIFirmwareUpdateAppHost)
return &NewWebUI<ash::FirmwareUpdateAppUI>;
@@ -1099,8 +1112,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::VmUI>;
}
if (url.host_piece() ==
- ash::personalization_app::kChromeUIPersonalizationAppHost &&
- chromeos::features::IsWallpaperWebUIEnabled()) {
+ ash::personalization_app::kChromeUIPersonalizationAppHost) {
return &NewWebUI<ash::personalization_app::PersonalizationAppUI>;
}
if (url.host_piece() == ash::kChromeUISystemExtensionsInternalsHost &&
@@ -1162,6 +1174,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID)
if (url.host_piece() == chrome::kChromeUIEnterpriseProfileWelcomeHost)
return &NewWebUI<EnterpriseProfileWelcomeUI>;
+ if (url.host_piece() == chrome::kChromeUIIntroHost &&
+ base::FeatureList::IsEnabled(kForYouFre))
+ return &NewWebUI<IntroUI>;
if (url.host_piece() == chrome::kChromeUIProfileCustomizationHost)
return &NewWebUI<ProfileCustomizationUI>;
if (url.host_piece() == chrome::kChromeUIProfilePickerHost)
@@ -1184,10 +1199,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUITabModalConfirmDialogHost)
return &NewWebUI<ConstrainedWebDialogUI>;
#endif
-#if BUILDFLAG(USE_NSS_CERTS) && defined(USE_AURA)
+
+#if BUILDFLAG(ENABLE_WEBUI_CERTIFICATE_VIEWER)
if (url.host_piece() == chrome::kChromeUICertificateViewerHost)
return &NewWebUI<CertificateViewerUI>;
-#endif // USE_NSS_CERTS && USE_AURA
+#endif // ENABLE_WEBUI_CERTIFICATE_VIEWER
if (url.host_piece() == chrome::kChromeUIPolicyHost)
return &NewWebUI<PolicyUI>;
@@ -1258,10 +1274,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_FUCHSIA)
- if (base::FeatureList::IsEnabled(features::kDesktopPWAsWebAppSettingsPage) &&
- url.host_piece() == chrome::kChromeUIWebAppSettingsHost) {
+ if (url.host_piece() == chrome::kChromeUIWebAppSettingsHost)
return &NewWebUI<WebAppSettingsUI>;
- }
#endif
if (IsAboutUI(url))
return &NewWebUI<AboutUI>;
@@ -1539,56 +1553,89 @@ std::vector<GURL> ChromeWebUIControllerFactory::GetListOfAcceptableURLs() {
return std::vector<GURL>{
GURL(chrome::kChromeUIUntrustedCroshURL),
GURL(ash::file_manager::kChromeUIFileManagerUntrustedURL),
- GURL(chrome::kChromeUIUntrustedTerminalURL), GURL(chrome::kOsUIAboutURL),
+ GURL(chrome::kChromeUIUntrustedTerminalURL),
+ GURL(chrome::kOsUIAboutURL),
GURL(chrome::kChromeUIAccountManagerErrorURL),
GURL(chrome::kOsUIAccountManagerErrorURL),
GURL(chrome::kChromeUIAccountMigrationWelcomeURL),
GURL(chrome::kOsUIAccountMigrationWelcomeURL),
GURL(chrome::kChromeUIAddSupervisionURL),
GURL(chrome::kOsUIAddSupervisionURL),
- GURL(chrome::kChromeUIAppDisabledURL), GURL(chrome::kOsUIAppDisabledURL),
+ GURL(chrome::kChromeUIAppDisabledURL),
+ GURL(chrome::kOsUIAppDisabledURL),
+ GURL(chrome::kOsUIAppServiceInternalsURL),
+ GURL(chrome::kOsUIBluetoothInternalsURL),
GURL(chrome::kChromeUIArcGraphicsTracingURL),
GURL(chrome::kChromeUIArcOverviewTracingURL),
GURL(chrome::kChromeUIArcPowerControlURL),
GURL(chrome::kChromeUIAssistantOptInURL),
GURL(chrome::kChromeUIBluetoothPairingURL),
- GURL(chrome::kOsUIComponentsURL), GURL(chrome::kChromeUICrashesUrl),
- GURL(chrome::kOsUICrashesURL), GURL(chrome::kOsUICreditsURL),
+ GURL(ash::kChromeUICameraAppURL),
+ GURL(chrome::kOsUIComponentsURL),
+ GURL(chrome::kChromeUICrashesUrl),
+ GURL(chrome::kOsUICrashesURL),
+ GURL(chrome::kOsUICreditsURL),
GURL(chrome::kChromeUIBorealisCreditsURL),
GURL(chrome::kChromeUICrostiniCreditsURL),
GURL(chrome::kChromeUICrostiniInstallerUrl),
GURL(chrome::kChromeUICrostiniUpgraderUrl),
- GURL(chrome::kChromeUICryptohomeURL), GURL(chrome::kOsUIDeviceLogURL),
+ GURL(chrome::kChromeUICryptohomeURL),
+ GURL(chrome::kOsUIDeviceLogURL),
GURL(chrome::kChromeUIDiagnosticsAppURL),
GURL(chrome::kChromeUIDriveInternalsUrl),
GURL(chrome::kOsUIDriveInternalsURL),
- GURL(chrome::kChromeUIEmojiPickerURL), GURL(chrome::kOsUIEmojiPickerURL),
+ GURL(chrome::kChromeUIEmojiPickerURL),
+ GURL(chrome::kOsUIEmojiPickerURL),
GURL(ash::file_manager::kChromeUIFileManagerURL),
- GURL(chrome::kChromeUIFlagsURL), GURL(chrome::kOsUIFlagsURL),
- GURL(chrome::kOsUIGpuURL), GURL(chrome::kOsUIHistogramsURL),
+ GURL(chrome::kChromeUICloudUploadURL),
+ GURL(chrome::kChromeUIFlagsURL),
+ GURL(chrome::kOsUIFlagsURL),
+ GURL(chrome::kOsUIGpuURL),
+ GURL(chrome::kOsUIHistogramsURL),
+ GURL(chrome::kChromeUIHumanPresenceInternalsURL),
GURL(chrome::kChromeUIIntenetConfigDialogURL),
GURL(chrome::kChromeUIIntenetDetailDialogURL),
GURL(chrome::kOsUIInvalidationsURL),
GURL(chrome::kChromeUILockScreenNetworkURL),
GURL(chrome::kChromeUILockScreenStartReauthURL),
+ GURL(chrome::kChromeUIManageMirrorSyncURL),
GURL(chrome::kChromeUIMultiDeviceSetupUrl),
- GURL(chrome::kChromeUINetworkUrl), GURL(chrome::kOsUINetworkURL),
- GURL(chrome::kChromeUIOSCreditsURL), GURL(chrome::kChromeUIPowerUrl),
+ GURL(chrome::kChromeUINetworkUrl),
+ GURL(chrome::kOsUINetworkURL),
+ GURL(chrome::kChromeUIOSCreditsURL),
+ GURL(chrome::kChromeUIPowerUrl),
GURL(chrome::kChromeUIPrintManagementUrl),
GURL(ash::multidevice::kChromeUIProximityAuthURL),
- GURL(chrome::kOsUIRestartURL), GURL(chrome::kChromeUIScanningAppURL),
- GURL(chrome::kOsUIScanningAppURL), GURL(chrome::kChromeUISetTimeURL),
- GURL(chrome::kChromeUIOSSettingsURL), GURL(chrome::kOsUISettingsURL),
- GURL(chrome::kOsUISettingsURL), GURL(chrome::kOsUISignInInternalsURL),
- GURL(chrome::kChromeUISlowURL), GURL(chrome::kChromeUISmbShareURL),
- GURL(chrome::kOsUISyncInternalsURL), GURL(chrome::kOsUISysInternalsUrl),
- GURL(chrome::kOsUITermsURL), GURL(chrome::kChromeUIUserImageURL),
- GURL(chrome::kOsUIVersionURL), GURL(chrome::kChromeUIVmUrl),
- GURL(chrome::kOsUISystemURL), GURL(chrome::kOsUIHelpAppURL),
- // The CL to land this didn't land yet. Once landed they need to be moved
- // to Lacros. However - as the refactor might precede this, there is no
- // TODO for it.
- GURL(chrome::kChromeUICertificateManagerDialogURL)};
+ GURL(ash::multidevice::kOsUIProximityAuthURL),
+ GURL(chrome::kChromeUINearbyInternalsURL),
+ GURL(chrome::kOsUINearbyInternalsURL),
+ GURL(chrome::kChromeUIMultiDeviceInternalsURL),
+ GURL(chrome::kOsUIMultiDeviceInternalsURL),
+ GURL(chrome::kOsUIRestartURL),
+ GURL(chrome::kChromeUIScanningAppURL),
+ GURL(chrome::kOsUIConnectivityDiagnosticsAppURL),
+ GURL(chrome::kOsUIDiagnosticsAppURL),
+ GURL(chrome::kOsUIFirmwareUpdaterAppURL),
+ GURL(chrome::kOsUIPrintManagementAppURL),
+ GURL(chrome::kOsUIRestartURL),
+ GURL(chrome::kOsUIScanningAppURL),
+ GURL(chrome::kChromeUISetTimeURL),
+ GURL(chrome::kChromeUIOSSettingsURL),
+ GURL(chrome::kOsUISettingsURL),
+ GURL(chrome::kOsUISettingsURL),
+ GURL(chrome::kOsUISignInInternalsURL),
+ GURL(chrome::kChromeUISlowURL),
+ GURL(chrome::kChromeUISmbShareURL),
+ GURL(chrome::kOsUISyncInternalsURL),
+ GURL(chrome::kOsUISysInternalsUrl),
+ GURL(chrome::kOsUITermsURL),
+ GURL(chrome::kChromeUIUserImageURL),
+ GURL(chrome::kOsUIVersionURL),
+ GURL(chrome::kChromeUIVmUrl),
+ GURL(chrome::kOsUISystemURL),
+ GURL(chrome::kOsUIHelpAppURL),
+ GURL(chrome::kOsUINetExportURL),
+ GURL(chrome::kOsUILauncherInternalsURL)};
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
return std::vector<GURL>{GURL(chrome::kChromeUIAboutURL),
GURL(chrome::kChromeUIComponentsUrl),
diff --git a/chromium/chrome/browser/ui/webui/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/OWNERS
index 0647ada3d09..8816a6e534f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/OWNERS
@@ -1,8 +1,4 @@
-achuith@chromium.org
-hidehiko@chromium.org
-khorimoto@chromium.org
-michaelpg@chromium.org
-xiyuan@chromium.org
+file://ash/webui/PLATFORM_OWNERS
per-file *bluetooth*=file://ui/webui/resources/cr_components/chromeos/bluetooth/OWNERS
per-file *net*=file://ui/webui/resources/cr_components/chromeos/network/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc
index 0a653ddd98c..f1f73d8d105 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc
@@ -21,7 +21,7 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui)
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
chrome::kChromeUIAccountManagerErrorHost);
- web_ui->RegisterDeprecatedMessageCallback(
+ web_ui->RegisterMessageCallback(
"closeDialog", base::BindRepeating(&WebDialogUI::CloseDialog,
weak_factory_.GetWeakPtr()));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc
index 34bdd928b00..1351ce3af38 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc
@@ -44,23 +44,23 @@ class MigrationMessageHandler : public content::WebUIMessageHandler {
private:
void RegisterMessages() override {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"reauthenticateAccount",
base::BindRepeating(
&MigrationMessageHandler::HandleReauthenticateAccount,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"closeDialog",
base::BindRepeating(&MigrationMessageHandler::HandleCloseDialog,
base::Unretained(this)));
}
// WebUI "reauthenticateAccount" message callback.
- void HandleReauthenticateAccount(const base::ListValue* args) {
+ void HandleReauthenticateAccount(const base::Value::List& args) {
AllowJavascript();
- CHECK(!args->GetListDeprecated().empty());
- const std::string& account_email = args->GetListDeprecated()[0].GetString();
+ CHECK(!args.empty());
+ const std::string& account_email = args[0].GetString();
Profile* profile = Profile::FromWebUI(web_ui());
::GetAccountManagerFacade(profile->GetPath().value())
@@ -71,7 +71,7 @@ class MigrationMessageHandler : public content::WebUIMessageHandler {
HandleCloseDialog(args);
}
- void HandleCloseDialog(const base::ListValue* args) {
+ void HandleCloseDialog(const base::Value::List& args) {
AllowJavascript();
close_dialog_closure_.Run();
@@ -120,7 +120,7 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(std::make_unique<MigrationMessageHandler>(
base::BindRepeating(&WebDialogUI::CloseDialog, weak_factory_.GetWeakPtr(),
- nullptr /* args */)));
+ base::Value::List() /* args */)));
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc
index 2640236a92b..efda029d6e8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_handler_utils.h"
+#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/app_update.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -11,15 +12,16 @@ using AddSupervisionHandlerUtilsTest = testing::Test;
// Tests that only the right apps are returned via the API.
TEST_F(AddSupervisionHandlerUtilsTest, TestShouldIncludeAppUpdate) {
// Return ARC apps.
- apps::mojom::App arc_state;
- arc_state.app_type = apps::mojom::AppType::kArc;
- apps::AppUpdate arc_update(&arc_state, nullptr /* delta */, EmptyAccountId());
+ auto arc_state =
+ std::make_unique<apps::App>(apps::AppType::kArc, "arc_app_id");
+ apps::AppUpdate arc_update(arc_state.get(), nullptr /* delta */,
+ EmptyAccountId());
EXPECT_TRUE(ShouldIncludeAppUpdate(arc_update));
// Don't return non-ARC apps.
- apps::mojom::App non_arc_state;
- non_arc_state.app_type = apps::mojom::AppType::kBuiltIn;
- apps::AppUpdate non_arc_update(&non_arc_state, nullptr /* delta */,
+ auto non_arc_state =
+ std::make_unique<apps::App>(apps::AppType::kBuiltIn, "builtin_app_id");
+ apps::AppUpdate non_arc_update(non_arc_state.get(), nullptr /* delta */,
EmptyAccountId());
EXPECT_FALSE(ShouldIncludeAppUpdate(non_arc_update));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
index bff93003357..4ae91e3bbfd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
@@ -90,9 +90,7 @@ std::pair<base::Value, std::string> MaybeLoadLastGraphicsModel(
return std::make_pair(base::Value(), "Failed to read last tracing model");
arc::ArcTracingGraphicsModel graphics_model;
- base::DictionaryValue* dictionary = nullptr;
- model->GetAsDictionary(&dictionary);
- if (!graphics_model.LoadFromValue(*dictionary)) {
+ if (!graphics_model.LoadFromValue(model->GetDict())) {
UpdateStatistics(Action::kInitialLoadFailed);
return std::make_pair(base::Value(), "Failed to load last tracing model");
}
@@ -226,11 +224,11 @@ std::pair<base::Value, std::string> BuildGraphicsModel(
graphics_model.set_app_icon_png(icon_png);
graphics_model.set_platform(base::GetLinuxDistro());
graphics_model.set_timestamp(timestamp);
- std::unique_ptr<base::DictionaryValue> model = graphics_model.Serialize();
+ base::Value::Dict model = graphics_model.Serialize();
std::string json_content;
base::JSONWriter::WriteWithOptions(
- *model, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_content);
+ model, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_content);
DCHECK(!json_content.empty());
if (!base::WriteFile(model_path, json_content.c_str(),
@@ -239,7 +237,8 @@ std::pair<base::Value, std::string> BuildGraphicsModel(
}
UpdateStatistics(Action::kBuildSucceeded);
- return std::make_pair(std::move(*model), "Tracing model is ready");
+ return std::make_pair(base::Value(std::move(model)),
+ "Tracing model is ready");
}
std::pair<base::Value, std::string> LoadGraphicsModel(
@@ -253,9 +252,10 @@ std::pair<base::Value, std::string> LoadGraphicsModel(
return std::make_pair(base::Value(), "Failed to load tracing model");
}
- std::unique_ptr<base::DictionaryValue> model = graphics_model.Serialize();
+ base::Value::Dict model = graphics_model.Serialize();
UpdateStatistics(Action::kLoadSucceeded);
- return std::make_pair(std::move(*model), "Tracing model is loaded");
+ return std::make_pair(base::Value(std::move(model)),
+ "Tracing model is loaded");
}
std::string GetJavascriptDomain(ArcGraphicsTracingMode mode) {
@@ -349,22 +349,22 @@ ArcGraphicsTracingHandler::~ArcGraphicsTracingHandler() {
}
void ArcGraphicsTracingHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"ready", base::BindRepeating(&ArcGraphicsTracingHandler::HandleReady,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"loadFromText",
base::BindRepeating(&ArcGraphicsTracingHandler::HandleLoadFromText,
base::Unretained(this)));
switch (mode_) {
case ArcGraphicsTracingMode::kFull:
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setStopOnJank",
base::BindRepeating(&ArcGraphicsTracingHandler::HandleSetStopOnJank,
base::Unretained(this)));
break;
case ArcGraphicsTracingMode::kOverview:
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setMaxTime",
base::BindRepeating(&ArcGraphicsTracingHandler::HandleSetMaxTime,
base::Unretained(this)));
@@ -600,7 +600,7 @@ void ArcGraphicsTracingHandler::OnGraphicsModelReady(
std::move(result.first));
}
-void ArcGraphicsTracingHandler::HandleReady(const base::ListValue* args) {
+void ArcGraphicsTracingHandler::HandleReady(const base::Value::List& args) {
if (mode_ != ArcGraphicsTracingMode::kFull)
return;
@@ -613,40 +613,40 @@ void ArcGraphicsTracingHandler::HandleReady(const base::ListValue* args) {
}
void ArcGraphicsTracingHandler::HandleSetStopOnJank(
- const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetListDeprecated().size());
+ const base::Value::List& args) {
+ DCHECK_EQ(1U, args.size());
DCHECK_EQ(ArcGraphicsTracingMode::kFull, mode_);
- if (!args->GetListDeprecated()[0].is_bool()) {
+ if (!args[0].is_bool()) {
LOG(ERROR) << "Invalid input";
return;
}
- stop_on_jank_ = args->GetListDeprecated()[0].GetBool();
+ stop_on_jank_ = args[0].GetBool();
}
-void ArcGraphicsTracingHandler::HandleSetMaxTime(const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetListDeprecated().size());
+void ArcGraphicsTracingHandler::HandleSetMaxTime(
+ const base::Value::List& args) {
+ DCHECK_EQ(1U, args.size());
DCHECK_EQ(ArcGraphicsTracingMode::kOverview, mode_);
- if (!args->GetListDeprecated()[0].is_int()) {
+ if (!args[0].is_int()) {
LOG(ERROR) << "Invalid input";
return;
}
- max_tracing_time_ = base::Seconds(args->GetListDeprecated()[0].GetInt());
+ max_tracing_time_ = base::Seconds(args[0].GetInt());
DCHECK_GE(max_tracing_time_, base::Seconds(1));
}
void ArcGraphicsTracingHandler::HandleLoadFromText(
- const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetListDeprecated().size());
- if (!args->GetListDeprecated()[0].is_string()) {
+ const base::Value::List& args) {
+ DCHECK_EQ(1U, args.size());
+ if (!args[0].is_string()) {
LOG(ERROR) << "Invalid input";
return;
}
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
- base::BindOnce(&LoadGraphicsModel, mode_,
- std::move(args->GetListDeprecated()[0].GetString())),
+ base::BindOnce(&LoadGraphicsModel, mode_, std::move(args[0].GetString())),
base::BindOnce(&ArcGraphicsTracingHandler::OnGraphicsModelReady,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
index 858d4d26d43..cfc6bea4f56 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
@@ -13,6 +13,7 @@
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing.h"
#include "components/exo/surface_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -29,7 +30,6 @@ class ArcSystemStatCollector;
namespace base {
class FilePath;
-class ListValue;
} // namespace base
namespace exo {
@@ -93,10 +93,10 @@ class ArcGraphicsTracingHandler : public content::WebUIMessageHandler,
void OnGraphicsModelReady(std::pair<base::Value, std::string> result);
// Handlers for calls from JS.
- void HandleReady(const base::ListValue* args);
- void HandleSetStopOnJank(const base::ListValue* args);
- void HandleSetMaxTime(const base::ListValue* args);
- void HandleLoadFromText(const base::ListValue* args);
+ void HandleReady(const base::Value::List& args);
+ void HandleSetStopOnJank(const base::Value::List& args);
+ void HandleSetMaxTime(const base::Value::List& args);
+ void HandleLoadFromText(const base::Value::List& args);
// Updates title and icon for the active ARC window.
void UpdateActiveArcWindowInfo();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc
index 132ede394d7..f9b580afae6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc
@@ -102,7 +102,7 @@ base::Value BuildTracingModel(
graphics_model.set_timestamp(timestamp);
graphics_model.Build(common_model);
- return std::move(*graphics_model.Serialize());
+ return base::Value(graphics_model.Serialize());
}
} // namespace
@@ -124,22 +124,22 @@ ArcPowerControlHandler::~ArcPowerControlHandler() {
}
void ArcPowerControlHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"ready", base::BindRepeating(&ArcPowerControlHandler::HandleReady,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setWakefulnessMode",
base::BindRepeating(&ArcPowerControlHandler::HandleSetWakefulnessMode,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setThrottling",
base::BindRepeating(&ArcPowerControlHandler::HandleSetThrottling,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"startTracing",
base::BindRepeating(&ArcPowerControlHandler::HandleStartTracing,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"stopTracing",
base::BindRepeating(&ArcPowerControlHandler::HandleStopTracing,
base::Unretained(this)));
@@ -174,7 +174,7 @@ void ArcPowerControlHandler::OnThrottle(bool throttled) {
}
}
-void ArcPowerControlHandler::HandleReady(const base::ListValue* args) {
+void ArcPowerControlHandler::HandleReady(const base::Value::List& args) {
arc::mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD(
arc::ArcServiceManager::Get()->arc_bridge_service()->power(),
GetWakefulnessMode);
@@ -195,15 +195,15 @@ void ArcPowerControlHandler::HandleReady(const base::ListValue* args) {
}
void ArcPowerControlHandler::HandleSetWakefulnessMode(
- const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetListDeprecated().size());
+ const base::Value::List& args) {
+ DCHECK_EQ(1U, args.size());
if (!power_control_enabled_) {
LOG(ERROR) << "Power control is not enabled";
return;
}
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
LOG(ERROR) << "Invalid input";
return;
}
@@ -212,7 +212,7 @@ void ArcPowerControlHandler::HandleSetWakefulnessMode(
arc::ArcServiceManager::Get()->arc_bridge_service()->power();
DCHECK(power);
- const std::string mode = args->GetListDeprecated()[0].GetString();
+ const std::string mode = args[0].GetString();
if (mode == kWakenessfullWakeUp) {
if (wakefulness_mode_ == arc::mojom::WakefulnessMode::ASLEEP) {
arc::mojom::PowerInstance* const power_instance =
@@ -240,15 +240,16 @@ void ArcPowerControlHandler::HandleSetWakefulnessMode(
}
}
-void ArcPowerControlHandler::HandleSetThrottling(const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetListDeprecated().size());
+void ArcPowerControlHandler::HandleSetThrottling(
+ const base::Value::List& args) {
+ DCHECK_EQ(1U, args.size());
if (!power_control_enabled_) {
LOG(ERROR) << "Power control is not enabled";
return;
}
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
LOG(ERROR) << "Invalid input";
return;
}
@@ -261,7 +262,7 @@ void ArcPowerControlHandler::HandleSetThrottling(const base::ListValue* args) {
return;
}
- const std::string mode = args->GetListDeprecated()[0].GetString();
+ const std::string mode = args[0].GetString();
if (mode == kThrottlingDisable) {
observer->SetActive(true);
observer->SetEnforced(true);
@@ -277,13 +278,13 @@ void ArcPowerControlHandler::HandleSetThrottling(const base::ListValue* args) {
}
}
-void ArcPowerControlHandler::HandleStartTracing(const base::ListValue* args) {
- DCHECK(!args->GetListDeprecated().size());
+void ArcPowerControlHandler::HandleStartTracing(const base::Value::List& args) {
+ DCHECK(!args.size());
StartTracing();
}
-void ArcPowerControlHandler::HandleStopTracing(const base::ListValue* args) {
- DCHECK(!args->GetListDeprecated().size());
+void ArcPowerControlHandler::HandleStopTracing(const base::Value::List& args) {
+ DCHECK(!args.size());
StopTracing();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h b/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h
index 84ad07f5c6b..2068e28b5a9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h
@@ -53,11 +53,11 @@ class ArcPowerControlHandler : public content::WebUIMessageHandler,
private:
// Handlers for calls from JS.
- void HandleReady(const base::ListValue* args);
- void HandleSetWakefulnessMode(const base::ListValue* args);
- void HandleSetThrottling(const base::ListValue* args);
- void HandleStartTracing(const base::ListValue* args);
- void HandleStopTracing(const base::ListValue* args);
+ void HandleReady(const base::Value::List& args);
+ void HandleSetWakefulnessMode(const base::Value::List& args);
+ void HandleSetThrottling(const base::Value::List& args);
+ void HandleStartTracing(const base::Value::List& args);
+ void HandleStopTracing(const base::Value::List& args);
void StartTracing();
void StopTracing();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
index 917134e234c..7c289055d86 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
@@ -28,8 +28,8 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/oobe_conditional_resources.h"
#include "chromeos/ash/components/assistant/buildflags.h"
-#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
-#include "chromeos/services/assistant/public/cpp/features.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_prefs.h"
+#include "chromeos/ash/services/assistant/public/cpp/features.h"
#include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h"
#include "content/public/browser/host_zoom_map.h"
@@ -88,8 +88,7 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
source->UseStringsJs();
source->AddResourcePaths(
base::make_span(kAssistantOptinResources, kAssistantOptinResourcesSize));
- source->AddResourcePath("assistant_optin.js", IDR_ASSISTANT_OPTIN_JS);
- source->SetDefaultResource(IDR_ASSISTANT_OPTIN_HTML);
+ source->SetDefaultResource(IDR_ASSISTANT_OPTIN_ASSISTANT_OPTIN_HTML);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
source->DisableTrustedTypesCSP();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
index 2d0e15330ec..663e4893349 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
@@ -7,7 +7,6 @@
#include <utility>
#include "ash/components/arc/arc_prefs.h"
-#include "ash/components/audio/cras_audio_handler.h"
#include "ash/constants/ash_features.h"
#include "base/containers/contains.h"
#include "base/metrics/histogram_macros.h"
@@ -16,9 +15,10 @@
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
-#include "chromeos/services/assistant/public/cpp/features.h"
-#include "chromeos/services/assistant/public/proto/activity_control_settings_common.pb.h"
+#include "chromeos/ash/components/audio/cras_audio_handler.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_prefs.h"
+#include "chromeos/ash/services/assistant/public/cpp/features.h"
+#include "chromeos/ash/services/assistant/public/proto/activity_control_settings_common.pb.h"
#include "components/consent_auditor/consent_auditor.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/consent_level.h"
@@ -31,6 +31,19 @@ using AssistantActivityControlConsent =
namespace chromeos {
+// TODO(https://crbug.com/1164001): move to forward declaration
+namespace assistant {
+using ::ash::assistant::ActivityControlSettingsUiSelector;
+using ::ash::assistant::ClassicActivityControlUiTexts;
+using ::ash::assistant::ConsentFlowUi;
+using ::ash::assistant::ConsentFlowUiSelector;
+using ::ash::assistant::ConsentFlowUiUpdate;
+using ::ash::assistant::SettingSetId;
+using ::ash::assistant::SettingsUi;
+using ::ash::assistant::SettingsUiSelector;
+using ::ash::assistant::SettingsUiUpdate;
+} // namespace assistant
+
namespace {
// Possible native assistant icons
@@ -115,102 +128,91 @@ assistant::SettingsUiUpdate GetSettingsUiUpdate(
}
// Helper method to create zippy data.
-base::Value CreateZippyData(const ActivityControlUi& activity_control_ui,
- bool is_minor_mode) {
- base::Value zippy_data(base::Value::Type::LIST);
+base::Value::List CreateZippyData(const ActivityControlUi& activity_control_ui,
+ bool is_minor_mode) {
+ base::Value::List zippy_data;
auto zippy_list = activity_control_ui.setting_zippy();
auto learn_more_dialog = activity_control_ui.learn_more_dialog();
for (auto& setting_zippy : zippy_list) {
- base::Value data(base::Value::Type::DICTIONARY);
- data.SetKey("title", base::Value(activity_control_ui.title()));
- data.SetKey("identity", base::Value(activity_control_ui.identity()));
+ base::Value::Dict data;
+ data.Set("title", activity_control_ui.title());
+ data.Set("identity", activity_control_ui.identity());
if (activity_control_ui.intro_text_paragraph_size()) {
- data.SetKey("intro",
- base::Value(activity_control_ui.intro_text_paragraph(0)));
+ data.Set("intro", activity_control_ui.intro_text_paragraph(0));
}
- data.SetKey("name", base::Value(setting_zippy.title()));
+ data.Set("name", setting_zippy.title());
if (setting_zippy.description_paragraph_size()) {
- data.SetKey("description",
- base::Value(setting_zippy.description_paragraph(0)));
+ data.Set("description", setting_zippy.description_paragraph(0));
}
if (setting_zippy.additional_info_paragraph_size()) {
- data.SetKey("additionalInfo",
- base::Value(setting_zippy.additional_info_paragraph(0)));
+ data.Set("additionalInfo", setting_zippy.additional_info_paragraph(0));
}
- data.SetKey("iconUri", base::Value(setting_zippy.icon_uri()));
- data.SetKey("nativeIconType",
- base::Value(static_cast<int>(
- SettingIdToIconType(setting_zippy.setting_set_id()))));
- data.SetKey("useNativeIcons",
- base::Value(ash::features::IsAssistantNativeIconsEnabled()));
- data.SetKey("popupLink", base::Value(l10n_util::GetStringUTF16(
- IDS_ASSISTANT_ACTIVITY_CONTROL_POPUP_LINK)));
+ data.Set("iconUri", setting_zippy.icon_uri());
+ data.Set(
+ "nativeIconType",
+ static_cast<int>(SettingIdToIconType(setting_zippy.setting_set_id())));
+ data.Set("useNativeIcons", ash::features::IsAssistantNativeIconsEnabled());
+ data.Set("popupLink", l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_ACTIVITY_CONTROL_POPUP_LINK));
if (is_minor_mode) {
- data.SetKey("learnMoreDialogTitle",
- base::Value(learn_more_dialog.title()));
+ data.Set("learnMoreDialogTitle", learn_more_dialog.title());
if (learn_more_dialog.paragraph_size()) {
- data.SetKey("learnMoreDialogContent",
- base::Value(learn_more_dialog.paragraph(0).value()));
+ data.Set("learnMoreDialogContent",
+ learn_more_dialog.paragraph(0).value());
}
} else {
- data.SetKey("learnMoreDialogTitle", base::Value(setting_zippy.title()));
+ data.Set("learnMoreDialogTitle", setting_zippy.title());
if (setting_zippy.additional_info_paragraph_size()) {
- data.SetKey("learnMoreDialogContent",
- base::Value(setting_zippy.additional_info_paragraph(0)));
+ data.Set("learnMoreDialogContent",
+ setting_zippy.additional_info_paragraph(0));
}
}
- data.SetKey("learnMoreDialogButton",
- base::Value(learn_more_dialog.dismiss_button()));
- data.SetKey("isMinorMode", base::Value(is_minor_mode));
+ data.Set("learnMoreDialogButton", learn_more_dialog.dismiss_button());
+ data.Set("isMinorMode", is_minor_mode);
zippy_data.Append(std::move(data));
}
return zippy_data;
}
// Helper method to create disclosure data.
-base::Value CreateDisclosureData(const SettingZippyList& disclosure_list) {
- base::Value disclosure_data(base::Value::Type::LIST);
+base::Value::List CreateDisclosureData(
+ const SettingZippyList& disclosure_list) {
+ base::Value::List disclosure_data;
for (auto& disclosure : disclosure_list) {
- base::Value data(base::Value::Type::DICTIONARY);
- data.SetKey("title", base::Value(disclosure.title()));
+ base::Value::Dict data;
+ data.Set("title", disclosure.title());
if (disclosure.description_paragraph_size()) {
- data.SetKey("description",
- base::Value(disclosure.description_paragraph(0)));
+ data.Set("description", disclosure.description_paragraph(0));
}
if (disclosure.additional_info_paragraph_size()) {
- data.SetKey("additionalInfo",
- base::Value(disclosure.additional_info_paragraph(0)));
+ data.Set("additionalInfo", disclosure.additional_info_paragraph(0));
}
- data.SetKey("iconUri", base::Value(disclosure.icon_uri()));
+ data.Set("iconUri", disclosure.icon_uri());
disclosure_data.Append(std::move(data));
}
return disclosure_data;
}
// Get string constants for settings ui.
-base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
- bool activity_control_needed,
- bool equal_weight_buttons) {
+base::Value::Dict GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
+ bool activity_control_needed,
+ bool equal_weight_buttons) {
auto consent_ui = settings_ui.consent_flow_ui().consent_ui();
auto activity_control_ui = consent_ui.activity_control_ui();
- base::Value dictionary(base::Value::Type::DICTIONARY);
+ base::Value::Dict dictionary;
- dictionary.SetKey("activityControlNeeded",
- base::Value(activity_control_needed));
- dictionary.SetKey("equalWeightButtons", base::Value(equal_weight_buttons));
+ dictionary.Set("activityControlNeeded", activity_control_needed);
+ dictionary.Set("equalWeightButtons", equal_weight_buttons);
// Add activity control string constants.
if (activity_control_needed) {
- dictionary.SetKey("valuePropTitle",
- base::Value(activity_control_ui.title()));
+ dictionary.Set("valuePropTitle", activity_control_ui.title());
if (activity_control_ui.footer_paragraph_size()) {
- dictionary.SetKey("valuePropFooter",
- base::Value(activity_control_ui.footer_paragraph(0)));
+ dictionary.Set("valuePropFooter",
+ activity_control_ui.footer_paragraph(0));
}
- dictionary.SetKey("valuePropNextButton",
- base::Value(consent_ui.accept_button_text()));
- dictionary.SetKey("valuePropSkipButton",
- base::Value(consent_ui.reject_button_text()));
+ dictionary.Set("valuePropNextButton", consent_ui.accept_button_text());
+ dictionary.Set("valuePropSkipButton", consent_ui.reject_button_text());
}
return dictionary;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
index 0ee6358e713..39f14ea69d1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
@@ -7,16 +7,13 @@
#include <string>
-#include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
+#include "base/values.h"
+#include "chromeos/ash/services/assistant/public/proto/settings_ui.pb.h"
#include "components/sync/protocol/user_consent_types.pb.h"
class PrefService;
class Profile;
-namespace base {
-class Value;
-} // namespace base
-
namespace chromeos {
// Type of Assistant opt-in flow status. This enum is used to back an UMA
@@ -56,27 +53,28 @@ void RecordAssistantActivityControlOptInStatus(
bool opted_in);
// Construct SettingsUiSelector for the ConsentFlow UI.
-assistant::SettingsUiSelector GetSettingsUiSelector();
+ash::assistant::SettingsUiSelector GetSettingsUiSelector();
// Construct SettingsUiUpdate for user opt-in.
-assistant::SettingsUiUpdate GetSettingsUiUpdate(
+ash::assistant::SettingsUiUpdate GetSettingsUiUpdate(
const std::string& consent_token);
using SettingZippyList = google::protobuf::RepeatedPtrField<
- assistant::ClassicActivityControlUiTexts::SettingZippy>;
+ ash::assistant::ClassicActivityControlUiTexts::SettingZippy>;
using ActivityControlUi =
- assistant::ConsentFlowUi::ConsentUi::ActivityControlUi;
+ ash::assistant::ConsentFlowUi::ConsentUi::ActivityControlUi;
// Helper method to create zippy data.
-base::Value CreateZippyData(const ActivityControlUi& activity_control_ui,
- bool is_minor_mode);
+base::Value::List CreateZippyData(const ActivityControlUi& activity_control_ui,
+ bool is_minor_mode);
// Helper method to create disclosure data.
-base::Value CreateDisclosureData(const SettingZippyList& disclosure_list);
+base::Value::List CreateDisclosureData(const SettingZippyList& disclosure_list);
// Get string constants for settings ui.
-base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
- bool activity_control_needed,
- bool equal_weight_buttons);
+base::Value::Dict GetSettingsUiStrings(
+ const ash::assistant::SettingsUi& settings_ui,
+ bool activity_control_needed,
+ bool equal_weight_buttons);
void RecordActivityControlConsent(
Profile* profile,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/audio/audio_handler.h b/chromium/chrome/browser/ui/webui/chromeos/audio/audio_handler.h
index de86c5e0ea8..732d02d55bf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/audio/audio_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/audio/audio_handler.h
@@ -7,10 +7,10 @@
#include <tuple>
-#include "ash/components/audio/audio_device.h"
-#include "ash/components/audio/cras_audio_handler.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/chromeos/audio/audio.mojom.h"
+#include "chromeos/ash/components/audio/audio_device.h"
+#include "chromeos/ash/components/audio/cras_audio_handler.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc
index 3f6fc91cfeb..b20ad15e16e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc
@@ -10,9 +10,9 @@
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_event_log.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
index a51fa223e46..62fe2eb7d97 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
@@ -7,11 +7,11 @@
#include "chrome/browser/ui/ash/network/network_connect_delegate_chromeos.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+// TODO(https://crbug.com/1164001): move to forward declaration
+#include "chromeos/ash/components/network/network_state.h"
namespace chromeos {
-class NetworkState;
-
namespace cellular_setup {
// DEPRECATED: Being replaced by new UI; see https://crbug.com/778021.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
index ec3cd3db0df..49becfead6c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
@@ -17,6 +17,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
+#include "base/scoped_observation.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -27,11 +28,11 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/device_state.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/ash/components/network/device_state.h"
+#include "chromeos/ash/components/network/network_event_log.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state_handler_observer.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
@@ -183,7 +184,7 @@ class MobileSetupUIHTMLSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string&) override { return "text/html"; }
+ std::string GetMimeType(const GURL&) override { return "text/html"; }
bool ShouldAddContentSecurityPolicy() override { return false; }
bool AllowCaching() override {
// Should not be cached to reflect dynamically-generated contents that may
@@ -233,7 +234,7 @@ class MobileSetupHandler : public content::WebUIMessageHandler,
void Reset();
// Handlers for JS WebUI messages.
- void HandleGetDeviceInfo(const base::ListValue* args);
+ void HandleGetDeviceInfo(const base::Value::List& args);
// NetworkStateHandlerObserver implementation.
void NetworkConnectionStateChanged(const NetworkState* network) override;
@@ -253,6 +254,11 @@ class MobileSetupHandler : public content::WebUIMessageHandler,
// connection state. This value is reflected in portal webui for lte networks.
// Initial value is true.
bool lte_portal_reachable_;
+
+ base::ScopedObservation<chromeos::NetworkStateHandler,
+ chromeos::NetworkStateHandlerObserver>
+ network_state_handler_observer_{this};
+
base::WeakPtrFactory<MobileSetupHandler> weak_ptr_factory_{this};
};
@@ -311,19 +317,16 @@ void MobileSetupUIHTMLSource::StartDataRequest(
}
NET_LOG(EVENT) << "Starting mobile setup: " << NetworkId(network);
- base::DictionaryValue strings;
-
- strings.SetStringKey(
- "view_account_error_title",
- l10n_util::GetStringUTF16(IDS_MOBILE_VIEW_ACCOUNT_ERROR_TITLE));
- strings.SetStringKey(
- "view_account_error_message",
- l10n_util::GetStringUTF16(IDS_MOBILE_VIEW_ACCOUNT_ERROR_MESSAGE));
- strings.SetStringKey("title",
- l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
- strings.SetStringKey("close_button", l10n_util::GetStringUTF16(IDS_CLOSE));
- strings.SetStringKey("cancel_button", l10n_util::GetStringUTF16(IDS_CANCEL));
- strings.SetStringKey("ok_button", l10n_util::GetStringUTF16(IDS_OK));
+ base::Value::Dict strings;
+
+ strings.Set("view_account_error_title",
+ l10n_util::GetStringUTF16(IDS_MOBILE_VIEW_ACCOUNT_ERROR_TITLE));
+ strings.Set("view_account_error_message",
+ l10n_util::GetStringUTF16(IDS_MOBILE_VIEW_ACCOUNT_ERROR_MESSAGE));
+ strings.Set("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
+ strings.Set("close_button", l10n_util::GetStringUTF16(IDS_CLOSE));
+ strings.Set("cancel_button", l10n_util::GetStringUTF16(IDS_CANCEL));
+ strings.Set("ok_button", l10n_util::GetStringUTF16(IDS_OK));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &strings);
@@ -331,10 +334,10 @@ void MobileSetupUIHTMLSource::StartDataRequest(
// mobile_setup_ui.cc will only be triggered from the detail page for
// activated cellular network.
DCHECK(network->activation_state() == shill::kActivationStateActivated);
- static const base::NoDestructor<std::string> html_string(
+ std::string html_string =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
- IDR_MOBILE_SETUP_PORTAL_PAGE_HTML));
- std::string full_html = webui::GetI18nTemplateHtml(*html_string, &strings);
+ IDR_MOBILE_SETUP_PORTAL_PAGE_HTML);
+ std::string full_html = webui::GetI18nTemplateHtml(html_string, strings);
std::move(callback).Run(base::RefCountedString::TakeString(&full_html));
}
@@ -391,19 +394,18 @@ void MobileSetupHandler::Reset() {
ash::MobileActivator::GetInstance()->RemoveObserver(this);
ash::MobileActivator::GetInstance()->TerminateActivation();
} else if (type_ == TYPE_PORTAL_LTE) {
- NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
- FROM_HERE);
+ network_state_handler_observer_.Reset();
}
}
void MobileSetupHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kJsGetDeviceInfo,
base::BindRepeating(&MobileSetupHandler::HandleGetDeviceInfo,
base::Unretained(this)));
}
-void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue* args) {
+void MobileSetupHandler::HandleGetDeviceInfo(const base::Value::List& args) {
DCHECK_NE(TYPE_ACTIVATION, type_);
if (!web_ui())
return;
@@ -432,7 +434,7 @@ void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue* args) {
if (network->network_technology() == shill::kNetworkTechnologyLte ||
network->network_technology() == shill::kNetworkTechnologyLteAdvanced) {
type_ = TYPE_PORTAL_LTE;
- nsh->AddObserver(this, FROM_HERE);
+ network_state_handler_observer_.Observe(nsh);
// Update the network status and notify the webui. This is the initial
// network state so the webui should be notified no matter what.
UpdatePortalReachability(network, true /* force notification */);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/OWNERS
index 063e0696d1f..985da0c1b6b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/OWNERS
@@ -1 +1 @@
-file://chromeos/components/chromebox_for_meetings/OWNERS
+file://chromeos/ash/components/chromebox_for_meetings/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/network_settings_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/network_settings_dialog.cc
index ed733b908eb..12758b04cbd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/network_settings_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/network_settings_dialog.cc
@@ -73,7 +73,7 @@ class NetworkSettingsMessageHandler : public content::WebUIMessageHandler {
void ShowManageCerts() {
// Dialogs manage their own lifecycle and will delete themselves.
CertificateManagerDialog* dialog = new CertificateManagerDialog(
- ProfileManager::GetActiveUserProfile(), nullptr, nullptr);
+ ProfileManager::GetActiveUserProfile(), nullptr);
dialog->Show();
}
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/BUILD.gn b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/BUILD.gn
new file mode 100644
index 00000000000..e2bd0908f91
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/chromeos/ui_mode.gni")
+import("//mojo/public/tools/bindings/mojom.gni")
+
+assert(is_chromeos_ash, "The cloud upload dialog is ash-chrome only")
+
+mojom("mojo_bindings") {
+ sources = [ "cloud_upload.mojom" ]
+
+ public_deps = [ "//mojo/public/mojom/base" ]
+ webui_module_path = "/"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/OWNERS
new file mode 100644
index 00000000000..b5340c81914
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/OWNERS
@@ -0,0 +1,4 @@
+file://ui/file_manager/OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom
new file mode 100644
index 00000000000..d1732458bc9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom
@@ -0,0 +1,29 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module chromeos.cloud_upload.mojom;
+
+import "mojo/public/mojom/base/file_path.mojom";
+
+// The selected action when the user closes the dialog.
+enum UserAction {
+ kCancel,
+ kUpload,
+};
+
+// Lives in the browser process. A renderer uses this to create a page handler
+// that enables communication between a renderer and the browser process.
+interface PageHandlerFactory {
+ // Creates a page handler to enable communication with the browser process.
+ CreatePageHandler(pending_receiver<PageHandler> handler);
+};
+
+// Lives in the browser process. A renderer uses this to invoke methods that
+// are implemented in the browser process.
+interface PageHandler {
+ // Returns the path of the Office file to upload.
+ GetUploadPath() => (mojo_base.mojom.FilePath upload_path);
+ // Returns the user selected action and requests the dialog to be closed.
+ RespondAndClose(UserAction response);
+};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.cc
new file mode 100644
index 00000000000..8d2bdf361a6
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.cc
@@ -0,0 +1,72 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h"
+
+#include "base/callback.h"
+#include "base/json/json_writer.h"
+#include "base/logging.h"
+#include "chrome/common/webui_url_constants.h"
+
+namespace chromeos::cloud_upload {
+namespace {
+
+void OnUploadActionReceived(const std::string& action) {
+ LOG(ERROR) << "ACTION: " << action;
+}
+
+} // namespace
+
+// static
+bool CloudUploadDialog::Show(
+ const std::vector<storage::FileSystemURL>& file_urls) {
+ // Allow no more than one upload dialog at a time. In the case of multiple
+ // upload requests, they should either be handled simultaneously or queued.
+ if (SystemWebDialogDelegate::HasInstance(
+ GURL(chrome::kChromeUICloudUploadURL))) {
+ return false;
+ }
+
+ DCHECK(!file_urls.empty());
+ // TODO(crbug.com/1336924) Add support for multi-file selection.
+ const storage::FileSystemURL file_url = file_urls[0];
+
+ // The pointer is managed by an instance of `views::WebDialogView` and removed
+ // in `SystemWebDialogDelegate::OnDialogClosed`.
+ CloudUploadDialog* dialog =
+ new CloudUploadDialog(file_url, base::BindOnce(&OnUploadActionReceived));
+
+ dialog->ShowSystemDialog();
+ return true;
+}
+
+void CloudUploadDialog::OnDialogClosed(const std::string& json_retval) {
+ if (callback_) {
+ std::move(callback_).Run(json_retval);
+ }
+ SystemWebDialogDelegate::OnDialogClosed(json_retval);
+}
+
+CloudUploadDialog::CloudUploadDialog(const storage::FileSystemURL& file_url,
+ UploadRequestCallback callback)
+ : SystemWebDialogDelegate(GURL(chrome::kChromeUICloudUploadURL),
+ std::u16string() /* title */),
+ file_url_(file_url),
+ callback_(std::move(callback)) {}
+
+CloudUploadDialog::~CloudUploadDialog() = default;
+
+std::string CloudUploadDialog::GetDialogArgs() const {
+ base::DictionaryValue args;
+ args.SetKey("path", base::Value(file_url_.path().BaseName().value()));
+ std::string json;
+ base::JSONWriter::Write(args, &json);
+ return json;
+}
+
+bool CloudUploadDialog::ShouldShowCloseButton() const {
+ return false;
+}
+
+} // namespace chromeos::cloud_upload
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h
new file mode 100644
index 00000000000..bb0e48fce81
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h
@@ -0,0 +1,48 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_DIALOG_H_
+
+#include <vector>
+
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "storage/browser/file_system/file_system_url.h"
+
+namespace chromeos::cloud_upload {
+
+// The string conversions of chromeos::cloud_upload::mojom::UserAction.
+const char kUserActionCancel[] = "cancel";
+const char kUserActionUpload[] = "upload";
+
+// Defines the web dialog used to help users upload Office files to the cloud.
+class CloudUploadDialog : public SystemWebDialogDelegate {
+ public:
+ using UploadRequestCallback =
+ base::OnceCallback<void(const std::string& action)>;
+
+ CloudUploadDialog(const CloudUploadDialog&) = delete;
+ CloudUploadDialog& operator=(const CloudUploadDialog&) = delete;
+
+ // Creates and shows a new dialog for the cloud upload workflow. Returns true
+ // if a new dialog has been effectively created.
+ static bool Show(const std::vector<storage::FileSystemURL>& file_urls);
+
+ void OnDialogClosed(const std::string& json_retval) override;
+
+ protected:
+ explicit CloudUploadDialog(const storage::FileSystemURL& file_url,
+ UploadRequestCallback callback);
+ std::string GetDialogArgs() const override;
+ ~CloudUploadDialog() override;
+ bool ShouldShowCloseButton() const override;
+
+ private:
+ const storage::FileSystemURL file_url_;
+ UploadRequestCallback callback_;
+};
+
+} // namespace chromeos::cloud_upload
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.cc
new file mode 100644
index 00000000000..63b5775a7e8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.cc
@@ -0,0 +1,30 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h"
+
+#include "base/files/file_path.h"
+
+namespace chromeos::cloud_upload {
+
+CloudUploadPageHandler::CloudUploadPageHandler(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandler>
+ pending_page_handler,
+ RespondAndCloseCallback callback)
+ : receiver_{this, std::move(pending_page_handler)},
+ callback_{std::move(callback)} {}
+
+CloudUploadPageHandler::~CloudUploadPageHandler() = default;
+
+void CloudUploadPageHandler::GetUploadPath(GetUploadPathCallback callback) {
+ std::move(callback).Run(std::move(base::FilePath("/from Chromebook")));
+}
+
+void CloudUploadPageHandler::RespondAndClose(mojom::UserAction action) {
+ if (callback_) {
+ std::move(callback_).Run(action);
+ }
+}
+
+} // namespace chromeos::cloud_upload
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h
new file mode 100644
index 00000000000..84109e0a5d7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h
@@ -0,0 +1,49 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_PAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_PAGE_HANDLER_H_
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom-shared.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
+
+namespace chromeos::cloud_upload {
+
+// Handles communication from the chrome://cloud-upload renderer process to
+// the browser process exposing various methods for the JS to invoke.
+class CloudUploadPageHandler
+ : public chromeos::cloud_upload::mojom::PageHandler {
+ public:
+ using RespondAndCloseCallback =
+ base::OnceCallback<void(mojom::UserAction action)>;
+ explicit CloudUploadPageHandler(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandler>
+ pending_page_handler,
+ RespondAndCloseCallback callback);
+
+ CloudUploadPageHandler(const CloudUploadPageHandler&) = delete;
+ CloudUploadPageHandler& operator=(const CloudUploadPageHandler&) = delete;
+
+ ~CloudUploadPageHandler() override;
+
+ // chromeos::cloud_upload::mojom::PageHandler:
+ void GetUploadPath(GetUploadPathCallback callback) override;
+ void RespondAndClose(mojom::UserAction action) override;
+
+ private:
+ mojo::Receiver<chromeos::cloud_upload::mojom::PageHandler> receiver_;
+ RespondAndCloseCallback callback_;
+
+ base::WeakPtrFactory<CloudUploadPageHandler> weak_ptr_factory_{this};
+};
+
+} // namespace chromeos::cloud_upload
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.cc
new file mode 100644
index 00000000000..d2a262083a0
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.cc
@@ -0,0 +1,64 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h"
+
+#include "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_dialog.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/cloud_upload_resources.h"
+#include "chrome/grit/cloud_upload_resources_map.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+namespace chromeos::cloud_upload {
+
+CloudUploadUI::CloudUploadUI(content::WebUI* web_ui)
+ : ui::MojoWebDialogUI{web_ui} {
+ content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd(
+ Profile::FromWebUI(web_ui), chrome::kChromeUICloudUploadHost);
+ webui::SetupWebUIDataSource(
+ source, base::make_span(kCloudUploadResources, kCloudUploadResourcesSize),
+ IDR_CLOUD_UPLOAD_MAIN_HTML);
+}
+
+CloudUploadUI::~CloudUploadUI() = default;
+
+void CloudUploadUI::BindInterface(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandlerFactory>
+ pending_receiver) {
+ if (factory_receiver_.is_bound()) {
+ factory_receiver_.reset();
+ }
+ factory_receiver_.Bind(std::move(pending_receiver));
+}
+
+void CloudUploadUI::CreatePageHandler(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandler>
+ receiver) {
+ page_handler_ = std::make_unique<CloudUploadPageHandler>(
+ std::move(receiver),
+ // base::Unretained() because |page_handler_| will not out-live |this|.
+ base::BindOnce(&CloudUploadUI::RespondAndCloseDialog,
+ base::Unretained(this)));
+}
+
+void CloudUploadUI::RespondAndCloseDialog(mojom::UserAction action) {
+ base::Value::List args;
+ switch (action) {
+ case mojom::UserAction::kCancel:
+ args.Append(kUserActionCancel);
+ break;
+ case mojom::UserAction::kUpload:
+ args.Append(kUserActionUpload);
+ break;
+ }
+ ui::MojoWebDialogUI::CloseDialog(args);
+}
+
+WEB_UI_CONTROLLER_TYPE_IMPL(CloudUploadUI);
+
+} // namespace chromeos::cloud_upload
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h
new file mode 100644
index 00000000000..053669465c8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_ui.h
@@ -0,0 +1,48 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_UI_H_
+
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom-shared.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload.mojom.h"
+#include "chrome/browser/ui/webui/chromeos/cloud_upload/cloud_upload_page_handler.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos::cloud_upload {
+
+// The UI for chrome://cloud-upload, used for uploading files to the cloud.
+class CloudUploadUI : public ui::MojoWebDialogUI,
+ public chromeos::cloud_upload::mojom::PageHandlerFactory {
+ public:
+ explicit CloudUploadUI(content::WebUI* web_ui);
+ CloudUploadUI(const CloudUploadUI&) = delete;
+ CloudUploadUI& operator=(const CloudUploadUI&) = delete;
+
+ ~CloudUploadUI() override;
+
+ // Instantiates implementor of the mojom::PageHandlerFactory
+ // mojo interface passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandlerFactory>
+ pending_receiver);
+
+ // chromeos::cloud_upload::mojom::PageHandlerFactory:
+ void CreatePageHandler(
+ mojo::PendingReceiver<chromeos::cloud_upload::mojom::PageHandler>
+ pending_page_handler) override;
+
+ private:
+ void RespondAndCloseDialog(mojom::UserAction action);
+
+ std::unique_ptr<CloudUploadPageHandler> page_handler_;
+ mojo::Receiver<chromeos::cloud_upload::mojom::PageHandlerFactory>
+ factory_receiver_{this};
+
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+} // namespace chromeos::cloud_upload
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CLOUD_UPLOAD_CLOUD_UPLOAD_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA
index b3cd94034ff..06e627fbb01 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA
@@ -1,3 +1 @@
-monorail {
- component: "UI>Shell>Containers"
-}
+mixins: "//chrome/browser/ash/guest_os/COMMON_METADATA"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc
index 6ed2f5495ab..b800ee87448 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc
@@ -213,7 +213,7 @@ void CrostiniInstallerUI::OnPageClosed() {
page_closed_ = true;
// CloseDialog() is a no-op if we are not in a dialog (e.g. user
// access the page using the URL directly, which is not supported).
- ui::MojoWebDialogUI::CloseDialog(nullptr);
+ ui::MojoWebDialogUI::CloseDialog(base::Value::List());
}
WEB_UI_CONTROLLER_TYPE_IMPL(CrostiniInstallerUI)
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA
index b3cd94034ff..06e627fbb01 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA
@@ -1,3 +1 @@
-monorail {
- component: "UI>Shell>Containers"
-}
+mixins: "//chrome/browser/ash/guest_os/COMMON_METADATA"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
index bd57b5081df..85cebb7f499 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
@@ -137,7 +137,7 @@ void RunLaunchClosure(base::WeakPtr<crostini::CrostiniManager> crostini_manager,
return;
}
crostini_manager->RestartCrostini(
- crostini::ContainerId::GetDefault(),
+ crostini::DefaultContainerId(),
base::BindOnce(
[](base::OnceClosure launch_closure,
crostini::CrostiniResult result) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc
index 5f179e1bbd9..69d57473dcd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_page_handler.cc
@@ -59,7 +59,7 @@ void CrostiniUpgraderPageHandler::Backup(bool show_file_chooser) {
Redisplay();
CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram(
crostini::UpgradeDialogEvent::kDidBackup);
- upgrader_ui_delegate_->Backup(crostini::ContainerId::GetDefault(),
+ upgrader_ui_delegate_->Backup(crostini::DefaultContainerId(),
show_file_chooser, web_contents_->GetWeakPtr());
}
@@ -69,14 +69,14 @@ void CrostiniUpgraderPageHandler::StartPrechecks() {
void CrostiniUpgraderPageHandler::Upgrade() {
Redisplay();
- upgrader_ui_delegate_->Upgrade(crostini::ContainerId::GetDefault());
+ upgrader_ui_delegate_->Upgrade(crostini::DefaultContainerId());
}
void CrostiniUpgraderPageHandler::Restore() {
Redisplay();
CrostiniUpgraderDialog::EmitUpgradeDialogEventHistogram(
crostini::UpgradeDialogEvent::kDidRestore);
- upgrader_ui_delegate_->Restore(crostini::ContainerId::GetDefault(),
+ upgrader_ui_delegate_->Restore(crostini::DefaultContainerId(),
web_contents_->GetWeakPtr());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc
index 16aee154049..69b2a1769de 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc
@@ -151,7 +151,7 @@ void CrostiniUpgraderUI::OnPageClosed() {
page_closed_ = true;
// CloseDialog() is a no-op if we are not in a dialog (e.g. user
// access the page using the URL directly, which is not supported).
- ui::MojoWebDialogUI::CloseDialog(nullptr);
+ ui::MojoWebDialogUI::CloseDialog(base::Value::List());
}
WEB_UI_CONTROLLER_TYPE_IMPL(CrostiniUpgraderUI)
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
index 6399714d1c9..f72c9ebe519 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
@@ -7,11 +7,11 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/values.h"
-#include "chromeos/dbus/cryptohome/rpc.pb.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/cryptohome/rpc.pb.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/userdataauth/cryptohome_pkcs11_client.h"
+#include "chromeos/ash/components/dbus/userdataauth/userdataauth_client.h"
#include "chromeos/dbus/tpm_manager/tpm_manager_client.h"
-#include "chromeos/dbus/userdataauth/cryptohome_pkcs11_client.h"
-#include "chromeos/dbus/userdataauth/userdataauth_client.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h
index db22103721a..d7d62530477 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h
@@ -8,9 +8,9 @@
#include <string>
#include "base/memory/weak_ptr.h"
+#include "chromeos/ash/components/dbus/userdataauth/userdataauth_client.h"
#include "chromeos/dbus/common/dbus_method_call_status.h"
#include "chromeos/dbus/tpm_manager/tpm_manager.pb.h"
-#include "chromeos/dbus/userdataauth/userdataauth_client.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc
index a45e6fea555..df11f5a5c69 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc
@@ -6,7 +6,6 @@
#include <utility>
-#include "ash/components/account_manager/account_manager_factory.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
@@ -19,6 +18,7 @@
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/image_fetcher/core/image_fetcher_service.h"
#include "components/image_fetcher/core/request_metadata.h"
@@ -178,16 +178,13 @@ void EduAccountLoginHandler::HandleParentSignin(const base::Value::List& args) {
}
parent_signin_callback_id_ = args[0].GetString();
- const base::DictionaryValue* parent = nullptr;
- args[1].GetAsDictionary(&parent);
- CHECK(parent);
- const base::Value* obfuscated_gaia_id_value =
- parent->GetDict().Find(kObfuscatedGaiaIdKey);
- DCHECK(obfuscated_gaia_id_value);
- std::string obfuscated_gaia_id = obfuscated_gaia_id_value->GetString();
+ const base::Value::Dict& parent = args[1].GetDict();
+ const std::string* obfuscated_gaia_id =
+ parent.FindString(kObfuscatedGaiaIdKey);
+ DCHECK(obfuscated_gaia_id);
const std::string* password = args[2].GetIfString();
- FetchAccessToken(obfuscated_gaia_id, password ? *password : std::string());
+ FetchAccessToken(*obfuscated_gaia_id, password ? *password : std::string());
}
void EduAccountLoginHandler::FetchFamilyMembers() {
@@ -205,7 +202,7 @@ void EduAccountLoginHandler::FetchFamilyMembers() {
}
void EduAccountLoginHandler::FetchParentImages(
- base::ListValue parents,
+ base::Value::List parents,
std::map<std::string, GURL> profile_image_urls) {
DCHECK(!profile_image_fetcher_);
image_fetcher::ImageFetcher* fetcher =
@@ -259,7 +256,7 @@ void EduAccountLoginHandler::FetchReAuthProofTokenForParent(
void EduAccountLoginHandler::OnGetFamilyMembersSuccess(
const std::vector<FamilyInfoFetcher::FamilyMember>& members) {
family_fetcher_.reset();
- base::ListValue parents;
+ base::Value::List parents;
std::map<std::string, GURL> profile_image_urls;
for (const auto& member : members) {
@@ -268,10 +265,10 @@ void EduAccountLoginHandler::OnGetFamilyMembersSuccess(
continue;
}
- base::DictionaryValue parent;
- parent.GetDict().Set("email", member.email);
- parent.GetDict().Set("displayName", member.display_name);
- parent.GetDict().Set(kObfuscatedGaiaIdKey, member.obfuscated_gaia_id);
+ base::Value::Dict parent;
+ parent.Set("email", member.email);
+ parent.Set("displayName", member.display_name);
+ parent.Set(kObfuscatedGaiaIdKey, member.obfuscated_gaia_id);
parents.Append(std::move(parent));
profile_image_urls[member.obfuscated_gaia_id] =
@@ -284,16 +281,16 @@ void EduAccountLoginHandler::OnGetFamilyMembersSuccess(
void EduAccountLoginHandler::OnFailure(FamilyInfoFetcher::ErrorCode error) {
family_fetcher_.reset();
RejectJavascriptCallback(base::Value(get_parents_callback_id_),
- base::ListValue());
+ base::Value::List());
get_parents_callback_id_.clear();
}
void EduAccountLoginHandler::OnParentProfileImagesFetched(
- base::ListValue parents,
+ base::Value::List parents,
std::map<std::string, gfx::Image> profile_images) {
profile_image_fetcher_.reset();
- for (auto& parent : parents.GetListDeprecated()) {
+ for (auto& parent : parents) {
const std::string* obfuscated_gaia_id =
parent.GetDict().FindString(kObfuscatedGaiaIdKey);
DCHECK(obfuscated_gaia_id);
@@ -328,8 +325,8 @@ void EduAccountLoginHandler::CreateReAuthProofTokenForParent(
LOG(ERROR)
<< "Could not get access token to create ReAuthProofToken for parent"
<< error.ToString();
- base::DictionaryValue result;
- result.GetDict().Set("isWrongPassword", false);
+ base::Value::Dict result;
+ result.Set("isWrongPassword", false);
RejectJavascriptCallback(base::Value(parent_signin_callback_id_), result);
parent_signin_callback_id_.clear();
return;
@@ -353,10 +350,9 @@ void EduAccountLoginHandler::OnReAuthProofTokenFailure(
<< static_cast<int>(error);
gaia_auth_fetcher_.reset();
- base::DictionaryValue result;
- result.GetDict().Set(
- "isWrongPassword",
- error == GaiaAuthConsumer::ReAuthProofTokenStatus::kInvalidGrant);
+ base::Value::Dict result;
+ result.Set("isWrongPassword",
+ error == GaiaAuthConsumer::ReAuthProofTokenStatus::kInvalidGrant);
RejectJavascriptCallback(base::Value(parent_signin_callback_id_), result);
parent_signin_callback_id_.clear();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h
index 5f8350e6ccf..e6a97ad8b03 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h
@@ -104,7 +104,7 @@ class EduAccountLoginHandler : public content::WebUIMessageHandler,
virtual void FetchFamilyMembers();
virtual void FetchParentImages(
- base::ListValue parents,
+ base::Value::List parents,
std::map<std::string, GURL> profile_image_urls);
virtual void FetchAccessToken(const std::string& obfuscated_gaia_id,
const std::string& password);
@@ -121,7 +121,7 @@ class EduAccountLoginHandler : public content::WebUIMessageHandler,
// ProfileImageFetcher callback
void OnParentProfileImagesFetched(
- base::ListValue parents,
+ base::Value::List parents,
std::map<std::string, gfx::Image> profile_images);
// signin::PrimaryAccountAccessTokenFetcher callback
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_unittest.cc
index f39dfffb4ff..69b0add88bb 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_unittest.cc
@@ -12,10 +12,10 @@
#include "base/test/task_environment.h"
#include "base/values.h"
#include "chrome/browser/ash/net/network_portal_detector_test_impl.h"
-#include "chromeos/dbus/shill/shill_clients.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_handler_test_helper.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/dbus/shill/shill_clients.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_handler_test_helper.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/image_fetcher/core/mock_image_fetcher.h"
#include "components/image_fetcher/core/request_metadata.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -85,29 +85,29 @@ std::map<std::string, gfx::Image> GetFakeProfileImageMap() {
};
}
-base::ListValue GetFakeParentsWithoutImage() {
- base::ListValue parents;
+base::Value::List GetFakeParentsWithoutImage() {
+ base::Value::List parents;
- base::DictionaryValue parent1;
- parent1.GetDict().Set("email", "homer@simpson.com");
- parent1.GetDict().Set("displayName", "Homer Simpson");
- parent1.GetDict().Set("obfuscatedGaiaId", kFakeParentGaiaId);
+ base::Value::Dict parent1;
+ parent1.Set("email", "homer@simpson.com");
+ parent1.Set("displayName", "Homer Simpson");
+ parent1.Set("obfuscatedGaiaId", kFakeParentGaiaId);
parents.Append(std::move(parent1));
- base::DictionaryValue parent2;
- parent2.GetDict().Set("email", std::string());
- parent2.GetDict().Set("displayName", "Marge Simpson");
- parent2.GetDict().Set("obfuscatedGaiaId", kFakeParentGaiaId2);
+ base::Value::Dict parent2;
+ parent2.Set("email", std::string());
+ parent2.Set("displayName", "Marge Simpson");
+ parent2.Set("obfuscatedGaiaId", kFakeParentGaiaId2);
parents.Append(std::move(parent2));
return parents;
}
-base::ListValue GetFakeParentsWithImage() {
- base::ListValue parents = GetFakeParentsWithoutImage();
+base::Value::List GetFakeParentsWithImage() {
+ base::Value::List parents = GetFakeParentsWithoutImage();
std::map<std::string, gfx::Image> profile_images = GetFakeProfileImageMap();
- for (auto& parent : parents.GetListDeprecated()) {
+ for (auto& parent : parents) {
const std::string* obfuscated_gaia_id =
parent.GetDict().FindString("obfuscatedGaiaId");
DCHECK(obfuscated_gaia_id);
@@ -129,12 +129,12 @@ base::ListValue GetFakeParentsWithImage() {
return parents;
}
-base::DictionaryValue GetFakeParent() {
- base::DictionaryValue parent;
- parent.GetDict().Set("email", "homer@simpson.com");
- parent.GetDict().Set("displayName", "Homer Simpson");
- parent.GetDict().Set("profileImageUrl", "http://profile.url/homer/image");
- parent.GetDict().Set("obfuscatedGaiaId", kFakeParentGaiaId);
+base::Value::Dict GetFakeParent() {
+ base::Value::Dict parent;
+ parent.Set("email", "homer@simpson.com");
+ parent.Set("displayName", "Homer Simpson");
+ parent.Set("profileImageUrl", "http://profile.url/homer/image");
+ parent.Set("obfuscatedGaiaId", kFakeParentGaiaId);
return parent;
}
@@ -159,7 +159,7 @@ class MockEduAccountLoginHandler : public EduAccountLoginHandler {
(override));
MOCK_METHOD(void,
FetchParentImages,
- (base::ListValue parents,
+ (base::Value::List parents,
(std::map<std::string, GURL> profile_image_urls)),
(override));
};
@@ -276,7 +276,7 @@ TEST_F(EduAccountLoginHandlerTest, HandleGetParentsFailure) {
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
VerifyJavascriptCallbackResolved(data, callback_id, false /*success*/);
- ASSERT_EQ(base::ListValue(), *data.arg3());
+ ASSERT_EQ(base::Value::List(), *data.arg3());
}
TEST_F(EduAccountLoginHandlerTest, HandleParentSigninSuccess) {
@@ -332,8 +332,8 @@ TEST_F(EduAccountLoginHandlerTest, HandleParentSigninAccessTokenFailure) {
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
VerifyJavascriptCallbackResolved(data, callback_id, false /*success*/);
- base::DictionaryValue result;
- result.GetDict().Set("isWrongPassword", false);
+ base::Value::Dict result;
+ result.Set("isWrongPassword", false);
ASSERT_EQ(result, *data.arg3());
}
@@ -366,8 +366,8 @@ TEST_F(EduAccountLoginHandlerTest, HandleParentSigninReAuthProofTokenFailure) {
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
VerifyJavascriptCallbackResolved(data, callback_id, false);
- base::DictionaryValue result;
- result.GetDict().Set("isWrongPassword", true);
+ base::Value::Dict result;
+ result.Set("isWrongPassword", true);
ASSERT_EQ(result, *data.arg3());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc
index 6f25e179354..ca41344241e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc
@@ -121,9 +121,9 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
ExpectEduCoexistenceState(EduCoexistenceStateTracker::FlowResult::kLaunched);
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(kCallbackId);
- web_ui()->HandleReceivedMessage("initializeEduArgs", &list_args);
+ web_ui()->HandleReceivedMessage("initializeEduArgs", list_args);
SimulateAccessTokenFetched(handler.get());
EXPECT_EQ(web_ui()->call_data().size(), 1u);
@@ -144,10 +144,10 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
ErrorCallsFromWebUI) {
std::unique_ptr<EduCoexistenceLoginHandler> handler = SetUpHandler();
- base::ListValue call_args;
+ base::Value::List call_args;
call_args.Append("error message 1");
call_args.Append("error message 2");
- web_ui()->HandleReceivedMessage("error", &call_args);
+ web_ui()->HandleReceivedMessage("error", call_args);
EXPECT_TRUE(handler->in_error_state());
@@ -166,9 +166,9 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
// C++ handler.
EXPECT_EQ(web_ui()->call_data().size(), 0u);
- base::ListValue call_args;
+ base::Value::List call_args;
call_args.Append("coexistence-data-init");
- web_ui()->HandleReceivedMessage("initializeEduArgs", &call_args);
+ web_ui()->HandleReceivedMessage("initializeEduArgs", call_args);
EXPECT_EQ(web_ui()->call_data().size(), 1u);
EXPECT_EQ(web_ui()->call_data()[0]->function_name(),
@@ -193,15 +193,15 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
SimulateAccessTokenFetched(handler.get());
- base::ListValue call_args;
+ base::Value::List call_args;
call_args.Append(FakeGaiaMixin::kFakeUserEmail);
call_args.Append(kToSVersion);
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(kConsentLoggedCallback);
list_args.Append(std::move(call_args));
- web_ui()->HandleReceivedMessage("consentLogged", &list_args);
+ web_ui()->HandleReceivedMessage("consentLogged", list_args);
const EduCoexistenceStateTracker::FlowState* tracker =
EduCoexistenceStateTracker::Get()->GetInfoForWebUIForTest(web_ui());
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc
index 0f99b1e45f5..96ab0054c88 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc
@@ -183,22 +183,22 @@ void EduCoexistenceLoginHandler::RegisterMessages() {
web_ui(), /* is_onboarding */ session_manager::SessionManager::Get()
->IsUserSessionBlocked());
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"initializeEduArgs",
base::BindRepeating(&EduCoexistenceLoginHandler::InitializeEduArgs,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"consentValid",
base::BindRepeating(&EduCoexistenceLoginHandler::ConsentValid,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"consentLogged",
base::BindRepeating(&EduCoexistenceLoginHandler::ConsentLogged,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"error", base::BindRepeating(&EduCoexistenceLoginHandler::OnError,
base::Unretained(this)));
}
@@ -255,10 +255,10 @@ void EduCoexistenceLoginHandler::OnOAuthAccessTokensFetched(
}
void EduCoexistenceLoginHandler::InitializeEduArgs(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- initialize_edu_args_callback_ = args->GetListDeprecated()[0].GetString();
+ initialize_edu_args_callback_ = args[0].GetString();
if (in_error_state_) {
FireWebUIListener(kOnErrorWebUIListener);
@@ -276,30 +276,28 @@ void EduCoexistenceLoginHandler::InitializeEduArgs(
void EduCoexistenceLoginHandler::SendInitializeEduArgs() {
DCHECK(oauth_access_token_.has_value());
DCHECK(initialize_edu_args_callback_.has_value());
- base::Value params(base::Value::Type::DICTIONARY);
+ base::Value::Dict params;
const std::string& app_locale = g_browser_process->GetApplicationLocale();
- params.SetStringKey("hl", app_locale);
+ params.Set("hl", app_locale);
- params.SetStringKey("url", GetEduCoexistenceURL());
+ params.Set("url", GetEduCoexistenceURL());
- params.SetStringKey("clientId",
- GaiaUrls::GetInstance()->oauth2_chrome_client_id());
- params.SetStringKey("sourceUi", GetSourceUI());
+ params.Set("clientId", GaiaUrls::GetInstance()->oauth2_chrome_client_id());
+ params.Set("sourceUi", GetSourceUI());
- params.SetStringKey("clientVersion", chrome::kChromeVersion);
- params.SetStringKey("eduCoexistenceAccessToken", oauth_access_token_->token);
- params.SetStringKey("eduCoexistenceId", GetOrCreateEduCoexistenceUserId());
- params.SetStringKey("platformVersion",
- base::SysInfo::OperatingSystemVersion());
+ params.Set("clientVersion", chrome::kChromeVersion);
+ params.Set("eduCoexistenceAccessToken", oauth_access_token_->token);
+ params.Set("eduCoexistenceId", GetOrCreateEduCoexistenceUserId());
+ params.Set("platformVersion", base::SysInfo::OperatingSystemVersion());
// Extended stable channel is not supported on Chrome OS Ash.
- params.SetStringKey("releaseChannel", chrome::GetChannelName(
- chrome::WithExtendedStable(false)));
- params.SetStringKey("deviceId", GetDeviceIdForActiveUserProfile());
+ params.Set("releaseChannel",
+ chrome::GetChannelName(chrome::WithExtendedStable(false)));
+ params.Set("deviceId", GetDeviceIdForActiveUserProfile());
- params.SetDoubleKey("signinTime", GetSigninTime().ToJsTimeIgnoringNull());
+ params.Set("signinTime", GetSigninTime().ToJsTimeIgnoringNull());
// TODO(crbug.com/1202135): Remove along with JS part.
- params.SetBoolKey("newOobeLayoutEnabled", true);
+ params.Set("newOobeLayoutEnabled", true);
// If the secondary edu account is being reauthenticated, the email address
// will be provided via the url of the webcontent. Example
@@ -309,38 +307,37 @@ void EduCoexistenceLoginHandler::SendInitializeEduArgs() {
const GURL& current_url = web_contents->GetURL();
std::string default_email;
if (net::GetValueForKeyInQuery(current_url, "email", &default_email)) {
- params.SetStringKey("email", default_email);
+ params.Set("email", default_email);
std::string read_only_email;
if (net::GetValueForKeyInQuery(current_url, "readOnlyEmail",
&read_only_email)) {
- params.SetStringKey("readOnlyEmail", read_only_email);
+ params.Set("readOnlyEmail", read_only_email);
}
}
}
ResolveJavascriptCallback(base::Value(initialize_edu_args_callback_.value()),
- std::move(params));
+ params);
initialize_edu_args_callback_ = absl::nullopt;
}
-void EduCoexistenceLoginHandler::ConsentValid(const base::ListValue* args) {
+void EduCoexistenceLoginHandler::ConsentValid(const base::Value::List& args) {
AllowJavascript();
DCHECK(!in_error_state_);
EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
web_ui(), EduCoexistenceStateTracker::FlowResult::kConsentValid);
}
-void EduCoexistenceLoginHandler::ConsentLogged(const base::ListValue* args) {
- if (!args || args->GetListDeprecated().size() == 0)
+void EduCoexistenceLoginHandler::ConsentLogged(const base::Value::List& args) {
+ if (args.size() == 0)
return;
DCHECK(!in_error_state_);
- account_added_callback_ = args->GetListDeprecated()[0].GetString();
+ account_added_callback_ = args[0].GetString();
- const base::Value::ConstListView& arguments =
- args->GetListDeprecated()[1].GetListDeprecated();
+ const base::Value::List& arguments = args[1].GetList();
edu_account_email_ = arguments[0].GetString();
terms_of_service_version_number_ = arguments[1].GetString();
@@ -350,13 +347,12 @@ void EduCoexistenceLoginHandler::ConsentLogged(const base::ListValue* args) {
edu_account_email_);
}
-void EduCoexistenceLoginHandler::OnError(const base::ListValue* args) {
+void EduCoexistenceLoginHandler::OnError(const base::Value::List& args) {
AllowJavascript();
- if (!args || args->GetListDeprecated().size() == 0)
+ if (args.size() == 0)
return;
in_error_state_ = true;
- const base::Value::ConstListView& arguments = args->GetListDeprecated();
- for (const base::Value& message : arguments) {
+ for (const base::Value& message : args) {
DCHECK(message.is_string());
LOG(ERROR) << message.GetString();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h
index 9934e8aa5b1..604cd3ec0f1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/memory/scoped_refptr.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "components/signin/public/identity_manager/access_token_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -17,10 +18,6 @@
class PrefRegistrySimple;
-namespace base {
-class ListValue;
-} // namespace base
-
namespace chromeos {
// Handler for EDU account login flow.
@@ -56,11 +53,11 @@ class EduCoexistenceLoginHandler : public content::WebUIMessageHandler,
private:
// Registered WebUi Message handlers.
- void InitializeEduArgs(const base::ListValue* args);
+ void InitializeEduArgs(const base::Value::List& args);
void SendInitializeEduArgs();
- void ConsentValid(const base::ListValue* args);
- void ConsentLogged(const base::ListValue* args);
- void OnError(const base::ListValue* args);
+ void ConsentValid(const base::Value::List& args);
+ void ConsentLogged(const base::Value::List& args);
+ void OnError(const base::Value::List& args);
// Used for getting child access token.
std::unique_ptr<signin::PrimaryAccountAccessTokenFetcher>
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
index a9e5dd581f8..200b6c47b9d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
@@ -18,8 +18,8 @@
#include "chrome/browser/ash/system/fake_input_device_settings.h"
#include "chrome/browser/ash/system/input_device_settings.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
-#include "chromeos/dbus/audio/fake_cras_audio_client.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/audio/fake_cras_audio_client.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power/fake_power_manager_client.h"
#include "content/public/browser/web_ui.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -61,11 +61,11 @@ const char kAudioNodesUpdated[] = "audioNodesUpdated";
const double kPowerLevelHigh = 50;
const double kPowerLevelLow = 2;
-bool GetString(const base::Value& dict,
+bool GetString(const base::Value::Dict& dict,
base::StringPiece key,
std::string* result) {
CHECK(result);
- const std::string* value = dict.GetDict().FindString(key);
+ const std::string* value = dict.FindString(key);
if (value) {
*result = *value;
}
@@ -107,7 +107,7 @@ class DeviceEmulatorMessageHandler::BluetoothObserver
void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceAdded(
const dbus::ObjectPath& object_path) {
- base::Value device = owner_->GetDeviceInfo(object_path);
+ base::Value::Dict device = owner_->GetDeviceInfo(object_path);
// Request to add the device to the view's list of devices.
owner_->FireWebUIListener("bluetooth-device-added", device);
@@ -177,18 +177,17 @@ class DeviceEmulatorMessageHandler::PowerObserver
void DeviceEmulatorMessageHandler::PowerObserver::PowerChanged(
const power_manager::PowerSupplyProperties& proto) {
- base::DictionaryValue power_properties;
-
- power_properties.GetDict().Set("battery_percent",
- int(proto.battery_percent()));
- power_properties.GetDict().Set("battery_state", int(proto.battery_state()));
- power_properties.GetDict().Set("external_power", int(proto.external_power()));
- power_properties.GetDict().Set("battery_time_to_empty_sec",
- int(proto.battery_time_to_empty_sec()));
- power_properties.GetDict().Set("battery_time_to_full_sec",
- int(proto.battery_time_to_full_sec()));
- power_properties.GetDict().Set("external_power_source_id",
- proto.external_power_source_id());
+ base::Value::Dict power_properties;
+
+ power_properties.Set("battery_percent", int(proto.battery_percent()));
+ power_properties.Set("battery_state", int(proto.battery_state()));
+ power_properties.Set("external_power", int(proto.external_power()));
+ power_properties.Set("battery_time_to_empty_sec",
+ int(proto.battery_time_to_empty_sec()));
+ power_properties.Set("battery_time_to_full_sec",
+ int(proto.battery_time_to_full_sec()));
+ power_properties.Set("external_power_source_id",
+ proto.external_power_source_id());
owner_->FireWebUIListener("power-properties-updated", power_properties);
}
@@ -247,14 +246,14 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo(
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath));
// Get each device's properties.
- base::Value devices(base::Value::Type::LIST);
+ base::Value::List devices;
for (const dbus::ObjectPath& path : paths)
devices.Append(GetDeviceInfo(path));
base::Value predefined_devices =
fake_bluetooth_device_client_->GetBluetoothDevicesAsDictionaries();
- base::Value pairing_method_options(base::Value::Type::LIST);
+ base::Value::List pairing_method_options;
pairing_method_options.Append(
bluez::FakeBluetoothDeviceClient::kPairingMethodNone);
pairing_method_options.Append(
@@ -262,7 +261,7 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo(
pairing_method_options.Append(
bluez::FakeBluetoothDeviceClient::kPairingMethodPassKey);
- base::Value pairing_action_options(base::Value::Type::LIST);
+ base::Value::List pairing_action_options;
pairing_action_options.Append(
bluez::FakeBluetoothDeviceClient::kPairingActionDisplay);
pairing_action_options.Append(
@@ -272,13 +271,11 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo(
pairing_action_options.Append(
bluez::FakeBluetoothDeviceClient::kPairingActionFail);
- base::Value info(base::Value::Type::DICTIONARY);
- info.GetDict().Set("predefined_devices", std::move(predefined_devices));
- info.GetDict().Set("devices", std::move(devices));
- info.GetDict().Set("pairing_method_options",
- std::move(pairing_method_options));
- info.GetDict().Set("pairing_action_options",
- std::move(pairing_action_options));
+ base::Value::Dict info;
+ info.Set("predefined_devices", std::move(predefined_devices));
+ info.Set("devices", std::move(devices));
+ info.Set("pairing_method_options", std::move(pairing_method_options));
+ info.Set("pairing_action_options", std::move(pairing_action_options));
// Send the list of devices to the view.
FireWebUIListener("bluetooth-info-updated", info);
@@ -311,13 +308,12 @@ void DeviceEmulatorMessageHandler::HandleInsertAudioNode(
const base::Value& device_value = args[0];
CHECK(device_value.is_dict());
- const base::DictionaryValue& device_dict =
- base::Value::AsDictionaryValue(device_value);
- audio_node.is_input = device_dict.GetDict().FindBool("isInput").value();
+ const base::Value::Dict& device_dict = device_value.GetDict();
+ audio_node.is_input = device_dict.FindBool("isInput").value();
CHECK(GetString(device_dict, "deviceName", &audio_node.device_name));
CHECK(GetString(device_dict, "type", &audio_node.type));
CHECK(GetString(device_dict, "name", &audio_node.name));
- audio_node.active = device_dict.GetDict().FindBool("active").value();
+ audio_node.active = device_dict.FindBool("active").value();
std::string tmp_id;
CHECK(GetString(device_dict, "id", &tmp_id));
@@ -565,8 +561,7 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue(
const base::Value& device_value = args[0];
CHECK(device_value.is_dict());
- const base::DictionaryValue& device_dict =
- base::Value::AsDictionaryValue(device_value);
+ const base::Value::Dict& device_dict = device_value.GetDict();
CHECK(GetString(device_dict, "path", &props.device_path));
CHECK(GetString(device_dict, "name", &props.device_name));
CHECK(GetString(device_dict, "alias", &props.device_alias));
@@ -575,12 +570,12 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue(
CHECK(GetString(device_dict, "pairingAuthToken", &props.pairing_auth_token));
CHECK(GetString(device_dict, "pairingAction", &props.pairing_action));
- absl::optional<int> class_value = device_dict.GetDict().FindInt("classValue");
+ absl::optional<int> class_value = device_dict.FindInt("classValue");
CHECK(class_value);
props.device_class = *class_value;
- props.is_trusted = device_dict.GetDict().FindBool("isTrusted").value();
- props.incoming = device_dict.GetDict().FindBool("incoming").value();
+ props.is_trusted = device_dict.FindBool("isTrusted").value();
+ props.incoming = device_dict.FindBool("incoming").value();
// Create the device and store it in the FakeBluetoothDeviceClient's observed
// list of devices.
@@ -590,7 +585,7 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue(
return props.device_path;
}
-base::Value DeviceEmulatorMessageHandler::GetDeviceInfo(
+base::Value::Dict DeviceEmulatorMessageHandler::GetDeviceInfo(
const dbus::ObjectPath& object_path) {
// Get the device's properties.
bluez::FakeBluetoothDeviceClient::Properties* props =
@@ -598,28 +593,28 @@ base::Value DeviceEmulatorMessageHandler::GetDeviceInfo(
bluez::FakeBluetoothDeviceClient::SimulatedPairingOptions* options =
fake_bluetooth_device_client_->GetPairingOptions(object_path);
- base::Value device(base::Value::Type::DICTIONARY);
- device.GetDict().Set("path", object_path.value());
- device.GetDict().Set("name", props->name.value());
- device.GetDict().Set("alias", props->alias.value());
- device.GetDict().Set("address", props->address.value());
+ base::Value::Dict device;
+ device.Set("path", object_path.value());
+ device.Set("name", props->name.value());
+ device.Set("alias", props->alias.value());
+ device.Set("address", props->address.value());
if (options) {
- device.GetDict().Set("pairingMethod", options->pairing_method);
- device.GetDict().Set("pairingAuthToken", options->pairing_auth_token);
- device.GetDict().Set("pairingAction", options->pairing_action);
+ device.Set("pairingMethod", options->pairing_method);
+ device.Set("pairingAuthToken", options->pairing_auth_token);
+ device.Set("pairingAction", options->pairing_action);
} else {
- device.GetDict().Set("pairingMethod", "");
- device.GetDict().Set("pairingAuthToken", "");
- device.GetDict().Set("pairingAction", "");
+ device.Set("pairingMethod", "");
+ device.Set("pairingAuthToken", "");
+ device.Set("pairingAction", "");
}
- device.GetDict().Set("classValue", int(props->bluetooth_class.value()));
- device.GetDict().Set("isTrusted", bool(props->trusted.value()));
- device.GetDict().Set("incoming", false);
+ device.Set("classValue", int(props->bluetooth_class.value()));
+ device.Set("isTrusted", bool(props->trusted.value()));
+ device.Set("incoming", false);
- base::Value uuids(base::Value::Type::LIST);
+ base::Value::List uuids;
for (const std::string& uuid : props->uuids.value())
uuids.Append(uuid);
- device.GetDict().Set("uuids", std::move(uuids));
+ device.Set("uuids", std::move(uuids));
return device;
}
@@ -666,17 +661,17 @@ void DeviceEmulatorMessageHandler::PointingStickExists(bool exists) {
void DeviceEmulatorMessageHandler::UpdateAudioNodes() {
// Get every active audio node and create a dictionary to
// send it to JavaScript.
- base::Value audio_nodes(base::Value::Type::LIST);
+ base::Value::List audio_nodes;
for (const AudioNode& node :
chromeos::FakeCrasAudioClient::Get()->node_list()) {
- base::Value audio_node(base::Value::Type::DICTIONARY);
-
- audio_node.GetDict().Set("isInput", node.is_input);
- audio_node.GetDict().Set("id", base::NumberToString(node.id));
- audio_node.GetDict().Set("deviceName", node.device_name);
- audio_node.GetDict().Set("type", node.type);
- audio_node.GetDict().Set("name", node.name);
- audio_node.GetDict().Set("active", node.active);
+ base::Value::Dict audio_node;
+
+ audio_node.Set("isInput", node.is_input);
+ audio_node.Set("id", base::NumberToString(node.id));
+ audio_node.Set("deviceName", node.device_name);
+ audio_node.Set("type", node.type);
+ audio_node.Set("name", node.name);
+ audio_node.Set("active", node.active);
audio_nodes.Append(std::move(audio_node));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h
index 13994f4e306..3183d7bdfde 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h
@@ -117,7 +117,7 @@ class DeviceEmulatorMessageHandler :
// Builds a dictionary with each key representing a property of the device
// with path |object_path|.
- base::Value GetDeviceInfo(const dbus::ObjectPath& object_path);
+ base::Value::Dict GetDeviceInfo(const dbus::ObjectPath& object_path);
void ConnectToBluetoothDevice(const std::string& address);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/guest_os_installer/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/guest_os_installer/DIR_METADATA
index b3cd94034ff..06e627fbb01 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/guest_os_installer/DIR_METADATA
+++ b/chromium/chrome/browser/ui/webui/chromeos/guest_os_installer/DIR_METADATA
@@ -1,3 +1 @@
-monorail {
- component: "UI>Shell>Containers"
-}
+mixins: "//chrome/browser/ash/guest_os/COMMON_METADATA"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/human_presence_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/human_presence_internals_ui.cc
index 6af5197bcd0..4b57f8dda72 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/human_presence_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/human_presence_internals_ui.cc
@@ -15,11 +15,11 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
+#include "chromeos/ash/components/dbus/hps/hps_service.pb.h"
+#include "chromeos/ash/components/dbus/human_presence/human_presence_dbus_client.h"
#include "chromeos/ash/components/human_presence/human_presence_configuration.h"
#include "chromeos/ash/components/human_presence/human_presence_internals.h"
#include "chromeos/ash/grit/ash_resources.h"
-#include "chromeos/dbus/hps/hps_service.pb.h"
-#include "chromeos/dbus/human_presence/human_presence_dbus_client.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -27,10 +27,79 @@
namespace {
+constexpr int kConsecutiveResultsFilterConfig = static_cast<int>(
+ hps::FeatureConfig::FilterConfigCase::kConsecutiveResultsFilterConfig);
+constexpr int kAverageFilterConfig = static_cast<int>(
+ hps::FeatureConfig::FilterConfigCase::kAverageFilterConfig);
+
+hps::FeatureConfig ParseFeatureConfigFromList(const base::Value::List& args) {
+ hps::FeatureConfig config;
+
+ // Check there is only one element in the list.
+ if (args.size() != 1) {
+ LOG(ERROR) << "HumanPresenceInternalsUIMessageHandler: Unexpected args "
+ "list with size "
+ << args.size();
+ return config;
+ }
+
+ // Check the only element is a JSON dictionary.
+ const base::Value::Dict* arg0 = args[0].GetIfDict();
+ if (!arg0) {
+ LOG(ERROR) << "HumanPresenceInternalsUIMessageHandler: Unexpected arg0, "
+ "expecting a dictionary.";
+ return config;
+ }
+
+ // Check that there is a valid filter_config_case in the map.
+ absl::optional<int> filter_config_case = arg0->FindInt("filter_config_case");
+ if (!filter_config_case.has_value() ||
+ (filter_config_case.value() != kConsecutiveResultsFilterConfig &&
+ filter_config_case.value() != kAverageFilterConfig)) {
+ LOG(ERROR) << "HumanPresenceInternalsUIMessageHandler: Unexpected "
+ "filter_config_case.";
+ return config;
+ }
+
+ // For the case of kConsecutiveResultsFilterConfig.
+ if (filter_config_case.value() == kConsecutiveResultsFilterConfig) {
+ auto& consecutive_results_filter_config =
+ *config.mutable_consecutive_results_filter_config();
+ consecutive_results_filter_config.set_positive_score_threshold(
+ arg0->FindInt("positive_score_threshold").value_or(0));
+ consecutive_results_filter_config.set_negative_score_threshold(
+ arg0->FindInt("negative_score_threshold").value_or(0));
+ consecutive_results_filter_config.set_positive_count_threshold(
+ arg0->FindInt("positive_count_threshold").value_or(1));
+ consecutive_results_filter_config.set_negative_count_threshold(
+ arg0->FindInt("negative_count_threshold").value_or(1));
+ consecutive_results_filter_config.set_uncertain_count_threshold(
+ arg0->FindInt("uncertain_count_threshold").value_or(1));
+ return config;
+ }
+
+ // For the case of kAverageFilterConfig.
+ if (filter_config_case.value() == kAverageFilterConfig) {
+ auto& average_filter_config = *config.mutable_average_filter_config();
+ average_filter_config.set_average_window_size(
+ arg0->FindInt("average_window_size").value_or(1));
+ average_filter_config.set_positive_score_threshold(
+ arg0->FindInt("positive_score_threshold").value_or(0));
+ average_filter_config.set_negative_score_threshold(
+ arg0->FindInt("negative_score_threshold").value_or(0));
+ average_filter_config.set_default_uncertain_score(
+ arg0->FindInt("default_uncertain_score").value_or(1));
+ return config;
+ }
+
+ NOTREACHED();
+ return config;
+}
+
// Class acting as a controller of the chrome://hps-internals WebUI.
class HumanPresenceInternalsUIMessageHandler
: public content::WebUIMessageHandler,
- public chromeos::HumanPresenceDBusClient::Observer {
+ public ash::HumanPresenceDBusClient::Observer {
public:
HumanPresenceInternalsUIMessageHandler();
@@ -46,7 +115,7 @@ class HumanPresenceInternalsUIMessageHandler
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
- // chromeos::HumanPresenceDBusClient::Observer implementation.
+ // ash::HumanPresenceDBusClient::Observer implementation.
void OnHpsSenseChanged(const hps::HpsResultProto&) override;
void OnHpsNotifyChanged(const hps::HpsResultProto&) override;
void OnRestart() override;
@@ -67,8 +136,8 @@ class HumanPresenceInternalsUIMessageHandler
static absl::optional<std::string> ReadManifest();
void UpdateManifest(absl::optional<std::string> manifest);
- base::ScopedObservation<chromeos::HumanPresenceDBusClient,
- chromeos::HumanPresenceDBusClient::Observer>
+ base::ScopedObservation<ash::HumanPresenceDBusClient,
+ ash::HumanPresenceDBusClient::Observer>
human_presence_observation_{this};
base::WeakPtrFactory<HumanPresenceInternalsUIMessageHandler>
msg_weak_ptr_factory_{this};
@@ -94,26 +163,26 @@ void HumanPresenceInternalsUIMessageHandler::OnHpsNotifyChanged(
void HumanPresenceInternalsUIMessageHandler::OnLockOnLeaveResult(
absl::optional<hps::HpsResultProto> state) {
- base::DictionaryValue value;
+ base::Value::Dict value;
if (state.has_value()) {
- value.SetInteger("state", state->value());
- value.SetInteger("inference_result", state->inference_result());
- value.SetInteger("inference_result_valid", state->inference_result_valid());
+ value.Set("state", state->value());
+ value.Set("inference_result", state->inference_result());
+ value.Set("inference_result_valid", state->inference_result_valid());
} else {
- value.SetBoolean("disabled", true);
+ value.Set("disabled", true);
}
FireWebUIListener(hps::kHumanPresenceInternalsLockOnLeaveChangedEvent, value);
}
void HumanPresenceInternalsUIMessageHandler::OnSnoopingProtectionResult(
absl::optional<hps::HpsResultProto> state) {
- base::DictionaryValue value;
+ base::Value::Dict value;
if (state.has_value()) {
- value.SetInteger("state", state->value());
- value.SetInteger("inference_result", state->inference_result());
- value.SetInteger("inference_result_valid", state->inference_result_valid());
+ value.Set("state", state->value());
+ value.Set("inference_result", state->inference_result());
+ value.Set("inference_result_valid", state->inference_result_valid());
} else {
- value.SetBoolean("disabled", true);
+ value.Set("disabled", true);
}
FireWebUIListener(hps::kHumanPresenceInternalsSnoopingProtectionChangedEvent,
value);
@@ -129,19 +198,20 @@ void HumanPresenceInternalsUIMessageHandler::OnShutdown() {
void HumanPresenceInternalsUIMessageHandler::Connect(
const base::Value::List& args) {
- if (!chromeos::HumanPresenceDBusClient::Get()) {
- LOG(ERROR) << "HPS dbus client not available";
+ if (!ash::HumanPresenceDBusClient::Get()) {
+ LOG(ERROR) << "HumanPresenceInternalsUIMessageHandler: HPS dbus client not "
+ "available";
return;
}
AllowJavascript();
- chromeos::HumanPresenceDBusClient::Get()->WaitForServiceToBeAvailable(
+ ash::HumanPresenceDBusClient::Get()->WaitForServiceToBeAvailable(
base::BindOnce(&HumanPresenceInternalsUIMessageHandler::OnConnected,
weak_ptr_factory_.GetWeakPtr()));
}
void HumanPresenceInternalsUIMessageHandler::OnConnected(bool connected) {
- base::DictionaryValue value;
- value.SetBoolean("connected", connected);
+ base::Value::Dict value;
+ value.Set("connected", connected);
FireWebUIListener(hps::kHumanPresenceInternalsConnectedEvent, value);
if (connected) {
@@ -177,54 +247,80 @@ void HumanPresenceInternalsUIMessageHandler::UpdateManifest(
void HumanPresenceInternalsUIMessageHandler::EnableLockOnLeave(
const base::Value::List& args) {
- if (!chromeos::HumanPresenceDBusClient::Get() ||
- !hps::GetEnableLockOnLeaveConfig().has_value()) {
+ hps::FeatureConfig config;
+
+ // If the args is empty, then try to get config from finch.
+ if (args.empty()) {
+ if (!ash::HumanPresenceDBusClient::Get() ||
+ !hps::GetEnableLockOnLeaveConfig().has_value()) {
+ FireWebUIListener(hps::kHumanPresenceInternalsEnableErrorEvent);
+ return;
+ }
+ config = *hps::GetEnableLockOnLeaveConfig();
+ } else {
+ // Gets config from JSON list.
+ config = ParseFeatureConfigFromList(args);
+ }
+ if (config.filter_config_case() ==
+ hps::FeatureConfig::FilterConfigCase::FILTER_CONFIG_NOT_SET) {
FireWebUIListener(hps::kHumanPresenceInternalsEnableErrorEvent);
return;
}
- hps::FeatureConfig config(*hps::GetEnableLockOnLeaveConfig());
config.set_report_raw_results(true);
- chromeos::HumanPresenceDBusClient::Get()->EnableHpsSense(config);
+ ash::HumanPresenceDBusClient::Get()->EnableHpsSense(config);
}
void HumanPresenceInternalsUIMessageHandler::DisableLockOnLeave(
const base::Value::List& args) {
- if (chromeos::HumanPresenceDBusClient::Get())
- chromeos::HumanPresenceDBusClient::Get()->DisableHpsSense();
+ if (ash::HumanPresenceDBusClient::Get())
+ ash::HumanPresenceDBusClient::Get()->DisableHpsSense();
}
void HumanPresenceInternalsUIMessageHandler::QueryLockOnLeave(
const base::Value::List& args) {
- if (!chromeos::HumanPresenceDBusClient::Get())
+ if (!ash::HumanPresenceDBusClient::Get())
return;
- chromeos::HumanPresenceDBusClient::Get()->GetResultHpsSense(base::BindOnce(
+ ash::HumanPresenceDBusClient::Get()->GetResultHpsSense(base::BindOnce(
&HumanPresenceInternalsUIMessageHandler::OnLockOnLeaveResult,
weak_ptr_factory_.GetWeakPtr()));
}
void HumanPresenceInternalsUIMessageHandler::EnableSnoopingProtection(
const base::Value::List& args) {
- if (!chromeos::HumanPresenceDBusClient::Get() ||
- !hps::GetEnableSnoopingProtectionConfig().has_value()) {
+ hps::FeatureConfig config;
+
+ // If the args is empty, then try to get config from finch.
+ if (args.empty()) {
+ if (!ash::HumanPresenceDBusClient::Get() ||
+ !hps::GetEnableSnoopingProtectionConfig().has_value()) {
+ FireWebUIListener(hps::kHumanPresenceInternalsEnableErrorEvent);
+ return;
+ }
+ config = *hps::GetEnableSnoopingProtectionConfig();
+ } else {
+ // Gets config from JSON list.
+ config = ParseFeatureConfigFromList(args);
+ }
+ if (config.filter_config_case() ==
+ hps::FeatureConfig::FilterConfigCase::FILTER_CONFIG_NOT_SET) {
FireWebUIListener(hps::kHumanPresenceInternalsEnableErrorEvent);
return;
}
- hps::FeatureConfig config(*hps::GetEnableSnoopingProtectionConfig());
config.set_report_raw_results(true);
- chromeos::HumanPresenceDBusClient::Get()->EnableHpsNotify(config);
+ ash::HumanPresenceDBusClient::Get()->EnableHpsNotify(config);
}
void HumanPresenceInternalsUIMessageHandler::DisableSnoopingProtection(
const base::Value::List& args) {
- if (chromeos::HumanPresenceDBusClient::Get())
- chromeos::HumanPresenceDBusClient::Get()->DisableHpsNotify();
+ if (ash::HumanPresenceDBusClient::Get())
+ ash::HumanPresenceDBusClient::Get()->DisableHpsNotify();
}
void HumanPresenceInternalsUIMessageHandler::QuerySnoopingProtection(
const base::Value::List& args) {
- if (!chromeos::HumanPresenceDBusClient::Get())
+ if (!ash::HumanPresenceDBusClient::Get())
return;
- chromeos::HumanPresenceDBusClient::Get()->GetResultHpsNotify(base::BindOnce(
+ ash::HumanPresenceDBusClient::Get()->GetResultHpsNotify(base::BindOnce(
&HumanPresenceInternalsUIMessageHandler::OnSnoopingProtectionResult,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -267,9 +363,8 @@ void HumanPresenceInternalsUIMessageHandler::RegisterMessages() {
}
void HumanPresenceInternalsUIMessageHandler::OnJavascriptAllowed() {
- if (chromeos::HumanPresenceDBusClient::Get())
- human_presence_observation_.Observe(
- chromeos::HumanPresenceDBusClient::Get());
+ if (ash::HumanPresenceDBusClient::Get())
+ human_presence_observation_.Observe(ash::HumanPresenceDBusClient::Get());
}
void HumanPresenceInternalsUIMessageHandler::OnJavascriptDisallowed() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
index de8c3981bfb..6e07ddbcf42 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -85,9 +85,9 @@ void ImageSource::StartDataRequestAfterPathExists(
}
}
-std::string ImageSource::GetMimeType(const std::string& path) {
+std::string ImageSource::GetMimeType(const GURL& url) {
std::string mime_type;
- std::string ext = base::FilePath(path).Extension();
+ std::string ext = base::FilePath(url.path_piece()).Extension();
if (!ext.empty())
net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type);
return mime_type;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/image_source.h b/chromium/chrome/browser/ui/webui/chromeos/image_source.h
index 9516b76a683..843934a5d08 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/image_source.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/image_source.h
@@ -35,7 +35,7 @@ class ImageSource : public content::URLDataSource {
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback got_data_callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
private:
// Continuation from StartDataRequest().
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc
index d177534ca60..342f974bf5d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "ash/components/login/auth/saml_password_attributes.h"
+#include "ash/components/login/auth/public/saml_password_attributes.h"
#include "base/check.h"
#include "base/values.h"
#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
@@ -52,24 +52,24 @@ ConfirmPasswordChangeHandler::~ConfirmPasswordChangeHandler() {
}
void ConfirmPasswordChangeHandler::HandleGetInitialState(
- const base::ListValue* params) {
- const std::string callback_id = params->GetListDeprecated()[0].GetString();
+ const base::Value::List& params) {
+ const std::string callback_id = params[0].GetString();
- base::Value state(base::Value::Type::DICTIONARY);
- state.SetBoolKey("showOldPasswordPrompt", scraped_old_password_.empty());
- state.SetBoolKey("showNewPasswordPrompt", scraped_new_password_.empty());
- state.SetBoolKey("showSpinner", show_spinner_initially_);
+ base::Value::Dict state;
+ state.Set("showOldPasswordPrompt", scraped_old_password_.empty());
+ state.Set("showNewPasswordPrompt", scraped_new_password_.empty());
+ state.Set("showSpinner", show_spinner_initially_);
AllowJavascript();
ResolveJavascriptCallback(base::Value(callback_id), state);
}
void ConfirmPasswordChangeHandler::HandleChangePassword(
- const base::ListValue* params) {
- const std::string old_password = FirstNonEmpty(
- params->GetListDeprecated()[0].GetString(), scraped_old_password_);
- const std::string new_password = FirstNonEmpty(
- params->GetListDeprecated()[1].GetString(), scraped_new_password_);
+ const base::Value::List& params) {
+ const std::string old_password =
+ FirstNonEmpty(params[0].GetString(), scraped_old_password_);
+ const std::string new_password =
+ FirstNonEmpty(params[1].GetString(), scraped_new_password_);
DCHECK(!old_password.empty() && !new_password.empty());
InSessionPasswordChangeManager::Get()->ChangePassword(
@@ -92,11 +92,11 @@ void ConfirmPasswordChangeHandler::OnEvent(
}
void ConfirmPasswordChangeHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getInitialState",
base::BindRepeating(&ConfirmPasswordChangeHandler::HandleGetInitialState,
weak_factory_.GetWeakPtr()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"changePassword",
base::BindRepeating(&ConfirmPasswordChangeHandler::HandleChangePassword,
weak_factory_.GetWeakPtr()));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h
index c0cbb31879e..14165ae92c4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h
@@ -27,11 +27,11 @@ class ConfirmPasswordChangeHandler
~ConfirmPasswordChangeHandler() override;
// Called by the JS UI to find out what to show and what size to be.
- void HandleGetInitialState(const base::ListValue* params);
+ void HandleGetInitialState(const base::Value::List& params);
// Tries to change the cryptohome password once the confirm-password-change
// dialog is filled in and the password change is confirmed.
- void HandleChangePassword(const base::ListValue* passwords);
+ void HandleChangePassword(const base::Value::List& passwords);
// InSessionPasswordChangeManager::Observer:
void OnEvent(InSessionPasswordChangeManager::Event event) override;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_captive_portal_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_captive_portal_dialog.cc
index b0978c3ed4f..a8c86d274a4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_captive_portal_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_captive_portal_dialog.cc
@@ -7,7 +7,7 @@
#include "ash/constants/ash_features.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h"
-#include "chromeos/network/network_connection_handler.h"
+#include "chromeos/ash/components/network/network_connection_handler.h"
#include "components/captive_portal/core/captive_portal_detector.h"
namespace chromeos {
@@ -21,9 +21,9 @@ LockScreenCaptivePortalDialog::LockScreenCaptivePortalDialog()
LockScreenCaptivePortalDialog::~LockScreenCaptivePortalDialog() = default;
void LockScreenCaptivePortalDialog::Show(Profile& profile) {
+ DCHECK(ProfileHelper::IsLockScreenProfile(&profile));
if (!is_running_) {
- ShowSystemDialogForBrowserContext(
- profile.GetPrimaryOTRProfile(/*create_if_needed=*/true));
+ ShowSystemDialogForBrowserContext(&profile);
is_running_ = true;
}
if (on_shown_callback_for_testing_) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_network_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_network_dialog.cc
index d93620bd9ba..3b8fbb7f7a7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_network_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_network_dialog.cc
@@ -41,8 +41,8 @@ void LockScreenNetworkDialog::OnDialogClosed(const std::string& json_retval) {
void LockScreenNetworkDialog::Show(Profile* profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- ShowSystemDialogForBrowserContext(
- profile->GetPrimaryOTRProfile(/*create_if_needed=*/true));
+ DCHECK(ProfileHelper::IsLockScreenProfile(profile));
+ ShowSystemDialogForBrowserContext(profile);
}
void LockScreenNetworkDialog::Dismiss() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc
index 2a5818e3e11..b697c6047b1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/base_lock_dialog.h"
@@ -30,9 +31,9 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_connection_handler.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_connection_handler.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -110,6 +111,24 @@ gfx::Size LockScreenStartReauthDialog::CalculateLockScreenReauthDialogSize(
return CalculateOobeDialogSizeForPrimaryDisplay();
}
+void LockScreenStartReauthDialog::RequestMediaAccessPermission(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ content::MediaResponseCallback callback) {
+ // This is required for accessing the camera for SAML logins.
+ MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
+ web_contents, request, std::move(callback), nullptr /* extension */);
+}
+
+bool LockScreenStartReauthDialog::CheckMediaAccessPermission(
+ content::RenderFrameHost* render_frame_host,
+ const GURL& security_origin,
+ blink::mojom::MediaStreamType type) {
+ // This is required for accessing the camera for SAML logins.
+ return MediaCaptureDevicesDispatcher::GetInstance()
+ ->CheckMediaAccessPermission(render_frame_host, security_origin, type);
+}
+
void LockScreenStartReauthDialog::Show() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (g_dialog) {
@@ -127,9 +146,8 @@ void LockScreenStartReauthDialog::OnProfileCreated(
Profile* profile,
Profile::CreateStatus status) {
if (status == Profile::CREATE_STATUS_INITIALIZED) {
- profile_ = profile;
- g_dialog->ShowSystemDialogForBrowserContext(
- profile->GetPrimaryOTRProfile(/*create_if_needed=*/true));
+ profile_ = profile->GetPrimaryOTRProfile(/*create_if_needed=*/true);
+ g_dialog->ShowSystemDialogForBrowserContext(profile_);
const NetworkStateInformer::State state = network_state_informer_->state();
// Show network or captive portal screen if needed.
// TODO(crbug.com/1237407): Handle other states in NetworkStateInformer
@@ -162,6 +180,13 @@ int LockScreenStartReauthDialog::GetDialogWidth() {
return ret.width();
}
+content::WebContents* LockScreenStartReauthDialog::GetWebContents() {
+ auto* web_ui = webui();
+ if (!web_ui)
+ return nullptr;
+ return web_ui->GetWebContents();
+}
+
void LockScreenStartReauthDialog::DeleteLockScreenNetworkDialog() {
if (!lock_screen_network_dialog_)
return;
@@ -282,6 +307,14 @@ void LockScreenStartReauthDialog::UpdateState(
const NetworkStateInformer::State state = network_state_informer_->state();
+ // If frame didn't load but we believe that we are online then we want to show
+ // the network screen (mimicking behaviour of `ErrorScreen` on signin screen).
+ if (reason == NetworkError::ERROR_REASON_FRAME_ERROR &&
+ state == NetworkStateInformer::ONLINE) {
+ ShowLockScreenNetworkDialog();
+ return;
+ }
+
if (state == NetworkStateInformer::OFFLINE) {
ShowLockScreenNetworkDialog();
} else if (state == NetworkStateInformer::CAPTIVE_PORTAL) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h
index dd0f612c11a..d6e0d722797 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h
@@ -12,8 +12,8 @@
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/base_lock_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state_handler_observer.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -35,10 +35,20 @@ class LockScreenStartReauthDialog
LockScreenStartReauthDialog(LockScreenStartReauthDialog const&) = delete;
~LockScreenStartReauthDialog() override;
+ // content::WebDialogDelegate
+ void RequestMediaAccessPermission(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ content::MediaResponseCallback callback) override;
+ bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
+ const GURL& security_origin,
+ blink::mojom::MediaStreamType type) override;
+
void Show();
void Dismiss();
bool IsRunning();
int GetDialogWidth();
+ content::WebContents* GetWebContents();
void DismissLockScreenNetworkDialog();
void DismissLockScreenCaptivePortalDialog();
@@ -53,6 +63,9 @@ class LockScreenStartReauthDialog
bool IsCaptivePortalDialogLoadedForTesting(base::OnceClosure callback);
void OnNetworkDialogReadyForTesting();
+ // NetworkStateInformer::NetworkStateInformerObserver:
+ void UpdateState(NetworkError::ErrorReason reason) override;
+
LockScreenNetworkDialog* get_network_dialog_for_testing() {
return lock_screen_network_dialog_.get();
}
@@ -75,9 +88,6 @@ class LockScreenStartReauthDialog
void OnDialogShown(content::WebUI* webui) override;
void OnDialogClosed(const std::string& json_retval) override;
- // NetworkStateInformer::NetworkStateInformerObserver:
- void UpdateState(NetworkError::ErrorReason reason) override;
-
// ChromeWebModalDialogManagerDelegate:
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc
index 2028ad296b0..ea4aa13eaec 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc
@@ -7,9 +7,10 @@
#include <memory>
#include "ash/components/login/auth/challenge_response/cert_utils.h"
-#include "ash/components/login/auth/cryptohome_key_constants.h"
+#include "ash/components/login/auth/public/cryptohome_key_constants.h"
#include "ash/constants/ash_features.h"
#include "base/notreached.h"
+#include "chrome/browser/ash/login/login_pref_names.h"
#include "chrome/browser/ash/login/saml/in_session_password_sync_manager.h"
#include "chrome/browser/ash/login/saml/in_session_password_sync_manager_factory.h"
#include "chrome/browser/ash/login/signin_partition_manager.h"
@@ -22,7 +23,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "chromeos/dbus/util/version_loader.h"
+#include "chromeos/version/version_loader.h"
#include "components/account_id/account_id.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/user_manager/known_user.h"
@@ -30,6 +31,7 @@
#include "content/public/browser/storage_partition.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h"
+#include "net/base/net_errors.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
@@ -132,12 +134,16 @@ void LockScreenReauthHandler::LoadAuthenticatorParam() {
}
void LockScreenReauthHandler::LoadGaia(const login::GaiaContext& context) {
+ LOG_ASSERT(Profile::FromWebUI(web_ui()) ==
+ ProfileHelper::Get()->GetLockScreenProfile());
// Start a new session with SigninPartitionManager, generating a unique
// StoragePartition.
login::SigninPartitionManager* signin_partition_manager =
login::SigninPartitionManager::Factory::GetForBrowserContext(
Profile::FromWebUI(web_ui()));
+ // TODO(http://crbug/1348126): we should also close signin session after the
+ // flow is finished.
signin_partition_manager->StartSigninSession(
web_ui()->GetWebContents(),
base::BindOnce(&LockScreenReauthHandler::LoadGaiaWithPartition,
@@ -205,8 +211,13 @@ void LockScreenReauthHandler::OnSetCookieForLoadGaiaWithPartition(
login::ExtractSamlPasswordAttributesEnabled());
params.SetStringKey("clientVersion", version_info::GetVersionNumber());
params.SetBoolKey("readOnlyEmail", true);
- params.SetBoolKey("enableAzureADIntegration",
- ash::features::IsAzureADIntegrationEnabled());
+ PrefService* local_state = g_browser_process->local_state();
+ if (local_state->IsManagedPreference(
+ ash::prefs::kUrlParameterToAutofillSAMLUsername)) {
+ params.SetStringKey("urlParameterToAutofillSAMLUsername",
+ local_state->GetString(
+ ash::prefs::kUrlParameterToAutofillSAMLUsername));
+ }
CallJavascript("loadAuthenticator", params);
if (features::IsNewLockScreenReauthLayoutEnabled()) {
@@ -383,6 +394,24 @@ void LockScreenReauthHandler::SamlConfirmPassword(
weak_factory_.GetWeakPtr()));
}
+void LockScreenReauthHandler::HandleWebviewLoadAborted(int error_code) {
+ if (error_code == net::ERR_INVALID_AUTH_CREDENTIALS) {
+ // Silently ignore this error - it is used as an intermediate state for
+ // committed interstitials (see https://crbug.com/1049349 for details).
+ return;
+ }
+
+ if (error_code == net::ERR_ABORTED) {
+ LOG(WARNING) << "Ignoring Gaia webview error: "
+ << net::ErrorToShortString(error_code);
+ return;
+ }
+
+ LOG(ERROR) << "Gaia webview error: " << net::ErrorToShortString(error_code);
+ auto* password_sync_manager = GetInSessionPasswordSyncManager();
+ password_sync_manager->OnWebviewLoadAborted();
+}
+
void LockScreenReauthHandler::ReloadGaia() {
CallJavascriptFunction(std::string(kMainElement) + "reloadAuthenticator");
}
@@ -410,6 +439,10 @@ void LockScreenReauthHandler::RegisterMessages() {
"onPasswordTyped",
base::BindRepeating(&LockScreenReauthHandler::HandleOnPasswordTyped,
weak_factory_.GetWeakPtr()));
+ web_ui()->RegisterHandlerCallback(
+ "webviewLoadAborted",
+ base::BindRepeating(&LockScreenReauthHandler::HandleWebviewLoadAborted,
+ weak_factory_.GetWeakPtr()));
}
bool LockScreenReauthHandler::IsAuthenticatorLoaded(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h
index bdef4dc5ed8..a32bc7861e6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h
@@ -34,6 +34,7 @@ class LockScreenReauthHandler : public content::WebUIMessageHandler {
void HandleAuthenticatorLoaded(const base::Value::List&);
void HandleUpdateUserPassword(const base::Value::List&);
void HandleOnPasswordTyped(const base::Value::List& value);
+ void HandleWebviewLoadAborted(int error_code);
bool IsAuthenticatorLoaded(base::OnceClosure callback);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc
index cb89578bd22..07013a3bc7a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "ash/components/login/auth/saml_password_attributes.h"
+#include "ash/components/login/auth/public/saml_password_attributes.h"
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h"
@@ -24,7 +24,7 @@ PasswordChangeHandler::PasswordChangeHandler(
: password_change_url_(password_change_url) {}
PasswordChangeHandler::~PasswordChangeHandler() = default;
-void PasswordChangeHandler::HandleInitialize(const base::ListValue* value) {
+void PasswordChangeHandler::HandleInitialize(const base::Value::List& value) {
Profile* profile = Profile::FromWebUI(web_ui());
CHECK(profile->GetPrefs()->GetBoolean(
prefs::kSamlInSessionPasswordChangeEnabled));
@@ -44,9 +44,9 @@ void PasswordChangeHandler::HandleInitialize(const base::ListValue* value) {
}
void PasswordChangeHandler::HandleChangePassword(
- const base::ListValue* params) {
- const base::Value& old_passwords = params->GetListDeprecated()[0];
- const base::Value& new_passwords = params->GetListDeprecated()[1];
+ const base::Value::List& params) {
+ const base::Value& old_passwords = params[0];
+ const base::Value& new_passwords = params[1];
VLOG(4) << "Scraped " << old_passwords.GetListDeprecated().size()
<< " old passwords";
VLOG(4) << "Scraped " << new_passwords.GetListDeprecated().size()
@@ -66,11 +66,11 @@ void PasswordChangeHandler::HandleChangePassword(
}
void PasswordChangeHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"initialize",
base::BindRepeating(&PasswordChangeHandler::HandleInitialize,
weak_factory_.GetWeakPtr()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"changePassword",
base::BindRepeating(&PasswordChangeHandler::HandleChangePassword,
weak_factory_.GetWeakPtr()));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h
index 2702af9dedb..fe34ab115da 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h
@@ -23,8 +23,8 @@ class PasswordChangeHandler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler:
void RegisterMessages() override;
- void HandleInitialize(const base::ListValue*);
- void HandleChangePassword(const base::ListValue* passwords);
+ void HandleInitialize(const base::Value::List&);
+ void HandleChangePassword(const base::Value::List& passwords);
private:
const std::string password_change_url_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc
index e6d6433b019..eda40613505 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "ash/components/login/auth/saml_password_attributes.h"
+#include "ash/components/login/auth/public/saml_password_attributes.h"
#include "ash/constants/ash_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -180,8 +180,8 @@ UrgentPasswordExpiryNotificationUI::UrgentPasswordExpiryNotificationUI(
source->UseStringsJs();
source->SetDefaultResource(IDR_URGENT_PASSWORD_EXPIRY_NOTIFICATION_HTML);
- source->AddResourcePath("urgent_password_expiry_notification.js",
- IDR_URGENT_PASSWORD_EXPIRY_NOTIFICATION_JS);
+ source->AddResourcePath("urgent_password_expiry_notification_app.js",
+ IDR_URGENT_PASSWORD_EXPIRY_NOTIFICATION_APP_JS);
web_ui->AddMessageHandler(
std::make_unique<UrgentPasswordExpiryNotificationHandler>());
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc
index 66ab0495c2b..718077b2726 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "ash/components/login/auth/saml_password_attributes.h"
+#include "ash/components/login/auth/public/saml_password_attributes.h"
#include "base/values.h"
#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
#include "chrome/browser/ash/login/saml/password_expiry_notification.h"
@@ -24,14 +24,14 @@ UrgentPasswordExpiryNotificationHandler::
~UrgentPasswordExpiryNotificationHandler() = default;
void UrgentPasswordExpiryNotificationHandler::HandleContinue(
- const base::ListValue* params) {
+ const base::Value::List& params) {
InSessionPasswordChangeManager::Get()->StartInSessionPasswordChange();
}
void UrgentPasswordExpiryNotificationHandler::HandleGetTitleText(
- const base::ListValue* params) {
- const std::string callback_id = params->GetListDeprecated()[0].GetString();
- const int ms_until_expiry = params->GetListDeprecated()[1].GetInt();
+ const base::Value::List& params) {
+ const std::string callback_id = params[0].GetString();
+ const int ms_until_expiry = params[1].GetInt();
const std::u16string title = PasswordExpiryNotification::GetTitleText(
base::Milliseconds(ms_until_expiry));
@@ -41,11 +41,11 @@ void UrgentPasswordExpiryNotificationHandler::HandleGetTitleText(
}
void UrgentPasswordExpiryNotificationHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"continue", base::BindRepeating(
&UrgentPasswordExpiryNotificationHandler::HandleContinue,
weak_factory_.GetWeakPtr()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getTitleText",
base::BindRepeating(
&UrgentPasswordExpiryNotificationHandler::HandleGetTitleText,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h
index fc5978420b1..7ec5ed3bfd1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h
@@ -27,10 +27,10 @@ class UrgentPasswordExpiryNotificationHandler
void RegisterMessages() override;
// User taps the button and agrees to change their password.
- void HandleContinue(const base::ListValue* params);
+ void HandleContinue(const base::Value::List& params);
// Need to update title to show new time remaining until password expiry.
- void HandleGetTitleText(const base::ListValue* params);
+ void HandleGetTitleText(const base::Value::List& params);
private:
base::WeakPtrFactory<UrgentPasswordExpiryNotificationHandler> weak_factory_{
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
index 964cdbddad2..5b655770fc0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
@@ -13,10 +13,10 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/internet_config_dialog_resources.h"
#include "chrome/grit/internet_config_dialog_resources_map.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_util.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_util.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" // nogncheck
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h
index 6fa5967c17d..7442e3b96d4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.h
@@ -8,14 +8,14 @@
#include <string>
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+// TODO(https://crbug.com/1164001): move to forward declaration
+#include "chromeos/ash/components/network/network_state.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h" // nogncheck
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/web_dialogs/web_dialog_ui.h"
namespace chromeos {
-class NetworkState;
-
class InternetConfigDialog : public SystemWebDialogDelegate {
public:
InternetConfigDialog(const InternetConfigDialog&) = delete;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
index 91bd29824b8..f451ff95f67 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
@@ -16,10 +16,10 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/internet_detail_dialog_resources.h"
#include "chrome/grit/internet_detail_dialog_resources_map.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_util.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_util.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" // nogncheck
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/strings/grit/components_strings.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.h
index d0ff2b66cd9..9ad6d377756 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_INTERNET_DETAIL_DIALOG_H_
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+// TODO(https://crbug.com/1164001): move to forward declaration
+#include "chromeos/ash/components/network/network_state.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h" // nogncheck
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/gfx/native_widget_types.h"
@@ -13,8 +15,6 @@
namespace chromeos {
-class NetworkState;
-
class InternetDetailDialog : public SystemWebDialogDelegate {
public:
InternetDetailDialog(const InternetDetailDialog&) = delete;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
index 4eaed4b9fbf..64c5b7c56a5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
@@ -1,10 +1 @@
-# primary (in CET)
-antrim@chromium.org
-raleksandrov@google.com
-rsorokin@chromium.org
-rrsilva@google.com
-
-# secondary (in PST)
-achuith@chromium.org
-alemate@chromium.org
-tbarzic@chromium.org
+file://ash/login/OOBE_WEBUI_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc
index 7ca163aeb24..07a6280a5f2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc
@@ -18,8 +18,7 @@ int GetNumberOfUserSelectedApps() {
const Profile* profile = ProfileManager::GetActiveUserProfile();
const PrefService* pref_service = profile->GetPrefs();
return static_cast<int>(
- pref_service->Get(arc::prefs::kArcFastAppReinstallPackages)
- ->GetListDeprecated()
+ pref_service->GetValueList(arc::prefs::kArcFastAppReinstallPackages)
.size());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
index c0af736e128..3f3a5277ac2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
@@ -17,8 +17,8 @@
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -40,8 +40,6 @@ std::string GetNetworkName(const std::string& service_path) {
namespace chromeos {
-constexpr StaticOobeScreenId AppLaunchSplashScreenView::kScreenId;
-
AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler(
const scoped_refptr<NetworkStateInformer>& network_state_informer,
ErrorScreen* error_screen)
@@ -69,19 +67,7 @@ void AppLaunchSplashScreenHandler::DeclareLocalizedValues(
product_os_name));
}
-void AppLaunchSplashScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- show_on_init_ = false;
- Show();
- }
-}
-
void AppLaunchSplashScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
-
is_shown_ = true;
base::Value::Dict data;
@@ -105,8 +91,6 @@ void AppLaunchSplashScreenHandler::Show() {
void AppLaunchSplashScreenHandler::RegisterMessages() {
AddCallback("configureNetwork",
&AppLaunchSplashScreenHandler::HandleConfigureNetwork);
- AddCallback("continueAppLaunch",
- &AppLaunchSplashScreenHandler::HandleContinueAppLaunch);
}
void AppLaunchSplashScreenHandler::Hide() {
@@ -126,10 +110,7 @@ void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) {
return;
state_ = state;
- if (IsJavascriptAllowed()) {
- SetLaunchText(
- l10n_util::GetStringUTF8(GetProgressMessageFromState(state_)));
- }
+ SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_)));
UpdateState(NetworkError::ERROR_REASON_UPDATE);
}
@@ -245,7 +226,7 @@ void AppLaunchSplashScreenHandler::PopulateAppInfo(
}
void AppLaunchSplashScreenHandler::SetLaunchText(const std::string& text) {
- CallJS("login.AppLaunchSplashScreen.updateMessage", text);
+ CallExternalAPI("updateMessage", text);
}
int AppLaunchSplashScreenHandler::GetProgressMessageFromState(
@@ -277,7 +258,7 @@ void AppLaunchSplashScreenHandler::HandleConfigureNetwork() {
LOG(WARNING) << "No delegate set to handle network configuration.";
}
-void AppLaunchSplashScreenHandler::HandleContinueAppLaunch() {
+void AppLaunchSplashScreenHandler::ContinueAppLaunch() {
if (!delegate_)
return;
@@ -287,7 +268,7 @@ void AppLaunchSplashScreenHandler::HandleContinueAppLaunch() {
}
void AppLaunchSplashScreenHandler::DoToggleNetworkConfig(bool visible) {
- CallJS("login.AppLaunchSplashScreen.toggleNetworkConfig", visible);
+ CallExternalAPI("toggleNetworkConfig", visible);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
index 86f687523c1..5455b25b2c9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
@@ -53,7 +53,8 @@ class AppLaunchSplashScreenView {
kShowingNetworkConfigureUI,
};
- constexpr static StaticOobeScreenId kScreenId{"app-launch-splash"};
+ inline constexpr static StaticOobeScreenId kScreenId{"app-launch-splash",
+ "AppLaunchSplashScreen"};
virtual ~AppLaunchSplashScreenView() {}
@@ -80,6 +81,9 @@ class AppLaunchSplashScreenView {
// Returns true if the default network has Internet access.
virtual bool IsNetworkReady() = 0;
+
+ // Continues app launch after error screen is shown.
+ virtual void ContinueAppLaunch() = 0;
};
// A class that handles the WebUI hooks for the app launch splash screen.
@@ -103,7 +107,6 @@ class AppLaunchSplashScreenHandler
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
// WebUIMessageHandler implementation:
void RegisterMessages() override;
@@ -117,6 +120,7 @@ class AppLaunchSplashScreenHandler
void ShowNetworkConfigureUI() override;
void ShowErrorMessage(KioskAppLaunchError::Error error) override;
bool IsNetworkReady() override;
+ void ContinueAppLaunch() override;
// NetworkStateInformer::NetworkStateInformerObserver implementation:
void OnNetworkReady() override;
@@ -127,12 +131,10 @@ class AppLaunchSplashScreenHandler
void SetLaunchText(const std::string& text);
int GetProgressMessageFromState(AppLaunchState state);
void HandleConfigureNetwork();
- void HandleContinueAppLaunch();
void DoToggleNetworkConfig(bool visible);
Delegate* delegate_ = nullptr;
bool is_shown_ = false;
- bool show_on_init_ = false;
AppLaunchState state_ = AppLaunchState::kPreparingProfile;
scoped_refptr<NetworkStateInformer> network_state_informer_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
index 988cdc5f68e..2d5d36e97ca 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
@@ -26,9 +26,8 @@
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
#include "components/consent_auditor/consent_auditor.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
@@ -68,8 +67,6 @@ ArcTermsOfServiceScreenHandler::~ArcTermsOfServiceScreenHandler() {
oobe_ui->RemoveObserver(this);
if (network_time_zone_observing_) {
network_time_zone_observing_ = false;
- chromeos::NetworkHandler::Get()->network_state_handler()->RemoveObserver(
- this, FROM_HERE);
system::TimezoneSettings::GetInstance()->RemoveObserver(this);
}
if (session_manager_observing_ && session_manager::SessionManager::Get()) {
@@ -142,11 +139,12 @@ void ArcTermsOfServiceScreenHandler::DeclareLocalizedValues(
builder->Add("arcTermsOfServiceScreenHeadingForChild",
IDS_ARC_OOBE_TERMS_HEADING_CHILD);
builder->Add("arcTermsOfServiceScreenDescription",
- IDS_ARC_OOBE_TERMS_DESCRIPTION);
+ IDS_ARC_OOBE_TERMS_DESCRIPTION);
builder->Add("arcTermsOfServiceScreenDescriptionForChild",
IDS_ARC_OOBE_TERMS_DESCRIPTION_CHILD);
builder->Add("arcTermsOfServiceLoading", IDS_ARC_OOBE_TERMS_LOADING);
- builder->Add("arcTermsOfServiceErrorTitle", IDS_OOBE_GENERIC_FATAL_ERROR_TITLE);
+ builder->Add("arcTermsOfServiceErrorTitle",
+ IDS_OOBE_GENERIC_FATAL_ERROR_TITLE);
builder->Add("arcTermsOfServiceErrorMessage", IDS_ARC_OOBE_TERMS_LOAD_ERROR);
builder->Add("arcTermsOfServiceRetryButton", IDS_ARC_OOBE_TERMS_BUTTON_RETRY);
builder->Add("arcTermsOfServiceAcceptButton",
@@ -252,8 +250,7 @@ void ArcTermsOfServiceScreenHandler::OnMetricsModeChanged(bool enabled,
ProfileHelper::Get()->GetUserByProfile(profile);
CHECK(user);
- const AccountId owner =
- user_manager::UserManager::Get()->GetOwnerAccountId();
+ const AccountId owner = user_manager::UserManager::Get()->GetOwnerAccountId();
// Owner may not be set in case of initial account setup. Note, in case of
// enterprise enrolled devices owner is always empty and we need to account
@@ -281,14 +278,16 @@ void ArcTermsOfServiceScreenHandler::OnMetricsModeChanged(bool enabled,
}
void ArcTermsOfServiceScreenHandler::OnBackupAndRestoreModeChanged(
- bool enabled, bool managed) {
+ bool enabled,
+ bool managed) {
backup_restore_managed_ = managed;
CallJS("login.ArcTermsOfServiceScreen.setBackupAndRestoreMode", enabled,
managed);
}
void ArcTermsOfServiceScreenHandler::OnLocationServicesModeChanged(
- bool enabled, bool managed) {
+ bool enabled,
+ bool managed) {
location_services_managed_ = managed;
CallJS("login.ArcTermsOfServiceScreen.setLocationServicesMode", enabled,
managed);
@@ -323,8 +322,7 @@ void ArcTermsOfServiceScreenHandler::Show() {
void ArcTermsOfServiceScreenHandler::Hide() {
if (network_time_zone_observing_) {
network_time_zone_observing_ = false;
- chromeos::NetworkHandler::Get()->network_state_handler()->RemoveObserver(
- this, FROM_HERE);
+ network_state_handler_observer_.Reset();
system::TimezoneSettings::GetInstance()->RemoveObserver(this);
}
if (session_manager_observing_ && session_manager::SessionManager::Get()) {
@@ -342,8 +340,8 @@ void ArcTermsOfServiceScreenHandler::StartNetworkAndTimeZoneObserving() {
if (network_time_zone_observing_)
return;
- chromeos::NetworkHandler::Get()->network_state_handler()->AddObserver(
- this, FROM_HERE);
+ network_state_handler_observer_.Observe(
+ chromeos::NetworkHandler::Get()->network_state_handler());
system::TimezoneSettings::GetInstance()->AddObserver(this);
network_time_zone_observing_ = true;
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
index 45fd506ab60..7045a0cb083 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
@@ -10,10 +10,12 @@
#include "ash/components/settings/timezone_settings.h"
#include "base/observer_list.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ash/arc/optin/arc_optin_preference_handler_observer.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
-#include "chromeos/network/network_state_handler_observer.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state_handler_observer.h"
#include "components/session_manager/core/session_manager_observer.h"
namespace arc {
@@ -194,6 +196,10 @@ class ArcTermsOfServiceScreenHandler
// To track if a child account is being set up.
bool is_child_account_;
+ base::ScopedObservation<chromeos::NetworkStateHandler,
+ chromeos::NetworkStateHandlerObserver>
+ network_state_handler_observer_{this};
+
std::unique_ptr<arc::ArcOptInPreferenceHandler> pref_handler_;
};
@@ -205,6 +211,6 @@ namespace ash {
using ::chromeos::ArcTermsOfServiceScreenHandler;
using ::chromeos::ArcTermsOfServiceScreenView;
using ::chromeos::ArcTermsOfServiceScreenViewObserver;
-}
+} // namespace ash
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ARC_TERMS_OF_SERVICE_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
index 99bfe5d8a4d..af916f9c5b7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
@@ -21,12 +21,12 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_prefs.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_service.h"
+#include "chromeos/ash/services/assistant/public/cpp/features.h"
+#include "chromeos/ash/services/assistant/public/proto/get_settings_ui.pb.h"
+#include "chromeos/ash/services/assistant/public/proto/settings_ui.pb.h"
#include "chromeos/dbus/power/power_manager_client.h"
-#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
-#include "chromeos/services/assistant/public/cpp/assistant_service.h"
-#include "chromeos/services/assistant/public/cpp/features.h"
-#include "chromeos/services/assistant/public/proto/get_settings_ui.pb.h"
-#include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h"
@@ -36,6 +36,18 @@
namespace chromeos {
+// TODO(https://crbug.com/1164001): remove after migrating to ash.
+namespace assistant {
+using ::ash::assistant::ConsentFlowUi_ConsentStatus_ALREADY_CONSENTED;
+using ::ash::assistant::ConsentFlowUi_ConsentStatus_ASK_FOR_CONSENT;
+using ::ash::assistant::ConsentFlowUiUpdateResult;
+using ::ash::assistant::EmailOptInUpdateResult;
+using ::ash::assistant::GetSettingsUiResponse;
+using ::ash::assistant::SettingsResponseHeader_AcceptRejectLayout_EQUAL_WEIGHT;
+using ::ash::assistant::SettingsUiSelector;
+using ::ash::assistant::SettingsUiUpdateResult;
+} // namespace assistant
+
namespace {
constexpr char kSkipPressed[] = "skip-pressed";
@@ -240,27 +252,23 @@ void AssistantOptInFlowScreenHandler::InitializeDeprecated() {
}
void AssistantOptInFlowScreenHandler::OnListeningHotword() {
- CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate",
- base::Value("listen"));
+ CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate", "listen");
}
void AssistantOptInFlowScreenHandler::OnProcessingHotword() {
- CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate",
- base::Value("process"));
+ CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate", "process");
}
void AssistantOptInFlowScreenHandler::OnSpeakerIdEnrollmentDone() {
StopSpeakerIdEnrollment();
- CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate",
- base::Value("done"));
+ CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate", "done");
}
void AssistantOptInFlowScreenHandler::OnSpeakerIdEnrollmentFailure() {
StopSpeakerIdEnrollment();
RecordAssistantOptInStatus(VOICE_MATCH_ENROLLMENT_ERROR);
voice_match_enrollment_error_ = true;
- CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate",
- base::Value("failure"));
+ CallJS("login.AssistantOptInFlowScreen.onVoiceMatchUpdate", "failure");
LOG(ERROR) << "Speaker ID enrollment failure.";
}
@@ -291,6 +299,7 @@ void AssistantOptInFlowScreenHandler::ShowNextScreen() {
void AssistantOptInFlowScreenHandler::OnActivityControlOptInResult(
bool opted_in) {
Profile* profile = ProfileManager::GetActiveUserProfile();
+ CHECK(!pending_consent_data_.empty());
auto data = pending_consent_data_.front();
pending_consent_data_.pop_front();
RecordActivityControlConsent(profile, data.ui_audit_key, opted_in,
@@ -298,6 +307,7 @@ void AssistantOptInFlowScreenHandler::OnActivityControlOptInResult(
if (opted_in) {
has_opted_in_any_consent_ = true;
RecordAssistantActivityControlOptInStatus(data.setting_type, opted_in);
+ CHECK(assistant::AssistantSettings::Get());
assistant::AssistantSettings::Get()->UpdateSettings(
GetSettingsUiUpdate(data.consent_token).SerializeAsString(),
base::BindOnce(
@@ -363,6 +373,7 @@ void AssistantOptInFlowScreenHandler::SendGetSettingsRequest() {
}
assistant::SettingsUiSelector selector = GetSettingsUiSelector();
+ CHECK(assistant::AssistantSettings::Get());
assistant::AssistantSettings::Get()->GetSettingsWithHeader(
selector.SerializeAsString(),
base::BindOnce(&AssistantOptInFlowScreenHandler::OnGetSettingsResponse,
@@ -373,17 +384,18 @@ void AssistantOptInFlowScreenHandler::SendGetSettingsRequest() {
void AssistantOptInFlowScreenHandler::StopSpeakerIdEnrollment() {
DCHECK(voice_match_enrollment_started_);
voice_match_enrollment_started_ = false;
+ CHECK(assistant::AssistantSettings::Get());
assistant::AssistantSettings::Get()->StopSpeakerIdEnrollment();
// Reset the mojom receiver of |SpeakerIdEnrollmentClient|.
ResetReceiver();
}
-void AssistantOptInFlowScreenHandler::ReloadContent(base::Value dict) {
+void AssistantOptInFlowScreenHandler::ReloadContent(base::Value::Dict dict) {
CallJS("login.AssistantOptInFlowScreen.reloadContent", std::move(dict));
}
void AssistantOptInFlowScreenHandler::AddSettingZippy(const std::string& type,
- base::Value data) {
+ base::Value::List data) {
CallJS("login.AssistantOptInFlowScreen.addSettingZippy", type,
std::move(data));
}
@@ -445,7 +457,7 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
RecordAssistantOptInStatus(FLOW_STARTED);
- base::Value zippy_data(base::Value::Type::LIST);
+ base::Value::List zippy_data;
bool skip_activity_control = true;
pending_consent_data_.clear();
// We read from `multi_consent_ui` field if it is populated and we assume user
@@ -509,18 +521,15 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
auto dictionary = GetSettingsUiStrings(settings_ui, activity_control_needed_,
equal_weight_buttons);
PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
- dictionary.SetKey(
- "voiceMatchEnforcedOff",
- base::Value(IsVoiceMatchEnforcedOff(prefs, is_oobe_in_progress)));
- dictionary.SetKey(
- "shouldSkipVoiceMatch",
- base::Value(!ash::AssistantState::Get()->HasAudioInputDevice()));
- dictionary.SetKey("childName", base::Value(GetGivenNameIfIsChild()));
- dictionary.SetKey(
- "isTabletMode",
- base::Value(ash::TabletMode::Get()->InTabletMode() ||
- (is_oobe_in_progress &&
- ash::switches::ShouldOobeUseTabletModeFirstRun())));
+ dictionary.Set("voiceMatchEnforcedOff",
+ IsVoiceMatchEnforcedOff(prefs, is_oobe_in_progress));
+ dictionary.Set("shouldSkipVoiceMatch",
+ !ash::AssistantState::Get()->HasAudioInputDevice());
+ dictionary.Set("childName", GetGivenNameIfIsChild());
+ dictionary.Set("isTabletMode",
+ ash::TabletMode::Get()->InTabletMode() ||
+ (is_oobe_in_progress &&
+ ash::switches::ShouldOobeUseTabletModeFirstRun()));
ReloadContent(std::move(dictionary));
// Skip activity control and users will be in opted out mode.
@@ -614,6 +623,7 @@ void AssistantOptInFlowScreenHandler::HandleVoiceMatchScreenUserAction(
DCHECK(!voice_match_enrollment_started_);
voice_match_enrollment_started_ = true;
+ CHECK(assistant::AssistantSettings::Get());
assistant::AssistantSettings::Get()->StartSpeakerIdEnrollment(
flow_type_ == ash::FlowType::kSpeakerIdRetrain,
weak_factory_.GetWeakPtr());
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
index 798f6f8c778..422ff21024a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
@@ -15,7 +15,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "chromeos/services/assistant/public/cpp/assistant_settings.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_settings.h"
#include "components/sync/protocol/user_consent_types.pb.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -123,8 +123,8 @@ class AssistantOptInFlowScreenHandler
void StopSpeakerIdEnrollment();
// Send message and consent data to the page.
- void ReloadContent(base::Value dict);
- void AddSettingZippy(const std::string& type, base::Value data);
+ void ReloadContent(base::Value::Dict dict);
+ void AddSettingZippy(const std::string& type, base::Value::List data);
// Update value prop screen to show the next settings.
void UpdateValuePropScreen();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
index 4ce89b8ad76..98829c2a9e1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
@@ -8,54 +8,19 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace ash {
-
-constexpr StaticOobeScreenId AutoEnrollmentCheckScreenView::kScreenId;
-
-}
-
namespace chromeos {
AutoEnrollmentCheckScreenHandler::AutoEnrollmentCheckScreenHandler()
: BaseScreenHandler(kScreenId) {}
-AutoEnrollmentCheckScreenHandler::~AutoEnrollmentCheckScreenHandler() {
- if (delegate_)
- delegate_->OnViewDestroyed(this);
-}
-
void AutoEnrollmentCheckScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void AutoEnrollmentCheckScreenHandler::SetDelegate(Delegate* delegate) {
- delegate_ = delegate;
- if (IsJavascriptAllowed())
- InitializeDeprecated();
-}
-
void AutoEnrollmentCheckScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("autoEnrollmentCheckScreenHeader",
- IDS_AUTO_ENROLLMENT_CHECK_SCREEN_HEADER);
builder->Add("autoEnrollmentCheckMessage",
IDS_AUTO_ENROLLMENT_CHECK_SCREEN_MESSAGE);
}
-void AutoEnrollmentCheckScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed() || !delegate_)
- return;
-
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
-void AutoEnrollmentCheckScreenHandler::RegisterMessages() {}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h
index 1d3a9c51b1b..e359e7e83da 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h
@@ -10,7 +10,7 @@
namespace chromeos {
-// WebUI implementation of AutoEnrollmentCheckScreenActor.
+// WebUI implementation of AutoEnrollmentCheckScreenView.
class AutoEnrollmentCheckScreenHandler : public AutoEnrollmentCheckScreenView,
public BaseScreenHandler {
public:
@@ -23,25 +23,14 @@ class AutoEnrollmentCheckScreenHandler : public AutoEnrollmentCheckScreenView,
AutoEnrollmentCheckScreenHandler& operator=(
const AutoEnrollmentCheckScreenHandler&) = delete;
- ~AutoEnrollmentCheckScreenHandler() override;
+ ~AutoEnrollmentCheckScreenHandler() override = default;
- // AutoEnrollmentCheckScreenActor implementation:
+ // AutoEnrollmentCheckScreenView:
void Show() override;
- void SetDelegate(Delegate* delegate) override;
- // BaseScreenHandler implementation:
+ // BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- // WebUIMessageHandler implementation:
- void RegisterMessages() override;
-
- private:
- Delegate* delegate_ = nullptr;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
index b7343ed4e89..b694f3c2812 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
@@ -71,7 +71,7 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
// All CallJS invocations can be recorded for tests if CallJS recording is
// enabled.
template <typename... Args>
- void CallJS(const std::string& function_name, Args... args) {
+ void CallJS(base::StringPiece function_name, Args... args) {
if (IsJavascriptAllowed()) {
CallJavascriptFunction(function_name, base::Value(std::move(args))...);
return;
@@ -79,11 +79,12 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
deferred_calls_.push_back(base::BindOnce(
&BaseWebUIHandler::CallJS<Args...>, base::Unretained(this),
- function_name, std::move(args)...));
+ std::string(function_name.data(), function_name.length()),
+ std::move(args)...));
}
template <typename... Args>
- void FireWebUIListenerWhenAllowed(const std::string& event_name,
+ void FireWebUIListenerWhenAllowed(base::StringPiece event_name,
Args... args) {
if (IsJavascriptAllowed()) {
FireWebUIListener(event_name, args...);
@@ -92,11 +93,13 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
deferred_calls_.push_back(
base::BindOnce(&BaseWebUIHandler::FireWebUIListenerWhenAllowed<Args...>,
- base::Unretained(this), event_name, std::move(args)...));
+ base::Unretained(this),
+ std::string(event_name.data(), event_name.length()),
+ std::move(args)...));
}
template <typename T, typename... Args>
- void AddCallback(const std::string& function_name,
+ void AddCallback(base::StringPiece function_name,
void (T::*method)(Args...)) {
base::RepeatingCallback<void(Args...)> callback =
base::BindRepeating(method, base::Unretained(static_cast<T*>(this)));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.cc b/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.cc
index de39434ca2a..322f58378df 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.cc
@@ -6,9 +6,9 @@
#include "ash/components/login/auth/auth_status_consumer.h"
#include "ash/components/login/auth/cryptohome_authenticator.h"
-#include "ash/components/login/auth/cryptohome_key_constants.h"
#include "ash/components/login/auth/extended_authenticator.h"
-#include "ash/components/login/auth/user_context.h"
+#include "ash/components/login/auth/public/cryptohome_key_constants.h"
+#include "ash/components/login/auth/public/user_context.h"
#include "ash/constants/ash_features.h"
#include "base/values.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.h b/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.h
index 9ebf706f0be..a4a03c9233e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/check_passwords_against_cryptohome_helper.h
@@ -7,7 +7,7 @@
#include "ash/components/login/auth/auth_status_consumer.h"
#include "ash/components/login/auth/cryptohome_authenticator.h"
-#include "ash/components/login/auth/user_context.h"
+#include "ash/components/login/auth/public/user_context.h"
#include "base/values.h"
#include "components/login/base_screen_handler_utils.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
index 367c8e01409..e5dc15d2945 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -128,7 +128,7 @@ void CoreOobeHandler::GetAdditionalParameters(base::Value::Dict* dict) {
base::Value(ash::TabletMode::Get()->InTabletMode()));
dict->Set("isDemoModeEnabled",
base::Value(DemoSetupController::IsDemoModeAllowed()));
- if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) {
+ if (policy::EnrollmentRequisitionManager::IsMeetDevice()) {
dict->Set("flowType", base::Value("meet"));
}
dict->Set("isQuickStartEnabled",
@@ -237,6 +237,10 @@ void CoreOobeHandler::ToggleSystemInfo() {
CallJS("cr.ui.Oobe.toggleSystemInfo");
}
+void CoreOobeHandler::LaunchHelpApp(int help_topic_id) {
+ HandleLaunchHelpApp(help_topic_id);
+}
+
void CoreOobeHandler::OnOobeConfigurationChanged() {
base::Value configuration(base::Value::Type::DICTIONARY);
configuration::FilterConfiguration(
@@ -266,6 +270,10 @@ void CoreOobeHandler::HandleRaiseTabKeyEvent(bool reverse) {
void CoreOobeHandler::HandleStartDemoModeSetupForTesting(
const std::string& demo_config) {
+ CHECK(base::FeatureList::IsEnabled(features::kOobeStartDemoModeForTesting))
+ << "If you see this crash please report in https://crbug.com/1100910. To "
+ "disable the crash run chrome with "
+ "--enable-features=OobeStartDemoModeForTesting";
DemoSession::DemoModeConfig config;
if (demo_config == "online") {
config = DemoSession::DemoModeConfig::kOnline;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
index 017477eaf17..b937155f9eb 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
@@ -39,6 +39,7 @@ class CoreOobeView {
virtual void UpdateClientAreaSize(const gfx::Size& size) = 0;
virtual void ToggleSystemInfo() = 0;
virtual void ForwardCancel() = 0;
+ virtual void LaunchHelpApp(int help_topic_id) = 0;
};
// The core handler for Javascript messages related to the "oobe" view.
@@ -91,6 +92,7 @@ class CoreOobeHandler : public BaseWebUIHandler,
void ToggleSystemInfo() override;
// Forwards the cancel accelerator value to the shown screen.
void ForwardCancel() override;
+ void LaunchHelpApp(int help_topic_id) override;
// ash::TabletModeObserver:
void OnTabletModeStarted() override;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc
index 45dd2b8c96d..aaccb714ee6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h"
#include "ash/constants/ash_switches.h"
-#include "ash/public/cpp/style/color_provider.h"
+#include "ash/public/cpp/style/dark_light_mode_controller.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -134,7 +134,7 @@ void DebugOverlayHandler::HandleCaptureScreenshot(const std::string& name) {
if (add_resolution_to_filename_)
filename.append("_" + rect.size().ToString());
- if (ash::ColorProvider::Get()->IsDarkModeEnabled()) {
+ if (ash::DarkLightModeController::Get()->IsDarkModeEnabled()) {
filename.append("_dark");
}
@@ -147,8 +147,8 @@ void DebugOverlayHandler::HandleCaptureScreenshot(const std::string& name) {
}
void DebugOverlayHandler::ToggleColorMode() {
- ash::ColorProvider::Get()->SetDarkModeEnabledForTest( // IN-TEST
- !ash::ColorProvider::Get()->IsDarkModeEnabled());
+ ash::DarkLightModeController::Get()->SetDarkModeEnabledForTest( // IN-TEST
+ !ash::DarkLightModeController::Get()->IsDarkModeEnabled());
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
index c03934a2a3c..23fd8f5d15f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
@@ -19,38 +19,16 @@
namespace chromeos {
-constexpr StaticOobeScreenId EnableDebuggingScreenView::kScreenId;
-
EnableDebuggingScreenHandler::EnableDebuggingScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.EnableDebuggingScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-EnableDebuggingScreenHandler::~EnableDebuggingScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+EnableDebuggingScreenHandler::~EnableDebuggingScreenHandler() = default;
void EnableDebuggingScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
-
DVLOG(1) << "Showing enable debugging screen.";
ShowInWebUI();
}
-void EnableDebuggingScreenHandler::Hide() {}
-
-void EnableDebuggingScreenHandler::SetDelegate(EnableDebuggingScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
- if (IsJavascriptAllowed())
- InitializeDeprecated();
-}
-
void EnableDebuggingScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("enableDebuggingScreenTitle",
@@ -93,29 +71,8 @@ void EnableDebuggingScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kDebuggingFeaturesRequested, false);
}
-void EnableDebuggingScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed() || !screen_)
- return;
-
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
-void EnableDebuggingScreenHandler::RegisterMessages() {
- BaseScreenHandler::RegisterMessages();
- AddCallback("enableDebuggingOnSetup",
- &EnableDebuggingScreenHandler::HandleOnSetup);
-}
-
-void EnableDebuggingScreenHandler::HandleOnSetup(
- const std::string& password) {
- screen_->HandleSetup(password);
-}
-
void EnableDebuggingScreenHandler::UpdateUIState(UIState state) {
- CallJS("login.EnableDebuggingScreen.updateState", static_cast<int>(state));
+ CallExternalAPI("updateState", static_cast<int>(state));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
index 3cd165e771b..dc44999e46a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
@@ -6,21 +6,20 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENABLE_DEBUGGING_SCREEN_HANDLER_H_
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
class PrefRegistrySimple;
-namespace ash {
-class EnableDebuggingScreen;
-}
-
namespace chromeos {
// Interface between enable debugging screen and its representation.
// Note, do not forget to call OnViewDestroyed in the dtor.
-class EnableDebuggingScreenView {
+class EnableDebuggingScreenView
+ : public base::SupportsWeakPtr<EnableDebuggingScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"debugging"};
+ inline constexpr static StaticOobeScreenId kScreenId{"debugging",
+ "EnableDebuggingScreen"};
enum UIState {
UI_STATE_ERROR = -1,
@@ -30,11 +29,9 @@ class EnableDebuggingScreenView {
UI_STATE_DONE = 4,
};
- virtual ~EnableDebuggingScreenView() {}
+ virtual ~EnableDebuggingScreenView() = default;
virtual void Show() = 0;
- virtual void Hide() = 0;
- virtual void SetDelegate(ash::EnableDebuggingScreen* screen) = 0;
virtual void UpdateUIState(UIState state) = 0;
};
@@ -54,29 +51,14 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
// EnableDebuggingScreenView implementation:
void Show() override;
- void Hide() override;
- void SetDelegate(ash::EnableDebuggingScreen* screen) override;
void UpdateUIState(UIState state) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- // WebUIMessageHandler implementation:
- void RegisterMessages() override;
// Registers Local State preferences.
static void RegisterPrefs(PrefRegistrySimple* registry);
-
- private:
- // JS messages handlers.
- void HandleOnSetup(const std::string& password);
-
- ash::EnableDebuggingScreen* screen_ = nullptr;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
index dba7e38ed09..d5252e816f7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
@@ -13,39 +13,15 @@
namespace chromeos {
-constexpr StaticOobeScreenId EncryptionMigrationScreenView::kScreenId;
-
EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.EncryptionMigrationScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-EncryptionMigrationScreenHandler::~EncryptionMigrationScreenHandler() {
- if (delegate_)
- delegate_->OnViewDestroyed(this);
-}
+EncryptionMigrationScreenHandler::~EncryptionMigrationScreenHandler() = default;
void EncryptionMigrationScreenHandler::Show() {
- if (!IsJavascriptAllowed() || !delegate_) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void EncryptionMigrationScreenHandler::Hide() {
- show_on_init_ = false;
-}
-
-void EncryptionMigrationScreenHandler::SetDelegate(
- EncryptionMigrationScreen* delegate) {
- delegate_ = delegate;
- BaseScreenHandler::SetBaseScreenDeprecated(delegate);
- if (IsJavascriptAllowed())
- InitializeDeprecated();
-}
-
void EncryptionMigrationScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("migrationReadyTitle", IDS_ENCRYPTION_MIGRATION_READY_TITLE);
@@ -94,47 +70,35 @@ void EncryptionMigrationScreenHandler::DeclareLocalizedValues(
builder->Add("gaiaLoading", IDS_LOGIN_GAIA_LOADING_MESSAGE);
}
-void EncryptionMigrationScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed() || !delegate_)
- return;
-
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
void EncryptionMigrationScreenHandler::SetBatteryState(double batteryPercent,
bool isEnoughBattery,
bool isCharging) {
- CallJS("login.EncryptionMigrationScreen.setBatteryState", batteryPercent,
- isEnoughBattery, isCharging);
+ CallExternalAPI("setBatteryState", batteryPercent, isEnoughBattery,
+ isCharging);
}
void EncryptionMigrationScreenHandler::SetIsResuming(bool isResuming) {
- CallJS("login.EncryptionMigrationScreen.setIsResuming", isResuming);
+ CallExternalAPI("setIsResuming", isResuming);
}
void EncryptionMigrationScreenHandler::SetUIState(UIState state) {
- CallJS("login.EncryptionMigrationScreen.setUIState", static_cast<int>(state));
+ CallExternalAPI("setUIState", static_cast<int>(state));
}
void EncryptionMigrationScreenHandler::SetSpaceInfoInString(
int64_t availableSpaceSize,
int64_t necessarySpaceSize) {
- CallJS("login.EncryptionMigrationScreen.setSpaceInfoInString",
- ui::FormatBytes(availableSpaceSize),
- ui::FormatBytes(necessarySpaceSize));
+ CallExternalAPI("setSpaceInfoInString", ui::FormatBytes(availableSpaceSize),
+ ui::FormatBytes(necessarySpaceSize));
}
void EncryptionMigrationScreenHandler::SetNecessaryBatteryPercent(
double batteryPercent) {
- CallJS("login.EncryptionMigrationScreen.setNecessaryBatteryPercent",
- batteryPercent);
+ CallExternalAPI("setNecessaryBatteryPercent", batteryPercent);
}
void EncryptionMigrationScreenHandler::SetMigrationProgress(double progress) {
- CallJS("login.EncryptionMigrationScreen.setMigrationProgress", progress);
+ CallExternalAPI("setMigrationProgress", progress);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
index 8cd9336f8ad..15ffbe05b85 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
@@ -5,17 +5,16 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class EncryptionMigrationScreen;
-}
-
namespace chromeos {
-class EncryptionMigrationScreenView {
+class EncryptionMigrationScreenView
+ : public base::SupportsWeakPtr<EncryptionMigrationScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"encryption-migration"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "encryption-migration", "EncryptionMigrationScreen"};
// Enumeration for migration UI state. These values must be kept in sync with
// EncryptionMigrationUIState in JS code, and match the numbering for
@@ -30,11 +29,9 @@ class EncryptionMigrationScreenView {
COUNT
};
- virtual ~EncryptionMigrationScreenView() {}
+ virtual ~EncryptionMigrationScreenView() = default;
virtual void Show() = 0;
- virtual void Hide() = 0;
- virtual void SetDelegate(ash::EncryptionMigrationScreen* delegate) = 0;
virtual void SetBatteryState(double batteryPercent,
bool isEnoughBattery,
bool isCharging) = 0;
@@ -63,8 +60,6 @@ class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView,
// EncryptionMigrationScreenView implementation:
void Show() override;
- void Hide() override;
- void SetDelegate(ash::EncryptionMigrationScreen* delegate) override;
void SetBatteryState(double batteryPercent,
bool isEnoughBattery,
bool isCharging) override;
@@ -78,11 +73,6 @@ class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView,
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- private:
- ash::EncryptionMigrationScreen* delegate_ = nullptr;
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
index 989d3dbb16e..5e092be18e7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/ash/login/wizard_controller.h"
#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
#include "chrome/browser/ash/policy/core/policy_oauth2_token_fetcher.h"
+#include "chrome/browser/ash/policy/enrollment/enrollment_config.h"
#include "chrome/browser/ash/policy/enrollment/enrollment_requisition_manager.h"
#include "chrome/browser/ash/policy/enrollment/enrollment_status.h"
#include "chrome/browser/browser_process.h"
@@ -35,8 +36,8 @@
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
#include "components/policy/core/browser/cloud/message_util.h"
#include "content/public/browser/browser_thread.h"
@@ -96,6 +97,8 @@ std::string EnrollmentModeToUIMode(policy::EnrollmentConfig::Mode mode) {
case policy::EnrollmentConfig::MODE_INITIAL_SERVER_FORCED:
case policy::EnrollmentConfig::MODE_ATTESTATION_INITIAL_SERVER_FORCED:
case policy::EnrollmentConfig::MODE_ATTESTATION_INITIAL_MANUAL_FALLBACK:
+ case policy::EnrollmentConfig::MODE_ATTESTATION_ROLLBACK_FORCED:
+ case policy::EnrollmentConfig::MODE_ATTESTATION_ROLLBACK_MANUAL_FALLBACK:
return kEnrollmentModeUIForced;
case policy::EnrollmentConfig::MODE_RECOVERY:
return kEnrollmentModeUIRecovery;
@@ -143,20 +146,17 @@ constexpr struct {
IDS_AD_ENCRYPTION_LEGACY_SUBTITLE,
authpolicy::KerberosEncryptionTypes::ENC_TYPES_LEGACY}};
-base::ListValue GetEncryptionTypesList() {
+base::Value::List GetEncryptionTypesList() {
const authpolicy::KerberosEncryptionTypes default_types =
authpolicy::KerberosEncryptionTypes::ENC_TYPES_STRONG;
- base::ListValue encryption_list;
+ base::Value::List encryption_list;
for (const auto& enc_types : kEncryptionTypes) {
- base::DictionaryValue enc_option;
- enc_option.SetKey(
- "title", base::Value(l10n_util::GetStringUTF16(enc_types.title_id)));
- enc_option.SetKey(
- "subtitle",
- base::Value(l10n_util::GetStringUTF16(enc_types.subtitle_id)));
- enc_option.SetKey("value", base::Value(enc_types.id));
- enc_option.SetKey("selected",
- base::Value(default_types == enc_types.encryption_types));
+ base::Value::Dict enc_option;
+ enc_option.Set("title", l10n_util::GetStringUTF16(enc_types.title_id));
+ enc_option.Set("subtitle",
+ l10n_util::GetStringUTF16(enc_types.subtitle_id));
+ enc_option.Set("value", enc_types.id);
+ enc_option.Set("selected", default_types == enc_types.encryption_types);
encryption_list.Append(std::move(enc_option));
}
return encryption_list;
@@ -443,6 +443,7 @@ void EnrollmentScreenHandler::ShowAuthError(
case GoogleServiceAuthError::REQUEST_CANCELED:
case GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE:
case GoogleServiceAuthError::SERVICE_ERROR:
+ case GoogleServiceAuthError::SCOPE_LIMITED_UNRECOVERABLE_ERROR:
ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR, false);
return;
case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
@@ -769,11 +770,11 @@ void EnrollmentScreenHandler::OnAdConfigurationUnlocked(
false /* show_unlock_password */);
return;
}
- base::DictionaryValue custom;
- custom.SetKey(
+ base::Value::Dict custom;
+ custom.Set(
"name",
base::Value(l10n_util::GetStringUTF8(IDS_AD_CONFIG_SELECTION_CUSTOM)));
- options->Append(std::move(custom));
+ options->GetList().Append(std::move(custom));
active_directory_join_type_ =
ActiveDirectoryDomainJoinType::USING_CONFIGURATION;
CallJS("login.OAuthEnrollmentScreen.setAdJoinConfiguration",
@@ -1082,6 +1083,12 @@ void EnrollmentScreenHandler::ShowErrorMessage(const std::string& message,
}
void EnrollmentScreenHandler::DoShow() {
+ if (config_.is_mode_attestation()) {
+ // Don't need sign-in partition for attestation enrollment.
+ DoShowWithData(ScreenDataForAttestationEnrollment());
+ return;
+ }
+
// Start a new session with SigninPartitionManager, generating a unique
// StoragePartition.
login::SigninPartitionManager* signin_partition_manager =
@@ -1100,31 +1107,52 @@ void EnrollmentScreenHandler::DoShowWithPartition(
if (shutdown_)
return;
- base::Value::Dict screen_data;
-
- screen_data.Set("webviewPartitionName", partition_name);
signin_partition_name_ = partition_name;
+ DoShowWithData(ScreenDataForOAuthEnrollment());
+}
+
+void EnrollmentScreenHandler::DoShowWithData(base::Value::Dict screen_data) {
+ ShowInWebUI(std::move(screen_data));
+ if (first_show_) {
+ first_show_ = false;
+ UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true);
+ }
+ histogram_helper_->OnScreenShow();
+}
+
+base::Value::Dict
+EnrollmentScreenHandler::ScreenDataForAttestationEnrollment() {
+ // Attestation-based enrollment doesn't require additional screen data.
+ return ScreenDataCommon();
+}
+
+base::Value::Dict EnrollmentScreenHandler::ScreenDataForOAuthEnrollment() {
+ base::Value::Dict screen_data = ScreenDataCommon();
+
+ screen_data.Set("webviewPartitionName", signin_partition_name_);
screen_data.Set("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
screen_data.Set("clientId",
GaiaUrls::GetInstance()->oauth2_chrome_client_id());
- screen_data.Set("enrollment_mode", EnrollmentModeToUIMode(config_.mode));
- screen_data.Set("is_enrollment_enforced", config_.is_forced());
- screen_data.Set("attestationBased", config_.is_mode_attestation());
screen_data.Set("management_domain", config_.management_domain);
- screen_data.Set("flow", GetFlowString(flow_type_));
screen_data.Set("gaia_buttons_type",
GetGaiaButtonsTypeString(gaia_buttons_type_));
const std::string app_locale = g_browser_process->GetApplicationLocale();
if (!app_locale.empty())
screen_data.Set("hl", app_locale);
- ShowInWebUI(std::move(screen_data));
- if (first_show_) {
- first_show_ = false;
- UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true);
- }
- histogram_helper_->OnScreenShow();
+ return screen_data;
+}
+
+base::Value::Dict EnrollmentScreenHandler::ScreenDataCommon() {
+ base::Value::Dict screen_data;
+
+ screen_data.Set("enrollment_mode", EnrollmentModeToUIMode(config_.mode));
+ screen_data.Set("is_enrollment_enforced", config_.is_forced());
+ screen_data.Set("attestationBased", config_.is_mode_attestation());
+ screen_data.Set("flow", GetFlowString(flow_type_));
+
+ return screen_data;
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
index 55ef82ba891..7cecbde5ead 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
@@ -159,12 +159,24 @@ class EnrollmentScreenHandler
// Display the given i18n string as a progress message.
void ShowWorking(int message_id);
- // Shows the screen.
+ // Shows the screen. Asynchronous for oauth-based enrollment.
void DoShow();
- // Shows the screen.
+ // Shows oauth-based enrollment screen using the given sign-in partition name.
void DoShowWithPartition(const std::string& partition_name);
+ // Shows the screen with the given data dictionary.
+ void DoShowWithData(base::Value::Dict screen_data);
+
+ // Screen data to be passed to web ui for attestation enrollment.
+ base::Value::Dict ScreenDataForAttestationEnrollment();
+
+ // Screen data to be passed to web ui for gaia oauth-based enrollment.
+ base::Value::Dict ScreenDataForOAuthEnrollment();
+
+ // Screen data to be passed to web ui for all enrollment modes.
+ base::Value::Dict ScreenDataCommon();
+
// Returns true if current visible screen is the enrollment sign-in page.
bool IsOnEnrollmentScreen();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
index 6d8d69063e6..8bf0d456d8c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
@@ -6,7 +6,6 @@
#include "base/time/time.h"
#include "base/values.h"
-#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/ash/login/ui/login_display_host.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -17,47 +16,17 @@
namespace chromeos {
-constexpr StaticOobeScreenId ErrorScreenView::kScreenId;
+ErrorScreenHandler::ErrorScreenHandler() : BaseScreenHandler(kScreenId) {}
-ErrorScreenHandler::ErrorScreenHandler() : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.ErrorMessageScreen.userActed");
-}
-
-ErrorScreenHandler::~ErrorScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+ErrorScreenHandler::~ErrorScreenHandler() = default;
void ErrorScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
-
base::Value::Dict data;
- data.Set("hasUserPods", ash::LoginDisplayHost::default_host()->HasUserPods());
+ if (LoginDisplayHost::default_host()) {
+ data.Set("hasUserPods",
+ ash::LoginDisplayHost::default_host()->HasUserPods());
+ }
ShowInWebUI(std::move(data));
-
- if (screen_)
- screen_->DoShow();
- showing_ = true;
-}
-
-void ErrorScreenHandler::Hide() {
- showing_ = false;
- show_on_init_ = false;
- if (screen_)
- screen_->DoHide();
-}
-
-void ErrorScreenHandler::Bind(ErrorScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void ErrorScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
}
void ErrorScreenHandler::ShowOobeScreen(OobeScreenId screen) {
@@ -67,36 +36,31 @@ void ErrorScreenHandler::ShowOobeScreen(OobeScreenId screen) {
void ErrorScreenHandler::SetErrorStateCode(
NetworkError::ErrorState error_state) {
- CallJS("login.ErrorMessageScreen.setErrorState",
- static_cast<int>(error_state));
+ CallExternalAPI("setErrorState", static_cast<int>(error_state));
}
void ErrorScreenHandler::SetErrorStateNetwork(const std::string& network_name) {
- CallJS("login.ErrorMessageScreen.setErrorStateNetwork", network_name);
+ CallExternalAPI("setErrorStateNetwork", network_name);
}
void ErrorScreenHandler::SetGuestSigninAllowed(bool value) {
- CallJS("login.ErrorMessageScreen.allowGuestSignin", value);
+ CallExternalAPI("allowGuestSignin", value);
}
void ErrorScreenHandler::SetOfflineSigninAllowed(bool value) {
- CallJS("login.ErrorMessageScreen.allowOfflineLogin", value);
+ CallExternalAPI("allowOfflineLogin", value);
}
void ErrorScreenHandler::SetShowConnectingIndicator(bool value) {
- CallJS("login.ErrorMessageScreen.showConnectingIndicator", value);
+ CallExternalAPI("showConnectingIndicator", value);
}
void ErrorScreenHandler::SetIsPersistentError(bool is_persistent) {
- CallJS("login.ErrorMessageScreen.setIsPersistentError", is_persistent);
+ CallExternalAPI("setIsPersistentError", is_persistent);
}
void ErrorScreenHandler::SetUIState(NetworkError::UIState ui_state) {
- CallJS("login.ErrorMessageScreen.setUIState", static_cast<int>(ui_state));
-}
-
-void ErrorScreenHandler::OnReloadGaiaClicked() {
- CallJS("login.GaiaSigninScreen.doReload");
+ CallExternalAPI("setUIState", static_cast<int>(ui_state));
}
void ErrorScreenHandler::DeclareLocalizedValues(
@@ -139,20 +103,10 @@ void ErrorScreenHandler::DeclareLocalizedValues(
builder->Add("proxySettingsMenuName",
IDS_NETWORK_PROXY_SETTINGS_LIST_ITEM_NAME);
builder->Add("addWiFiNetworkMenuName", IDS_NETWORK_ADD_WI_FI_LIST_ITEM_NAME);
+ builder->Add("autoEnrollmentErrorMessageTitle", IDS_LOGIN_AUTO_ENROLLMENT_OFFLINE_TITLE);
ui::network_element::AddLocalizedValuesToBuilder(builder);
builder->Add("offlineLogin", IDS_OFFLINE_LOGIN_HTML);
}
-void ErrorScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed())
- return;
-
- if (show_on_init_) {
- // TODO(nkostylev): Check that context initial state is properly passed.
- Show();
- show_on_init_ = false;
- }
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
index 2c2e19f882a..587dccff06d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
@@ -5,35 +5,24 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class ErrorScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between ErrorScreen and its actual
// representation. Owned by ErrorScreen.
-class ErrorScreenView {
+class ErrorScreenView : public base::SupportsWeakPtr<ErrorScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"error-message"};
+ inline constexpr static StaticOobeScreenId kScreenId{"error-message",
+ "ErrorMessageScreen"};
- virtual ~ErrorScreenView() {}
+ virtual ~ErrorScreenView() = default;
// Shows the contents of the screen.
virtual void Show() = 0;
- // Hides the contents of the screen.
- virtual void Hide() = 0;
-
- // Binds `screen` to the view.
- virtual void Bind(ash::ErrorScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
// Switches to `screen`.
virtual void ShowOobeScreen(OobeScreenId screen) = 0;
@@ -57,9 +46,6 @@ class ErrorScreenView {
// Sets current UI state of the screen.
virtual void SetUIState(NetworkError::UIState ui_state) = 0;
-
- // Reloads gaia.
- virtual void OnReloadGaiaClicked() = 0;
};
// A class that handles the WebUI hooks in error screen.
@@ -77,9 +63,6 @@ class ErrorScreenHandler : public BaseScreenHandler, public ErrorScreenView {
private:
// ErrorScreenView:
void Show() override;
- void Hide() override;
- void Bind(ash::ErrorScreen* screen) override;
- void Unbind() override;
void ShowOobeScreen(OobeScreenId screen) override;
void SetErrorStateCode(NetworkError::ErrorState error_state) override;
void SetErrorStateNetwork(const std::string& network_name) override;
@@ -88,25 +71,14 @@ class ErrorScreenHandler : public BaseScreenHandler, public ErrorScreenView {
void SetShowConnectingIndicator(bool value) override;
void SetIsPersistentError(bool is_persistent) override;
void SetUIState(NetworkError::UIState ui_state) override;
- void OnReloadGaiaClicked() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
// WebUI message handlers.
void HandleHideCaptivePortal();
- // Non-owning ptr.
- ash::ErrorScreen* screen_ = nullptr;
-
- // Should the screen be shown right after initialization?
- bool show_on_init_ = false;
-
- // Whether the error screen is currently shown.
- bool showing_ = false;
-
base::WeakPtrFactory<ErrorScreenHandler> weak_ptr_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h
index 8a54b15ac8b..ca13f558685 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h
@@ -20,6 +20,7 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView {
void ShowNetworkConfigureUI() override {}
void ShowErrorMessage(KioskAppLaunchError::Error error) override;
bool IsNetworkReady() override;
+ void ContinueAppLaunch() override {}
KioskAppLaunchError::Error GetErrorMessageType() const;
void SetNetworkReady(bool ready);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h
index 8fb9ec23cc1..2b4e1a06319 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h
@@ -27,9 +27,6 @@ class FakeUpdateRequiredScreenHandler : public UpdateRequiredView {
private:
void Show() override {}
- void Hide() override {}
- void Bind(ash::UpdateRequiredScreen* screen) override {}
- void Unbind() override {}
void SetIsConnected(bool connected) override {}
void SetUpdateProgressUnavailable(bool unavailable) override {}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc
index 94dc8aa58d2..0200d17f9f0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc
@@ -12,18 +12,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId FamilyLinkNoticeView::kScreenId;
-
FamilyLinkNoticeScreenHandler::FamilyLinkNoticeScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.FamilyLinkNoticeScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-FamilyLinkNoticeScreenHandler::~FamilyLinkNoticeScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+FamilyLinkNoticeScreenHandler::~FamilyLinkNoticeScreenHandler() = default;
void FamilyLinkNoticeScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -41,32 +33,20 @@ void FamilyLinkNoticeScreenHandler::DeclareLocalizedValues(
IDS_LOGIN_FAMILY_LINK_NOTICE_SCREEN_CONTINUE_BUTTON);
}
-void FamilyLinkNoticeScreenHandler::InitializeDeprecated() {}
-
void FamilyLinkNoticeScreenHandler::Show() {
ShowInWebUI();
}
-void FamilyLinkNoticeScreenHandler::Bind(FamilyLinkNoticeScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void FamilyLinkNoticeScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void FamilyLinkNoticeScreenHandler::SetIsNewGaiaAccount(bool value) {
- CallJS("login.FamilyLinkNoticeScreen.setIsNewGaiaAccount", value);
+ CallExternalAPI("setIsNewGaiaAccount", value);
}
void FamilyLinkNoticeScreenHandler::SetDisplayEmail(const std::string& value) {
- CallJS("login.FamilyLinkNoticeScreen.setDisplayEmail", value);
+ CallExternalAPI("setDisplayEmail", value);
}
void FamilyLinkNoticeScreenHandler::SetDomain(const std::string& value) {
- CallJS("login.FamilyLinkNoticeScreen.setDomain", value);
+ CallExternalAPI("setDomain", value);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h
index c4ada8eb962..3f3358ca242 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h
@@ -7,31 +7,24 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class FamilyLinkNoticeScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between FamilyLinkNoticeScreen and its
// WebUI representation.
-class FamilyLinkNoticeView {
+class FamilyLinkNoticeView
+ : public base::SupportsWeakPtr<FamilyLinkNoticeView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"family-link-notice"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "family-link-notice", "FamilyLinkNoticeScreen"};
virtual ~FamilyLinkNoticeView() = default;
// Shows the contents of the screen.
virtual void Show() = 0;
- // Binds `screen` to the view.
- virtual void Bind(ash::FamilyLinkNoticeScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
// Set if account is a new gaia account user just created.
virtual void SetIsNewGaiaAccount(bool value) = 0;
@@ -57,8 +50,6 @@ class FamilyLinkNoticeScreenHandler : public FamilyLinkNoticeView,
private:
void Show() override;
- void Bind(ash::FamilyLinkNoticeScreen* screen) override;
- void Unbind() override;
void SetIsNewGaiaAccount(bool value) override;
void SetDisplayEmail(const std::string& value) override;
void SetDomain(const std::string& value) override;
@@ -66,9 +57,6 @@ class FamilyLinkNoticeScreenHandler : public FamilyLinkNoticeView,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::FamilyLinkNoticeScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
index c2eadaceec3..fb5c9136b79 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
@@ -14,13 +14,8 @@
namespace chromeos {
-constexpr StaticOobeScreenId FingerprintSetupScreenView::kScreenId;
-
FingerprintSetupScreenHandler::FingerprintSetupScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.FingerprintSetupScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
FingerprintSetupScreenHandler::~FingerprintSetupScreenHandler() = default;
@@ -105,6 +100,12 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues(
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_LEFT_SIDE_ARIA_LABEL;
aria_label_includes_device = true;
break;
+ case quick_unlock::FingerprintLocation::LEFT_OF_POWER_BUTTON_TOP_RIGHT:
+ description_id =
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_LEFT_OF_POWER_BUTTON_TOP_RIGHT;
+ description_id_for_child =
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_LEFT_OF_POWER_BUTTON_TOP_RIGHT_CHILD;
+ break;
case quick_unlock::FingerprintLocation::UNKNOWN:
description_id =
IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_GENERAL_DESCRIPTION;
@@ -119,6 +120,10 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues(
ui::GetChromeOSDeviceName());
builder->AddF("setupFingerprintScreenDescriptionForChild",
description_id_for_child, ui::GetChromeOSDeviceName());
+
+ if (ash::quick_unlock::IsLeftOfPowerButtonTopRightFingerprint())
+ return;
+
if (aria_label_includes_device) {
builder->AddF("setupFingerprintScreenAriaLabel", aria_label_id,
ui::GetChromeOSDeviceName());
@@ -127,15 +132,6 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues(
}
}
-void FingerprintSetupScreenHandler::RegisterMessages() {
- BaseScreenHandler::RegisterMessages();
-}
-
-void FingerprintSetupScreenHandler::Bind(FingerprintSetupScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
-}
-
void FingerprintSetupScreenHandler::Show() {
auto* user_manager = user_manager::UserManager::Get();
base::Value::Dict data;
@@ -143,21 +139,16 @@ void FingerprintSetupScreenHandler::Show() {
ShowInWebUI(std::move(data));
}
-void FingerprintSetupScreenHandler::Hide() {}
-
-void FingerprintSetupScreenHandler::InitializeDeprecated() {}
-
void FingerprintSetupScreenHandler::OnEnrollScanDone(
device::mojom::ScanResult scan_result,
bool enroll_session_complete,
int percent_complete) {
- CallJS("login.FingerprintSetupScreen.onEnrollScanDone",
- static_cast<int>(scan_result), enroll_session_complete,
- percent_complete);
+ CallExternalAPI("onEnrollScanDone", static_cast<int>(scan_result),
+ enroll_session_complete, percent_complete);
}
void FingerprintSetupScreenHandler::EnableAddAnotherFinger(bool enable) {
- CallJS("login.FingerprintSetupScreen.enableAddAnotherFinger", enable);
+ CallExternalAPI("enableAddAnotherFinger", enable);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h
index 0a71cfde24e..fb05c4ab73c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h
@@ -5,32 +5,25 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_FINGERPRINT_SETUP_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_FINGERPRINT_SETUP_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "services/device/public/mojom/fingerprint.mojom.h"
-namespace ash {
-class FingerprintSetupScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between FingerprintSetupScreen and its
// WebUI representation.
-class FingerprintSetupScreenView {
+class FingerprintSetupScreenView
+ : public base::SupportsWeakPtr<FingerprintSetupScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"fingerprint-setup"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "fingerprint-setup", "FingerprintSetupScreen"};
virtual ~FingerprintSetupScreenView() = default;
- // Sets screen this view belongs to.
- virtual void Bind(ash::FingerprintSetupScreen* screen) = 0;
-
// Shows the contents of the screen.
virtual void Show() = 0;
- // Hides the contents of the screen.
- virtual void Hide() = 0;
-
// Enables adding new finger.
virtual void EnableAddAnotherFinger(bool enable) = 0;
@@ -57,22 +50,13 @@ class FingerprintSetupScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void RegisterMessages() override;
// FingerprintSetupScreenView:
- void Bind(ash::FingerprintSetupScreen* screen) override;
void Show() override;
- void Hide() override;
void EnableAddAnotherFinger(bool enable) override;
void OnEnrollScanDone(device::mojom::ScanResult scan_result,
bool enroll_session_complete,
int percent_complete) override;
-
- // BaseScreenHandler:
- void InitializeDeprecated() override;
-
- private:
- ash::FingerprintSetupScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc
index 8c28cebc675..a8500ca5054 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h"
+#include "ash/constants/ash_features.h"
#include "base/values.h"
#include "chrome/browser/ash/login/oobe_screen.h"
#include "chrome/browser/ash/login/screens/gaia_password_changed_screen.h"
@@ -15,18 +16,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId GaiaPasswordChangedView::kScreenId;
-
GaiaPasswordChangedScreenHandler::GaiaPasswordChangedScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.GaiaPasswordChangedScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-GaiaPasswordChangedScreenHandler::~GaiaPasswordChangedScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+GaiaPasswordChangedScreenHandler::~GaiaPasswordChangedScreenHandler() = default;
void GaiaPasswordChangedScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -43,11 +36,27 @@ void GaiaPasswordChangedScreenHandler::DeclareLocalizedValues(
builder->Add("passwordChangedProceedAnywayTitle",
IDS_LOGIN_PASSWORD_CHANGED_PROCEED_ANYWAY);
builder->Add("passwordChangedTryAgain", IDS_LOGIN_PASSWORD_CHANGED_TRY_AGAIN);
+ builder->Add("dataLossWarningTitle",
+ IDS_LOGIN_PASSWORD_CHANGED_DATA_LOSS_WARNING_TITLE);
+ builder->Add("dataLossWarningSubtitleP1",
+ IDS_LOGIN_PASSWORD_CHANGED_DATA_LOSS_WARNING_SUBTITLE_P1);
+ builder->Add("dataLossWarningSubtitleP2",
+ IDS_LOGIN_PASSWORD_CHANGED_DATA_LOSS_WARNING_SUBTITLE_P2);
+ builder->Add("recoverLocalDataTitle",
+ IDS_LOGIN_PASSWORD_CHANGED_RECOVER_DATA_TITLE);
+ builder->Add("recoverLocalDataSubtitle",
+ IDS_LOGIN_PASSWORD_CHANGED_RECOVER_DATA_SUBTITLE);
+ builder->Add("continueAndDeleteDataButton",
+ IDS_LOGIN_PASSWORD_CHANGED_CONTINUE_AND_DELETE_BUTTON);
+ builder->Add("continueWithoutLocalDataButton",
+ IDS_LOGIN_PASSWORD_CHANGED_CONTINUE_WITHOUT_LOCAL_DATA_BUTTON);
}
-void GaiaPasswordChangedScreenHandler::InitializeDeprecated() {
- AddCallback("migrateUserData",
- &GaiaPasswordChangedScreenHandler::HandleMigrateUserData);
+void GaiaPasswordChangedScreenHandler::GetAdditionalParameters(
+ base::Value::Dict* dict) {
+ dict->Set("isCryptohomeRecoveryUIFlowEnabled",
+ ash::features::IsCryptohomeRecoveryFlowUIEnabled());
+ BaseScreenHandler::GetAdditionalParameters(dict);
}
void GaiaPasswordChangedScreenHandler::Show(const std::string& email,
@@ -58,20 +67,4 @@ void GaiaPasswordChangedScreenHandler::Show(const std::string& email,
ShowInWebUI(std::move(data));
}
-void GaiaPasswordChangedScreenHandler::Bind(GaiaPasswordChangedScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void GaiaPasswordChangedScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
-void GaiaPasswordChangedScreenHandler::HandleMigrateUserData(
- const std::string& old_password) {
- if (screen_)
- screen_->MigrateUserData(old_password);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h
index 6feb36225f9..2fcd76d4443 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h
@@ -7,30 +7,23 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class GaiaPasswordChangedScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between GaiaPasswordChangedScreen and its
// WebUI representation.
-class GaiaPasswordChangedView {
+class GaiaPasswordChangedView
+ : public base::SupportsWeakPtr<GaiaPasswordChangedView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"gaia-password-changed"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "gaia-password-changed", "GaiaPasswordChangedScreen"};
- virtual ~GaiaPasswordChangedView() {}
+ virtual ~GaiaPasswordChangedView() = default;
// Shows the contents of the screen.
virtual void Show(const std::string& email, bool has_error) = 0;
-
- // Binds `screen` to the view.
- virtual void Bind(ash::GaiaPasswordChangedScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
};
class GaiaPasswordChangedScreenHandler : public GaiaPasswordChangedView,
@@ -47,17 +40,11 @@ class GaiaPasswordChangedScreenHandler : public GaiaPasswordChangedView,
private:
void Show(const std::string& email, bool has_error) override;
- void Bind(ash::GaiaPasswordChangedScreen* screen) override;
- void Unbind() override;
-
- void HandleMigrateUserData(const std::string& old_password);
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::GaiaPasswordChangedScreen* screen_ = nullptr;
+ void GetAdditionalParameters(base::Value::Dict* dict) override;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index 8fc34e393c4..f384aab2375 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -10,10 +10,10 @@
#include <utility>
#include "ash/components/login/auth/challenge_response/cert_utils.h"
-#include "ash/components/login/auth/cryptohome_key_constants.h"
-#include "ash/components/login/auth/saml_password_attributes.h"
-#include "ash/components/login/auth/sync_trusted_vault_keys.h"
-#include "ash/components/login/auth/user_context.h"
+#include "ash/components/login/auth/public/cryptohome_key_constants.h"
+#include "ash/components/login/auth/public/saml_password_attributes.h"
+#include "ash/components/login/auth/public/sync_trusted_vault_keys.h"
+#include "ash/components/login/auth/public/user_context.h"
#include "ash/components/settings/cros_settings_names.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
@@ -40,6 +40,7 @@
#include "base/values.h"
#include "chrome/browser/ash/authpolicy/authpolicy_helper.h"
#include "chrome/browser/ash/login/helper.h"
+#include "chrome/browser/ash/login/login_pref_names.h"
#include "chrome/browser/ash/login/reauth_stats.h"
#include "chrome/browser/ash/login/saml/public_saml_url_fetcher.h"
#include "chrome/browser/ash/login/saml/saml_metric_utils.h"
@@ -88,8 +89,8 @@
#include "chromeos/components/security_token_pin/constants.h"
#include "chromeos/components/security_token_pin/error_generator.h"
#include "chromeos/constants/devicetype.h"
-#include "chromeos/dbus/util/version_loader.h"
#include "chromeos/strings/grit/chromeos_strings.h"
+#include "chromeos/version/version_loader.h"
#include "components/login/base_screen_handler_utils.h"
#include "components/login/localized_values_builder.h"
#include "components/policy/proto/chrome_device_policy.pb.h"
@@ -313,6 +314,7 @@ bool ShouldPrepareForRecovery(const AccountId& account_id) {
ash::ReauthReason::INVALID_TOKEN_HANDLE,
ash::ReauthReason::SYNC_FAILED,
ash::ReauthReason::PASSWORD_UPDATE_SKIPPED,
+ ash::ReauthReason::FORGOT_PASSWORD,
};
user_manager::KnownUser known_user(g_browser_process->local_state());
absl::optional<int> reauth_reason = known_user.FindReauthReason(account_id);
@@ -408,6 +410,8 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
const bool* collect_stats_consent) {
base::Value params(base::Value::Type::DICTIONARY);
+ // TODO(https://crbug.com/1338102): Looks like `forceReload` isn't used
+ // anywhere further. Remove?
params.SetBoolKey("forceReload", context.force_reload);
params.SetStringKey("gaiaId", context.gaia_id);
params.SetBoolKey("readOnlyEmail", true);
@@ -558,8 +562,14 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
!gaia_reauth_request_token_.empty()) {
params.SetStringKey("rart", gaia_reauth_request_token_);
}
- params.SetBoolKey("enableAzureADIntegration",
- ash::features::IsAzureADIntegrationEnabled());
+
+ PrefService* local_state = g_browser_process->local_state();
+ if (local_state->IsManagedPreference(
+ ash::prefs::kUrlParameterToAutofillSAMLUsername)) {
+ params.SetStringKey("urlParameterToAutofillSAMLUsername",
+ local_state->GetString(
+ ash::prefs::kUrlParameterToAutofillSAMLUsername));
+ }
was_security_token_pin_canceled_ = false;
@@ -717,6 +727,13 @@ void GaiaScreenHandler::HandleAuthExtensionLoaded() {
// used during the current sign-in attempt.
extension_provided_client_cert_usage_observer_ =
std::make_unique<LoginClientCertUsageObserver>();
+
+ // Clear old storage partitions after a new sign-in page is loaded. All
+ // reference to the old storage partitions should be cleared.
+ login::SigninPartitionManager* signin_partition_manager =
+ login::SigninPartitionManager::Factory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+ signin_partition_manager->DisposeOldStoragePartitions();
}
void GaiaScreenHandler::HandleWebviewLoadAborted(int error_code) {
@@ -925,11 +942,17 @@ void GaiaScreenHandler::HandleSamlChallengeMachineKey(
CreateSamlChallengeKeyHandler();
saml_challenge_key_handler_->Run(
Profile::FromWebUI(web_ui()),
- base::BindOnce(&GaiaScreenHandler::ResolveJavascriptCallback,
+ base::BindOnce(&GaiaScreenHandler::HandleSamlChallengeMachineKeyResult,
weak_factory_.GetWeakPtr(), base::Value(callback_id)),
GURL(url), challenge);
}
+void GaiaScreenHandler::HandleSamlChallengeMachineKeyResult(
+ base::Value callback_id,
+ base::Value::Dict result) {
+ ResolveJavascriptCallback(callback_id, result);
+}
+
void GaiaScreenHandler::HandleGaiaUIReady() {
VLOG(1) << "Gaia is loaded";
@@ -1149,7 +1172,8 @@ void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool is_third_party_idp,
void GaiaScreenHandler::Show() {
base::Value::Dict data;
- data.Set("hasUserPods", LoginDisplayHost::default_host()->HasUserPods());
+ if (LoginDisplayHost::default_host())
+ data.Set("hasUserPods", LoginDisplayHost::default_host()->HasUserPods());
ShowInWebUI(std::move(data));
elapsed_timer_ = std::make_unique<base::ElapsedTimer>();
hidden_ = false;
@@ -1211,6 +1235,10 @@ void GaiaScreenHandler::ShowSigninScreenForTest(const std::string& username,
}
}
+void GaiaScreenHandler::Reset() {
+ CallExternalAPI("reset");
+}
+
void GaiaScreenHandler::ShowSecurityTokenPinDialog(
const std::string& /*caller_extension_name*/,
security_token_pin::CodeType code_type,
@@ -1311,7 +1339,7 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
// TODO(crbug.com/1105387): Part of initial screen logic.
PrefService* prefs = g_browser_process->local_state();
- if (prefs->GetBoolean(prefs::kFactoryResetRequested)) {
+ if (prefs->GetBoolean(::prefs::kFactoryResetRequested)) {
DCHECK(LoginDisplayHost::default_host());
LoginDisplayHost::default_host()->StartWizard(ResetView::kScreenId);
}
@@ -1331,6 +1359,10 @@ void GaiaScreenHandler::ShowAllowlistCheckFailedError() {
CallExternalAPI("showAllowlistCheckFailedError", std::move(params));
}
+void GaiaScreenHandler::ReloadGaiaAuthenticator() {
+ CallExternalAPI("doReload");
+}
+
void GaiaScreenHandler::LoadAuthExtension(bool force) {
VLOG(1) << "LoadAuthExtension, force: " << force;
if (auth_extension_being_loaded_) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
index 83c6e55bbbe..62c2fa5d660 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
@@ -85,6 +85,8 @@ class GaiaView : public base::SupportsWeakPtr<GaiaView> {
virtual void SetGaiaPath(GaiaPath gaia_path) = 0;
// Show error UI at the end of GAIA flow when user is not allowlisted.
virtual void ShowAllowlistCheckFailedError() = 0;
+ // Reloads authenticator.
+ virtual void ReloadGaiaAuthenticator() = 0;
// Show sign-in screen for the given credentials. `services` is a list of
// services returned by userInfo call as JSON array. Should be an empty array
@@ -92,6 +94,8 @@ class GaiaView : public base::SupportsWeakPtr<GaiaView> {
virtual void ShowSigninScreenForTest(const std::string& username,
const std::string& password,
const std::string& services) = 0;
+ // Reset authenticator.
+ virtual void Reset() = 0;
};
// A class that handles WebUI hooks in Gaia screen.
@@ -133,10 +137,12 @@ class GaiaScreenHandler : public BaseScreenHandler,
void Hide() override;
void SetGaiaPath(GaiaPath gaia_path) override;
void ShowAllowlistCheckFailedError() override;
+ void ReloadGaiaAuthenticator() override;
void ShowSigninScreenForTest(const std::string& username,
const std::string& password,
const std::string& services) override;
+ void Reset() override;
// SecurityTokenPinDialogHost:
void ShowSecurityTokenPinDialog(
@@ -221,6 +227,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
void HandleSamlChallengeMachineKey(const std::string& callback_id,
const std::string& url,
const std::string& challenge);
+ void HandleSamlChallengeMachineKeyResult(base::Value callback_id,
+ base::Value::Dict result);
void HandleGaiaUIReady();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc
index 5249d6e7b6e..21e87df28ce 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc
@@ -10,32 +10,15 @@
namespace chromeos {
-constexpr StaticOobeScreenId GestureNavigationScreenView::kScreenId;
-
GestureNavigationScreenHandler::GestureNavigationScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.GestureNavigationScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
GestureNavigationScreenHandler::~GestureNavigationScreenHandler() = default;
void GestureNavigationScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
-
ShowInWebUI();
}
-void GestureNavigationScreenHandler::Bind(GestureNavigationScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
-}
-
-void GestureNavigationScreenHandler::Hide() {}
-
void GestureNavigationScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("gestureNavigationIntroTitle",
@@ -62,22 +45,4 @@ void GestureNavigationScreenHandler::DeclareLocalizedValues(
IDS_OOBE_GESTURE_NAVIGATION_OVERVIEW_DESCRIPTION);
}
-void GestureNavigationScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
-void GestureNavigationScreenHandler::RegisterMessages() {
- AddCallback("handleGesturePageChange",
- &GestureNavigationScreenHandler::HandleGesturePageChange);
- BaseScreenHandler::RegisterMessages();
-}
-
-void GestureNavigationScreenHandler::HandleGesturePageChange(
- const std::string& new_page) {
- screen_->GesturePageChange(new_page);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h
index 4fd38000bb2..96c8d0573f5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h
@@ -5,24 +5,21 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GESTURE_NAVIGATION_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GESTURE_NAVIGATION_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class GestureNavigationScreen;
-}
-
namespace chromeos {
// Interface between gesture navigation screen and its representation.
-class GestureNavigationScreenView {
+class GestureNavigationScreenView
+ : public base::SupportsWeakPtr<GestureNavigationScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"gesture-navigation"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "gesture-navigation", "GestureNavigationScreen"};
- virtual ~GestureNavigationScreenView() {}
+ virtual ~GestureNavigationScreenView() = default;
- virtual void Bind(ash::GestureNavigationScreen* screen) = 0;
virtual void Show() = 0;
- virtual void Hide() = 0;
};
// WebUI implementation of GestureNavigationScreenView.
@@ -40,25 +37,11 @@ class GestureNavigationScreenHandler : public GestureNavigationScreenView,
const GestureNavigationScreenHandler&) = delete;
// GestureNavigationScreenView:
- void Bind(ash::GestureNavigationScreen* screen) override;
void Show() override;
- void Hide() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
- void RegisterMessages() override;
-
- private:
- // Called when the currently shown page for the gesture navigation screen is
- // changed.
- void HandleGesturePageChange(const std::string& new_page);
-
- ash::GestureNavigationScreen* screen_ = nullptr;
-
- // If true, InitializeDeprecated() will call Show().
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.cc
index 8dc9f787650..649d1628a35 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.cc
@@ -11,16 +11,9 @@
namespace chromeos {
-constexpr StaticOobeScreenId GuestTosScreenView::kScreenId;
+GuestTosScreenHandler::GuestTosScreenHandler() : BaseScreenHandler(kScreenId) {}
-GuestTosScreenHandler::GuestTosScreenHandler() : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.GuestTosScreen.userActed");
-}
-
-GuestTosScreenHandler::~GuestTosScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+GuestTosScreenHandler::~GuestTosScreenHandler() = default;
void GuestTosScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -39,45 +32,12 @@ void GuestTosScreenHandler::DeclareLocalizedValues(
builder->Add("guestTosLoading", IDS_GUEST_TOS_LOADING);
}
-void GuestTosScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- Show(google_eula_url_, cros_eula_url_);
- show_on_init_ = false;
- }
-}
-
void GuestTosScreenHandler::Show(const std::string& google_eula_url,
const std::string& cros_eula_url) {
- google_eula_url_ = google_eula_url;
- cros_eula_url_ = cros_eula_url;
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
-
base::Value::Dict data;
data.Set("googleEulaUrl", google_eula_url);
data.Set("crosEulaUrl", cros_eula_url);
ShowInWebUI(std::move(data));
}
-void GuestTosScreenHandler::Bind(GuestTosScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void GuestTosScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
-void GuestTosScreenHandler::RegisterMessages() {
- BaseScreenHandler::RegisterMessages();
- AddCallback("GuestToSAccept", &GuestTosScreenHandler::HandleAccept);
-}
-
-void GuestTosScreenHandler::HandleAccept(bool enable_usage_stats) {
- if (screen_)
- screen_->OnAccept(enable_usage_stats);
-}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h
index 11804785a34..cc6bd92389b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h
@@ -5,26 +5,22 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GUEST_TOS_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GUEST_TOS_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class GuestTosScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between GuestTosScreen and its
// WebUI representation.
-class GuestTosScreenView {
+class GuestTosScreenView : public base::SupportsWeakPtr<GuestTosScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"guest-tos"};
+ inline constexpr static StaticOobeScreenId kScreenId{"guest-tos",
+ "GuestTosScreen"};
virtual ~GuestTosScreenView() = default;
virtual void Show(const std::string& google_eula_url,
const std::string& cros_eula_url) = 0;
- virtual void Bind(ash::GuestTosScreen* screen) = 0;
- virtual void Unbind() = 0;
};
class GuestTosScreenHandler : public GuestTosScreenView,
@@ -41,21 +37,10 @@ class GuestTosScreenHandler : public GuestTosScreenView,
// GuestTosScreenView
void Show(const std::string& google_eula_url,
const std::string& cros_eula_url) override;
- void Bind(ash::GuestTosScreen* screen) override;
- void Unbind() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
- void RegisterMessages() override;
-
- void HandleAccept(bool enable_usage_stats);
-
- ash::GuestTosScreen* screen_ = nullptr;
- bool show_on_init_ = false;
- std::string google_eula_url_;
- std::string cros_eula_url_;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
index ca2e2d5f581..446b6aa29b1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
@@ -14,8 +14,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/session_manager/session_manager_client.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/session_manager/session_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
@@ -66,14 +66,14 @@ void KioskAutolaunchScreenHandler::UpdateKioskApp() {
return;
}
- base::DictionaryValue app_info;
- app_info.SetStringKey("appName", app.name);
+ base::Value::Dict app_info;
+ app_info.Set("appName", app.name);
std::string icon_url("chrome://theme/IDR_APP_DEFAULT_ICON");
if (!app.icon.isNull())
icon_url = webui::GetBitmapDataUrl(*app.icon.bitmap());
- app_info.SetStringKey("appIconUrl", icon_url);
+ app_info.Set("appIconUrl", icon_url);
CallJS("login.AutolaunchScreen.updateApp", std::move(app_info));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
index df949dcfe26..477271a75ad 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
@@ -17,33 +17,15 @@
namespace chromeos {
-constexpr StaticOobeScreenId KioskEnableScreenView::kScreenId;
-
KioskEnableScreenHandler::KioskEnableScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.KioskEnableScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-KioskEnableScreenHandler::~KioskEnableScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+KioskEnableScreenHandler::~KioskEnableScreenHandler() = default;
void KioskEnableScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void KioskEnableScreenHandler::SetScreen(KioskEnableScreen* screen) {
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
- screen_ = screen;
- if (IsJavascriptAllowed() && screen_)
- InitializeDeprecated();
-}
-
void KioskEnableScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("kioskEnableWarningText",
@@ -57,18 +39,8 @@ void KioskEnableScreenHandler::DeclareLocalizedValues(
builder->Add("kioskEnableErrorMsg", IDS_KIOSK_ENABLE_SCREEN_ERROR);
}
-void KioskEnableScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed() || !screen_)
- return;
-
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
void KioskEnableScreenHandler::ShowKioskEnabled(bool success) {
- CallJS("login.KioskEnableScreen.onCompleted", success);
+ CallExternalAPI("onCompleted", success);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h
index 5ce45547c76..110569936de 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h
@@ -9,22 +9,19 @@
#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class KioskEnableScreen;
-}
-
namespace chromeos {
// Interface between enable kiosk screen and its representation.
// Note, do not forget to call OnViewDestroyed in the dtor.
-class KioskEnableScreenView {
+class KioskEnableScreenView
+ : public base::SupportsWeakPtr<KioskEnableScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"kiosk-enable"};
+ inline constexpr static StaticOobeScreenId kScreenId{"kiosk-enable",
+ "KioskEnableScreen"};
- virtual ~KioskEnableScreenView() {}
+ virtual ~KioskEnableScreenView() = default;
virtual void Show() = 0;
- virtual void SetScreen(ash::KioskEnableScreen* screen) = 0;
virtual void ShowKioskEnabled(bool success) = 0;
};
@@ -43,19 +40,11 @@ class KioskEnableScreenHandler : public KioskEnableScreenView,
// KioskEnableScreenView:
void Show() override;
- void SetScreen(ash::KioskEnableScreen* screen) override;
void ShowKioskEnabled(bool success) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- private:
- ash::KioskEnableScreen* screen_ = nullptr;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc
index 7c415420f84..1201d85ba46 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc
@@ -13,26 +13,11 @@
namespace chromeos {
-constexpr StaticOobeScreenId LocaleSwitchView::kScreenId;
-
LocaleSwitchScreenHandler::LocaleSwitchScreenHandler(
CoreOobeView* core_oobe_view)
: BaseScreenHandler(kScreenId), core_oobe_view_(core_oobe_view) {}
-LocaleSwitchScreenHandler::~LocaleSwitchScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
-
-void LocaleSwitchScreenHandler::Bind(LocaleSwitchScreen* screen) {
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
- screen_ = screen;
-}
-
-void LocaleSwitchScreenHandler::Unbind() {
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
- screen_ = nullptr;
-}
+LocaleSwitchScreenHandler::~LocaleSwitchScreenHandler() = default;
void LocaleSwitchScreenHandler::UpdateStrings() {
base::Value::Dict localized_strings = GetOobeUI()->GetLocalizedStrings();
@@ -42,6 +27,4 @@ void LocaleSwitchScreenHandler::UpdateStrings() {
void LocaleSwitchScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {}
-void LocaleSwitchScreenHandler::InitializeDeprecated() {}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h
index 67bc6349d07..cba7b6c9346 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h
@@ -5,18 +5,16 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOCALE_SWITCH_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOCALE_SWITCH_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
-namespace ash {
-class LocaleSwitchScreen;
-}
-
namespace chromeos {
-class LocaleSwitchView {
+class LocaleSwitchView : public base::SupportsWeakPtr<LocaleSwitchView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"locale-switch"};
+ inline constexpr static StaticOobeScreenId kScreenId{"locale-switch",
+ "LocaleSwitchScreen"};
LocaleSwitchView() = default;
virtual ~LocaleSwitchView() = default;
@@ -24,8 +22,6 @@ class LocaleSwitchView {
LocaleSwitchView(const LocaleSwitchView&) = delete;
LocaleSwitchView& operator=(const LocaleSwitchView&) = delete;
- virtual void Bind(ash::LocaleSwitchScreen* screen) = 0;
- virtual void Unbind() = 0;
virtual void UpdateStrings() = 0;
};
@@ -39,18 +35,14 @@ class LocaleSwitchScreenHandler : public BaseScreenHandler,
~LocaleSwitchScreenHandler() override;
// LocaleSwitchView:
- void Bind(ash::LocaleSwitchScreen* screen) override;
- void Unbind() override;
void UpdateStrings() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
private:
- ash::LocaleSwitchScreen* screen_ = nullptr;
- CoreOobeView* core_oobe_view_ = nullptr;
+ base::raw_ptr<CoreOobeView> core_oobe_view_;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.cc
index ce9cf9d518f..7980783c111 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.cc
@@ -4,47 +4,21 @@
#include "chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h"
-#include "ash/components/arc/arc_prefs.h"
-#include "ash/public/cpp/login_screen.h"
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/metrics/histogram_macros.h"
-#include "chrome/browser/ash/arc/arc_util.h"
-#include "chrome/browser/ash/arc/session/arc_session_manager.h"
+#include "ash/components/arc/session/arc_management_transition.h"
#include "chrome/browser/ash/login/oobe_screen.h"
#include "chrome/browser/ash/login/screens/management_transition_screen.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/ash/system_tray_client_impl.h"
-#include "chrome/browser/ui/managed_ui.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-constexpr base::TimeDelta kWaitingTimeout = base::Minutes(2);
-
-} // namespace
-
namespace chromeos {
-namespace {
-
-// Management transition screen step names.
-const char kManagementTransitionStepError[] = "error";
-
-} // namespace
-
-constexpr StaticOobeScreenId ManagementTransitionScreenView::kScreenId;
ManagementTransitionScreenHandler::ManagementTransitionScreenHandler()
: BaseScreenHandler(kScreenId) {}
-ManagementTransitionScreenHandler::~ManagementTransitionScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
- timer_.Stop();
-}
+ManagementTransitionScreenHandler::~ManagementTransitionScreenHandler() =
+ default;
void ManagementTransitionScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -63,113 +37,18 @@ void ManagementTransitionScreenHandler::DeclareLocalizedValues(
IDS_SUPERVISION_TRANSITION_ERROR_BUTTON);
}
-void ManagementTransitionScreenHandler::RegisterMessages() {
- AddCallback(
- "finishManagementTransition",
- &ManagementTransitionScreenHandler::OnManagementTransitionFinished);
- BaseScreenHandler::RegisterMessages();
-}
-
-void ManagementTransitionScreenHandler::Bind(
- ManagementTransitionScreen* screen) {
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
- screen_ = screen;
- if (IsJavascriptAllowed())
- InitializeDeprecated();
-}
-
-void ManagementTransitionScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
- timer_.Stop();
-}
-
-void ManagementTransitionScreenHandler::Show() {
- if (!IsJavascriptAllowed() || !screen_) {
- show_on_init_ = true;
- return;
- }
-
- screen_shown_time_ = base::TimeTicks::Now();
-
- timer_.Start(
- FROM_HERE, kWaitingTimeout,
- base::BindOnce(
- &ManagementTransitionScreenHandler::OnManagementTransitionFailed,
- weak_factory_.GetWeakPtr()));
-
- Profile* profile = ProfileManager::GetActiveUserProfile();
- DCHECK(!ProfileHelper::IsSigninProfile(profile));
-
- registrar_.Init(profile->GetPrefs());
- registrar_.Add(
- arc::prefs::kArcManagementTransition,
- base::BindRepeating(
- &ManagementTransitionScreenHandler::OnManagementTransitionFinished,
- weak_factory_.GetWeakPtr()));
-
- // Disable system tray, shutdown button and prevent login as guest when
- // management transition screen is shown.
- SystemTrayClientImpl::Get()->SetPrimaryTrayEnabled(false);
- ash::LoginScreen::Get()->EnableShutdownButton(false);
- ash::LoginScreen::Get()->SetAllowLoginAsGuest(false);
- ash::LoginScreen::Get()->SetIsFirstSigninStep(false);
-
+void ManagementTransitionScreenHandler::Show(
+ arc::ArcManagementTransition arc_management_transition,
+ std::string management_entity) {
base::Value::Dict data;
- data.Set("arcTransition",
- static_cast<int>(arc::GetManagementTransition(profile)));
- data.Set("managementEntity",
- chrome::GetAccountManagerIdentity(profile).value_or(std::string()));
- ShowInWebUI(std::move(data));
-}
-
-void ManagementTransitionScreenHandler::Hide() {}
-
-base::OneShotTimer* ManagementTransitionScreenHandler::GetTimerForTesting() {
- return &timer_;
-}
+ data.Set("arcTransition", static_cast<int>(arc_management_transition));
+ data.Set("managementEntity", management_entity);
-void ManagementTransitionScreenHandler::InitializeDeprecated() {
- if (!screen_ || !show_on_init_)
- return;
-
- Show();
- show_on_init_ = false;
-}
-
-void ManagementTransitionScreenHandler::ShowStep(const char* step) {
- CallJS("login.ManagementTransitionScreen.showStep", std::string(step));
-}
-
-void ManagementTransitionScreenHandler::OnManagementTransitionFailed() {
- LOG(ERROR) << "Management transition failed; resetting ARC++ data.";
- // Prevent ARC++ data removal below from triggering the success flow (since it
- // will reset the management transition pref).
- registrar_.RemoveAll();
- timed_out_ = true;
- arc::ArcSessionManager::Get()->RequestArcDataRemoval();
- arc::ArcSessionManager::Get()->StopAndEnableArc();
- ShowStep(kManagementTransitionStepError);
+ ShowInWebUI(std::move(data));
}
-void ManagementTransitionScreenHandler::OnManagementTransitionFinished() {
- // This method is called both when management transition succeeds (observing
- // pref changes) and when it fails ("OK" button from error screen, see
- // RegisterMessages()). Once this screen exits, user session will be started,
- // so there's no need to re-enable shutdown button from login screen, only the
- // system tray.
- SystemTrayClientImpl::Get()->SetPrimaryTrayEnabled(true);
- if (screen_)
- screen_->OnManagementTransitionFinished();
-
- UMA_HISTOGRAM_BOOLEAN("Arc.Supervision.Transition.Screen.Successful",
- !timed_out_);
- if (!timed_out_) {
- base::TimeDelta timeDelta = base::TimeTicks::Now() - screen_shown_time_;
- DVLOG(1) << "Transition succeeded in: " << timeDelta.InSecondsF();
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Arc.Supervision.Transition.Screen.Success.TimeDelta", timeDelta);
- }
+void ManagementTransitionScreenHandler::ShowError() {
+ CallExternalAPI("showStep", "error");
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h
index d389e08dbbc..b15e4fe80d2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/management_transition_screen_handler.h
@@ -5,36 +5,32 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MANAGEMENT_TRANSITION_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MANAGEMENT_TRANSITION_SCREEN_HANDLER_H_
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "chrome/browser/profiles/profile.h"
+#include "ash/components/arc/session/arc_management_transition.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "components/prefs/pref_change_registrar.h"
-
-namespace ash {
-class ManagementTransitionScreen;
-}
namespace chromeos {
// Interface for dependency injection between ManagementTransitionScreen
// and its WebUI representation.
-class ManagementTransitionScreenView {
+class ManagementTransitionScreenView
+ : public base::SupportsWeakPtr<ManagementTransitionScreenView> {
public:
// Renamed from "supervision-transition".
- constexpr static StaticOobeScreenId kScreenId{"management-transition"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "management-transition", "ManagementTransitionScreen"};
ManagementTransitionScreenView(const ManagementTransitionScreenView&) =
delete;
ManagementTransitionScreenView& operator=(
const ManagementTransitionScreenView&) = delete;
- virtual ~ManagementTransitionScreenView() {}
+ virtual ~ManagementTransitionScreenView() = default;
- virtual void Bind(ash::ManagementTransitionScreen* screen) = 0;
- virtual void Unbind() = 0;
- virtual void Show() = 0;
- virtual void Hide() = 0;
+ virtual void Show(arc::ArcManagementTransition arc_management_transition,
+ std::string management_entity) = 0;
+
+ virtual void ShowError() = 0;
protected:
ManagementTransitionScreenView() = default;
@@ -58,46 +54,11 @@ class ManagementTransitionScreenHandler
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void RegisterMessages() override;
-
- // ManagementTransitionScreenView:
- void Bind(ash::ManagementTransitionScreen* screen) override;
- void Unbind() override;
- void Show() override;
- void Hide() override;
-
- base::OneShotTimer* GetTimerForTesting();
-
- private:
- // BaseScreenHandler:
- void InitializeDeprecated() override;
-
- // Shows a given step.
- void ShowStep(const char* step);
-
- // Called when the max wait timeout is reached.
- void OnManagementTransitionFailed();
-
- void OnManagementTransitionFinished();
-
- ash::ManagementTransitionScreen* screen_ = nullptr;
-
- // Whether the screen should be shown right after initialization.
- bool show_on_init_ = false;
-
- // Whether screen timed out waiting for transition to occur and displayed the
- // error screen.
- bool timed_out_ = false;
-
- base::TimeTicks screen_shown_time_;
-
- // Timer used to exit the page when timeout reaches.
- base::OneShotTimer timer_;
- // Listens to pref changes.
- PrefChangeRegistrar registrar_;
+ void Show(arc::ArcManagementTransition arc_management_transition,
+ std::string management_entity) override;
- base::WeakPtrFactory<ManagementTransitionScreenHandler> weak_factory_{this};
+ void ShowError() override;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
index e429b99979b..e061399da1b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
@@ -6,15 +6,11 @@
#include <utility>
-#include "ash/constants/ash_pref_names.h"
#include "base/command_line.h"
-#include "base/metrics/histogram_functions.h"
#include "base/values.h"
#include "chrome/browser/ash/login/screens/marketing_opt_in_screen.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-#include "components/prefs/pref_service.h"
#include "ui/chromeos/devicetype_utils.h"
namespace chromeos {
@@ -24,29 +20,25 @@ namespace {
constexpr char kOptInVisibility[] = "optInVisibility";
constexpr char kOptInDefaultState[] = "optInDefaultState";
constexpr char kLegalFooterVisibility[] = "legalFooterVisibility";
-
-void RecordShowShelfNavigationButtonsValueChange(bool enabled) {
- base::UmaHistogramBoolean(
- "Accessibility.CrosShelfNavigationButtonsInTabletModeChanged.OOBE",
- enabled);
-}
+constexpr char kCloudGamingDevice[] = "cloudGamingDevice";
} // namespace
-constexpr StaticOobeScreenId MarketingOptInScreenView::kScreenId;
-
MarketingOptInScreenHandler::MarketingOptInScreenHandler()
: BaseScreenHandler(kScreenId) {}
-MarketingOptInScreenHandler::~MarketingOptInScreenHandler() {
- if (a11y_nav_buttons_toggle_metrics_reporter_timer_.IsRunning())
- a11y_nav_buttons_toggle_metrics_reporter_timer_.FireNow();
-}
+MarketingOptInScreenHandler::~MarketingOptInScreenHandler() = default;
void MarketingOptInScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("marketingOptInScreenTitle",
IDS_LOGIN_MARKETING_OPT_IN_SCREEN_TITLE);
+ builder->Add("marketingOptInScreenGameDeviceTitle",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_WITH_CLOUDGAMINGDEVICE_TITLE);
+ builder->AddF(
+ "marketingOptInScreenGameDeviceSubtitle",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_WITH_CLOUDGAMINGDEVICE_SUBTITLE,
+ ui::GetChromeOSDeviceName());
builder->AddF("marketingOptInScreenSubtitle",
IDS_LOGIN_MARKETING_OPT_IN_SCREEN_SUBTITLE,
ui::GetChromeOSDeviceName());
@@ -56,6 +48,10 @@ void MarketingOptInScreenHandler::DeclareLocalizedValues(
builder->Add(
"marketingOptInGetChromebookUpdates",
IDS_LOGIN_MARKETING_OPT_IN_SCREEN_GET_CHROMEBOOK_UPDATES_SIGN_ME_UP);
+ builder->AddF(
+ "marketingOptInGameDeviceUpdates",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_WITH_CLOUDGAMINGDEVICE_SIGN_ME_UP,
+ ui::GetChromeOSDeviceName());
builder->Add("marketingOptInScreenAllSet", IDS_LOGIN_GET_STARTED);
builder->Add("marketingOptInScreenUnsubscribeShort",
IDS_LOGIN_MARKETING_OPT_IN_SCREEN_UNSUBSCRIBE_SHORT);
@@ -73,47 +69,27 @@ void MarketingOptInScreenHandler::DeclareLocalizedValues(
IDS_MARKETING_OPT_IN_ACCESSIBILITY_DONE_BUTTON);
}
-void MarketingOptInScreenHandler::Bind(MarketingOptInScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
-}
-
void MarketingOptInScreenHandler::Show(bool opt_in_visible,
bool opt_in_default_state,
- bool legal_footer_visible) {
+ bool legal_footer_visible,
+ bool cloud_gaming_enabled) {
base::Value::Dict data;
data.Set(kOptInVisibility, opt_in_visible);
data.Set(kOptInDefaultState, opt_in_default_state);
data.Set(kLegalFooterVisibility, legal_footer_visible);
+ data.Set(kCloudGamingDevice, cloud_gaming_enabled);
ShowInWebUI(std::move(data));
}
-void MarketingOptInScreenHandler::Hide() {
- if (a11y_nav_buttons_toggle_metrics_reporter_timer_.IsRunning())
- a11y_nav_buttons_toggle_metrics_reporter_timer_.FireNow();
-}
-
void MarketingOptInScreenHandler::UpdateA11ySettingsButtonVisibility(
bool shown) {
- CallJS("login.MarketingOptInScreen.updateA11ySettingsButtonVisibility",
- shown);
+ CallExternalAPI("updateA11ySettingsButtonVisibility", shown);
}
void MarketingOptInScreenHandler::UpdateA11yShelfNavigationButtonToggle(
bool enabled) {
- CallJS("login.MarketingOptInScreen.updateA11yNavigationButtonToggle",
- enabled);
-}
-
-void MarketingOptInScreenHandler::InitializeDeprecated() {}
-
-void MarketingOptInScreenHandler::RegisterMessages() {
- AddCallback("login.MarketingOptInScreen.onGetStarted",
- &MarketingOptInScreenHandler::HandleOnGetStarted);
- AddCallback(
- "login.MarketingOptInScreen.setA11yNavigationButtonsEnabled",
- &MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled);
+ CallExternalAPI("updateA11yNavigationButtonToggle", enabled);
}
void MarketingOptInScreenHandler::GetAdditionalParameters(
@@ -121,19 +97,4 @@ void MarketingOptInScreenHandler::GetAdditionalParameters(
BaseScreenHandler::GetAdditionalParameters(parameters);
}
-void MarketingOptInScreenHandler::HandleOnGetStarted(
- bool chromebook_email_opt_in) {
- screen_->OnGetStarted(chromebook_email_opt_in);
-}
-
-void MarketingOptInScreenHandler::HandleSetA11yNavigationButtonsEnabled(
- bool enabled) {
- ProfileManager::GetActiveUserProfile()->GetPrefs()->SetBoolean(
- ash::prefs::kAccessibilityTabletModeShelfNavigationButtonsEnabled,
- enabled);
- a11y_nav_buttons_toggle_metrics_reporter_timer_.Start(
- FROM_HERE, base::Seconds(10),
- base::BindOnce(&RecordShowShelfNavigationButtonsValueChange, enabled));
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h
index 52f38fa43d1..9429d653602 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h
@@ -5,34 +5,28 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MARKETING_OPT_IN_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MARKETING_OPT_IN_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class MarketingOptInScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between MarketingOptInScreen and its
// WebUI representation.
-class MarketingOptInScreenView {
+class MarketingOptInScreenView
+ : public base::SupportsWeakPtr<MarketingOptInScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"marketing-opt-in"};
+ inline constexpr static StaticOobeScreenId kScreenId{"marketing-opt-in",
+ "MarketingOptInScreen"};
virtual ~MarketingOptInScreenView() = default;
- // Sets screen this view belongs to.
- virtual void Bind(ash::MarketingOptInScreen* screen) = 0;
-
// Shows the contents of the screen.
virtual void Show(bool opt_in_visible,
bool opt_in_default_state,
- bool legal_footer_visible) = 0;
-
- // Hides the contents of the screen.
- virtual void Hide() = 0;
+ bool legal_footer_visible,
+ bool cloud_gaming_enabled) = 0;
// Sets whether the a11y Settings button is visible.
virtual void UpdateA11ySettingsButtonVisibility(bool shown) = 0;
@@ -61,31 +55,16 @@ class MarketingOptInScreenHandler : public BaseScreenHandler,
::login::LocalizedValuesBuilder* builder) override;
// MarketingOptInScreenView:
- void Bind(ash::MarketingOptInScreen* screen) override;
void Show(bool opt_in_visible,
bool opt_in_default_state,
- bool legal_footer_visible) override;
- void Hide() override;
+ bool legal_footer_visible,
+ bool cloud_gaming_enabled) override;
void UpdateA11ySettingsButtonVisibility(bool shown) override;
void UpdateA11yShelfNavigationButtonToggle(bool enabled) override;
private:
// BaseScreenHandler:
- void InitializeDeprecated() override;
- void RegisterMessages() override;
void GetAdditionalParameters(base::Value::Dict* parameters) override;
-
- // WebUI event handlers.
- void HandleOnGetStarted(bool chromebook_email_opt_in);
- void HandleSetA11yNavigationButtonsEnabled(bool enabled);
-
- ash::MarketingOptInScreen* screen_ = nullptr;
-
- // Timer to record user changed value for the accessibility setting to turn
- // shelf navigation buttons on in tablet mode. The metric is recorded with 10
- // second delay to avoid overreporting when the user keeps toggling the
- // setting value in the screen UI.
- base::OneShotTimer a11y_nav_buttons_toggle_metrics_reporter_timer_;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
index a76a3a6f961..f0360da8e46 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
@@ -13,13 +13,8 @@
namespace chromeos {
-constexpr StaticOobeScreenId MultiDeviceSetupScreenView::kScreenId;
-
MultiDeviceSetupScreenHandler::MultiDeviceSetupScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.MultiDeviceSetupScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
MultiDeviceSetupScreenHandler::~MultiDeviceSetupScreenHandler() = default;
@@ -28,10 +23,6 @@ void MultiDeviceSetupScreenHandler::DeclareLocalizedValues(
multidevice_setup::AddLocalizedValuesToBuilder(builder);
}
-void MultiDeviceSetupScreenHandler::Bind(MultiDeviceSetupScreen* screen) {
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
-}
-
void MultiDeviceSetupScreenHandler::Show() {
ShowInWebUI();
FireWebUIListenerWhenAllowed("multidevice_setup.initializeSetupFlow");
@@ -43,8 +34,4 @@ void MultiDeviceSetupScreenHandler::GetAdditionalParameters(
base::Value(ash::features::IsWifiSyncAndroidEnabled()));
}
-void MultiDeviceSetupScreenHandler::Hide() {}
-
-void MultiDeviceSetupScreenHandler::InitializeDeprecated() {}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h
index 6b5d717e9d6..ecada60c0c0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h
@@ -5,26 +5,23 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MULTIDEVICE_SETUP_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MULTIDEVICE_SETUP_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class MultiDeviceSetupScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between MultiDeviceSetupScreen and its
// WebUI representation.
-class MultiDeviceSetupScreenView {
+class MultiDeviceSetupScreenView
+ : public base::SupportsWeakPtr<MultiDeviceSetupScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"multidevice-setup-screen"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "multidevice-setup-screen", "MultiDeviceSetupScreen"};
virtual ~MultiDeviceSetupScreenView() = default;
- virtual void Bind(ash::MultiDeviceSetupScreen* screen) = 0;
virtual void Show() = 0;
- virtual void Hide() = 0;
};
// Concrete MultiDeviceSetupScreenView WebUI-based implementation.
@@ -47,13 +44,7 @@ class MultiDeviceSetupScreenHandler : public BaseScreenHandler,
void GetAdditionalParameters(base::Value::Dict* dict) override;
// MultiDeviceSetupScreenView:
- void Bind(ash::MultiDeviceSetupScreen* screen) override;
void Show() override;
- void Hide() override;
-
- private:
- // BaseScreenHandler:
- void InitializeDeprecated() override;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc
index ed83855688e..29770dadcb6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc
@@ -7,9 +7,9 @@
#include "chrome/browser/ash/login/ui/login_display_host.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_type_pattern.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_type_pattern.h"
#include "components/onc/onc_constants.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
index df3efbbd0ca..029a9792013 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
@@ -14,8 +14,8 @@
#include "chrome/browser/ash/login/startup_utils.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
#include "ui/chromeos/strings/network_element_localized_strings_provider.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
index 19978e9f92d..9ea8f252bbf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
@@ -10,10 +10,9 @@
#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
+#include "chromeos/ash/components/network/network_state.h"
#include "chromeos/ash/components/network/proxy/proxy_config_handler.h"
#include "chromeos/ash/components/network/proxy/ui_proxy_config_service.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/proxy_config/proxy_prefs.h"
#include "net/proxy_resolution/proxy_config.h"
@@ -36,6 +35,7 @@ NetworkStateInformer::State GetStateForDefaultNetwork() {
return NetworkStateInformer::OFFLINE;
if (network_portal_detector::GetInstance()->IsEnabled()) {
+ /// TODO(b/207069182): Remove this clause and rely on NetworkState.
NetworkPortalDetector::CaptivePortalStatus status =
network_portal_detector::GetInstance()->GetCaptivePortalStatus();
if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN &&
@@ -60,12 +60,24 @@ NetworkStateInformer::State GetStateForDefaultNetwork() {
if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL)
return NetworkStateInformer::CAPTIVE_PORTAL;
} else {
- if (NetworkState::StateIsConnecting(network->connection_state()))
+ if (network->IsConnectingState())
return NetworkStateInformer::CONNECTING;
- if (network->connection_state() == shill::kStateOnline)
- return NetworkStateInformer::ONLINE;
- if (network->IsCaptivePortal())
- return NetworkStateInformer::CAPTIVE_PORTAL;
+ if (network->IsConnectedState()) {
+ auto portal_state = network->GetPortalState();
+ switch (portal_state) {
+ case NetworkState::PortalState::kUnknown:
+ return NetworkStateInformer::UNKNOWN;
+ case NetworkState::PortalState::kOnline:
+ return NetworkStateInformer::ONLINE;
+ case NetworkState::PortalState::kPortalSuspected:
+ case NetworkState::PortalState::kPortal:
+ return NetworkStateInformer::CAPTIVE_PORTAL;
+ case NetworkState::PortalState::kProxyAuthRequired:
+ return NetworkStateInformer::PROXY_AUTH_REQUIRED;
+ case NetworkState::PortalState::kNoInternet:
+ return NetworkStateInformer::CAPTIVE_PORTAL;
+ }
+ }
}
// If there is no connection to the internet report it as online for the
@@ -86,17 +98,13 @@ NetworkStateInformer::State GetStateForDefaultNetwork() {
NetworkStateInformer::NetworkStateInformer() : state_(OFFLINE) {}
NetworkStateInformer::~NetworkStateInformer() {
- if (NetworkHandler::IsInitialized()) {
- NetworkHandler::Get()->network_state_handler()->RemoveObserver(
- this, FROM_HERE);
- }
network_portal_detector::GetInstance()->RemoveObserver(this);
}
void NetworkStateInformer::Init() {
UpdateState();
- NetworkHandler::Get()->network_state_handler()->AddObserver(
- this, FROM_HERE);
+ network_state_handler_observer_.Observe(
+ NetworkHandler::Get()->network_state_handler());
network_portal_detector::GetInstance()->AddAndFireObserver(this);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
index 075dc7f9ec9..8a86ff64f6f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h
@@ -13,10 +13,12 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/ash/login/ui/captive_portal_window_proxy.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_state_handler_observer.h"
#include "chromeos/ash/components/network/portal_detector/network_portal_detector.h"
-#include "chromeos/network/network_state_handler_observer.h"
namespace base {
class Value;
@@ -27,11 +29,10 @@ namespace chromeos {
// Class which observes network state changes and calls registered callbacks.
// State is considered changed if connection or the active network has been
// changed. Also, it answers to the requests about current network state.
-class NetworkStateInformer
- : public chromeos::NetworkStateHandlerObserver,
- public chromeos::NetworkPortalDetector::Observer,
- public CaptivePortalWindowProxyDelegate,
- public base::RefCounted<NetworkStateInformer> {
+class NetworkStateInformer : public chromeos::NetworkStateHandlerObserver,
+ public chromeos::NetworkPortalDetector::Observer,
+ public CaptivePortalWindowProxyDelegate,
+ public base::RefCounted<NetworkStateInformer> {
public:
enum State {
OFFLINE = 0,
@@ -98,6 +99,10 @@ class NetworkStateInformer
base::ObserverList<NetworkStateInformerObserver>::Unchecked observers_;
+ base::ScopedObservation<chromeos::NetworkStateHandler,
+ chromeos::NetworkStateHandlerObserver>
+ network_state_handler_observer_{this};
+
base::WeakPtrFactory<NetworkStateInformer> weak_ptr_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc
index 2e58f5171f5..5d42bc90d7e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h"
-#include "chrome/browser/ash/login/screens/offline_login_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
@@ -13,25 +12,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId OfflineLoginView::kScreenId;
-
OfflineLoginScreenHandler::OfflineLoginScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.OfflineLoginScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-OfflineLoginScreenHandler::~OfflineLoginScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
-
-void OfflineLoginScreenHandler::RegisterMessages() {
- BaseScreenHandler::RegisterMessages();
- AddCallback("completeOfflineAuthentication",
- &OfflineLoginScreenHandler::HandleCompleteAuth);
- AddCallback("OfflineLogin.onEmailSubmitted",
- &OfflineLoginScreenHandler::HandleEmailSubmitted);
-}
+OfflineLoginScreenHandler::~OfflineLoginScreenHandler() = default;
void OfflineLoginScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -51,64 +35,28 @@ void OfflineLoginScreenHandler::DeclareLocalizedValues(
builder->Add("offlineLoginOkBtn", IDS_OFFLINE_LOGIN_OK_BUTTON_TEXT);
}
-void OfflineLoginScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- show_on_init_ = false;
- Show();
- }
-}
-
-void OfflineLoginScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
- ShowInWebUI();
+void OfflineLoginScreenHandler::Show(base::Value::Dict params) {
+ ShowInWebUI(std::move(params));
}
void OfflineLoginScreenHandler::Hide() {
Reset();
}
-void OfflineLoginScreenHandler::Bind(OfflineLoginScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void OfflineLoginScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void OfflineLoginScreenHandler::Reset() {
- CallJS("login.OfflineLoginScreen.reset");
-}
-
-void OfflineLoginScreenHandler::HandleCompleteAuth(
- const std::string& username,
- const std::string& password) {
- screen_->HandleCompleteAuth(username, password);
-}
-
-void OfflineLoginScreenHandler::HandleEmailSubmitted(
- const std::string& username) {
- screen_->HandleEmailSubmitted(username);
-}
-
-void OfflineLoginScreenHandler::LoadParams(base::DictionaryValue params) {
- CallJS("login.OfflineLoginScreen.loadParams", std::move(params));
+ CallExternalAPI("reset");
}
void OfflineLoginScreenHandler::ShowPasswordPage() {
- CallJS("login.OfflineLoginScreen.proceedToPasswordPage");
+ CallExternalAPI("proceedToPasswordPage");
}
void OfflineLoginScreenHandler::ShowOnlineRequiredDialog() {
- CallJS("login.OfflineLoginScreen.showOnlineRequiredDialog");
+ CallExternalAPI("showOnlineRequiredDialog");
}
void OfflineLoginScreenHandler::ShowPasswordMismatchMessage() {
- CallJS("login.OfflineLoginScreen.showPasswordMismatchMessage");
+ CallExternalAPI("showPasswordMismatchMessage");
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h
index f055e347af6..76baa91e43e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h
@@ -13,33 +13,23 @@ class OfflineLoginScreen;
namespace chromeos {
-class OfflineLoginView {
+class OfflineLoginView : public base::SupportsWeakPtr<OfflineLoginView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"offline-login"};
+ inline constexpr static StaticOobeScreenId kScreenId{"offline-login",
+ "OfflineLoginScreen"};
OfflineLoginView() = default;
virtual ~OfflineLoginView() = default;
// Shows the contents of the screen.
- virtual void Show() = 0;
+ virtual void Show(base::Value::Dict params) = 0;
// Hide the contents of the screen.
virtual void Hide() = 0;
- // Binds |screen| to the view.
- virtual void Bind(ash::OfflineLoginScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
// Clear the input fields on the screen.
virtual void Reset() = 0;
- // Preload e-mail, enterprise domain and e-mail domain.
- // TODO(dkuzmin): merge this function with Show() in future and use
- // ShowScreenWithData in handler.
- virtual void LoadParams(base::DictionaryValue params) = 0;
-
// Proceeds to the password input dialog.
virtual void ShowPasswordPage() = 0;
@@ -64,29 +54,18 @@ class OfflineLoginScreenHandler : public BaseScreenHandler,
private:
void HandleCompleteAuth(const std::string& username,
const std::string& password);
- void HandleEmailSubmitted(const std::string& username);
// OfflineLoginView:
- void Show() override;
+ void Show(base::Value::Dict params) override;
void Hide() override;
- void Bind(ash::OfflineLoginScreen* screen) override;
- void Unbind() override;
void Reset() override;
- void LoadParams(base::DictionaryValue params) override;
void ShowPasswordPage() override;
void ShowOnlineRequiredDialog() override;
void ShowPasswordMismatchMessage() override;
// BaseScreenHandler:
- void RegisterMessages() override;
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::OfflineLoginScreen* screen_ = nullptr;
-
- // Whether the screen should be shown right after initialization.
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc b/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc
index e37a58b3763..54c3133987f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/online_login_helper.h"
#include "ash/components/login/auth/challenge_response/cert_utils.h"
-#include "ash/components/login/auth/cryptohome_key_constants.h"
+#include "ash/components/login/auth/public/cryptohome_key_constants.h"
#include "chrome/browser/ash/login/signin_partition_manager.h"
#include "chrome/browser/ash/login/ui/login_display_host_webui.h"
#include "chrome/browser/ash/login/ui/signin_ui.h"
@@ -14,7 +14,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "chromeos/dbus/util/version_loader.h"
+#include "chromeos/version/version_loader.h"
#include "content/public/browser/storage_partition.h"
#include "google_apis/gaia/gaia_urls.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h b/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h
index 39971173776..bf0b70b4220 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h
@@ -10,9 +10,9 @@
#include "ash/components/login/auth/cryptohome_authenticator.h"
// TODO(https://crbug.com/1164001): move to forward declaration
-#include "ash/components/login/auth/sync_trusted_vault_keys.h"
+#include "ash/components/login/auth/public/sync_trusted_vault_keys.h"
// TODO(https://crbug.com/1164001): move to forward declaration
-#include "ash/components/login/auth/user_context.h"
+#include "ash/components/login/auth/public/user_context.h"
#include "chrome/browser/ash/login/login_client_cert_usage_observer.h"
#include "chrome/browser/ash/login/signin_partition_manager.h"
#include "chrome/browser/ash/login/ui/login_display_host.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
index 01411d64863..cfa5b33f308 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
@@ -88,12 +88,12 @@ void OobeDisplayChooser::MoveToTouchDisplay() {
device_data_manager->GetTouchscreenDevices()) {
if (IsAllowListedVendorId(device.vendor_id) &&
device.target_display_id != display::kInvalidDisplayId) {
- auto config_properties = ash::mojom::DisplayConfigProperties::New();
+ auto config_properties = crosapi::mojom::DisplayConfigProperties::New();
config_properties->set_primary = true;
cros_display_config_->SetDisplayProperties(
base::NumberToString(device.target_display_id),
- std::move(config_properties), ash::mojom::DisplayConfigSource::kUser,
- base::DoNothing());
+ std::move(config_properties),
+ crosapi::mojom::DisplayConfigSource::kUser, base::DoNothing());
break;
}
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
index 3cc17a7f272..685e6b32a83 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h
@@ -5,9 +5,9 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_DISPLAY_CHOOSER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_DISPLAY_CHOOSER_H_
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
+#include "chromeos/crosapi/mojom/cros_display_config.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/events/devices/device_data_manager.h"
@@ -33,7 +33,7 @@ class OobeDisplayChooser : public ui::InputDeviceEventObserver {
void TryToPlaceUiOnTouchDisplay();
void set_cros_display_config_for_test(
- mojo::PendingRemote<ash::mojom::CrosDisplayConfigController>
+ mojo::PendingRemote<crosapi::mojom::CrosDisplayConfigController>
cros_display_config) {
cros_display_config_.reset();
cros_display_config_.Bind(std::move(cros_display_config));
@@ -53,7 +53,8 @@ class OobeDisplayChooser : public ui::InputDeviceEventObserver {
base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
scoped_observation_{this};
- mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config_;
+ mojo::Remote<crosapi::mojom::CrosDisplayConfigController>
+ cros_display_config_;
base::WeakPtrFactory<OobeDisplayChooser> weak_ptr_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
index 1ae02bc36ad..26e427e3909 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
@@ -8,11 +8,11 @@
#include <vector>
#include "ash/display/display_configuration_controller.h"
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "ash/shell.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/test/base/chrome_ash_test_base.h"
+#include "chromeos/crosapi/mojom/cros_display_config.mojom.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -30,48 +30,50 @@ namespace chromeos {
namespace {
-class TestCrosDisplayConfig : public ash::mojom::CrosDisplayConfigController {
+class TestCrosDisplayConfig
+ : public crosapi::mojom::CrosDisplayConfigController {
public:
TestCrosDisplayConfig() = default;
TestCrosDisplayConfig(const TestCrosDisplayConfig&) = delete;
TestCrosDisplayConfig& operator=(const TestCrosDisplayConfig&) = delete;
- mojo::PendingRemote<ash::mojom::CrosDisplayConfigController>
+ mojo::PendingRemote<crosapi::mojom::CrosDisplayConfigController>
CreateRemoteAndBind() {
return receiver_.BindNewPipeAndPassRemote();
}
- // ash::mojom::CrosDisplayConfigController:
+ // crosapi::mojom::CrosDisplayConfigController:
void AddObserver(
- mojo::PendingAssociatedRemote<ash::mojom::CrosDisplayConfigObserver>
+ mojo::PendingAssociatedRemote<crosapi::mojom::CrosDisplayConfigObserver>
observer) override {}
void GetDisplayLayoutInfo(GetDisplayLayoutInfoCallback callback) override {}
- void SetDisplayLayoutInfo(ash::mojom::DisplayLayoutInfoPtr info,
+ void SetDisplayLayoutInfo(crosapi::mojom::DisplayLayoutInfoPtr info,
SetDisplayLayoutInfoCallback callback) override {}
void GetDisplayUnitInfoList(
bool single_unified,
GetDisplayUnitInfoListCallback callback) override {}
- void SetDisplayProperties(const std::string& id,
- ash::mojom::DisplayConfigPropertiesPtr properties,
- ash::mojom::DisplayConfigSource source,
- SetDisplayPropertiesCallback callback) override {
+ void SetDisplayProperties(
+ const std::string& id,
+ crosapi::mojom::DisplayConfigPropertiesPtr properties,
+ crosapi::mojom::DisplayConfigSource source,
+ SetDisplayPropertiesCallback callback) override {
if (properties->set_primary) {
int64_t display_id;
base::StringToInt64(id, &display_id);
ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(
display_id);
}
- std::move(callback).Run(ash::mojom::DisplayConfigResult::kSuccess);
+ std::move(callback).Run(crosapi::mojom::DisplayConfigResult::kSuccess);
}
void SetUnifiedDesktopEnabled(bool enabled) override {}
void OverscanCalibration(const std::string& display_id,
- ash::mojom::DisplayConfigOperation op,
+ crosapi::mojom::DisplayConfigOperation op,
const absl::optional<gfx::Insets>& delta,
OverscanCalibrationCallback callback) override {}
void TouchCalibration(const std::string& display_id,
- ash::mojom::DisplayConfigOperation op,
- ash::mojom::TouchCalibrationPtr calibration,
+ crosapi::mojom::DisplayConfigOperation op,
+ crosapi::mojom::TouchCalibrationPtr calibration,
TouchCalibrationCallback callback) override {}
void HighlightDisplay(int64_t id) override {}
void DragDisplayDelta(int64_t display_id,
@@ -79,7 +81,7 @@ class TestCrosDisplayConfig : public ash::mojom::CrosDisplayConfigController {
int32_t delta_y) override {}
private:
- mojo::Receiver<ash::mojom::CrosDisplayConfigController> receiver_{this};
+ mojo::Receiver<crosapi::mojom::CrosDisplayConfigController> receiver_{this};
};
class OobeDisplayChooserTest : public ChromeAshTestBase {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
index b816d486c3f..2d0d3d013a7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -21,6 +21,7 @@
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/logging.h"
+#include "base/notreached.h"
#include "base/system/sys_info.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
@@ -102,7 +103,6 @@
#include "chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
-#include "chrome/browser/ui/webui/chromeos/video_source.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/test_files_request_filter.h"
#include "chrome/browser/ui/webui/theme_source.h"
@@ -120,6 +120,7 @@
#include "chrome/grit/gaia_auth_host_resources_map.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/oobe_conditional_resources.h"
+#include "chrome/grit/oobe_unconditional_resources.h"
#include "chrome/grit/oobe_unconditional_resources_map.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" // nogncheck
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
@@ -148,9 +149,9 @@ namespace mojom = ::ash::multidevice_setup::mojom;
namespace {
-const char* kKnownDisplayTypes[] = {
- OobeUI::kAppLaunchSplashDisplay, OobeUI::kGaiaSigninDisplay,
- OobeUI::kLoginDisplay, OobeUI::kOobeDisplay};
+const char* kKnownDisplayTypes[] = {OobeUI::kAppLaunchSplashDisplay,
+ OobeUI::kGaiaSigninDisplay,
+ OobeUI::kOobeDisplay};
// Sorted
constexpr char kArcOverlayCSSPath[] = "overlay.css";
@@ -158,31 +159,20 @@ constexpr char kArcPlaystoreCSSPath[] = "playstore.css";
constexpr char kArcPlaystoreJSPath[] = "playstore.js";
constexpr char kArcPlaystoreLogoPath[] = "playstore.svg";
constexpr char kArcSupervisionIconPath[] = "supervision_icon.png";
-constexpr char kCustomElementsHTMLPath[] = "custom_elements.html";
-constexpr char kDebuggerJSPath[] = "debug/debug.js";
constexpr char kDebuggerMJSPath[] = "debug/debug.m.js";
constexpr char kDebuggerUtilJSPath[] = "debug/debug_util.js";
constexpr char kKeyboardUtilsJSPath[] = "keyboard_utils.js";
-constexpr char kKeyboardUtilsForInjectionPath[] =
- "components/keyboard_utils_for_injection.js";
constexpr char kKeyboardUtilsForInjectionModulePath[] =
"components/keyboard_utils_for_injection.m.js";
-constexpr char kLoginJSPath[] = "login.js";
-constexpr char kOobeJSPath[] = "oobe.js";
constexpr char kProductLogoPath[] = "product-logo.png";
// TODO(crbug.com/1261902): Clean-up old implementation once feature is
// launched.
-constexpr char kRecommendAppOldListViewJSPath[] =
- "recommend_app_old_list_view.js";
constexpr char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js";
-constexpr char kTestAPIJSPath[] = "test_api.js";
constexpr char kTestAPIJsMPath[] = "test_api/test_api.m.js";
constexpr char kWebviewSamlInjectedJSPath[] = "webview_saml_injected.js";
// Components
-constexpr char kOobeCustomVarsCssHTML[] =
- "components/oobe_vars/oobe_custom_vars_css.html";
constexpr char kOobeCustomVarsCssJsM[] =
"components/oobe_vars/oobe_custom_vars_css.m.js";
@@ -229,12 +219,9 @@ void AddArcScreensResources(content::WebUIDataSource* source) {
// TODO(crbug.com/1261902): Clean-up old implementation once feature is
// launched.
- if (features::IsOobeNewRecommendAppsEnabled()) {
+ if (!features::IsOobeNewRecommendAppsEnabled()) {
source->AddResourcePath(kRecommendAppListViewJSPath,
IDR_ARC_SUPPORT_RECOMMEND_APP_LIST_VIEW_JS);
- } else {
- source->AddResourcePath(kRecommendAppOldListViewJSPath,
- IDR_ARC_SUPPORT_RECOMMEND_APP_OLD_LIST_VIEW_JS);
}
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
source->AddResourcePath(kArcAppDownloadingVideoPath,
@@ -258,7 +245,7 @@ void AddMultiDeviceSetupResources(content::WebUIDataSource* source) {
network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
}
-void AddDebuggerResources(content::WebUIDataSource* source, bool use_poly3) {
+void AddDebuggerResources(content::WebUIDataSource* source) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool enable_debugger = command_line->HasSwitch(switches::kShowOobeDevOverlay);
// Enable for ChromeOS-on-linux for developers and test images.
@@ -269,15 +256,10 @@ void AddDebuggerResources(content::WebUIDataSource* source, bool use_poly3) {
if (enable_debugger) {
source->AddResourcePath(kDebuggerUtilJSPath, IDR_OOBE_DEBUGGER_UTIL_JS);
- if (use_poly3) {
- source->AddResourcePath(kDebuggerMJSPath, IDR_OOBE_DEBUGGER_M_JS);
- } else {
- source->AddResourcePath(kDebuggerJSPath, IDR_OOBE_DEBUGGER_JS);
- }
+ source->AddResourcePath(kDebuggerMJSPath, IDR_OOBE_DEBUGGER_M_JS);
} else {
// Serve empty files under all resource paths.
source->AddResourcePath(kDebuggerMJSPath, IDR_OOBE_DEBUGGER_STUB_JS);
- source->AddResourcePath(kDebuggerJSPath, IDR_OOBE_DEBUGGER_STUB_JS);
source->AddResourcePath(kDebuggerUtilJSPath, IDR_OOBE_DEBUGGER_STUB_JS);
}
}
@@ -286,56 +268,12 @@ void AddTestAPIResources(content::WebUIDataSource* source) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool enable_test_api = command_line->HasSwitch(switches::kEnableOobeTestAPI);
if (enable_test_api) {
- source->AddResourcePath(kTestAPIJSPath, IDR_OOBE_TEST_API_JS);
source->AddResourcePath(kTestAPIJsMPath, IDR_OOBE_TEST_API_M_JS);
} else {
- source->AddResourcePath(kTestAPIJSPath, IDR_OOBE_TEST_API_STUB_JS);
source->AddResourcePath(kTestAPIJsMPath, IDR_OOBE_TEST_API_STUB_M_JS);
}
}
-// Default and non-shared resource definition for kOobeDisplay display type.
-// chrome://oobe/oobe
-void AddOobeDisplayTypeDefaultResources(content::WebUIDataSource* source) {
- if (switches::IsOsInstallAllowed()) {
- source->SetDefaultResource(IDR_OS_INSTALL_OOBE_HTML);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_OS_INSTALL_OOBE_HTML);
- } else {
- source->SetDefaultResource(IDR_OOBE_HTML);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_OOBE_HTML);
- }
- source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS);
-}
-
-// Default and non-shared resource definition for kLoginDisplay display type.
-// chrome://oobe/login
-void AddLoginDisplayTypeDefaultResources(content::WebUIDataSource* source) {
- if (switches::IsOsInstallAllowed()) {
- source->SetDefaultResource(IDR_OS_INSTALL_LOGIN_HTML);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_OS_INSTALL_LOGIN_HTML);
- } else {
- source->SetDefaultResource(IDR_MD_LOGIN_HTML);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_LOGIN_HTML);
- }
- source->AddResourcePath(kLoginJSPath, IDR_OOBE_JS);
-}
-
-// Polymer3 could be turned on for both flows (OOBE & 'Add Person'), or just
-// for the 'Add Person' flow.
-bool ShouldUsePolymer3Resources(bool is_oobe_flow) {
- const bool is_add_person_flow = !is_oobe_flow;
- const bool poly3_enabled_for_both_flows = features::IsOobePolymer3Enabled();
- const bool poly3_enabled_for_addperson_flow =
- features::IsOobeAddPersonPolymer3Enabled();
-
- return poly3_enabled_for_both_flows ||
- (poly3_enabled_for_addperson_flow && is_add_person_flow);
-}
-
// Creates a WebUIDataSource for chrome://oobe
content::WebUIDataSource* CreateOobeUIDataSource(
const base::Value::Dict& localized_strings,
@@ -349,23 +287,13 @@ content::WebUIDataSource* CreateOobeUIDataSource(
OobeUI::AddOobeComponents(source);
- // Determine whether this is the 'OOBE' or the 'Add Person' flow, and add
- // either Polymer3 or Polymer2 default resources.
+ source->SetDefaultResource(IDR_OOBE_UNCONDITIONAL_OOBE_HTML);
+
+ // Add boolean variables that are used to add screens
+ // dynamically depending on the flow type.
const bool is_oobe_flow = display_type == OobeUI::kOobeDisplay;
- const bool use_polymer3_resources = ShouldUsePolymer3Resources(is_oobe_flow);
- if (use_polymer3_resources) {
- source->SetDefaultResource(IDR_OOBE_POLY3_HTML);
- // Add boolean variables that are used by Polymer3 to add screens
- // dynamically depending on the flow type.
- source->AddBoolean("isOsInstallAllowed", switches::IsOsInstallAllowed());
- source->AddBoolean("isOobeFlow", is_oobe_flow);
- } else { /* Polymer 2 Resources */
- if (is_oobe_flow) {
- AddOobeDisplayTypeDefaultResources(source);
- } else /* is_add_person_flow */ {
- AddLoginDisplayTypeDefaultResources(source);
- }
- }
+ source->AddBoolean("isOsInstallAllowed", switches::IsOsInstallAllowed());
+ source->AddBoolean("isOobeFlow", is_oobe_flow);
// Configure shared resources
AddProductLogoResources(source);
@@ -376,14 +304,12 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddAssistantScreensResources(source);
AddMultiDeviceSetupResources(source);
- AddDebuggerResources(source, use_polymer3_resources);
+ AddDebuggerResources(source);
AddTestAPIResources(source);
source->AddResourcePath(kWebviewSamlInjectedJSPath,
IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
- source->AddResourcePath(kKeyboardUtilsForInjectionPath,
- IDR_KEYBOARD_UTILS_FOR_INJECTION_JS);
source->AddResourcePath(kKeyboardUtilsForInjectionModulePath,
IDR_KEYBOARD_UTILS_FOR_INJECTION_M_JS);
source->OverrideContentSecurityPolicy(
@@ -404,8 +330,8 @@ std::string GetDisplayType(const GURL& url) {
std::string path = url.path().size() ? url.path().substr(1) : "";
if (!base::Contains(kKnownDisplayTypes, path)) {
- LOG(ERROR) << "Unknown display type '" << path << "'. Setting default.";
- return OobeUI::kLoginDisplay;
+ NOTREACHED() << "Unknown display type '" << path << "'. Setting default.";
+ return OobeUI::kOobeDisplay;
}
return path;
}
@@ -415,7 +341,6 @@ std::string GetDisplayType(const GURL& url) {
// static
const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash";
const char OobeUI::kGaiaSigninDisplay[] = "gaia-signin";
-const char OobeUI::kLoginDisplay[] = "login";
const char OobeUI::kOobeDisplay[] = "oobe";
void OobeUI::ConfigureOobeDisplay() {
@@ -458,7 +383,8 @@ void OobeUI::ConfigureOobeDisplay() {
AddScreenHandler(std::make_unique<ErrorScreenHandler>());
- error_screen_ = std::make_unique<ErrorScreen>(GetView<ErrorScreenHandler>());
+ error_screen_ =
+ std::make_unique<ErrorScreen>(GetView<ErrorScreenHandler>()->AsWeakPtr());
ErrorScreen* error_screen = error_screen_.get();
AddScreenHandler(std::make_unique<EnrollmentScreenHandler>(
@@ -567,10 +493,6 @@ void OobeUI::ConfigureOobeDisplay() {
content::WebContents* contents = web_ui()->GetWebContents();
extensions::TabHelper::CreateForWebContents(contents);
- // // Handler for the oobe video assets which will be shown if available.
- content::URLDataSource::Add(profile,
- std::make_unique<chromeos::VideoSource>());
-
if (policy::EnrollmentRequisitionManager::IsRemoraRequisition())
oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>();
}
@@ -662,14 +584,9 @@ void OobeUI::AddOobeComponents(content::WebUIDataSource* source) {
if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) {
source->AddResourcePath(
- kOobeCustomVarsCssHTML,
- IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_REMORA_CSS_HTML);
- source->AddResourcePath(
kOobeCustomVarsCssJsM,
IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_REMORA_CSS_M_JS);
} else {
- source->AddResourcePath(kOobeCustomVarsCssHTML,
- IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_CSS_HTML);
source->AddResourcePath(kOobeCustomVarsCssJsM,
IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_CSS_M_JS);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
index dd8271278c9..fa960dfc788 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
@@ -43,7 +43,6 @@ class OobeUI : public ui::MojoWebUIController {
// example chrome://oobe/gaia-signin.
static const char kAppLaunchSplashDisplay[];
static const char kGaiaSigninDisplay[];
- static const char kLoginDisplay[];
static const char kOobeDisplay[];
class Observer {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc
index 06ae858db4c..543fb0cc25d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc
@@ -10,36 +10,15 @@
namespace chromeos {
-constexpr StaticOobeScreenId PackagedLicenseView::kScreenId;
-
PackagedLicenseScreenHandler::PackagedLicenseScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.PackagedLicenseScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-PackagedLicenseScreenHandler::~PackagedLicenseScreenHandler() {}
+PackagedLicenseScreenHandler::~PackagedLicenseScreenHandler() = default;
void PackagedLicenseScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void PackagedLicenseScreenHandler::Hide() {}
-
-void PackagedLicenseScreenHandler::Bind(PackagedLicenseScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void PackagedLicenseScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void PackagedLicenseScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("oobePackagedLicenseTitle", IDS_OOBE_PACKAGED_LICENSE_TITLE);
@@ -53,11 +32,4 @@ void PackagedLicenseScreenHandler::DeclareLocalizedValues(
IDS_OOBE_PACKAGED_LICENSE_DONT_ENROLL_BUTTON_LABEL);
}
-void PackagedLicenseScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h
index 016cf3a0004..844a2341d24 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h
@@ -5,34 +5,23 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_PACKAGED_LICENSE_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_PACKAGED_LICENSE_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class PackagedLicenseScreen;
-}
-
namespace chromeos {
-class PackagedLicenseView {
+class PackagedLicenseView : public base::SupportsWeakPtr<PackagedLicenseView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"packaged-license"};
+ inline constexpr static StaticOobeScreenId kScreenId{"packaged-license",
+ "PackagedLicenseScreen"};
PackagedLicenseView() = default;
PackagedLicenseView(const PackagedLicenseView&) = delete;
PackagedLicenseView& operator=(const PackagedLicenseView&) = delete;
virtual ~PackagedLicenseView() = default;
- // Binds `screen` to the view.
- virtual void Bind(ash::PackagedLicenseScreen* screen) = 0;
-
- // Unbinds model from the view.
- virtual void Unbind() = 0;
-
// Shows the contents of the screen.
virtual void Show() = 0;
-
- // Hides the contents of the screen.
- virtual void Hide() = 0;
};
// A class that handles WebUI hooks in PackagedLicense screen.
@@ -46,22 +35,12 @@ class PackagedLicenseScreenHandler : public BaseScreenHandler,
delete;
~PackagedLicenseScreenHandler() override;
- // PackagedLicenseView:
- void Bind(ash::PackagedLicenseScreen* screen) override;
- void Unbind() override;
void Show() override;
- void Hide() override;
private:
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
-
- ash::PackagedLicenseScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc
index 891c39937ba..1a444420af2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc
@@ -18,19 +18,10 @@ constexpr char kUsername[] = "username";
} // namespace
-// static
-constexpr StaticOobeScreenId ParentalHandoffScreenView::kScreenId;
-
ParentalHandoffScreenHandler::ParentalHandoffScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.ParentalHandoffScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-ParentalHandoffScreenHandler::~ParentalHandoffScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+ParentalHandoffScreenHandler::~ParentalHandoffScreenHandler() = default;
void ParentalHandoffScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -42,8 +33,6 @@ void ParentalHandoffScreenHandler::DeclareLocalizedValues(
IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_SUBTITLE);
}
-void ParentalHandoffScreenHandler::InitializeDeprecated() {}
-
void ParentalHandoffScreenHandler::Show(const std::u16string& username) {
base::Value::Dict data;
data.Set(kUsername, username);
@@ -51,14 +40,4 @@ void ParentalHandoffScreenHandler::Show(const std::u16string& username) {
ShowInWebUI(std::move(data));
}
-void ParentalHandoffScreenHandler::Bind(ParentalHandoffScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void ParentalHandoffScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h
index cf63b8a050e..b3a7a0e1c23 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h
@@ -7,12 +7,9 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class ParentalHandoffScreen;
-}
-
namespace login {
class LocalizedValuesBuilder;
} // namespace login
@@ -21,20 +18,16 @@ namespace chromeos {
// Interface for dependency injection between ParentalHandoffScreen and its
// WebUI representation.
-class ParentalHandoffScreenView {
+class ParentalHandoffScreenView
+ : public base::SupportsWeakPtr<ParentalHandoffScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"parental-handoff"};
+ inline constexpr static StaticOobeScreenId kScreenId{"parental-handoff",
+ "ParentalHandoffScreen"};
virtual ~ParentalHandoffScreenView() = default;
// Shows the contents of the screen.
virtual void Show(const std::u16string& username) = 0;
-
- // Binds |screen| to the view.
- virtual void Bind(ash::ParentalHandoffScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
};
class ParentalHandoffScreenHandler : public BaseScreenHandler,
@@ -52,14 +45,9 @@ class ParentalHandoffScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
// Shows the contents of the screen.
void Show(const std::u16string& username) override;
- void Bind(ash::ParentalHandoffScreen* screen) override;
- void Unbind() override;
-
- ash::ParentalHandoffScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc
index ce2792e2508..0cecb8fcda9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc
@@ -17,13 +17,9 @@
namespace chromeos {
-constexpr StaticOobeScreenId PinSetupScreenView::kScreenId;
+PinSetupScreenHandler::PinSetupScreenHandler() : BaseScreenHandler(kScreenId) {}
-PinSetupScreenHandler::PinSetupScreenHandler() : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.PinSetupScreen.userActed");
-}
-
-PinSetupScreenHandler::~PinSetupScreenHandler() {}
+PinSetupScreenHandler::~PinSetupScreenHandler() = default;
void PinSetupScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -76,21 +72,6 @@ void PinSetupScreenHandler::DeclareLocalizedValues(
IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_INTERNAL_ERROR);
}
-void PinSetupScreenHandler::RegisterMessages() {
- BaseScreenHandler::RegisterMessages();
-}
-
-void PinSetupScreenHandler::GetAdditionalParameters(base::Value::Dict* dict) {}
-
-void PinSetupScreenHandler::Bind(PinSetupScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
-}
-
-void PinSetupScreenHandler::Hide() {}
-
-void PinSetupScreenHandler::InitializeDeprecated() {}
-
void PinSetupScreenHandler::Show(const std::string& token,
bool is_child_account) {
base::Value::Dict data;
@@ -100,7 +81,7 @@ void PinSetupScreenHandler::Show(const std::string& token,
}
void PinSetupScreenHandler::SetLoginSupportAvailable(bool available) {
- CallJS("login.PinSetupScreen.setHasLoginSupport", available);
+ CallExternalAPI("setHasLoginSupport", available);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h
index 7b77e9d5ff0..8291697035e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h
@@ -7,32 +7,24 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class PinSetupScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between PinSetupScreen and its
// WebUI representation.
-class PinSetupScreenView {
+class PinSetupScreenView : public base::SupportsWeakPtr<PinSetupScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"pin-setup"};
+ inline constexpr static StaticOobeScreenId kScreenId{"pin-setup",
+ "PinSetupScreen"};
virtual ~PinSetupScreenView() = default;
- // Sets screen this view belongs to.
- virtual void Bind(ash::PinSetupScreen* screen) = 0;
-
// Shows the contents of the screen, using |token| to access QuickUnlock API.
virtual void Show(const std::string& token, bool is_child_account) = 0;
- // Hides the contents of the screen.
- virtual void Hide() = 0;
-
virtual void SetLoginSupportAvailable(bool available) = 0;
};
@@ -52,18 +44,10 @@ class PinSetupScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void GetAdditionalParameters(base::Value::Dict* dict) override;
- void RegisterMessages() override;
// PinSetupScreenView:
- void Bind(ash::PinSetupScreen* screen) override;
- void Hide() override;
- void InitializeDeprecated() override;
void Show(const std::string& token, bool is_child_account) override;
void SetLoginSupportAvailable(bool available) override;
-
- private:
- ash::PinSetupScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/quick_start_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/quick_start_screen_handler.cc
index 8eace961331..925a4b1bb87 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/quick_start_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/quick_start_screen_handler.cc
@@ -17,21 +17,21 @@ void QuickStartScreenHandler::Show() {
ShowInWebUI();
}
-std::vector<base::Value> ToValue(const ash::quick_start::ShapeList& list) {
- std::vector<base::Value> result;
+base::Value ToValue(const ash::quick_start::ShapeList& list) {
+ base::Value::List result;
for (const ash::quick_start::ShapeHolder& shape_holder : list) {
- base::flat_map<std::string, base::Value> val;
- val["shape"] = base::Value(static_cast<int>(shape_holder.shape));
- val["color"] = base::Value(static_cast<int>(shape_holder.color));
- val["digit"] = base::Value(static_cast<int>(shape_holder.digit));
- result.emplace_back(std::move(val));
+ base::Value::Dict val;
+ val.Set("shape", static_cast<int>(shape_holder.shape));
+ val.Set("color", static_cast<int>(shape_holder.color));
+ val.Set("digit", static_cast<int>(shape_holder.digit));
+ result.Append(std::move(val));
}
- return result;
+ return base::Value(std::move(result));
}
void QuickStartScreenHandler::SetShapes(
const ash::quick_start::ShapeList& shape_list) {
- CallExternalAPI("setFigures", base::Value(ToValue(shape_list)));
+ CallExternalAPI("setFigures", ToValue(shape_list));
}
void QuickStartScreenHandler::DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
index 0393d118c7d..38bd2c5a7f4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
@@ -103,7 +103,7 @@ void RecommendAppsScreenHandler::LoadAppListInUI(base::Value app_list) {
const ui::ResourceBundle& resource_bundle =
ui::ResourceBundle::GetSharedInstance();
std::string app_list_webview = resource_bundle.LoadDataResourceString(
- IDR_ARC_SUPPORT_RECOMMEND_APP_OLD_LIST_VIEW_HTML);
+ IDR_ARC_SUPPORT_RECOMMEND_APP_LIST_VIEW_HTML);
CallExternalAPI("setWebview", app_list_webview);
}
CallExternalAPI("loadAppList", std::move(app_list));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
index 2d9cf5f85a7..c38b6ee25fd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/session_manager/session_manager_client.h"
+#include "chromeos/ash/components/dbus/session_manager/session_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -22,36 +22,14 @@ namespace chromeos {
constexpr StaticOobeScreenId ResetView::kScreenId;
-ResetScreenHandler::ResetScreenHandler() : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.ResetScreen.userActed");
-}
-
-ResetScreenHandler::~ResetScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
-
-void ResetScreenHandler::Bind(ResetScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
+ResetScreenHandler::ResetScreenHandler() : BaseScreenHandler(kScreenId) {}
-void ResetScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
+ResetScreenHandler::~ResetScreenHandler() = default;
void ResetScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void ResetScreenHandler::Hide() {
-}
-
void ResetScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("resetScreenAccessibleTitle", IDS_RESET_SCREEN_TITLE);
@@ -96,24 +74,9 @@ void ResetScreenHandler::DeclareLocalizedValues(
builder->Add("confirmResetButton", IDS_RESET_SCREEN_POPUP_CONFIRM_BUTTON);
}
-void ResetScreenHandler::DeclareJSCallbacks() {
- AddCallback("ResetScreen.setTpmFirmwareUpdateChecked",
- &ResetScreenHandler::HandleSetTpmFirmwareUpdateChecked);
-}
-
-void ResetScreenHandler::InitializeDeprecated() {
- if (!IsJavascriptAllowed())
- return;
-
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
void ResetScreenHandler::SetIsRollbackAvailable(bool value) {
is_rollback_available_ = value;
- CallJS("login.ResetScreen.setIsRollbackAvailable", value);
+ CallExternalAPI("setIsRollbackAvailable", value);
}
// Only serve the request if the confirmation dialog isn't being shown.
@@ -122,31 +85,32 @@ void ResetScreenHandler::SetIsRollbackRequested(bool value) {
return;
is_rollback_requested_ = value;
- CallJS("login.ResetScreen.setIsRollbackRequested", value);
+
+ CallExternalAPI("setIsRollbackRequested", value);
}
void ResetScreenHandler::SetIsTpmFirmwareUpdateAvailable(bool value) {
- CallJS("login.ResetScreen.setIsTpmFirmwareUpdateAvailable", value);
+ CallExternalAPI("setIsTpmFirmwareUpdateAvailable", value);
}
void ResetScreenHandler::SetIsTpmFirmwareUpdateChecked(bool value) {
is_tpm_firmware_update_checked_ = value;
- CallJS("login.ResetScreen.setIsTpmFirmwareUpdateChecked", value);
+ CallExternalAPI("setIsTpmFirmwareUpdateChecked", value);
}
void ResetScreenHandler::SetIsTpmFirmwareUpdateEditable(bool value) {
- CallJS("login.ResetScreen.setIsTpmFirmwareUpdateEditable", value);
+ CallExternalAPI("setIsTpmFirmwareUpdateEditable", value);
}
void ResetScreenHandler::SetTpmFirmwareUpdateMode(
tpm_firmware_update::Mode value) {
mode_ = value;
- CallJS("login.ResetScreen.setTpmFirmwareUpdateMode", static_cast<int>(value));
+ CallExternalAPI("setTpmFirmwareUpdateMode", static_cast<int>(value));
}
void ResetScreenHandler::SetShouldShowConfirmationDialog(bool value) {
is_showing_confirmation_dialog_ = value;
- CallJS("login.ResetScreen.setShouldShowConfirmationDialog", value);
+ CallExternalAPI("setShouldShowConfirmationDialog", value);
}
void ResetScreenHandler::SetConfirmationDialogClosed() {
@@ -155,7 +119,7 @@ void ResetScreenHandler::SetConfirmationDialogClosed() {
void ResetScreenHandler::SetScreenState(State value) {
state_ = value;
- CallJS("login.ResetScreen.setScreenState", static_cast<int>(value));
+ CallExternalAPI("setScreenState", static_cast<int>(value));
}
ResetView::State ResetScreenHandler::GetScreenState() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
index 99c4ba63d83..21c23441af9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
@@ -5,27 +5,21 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RESET_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/tpm_firmware_update.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class ResetScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between ResetScreen and its actual
// representation, either views based or WebUI.
-class ResetView {
+class ResetView : public base::SupportsWeakPtr<ResetView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"reset"};
+ inline constexpr static StaticOobeScreenId kScreenId{"reset", "ResetScreen"};
- virtual ~ResetView() {}
+ virtual ~ResetView() = default;
- virtual void Bind(ash::ResetScreen* screen) = 0;
- virtual void Unbind() = 0;
virtual void Show() = 0;
- virtual void Hide() = 0;
enum class State {
kRestartRequired = 0,
@@ -64,17 +58,11 @@ class ResetScreenHandler : public ResetView,
~ResetScreenHandler() override;
- // ResetView implementation:
- void Bind(ash::ResetScreen* screen) override;
- void Unbind() override;
void Show() override;
- void Hide() override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void DeclareJSCallbacks() override;
- void InitializeDeprecated() override;
void SetIsRollbackAvailable(bool value) override;
void SetIsRollbackRequested(bool value) override;
void SetIsTpmFirmwareUpdateAvailable(bool value) override;
@@ -93,11 +81,6 @@ class ResetScreenHandler : public ResetView,
private:
void HandleSetTpmFirmwareUpdateChecked(bool value);
- ash::ResetScreen* screen_ = nullptr;
-
- // If true, InitializeDeprecated() will call Show().
- bool show_on_init_ = false;
-
ResetView::State state_ = ResetView::State::kRestartRequired;
tpm_firmware_update::Mode mode_ = tpm_firmware_update::Mode::kNone;
bool is_rollback_available_ = false;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc
index 0f4cf9ce13c..f76621b353b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc
@@ -137,7 +137,7 @@ base::TimeDelta SamlChallengeKeyHandler::GetTpmResponseTimeout() const {
void SamlChallengeKeyHandler::ReturnResult(
const attestation::TpmChallengeKeyResult& result) {
- base::Value js_result(base::Value::Type::DICTIONARY);
+ base::Value::Dict js_result;
if (!result.IsSuccess()) {
LOG(WARNING) << "Device attestation error: " << result.GetErrorMessage();
}
@@ -145,8 +145,8 @@ void SamlChallengeKeyHandler::ReturnResult(
std::string encoded_result_data;
base::Base64Encode(result.challenge_response, &encoded_result_data);
- js_result.SetKey(kSuccessField, base::Value(result.IsSuccess()));
- js_result.SetKey(kResponseField, base::Value(encoded_result_data));
+ js_result.Set(kSuccessField, result.IsSuccess());
+ js_result.Set(kResponseField, encoded_result_data);
std::move(callback_).Run(std::move(js_result));
tpm_key_challenger_.reset();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h
index 49665ffea49..e9697a0f74c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h
@@ -22,7 +22,8 @@ namespace chromeos {
// attestation during SAML authentication.
class SamlChallengeKeyHandler final {
public:
- using CallbackType = base::OnceCallback<void(const base::Value& response)>;
+ using CallbackType =
+ base::OnceCallback<void(const base::Value::Dict response)>;
SamlChallengeKeyHandler();
SamlChallengeKeyHandler(const SamlChallengeKeyHandler&) = delete;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc
index feec442d989..29fb328b3eb 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc
@@ -16,18 +16,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId SignInFatalErrorView::kScreenId;
-
SignInFatalErrorScreenHandler::SignInFatalErrorScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.SignInFatalErrorScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-SignInFatalErrorScreenHandler::~SignInFatalErrorScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+SignInFatalErrorScreenHandler::~SignInFatalErrorScreenHandler() = default;
void SignInFatalErrorScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -46,8 +38,6 @@ void SignInFatalErrorScreenHandler::DeclareLocalizedValues(
IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL);
}
-void SignInFatalErrorScreenHandler::InitializeDeprecated() {}
-
void SignInFatalErrorScreenHandler::Show(SignInFatalErrorScreen::Error error,
const base::Value* params) {
base::Value::Dict screen_data =
@@ -57,14 +47,4 @@ void SignInFatalErrorScreenHandler::Show(SignInFatalErrorScreen::Error error,
ShowInWebUI(std::move(screen_data));
}
-void SignInFatalErrorScreenHandler::Bind(SignInFatalErrorScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void SignInFatalErrorScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h
index c2d743cf469..d1726af4da2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_FATAL_ERROR_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_FATAL_ERROR_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ash/login/screens/signin_fatal_error_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
@@ -13,20 +14,16 @@ namespace chromeos {
// Interface for dependency injection between SignInFatalErrorScreen and its
// WebUI representation.
-class SignInFatalErrorView {
+class SignInFatalErrorView
+ : public base::SupportsWeakPtr<SignInFatalErrorView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"signin-fatal-error"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "signin-fatal-error", "SignInFatalErrorScreen"};
virtual ~SignInFatalErrorView() = default;
// Shows the contents of the screen.
virtual void Show(SignInFatalErrorScreen::Error error,
const base::Value* params) = 0;
-
- // Binds `screen` to the view.
- virtual void Bind(SignInFatalErrorScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
};
class SignInFatalErrorScreenHandler : public SignInFatalErrorView,
@@ -43,15 +40,10 @@ class SignInFatalErrorScreenHandler : public SignInFatalErrorView,
private:
void Show(SignInFatalErrorScreen::Error error,
const base::Value* params) override;
- void Bind(SignInFatalErrorScreen* screen) override;
- void Unbind() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- SignInFatalErrorScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index bd17d21b3e2..d2f512f4ce4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -11,8 +11,8 @@
#include <utility>
#include <vector>
-#include "ash/components/login/auth/key.h"
-#include "ash/components/login/auth/user_context.h"
+#include "ash/components/login/auth/public/key.h"
+#include "ash/components/login/auth/public/user_context.h"
#include "ash/components/proximity_auth/screenlock_bridge.h"
#include "ash/constants/ash_features.h"
#include "ash/public/mojom/tray_action.mojom.h"
@@ -61,15 +61,14 @@
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
-#include "chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_registry_simple.h"
@@ -138,34 +137,15 @@ namespace chromeos {
namespace {
-bool IsOnline(NetworkStateInformer::State state,
- NetworkError::ErrorReason reason) {
- return state == NetworkStateInformer::ONLINE &&
- reason != NetworkError::ERROR_REASON_PORTAL_DETECTED &&
- reason != NetworkError::ERROR_REASON_LOADING_TIMEOUT;
-}
-
-bool IsBehindCaptivePortal(NetworkStateInformer::State state,
- NetworkError::ErrorReason reason) {
- return state == NetworkStateInformer::CAPTIVE_PORTAL ||
- reason == NetworkError::ERROR_REASON_PORTAL_DETECTED;
-}
-
bool IsProxyError(NetworkStateInformer::State state,
NetworkError::ErrorReason reason,
net::Error frame_error) {
- return state == NetworkStateInformer::PROXY_AUTH_REQUIRED ||
- reason == NetworkError::ERROR_REASON_PROXY_AUTH_CANCELLED ||
- reason == NetworkError::ERROR_REASON_PROXY_CONNECTION_FAILED ||
+ return NetworkStateInformer::IsProxyError(state, reason) ||
(reason == NetworkError::ERROR_REASON_FRAME_ERROR &&
(frame_error == net::ERR_PROXY_CONNECTION_FAILED ||
frame_error == net::ERR_TUNNEL_CONNECTION_FAILED));
}
-bool IsSigninScreen(const OobeScreenId screen) {
- return screen == GaiaView::kScreenId;
-}
-
} // namespace
// SigninScreenHandler implementation ------------------------------------------
@@ -207,9 +187,6 @@ void SigninScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {}
void SigninScreenHandler::RegisterMessages() {
- AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito);
- AddCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin);
-
AddCallback("showLoadingTimeoutError",
&SigninScreenHandler::HandleShowLoadingTimeoutError);
}
@@ -293,8 +270,9 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
}
connecting_callback_.Cancel();
- const bool is_online = IsOnline(state, reason);
- const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason);
+ const bool is_online = NetworkStateInformer::IsOnline(state, reason);
+ const bool is_behind_captive_portal =
+ NetworkStateInformer::IsBehindCaptivePortal(state, reason);
const bool is_gaia_loading_timeout =
(reason == NetworkError::ERROR_REASON_LOADING_TIMEOUT);
const bool is_gaia_error =
@@ -318,8 +296,7 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
// Hide offline message (if needed) and return if current screen is
// not a Gaia frame.
if (!is_gaia_signin) {
- if (!IsSigninScreenHiddenByError())
- HideOfflineMessage(state, reason);
+ HideOfflineMessage(state, reason);
return;
}
@@ -363,6 +340,8 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
if (!is_online || is_gaia_loading_timeout || is_gaia_error) {
if (GetCurrentScreen() != ErrorScreenView::kScreenId) {
error_screen_->SetParentScreen(GaiaView::kScreenId);
+ error_screen_->SetHideCallback(base::BindOnce(
+ &SigninScreenHandler::OnErrorScreenHide, weak_factory_.GetWeakPtr()));
error_screen_->ShowNetworkErrorMessage(state, reason);
histogram_helper_->OnErrorShow(error_screen_->GetErrorState());
}
@@ -376,13 +355,12 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
void SigninScreenHandler::HideOfflineMessage(NetworkStateInformer::State state,
NetworkError::ErrorReason reason) {
- if (!IsSigninScreenHiddenByError())
+ if (!IsGaiaHiddenByError())
return;
gaia_reload_reason_ = NetworkError::ERROR_REASON_NONE;
error_screen_->Hide();
- histogram_helper_->OnErrorHide();
// Forces a reload for Gaia screen on hiding error message.
if (IsGaiaVisible() || IsGaiaHiddenByError())
@@ -441,24 +419,9 @@ void SigninScreenHandler::ReenableNetworkStateUpdatesAfterProxyAuth() {
network_state_ignored_until_proxy_auth_ = false;
}
-void SigninScreenHandler::HandleLaunchIncognito() {
- UserContext context(user_manager::USER_TYPE_GUEST, EmptyAccountId());
- if (delegate_)
- delegate_->Login(context, SigninSpecifics());
-}
-
-void SigninScreenHandler::HandleOfflineLogin() {
- if (!delegate_) {
- NOTREACHED();
- return;
- }
-
- auto* offline_login_screen =
- WizardController::default_controller()->GetScreen<OfflineLoginScreen>();
- offline_login_screen->LoadOffline();
- HideOfflineMessage(NetworkStateInformer::OFFLINE,
- NetworkError::ERROR_REASON_NONE);
- LoginDisplayHost::default_host()->StartWizard(OfflineLoginView::kScreenId);
+void SigninScreenHandler::OnErrorScreenHide() {
+ histogram_helper_->OnErrorHide();
+ ShowScreenDeprecated(GaiaView::kScreenId);
}
void SigninScreenHandler::HandleShowLoadingTimeoutError() {
@@ -466,16 +429,12 @@ void SigninScreenHandler::HandleShowLoadingTimeoutError() {
}
bool SigninScreenHandler::IsGaiaVisible() {
- return IsSigninScreen(GetCurrentScreen());
+ return GetCurrentScreen() == GaiaView::kScreenId;
}
bool SigninScreenHandler::IsGaiaHiddenByError() {
- return IsSigninScreenHiddenByError();
-}
-
-bool SigninScreenHandler::IsSigninScreenHiddenByError() {
return (GetCurrentScreen() == ErrorScreenView::kScreenId) &&
- (IsSigninScreen(error_screen_->GetParentScreen()));
+ (error_screen_->GetParentScreen() == GaiaView::kScreenId);
}
net::Error SigninScreenHandler::FrameError() const {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index 664e717865e..f712c161896 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -33,7 +33,6 @@
namespace ash {
class LoginDisplayHostMojo;
-class UserContext;
namespace mojom {
enum class TrayActionState;
@@ -48,11 +47,6 @@ class GaiaScreenHandler;
class SigninScreenHandlerDelegate {
public:
// --------------- Sign in/out methods.
- // Sign in using username and password specified as a part of `user_context`.
- // Used for both known and new users.
- virtual void Login(const UserContext& user_context,
- const SigninSpecifics& specifics) = 0;
-
// Returns true if sign in is in progress.
virtual bool IsSigninInProgress() const = 0;
@@ -109,8 +103,6 @@ class SigninScreenHandler
friend class ReportDnsCacheClearedOnUIThread;
void UpdateStateInternal(NetworkError::ErrorReason reason, bool force_update);
- void SetupAndShowOfflineMessage(NetworkStateInformer::State state,
- NetworkError::ErrorReason reason);
void HideOfflineMessage(NetworkStateInformer::State state,
NetworkError::ErrorReason reason);
void ReloadGaia(bool force_reload);
@@ -128,9 +120,6 @@ class SigninScreenHandler
const content::NotificationDetails& details) override;
// WebUI message handlers.
- void HandleLaunchIncognito();
- void HandleOfflineLogin();
-
void HandleShowLoadingTimeoutError();
// Returns true if current visible screen is the Gaia sign-in page.
@@ -140,10 +129,6 @@ class SigninScreenHandler
// Gaia sign-in page.
bool IsGaiaHiddenByError();
- // Returns true if current screen is the error screen over signin
- // screen.
- bool IsSigninScreenHiddenByError();
-
net::Error FrameError() const;
@@ -151,6 +136,10 @@ class SigninScreenHandler
// responding to network state notifications.
void ReenableNetworkStateUpdatesAfterProxyAuth();
+ // Error screen hide callback which records error screen metrics and shows
+ // GAIA.
+ void OnErrorScreenHide();
+
// A delegate that glues this handler with backend LoginDisplay.
SigninScreenHandlerDelegate* delegate_ = nullptr;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/ssh_configured_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/ssh_configured_handler.cc
index 03faecc2467..380948a1b68 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/ssh_configured_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/ssh_configured_handler.cc
@@ -6,8 +6,7 @@
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
+#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#include "components/login/localized_values_builder.h"
#include "third_party/cros_system_api/dbus/debugd/dbus-constants.h"
@@ -23,16 +22,12 @@ void OnDebugServiceAvailable(
debugd::DevFeatureFlag::DEV_FEATURES_DISABLED);
return;
}
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->QueryDebuggingFeatures(std::move(callback));
+ DebugDaemonClient::Get()->QueryDebuggingFeatures(std::move(callback));
}
void QueryDebuggingFeatures(
DebugDaemonClient::QueryDevFeaturesCallback callback) {
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->WaitForServiceToBeAvailable(
+ DebugDaemonClient::Get()->WaitForServiceToBeAvailable(
base::BindOnce(&OnDebugServiceAvailable, std::move(callback)));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
index 2f26cd447c9..608f73c65e3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
@@ -146,9 +146,7 @@ void SyncConsentScreenHandler::Bind(SyncConsentScreen* screen) {
}
void SyncConsentScreenHandler::Show(bool is_arc_restricted) {
- auto* user_manager = user_manager::UserManager::Get();
base::Value::Dict data;
- data.Set("isChildAccount", user_manager->IsLoggedInAsChildUser());
data.Set("isArcRestricted", is_arc_restricted);
ShowInWebUI(std::move(data));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
index 09cfb19c6b7..1d52917e9f8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
@@ -12,7 +12,6 @@
#include "base/strings/string_split.h"
#include "base/values.h"
#include "chrome/browser/ash/base/locale_util.h"
-#include "chrome/browser/ash/login/screens/terms_of_service_screen.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -30,17 +29,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId TermsOfServiceScreenView::kScreenId;
-
TermsOfServiceScreenHandler::TermsOfServiceScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.TermsOfServiceScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-TermsOfServiceScreenHandler::~TermsOfServiceScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+TermsOfServiceScreenHandler::~TermsOfServiceScreenHandler() = default;
void TermsOfServiceScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -59,64 +51,26 @@ void TermsOfServiceScreenHandler::DeclareLocalizedValues(
IDS_TERMS_OF_SERVICE_SCREEN_RETRY_BUTTON);
}
-void TermsOfServiceScreenHandler::SetScreen(TermsOfServiceScreen* screen) {
- BaseScreenHandler::SetBaseScreenDeprecated(screen);
- screen_ = screen;
-}
-
void TermsOfServiceScreenHandler::Show(const std::string& manager) {
- manager_ = manager;
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
- // Update the UI to show an error message or the Terms of Service.
- UpdateTermsOfServiceInUI();
-
base::Value::Dict data;
- data.Set("manager", manager_);
+ data.Set("manager", manager);
ShowInWebUI(std::move(data));
}
-void TermsOfServiceScreenHandler::Hide() {}
-
void TermsOfServiceScreenHandler::OnLoadError() {
- load_error_ = true;
- terms_of_service_ = "";
- UpdateTermsOfServiceInUI();
+ terms_loaded_ = false;
+ CallExternalAPI("setTermsOfServiceLoadError");
}
void TermsOfServiceScreenHandler::OnLoadSuccess(
const std::string& terms_of_service) {
- load_error_ = false;
- terms_of_service_ = terms_of_service;
- UpdateTermsOfServiceInUI();
+ terms_loaded_ = true;
+ CallExternalAPI("setTermsOfService", terms_of_service);
}
bool TermsOfServiceScreenHandler::AreTermsLoaded() {
- return !load_error_ && !terms_of_service_.empty();
-}
-
-void TermsOfServiceScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- Show(manager_);
- show_on_init_ = false;
- }
-}
-
-void TermsOfServiceScreenHandler::UpdateTermsOfServiceInUI() {
- if (!IsJavascriptAllowed())
- return;
-
- // If either `load_error_` or `terms_of_service_` is set, the download of the
- // Terms of Service has completed and the UI should be updated. Otherwise, the
- // download is still in progress and the UI will be updated when the
- // OnLoadError() or the OnLoadSuccess() callback is called.
- if (load_error_)
- CallJS("login.TermsOfServiceScreen.setTermsOfServiceLoadError");
- else if (!terms_of_service_.empty())
- CallJS("login.TermsOfServiceScreen.setTermsOfService", terms_of_service_);
+ return terms_loaded_;
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h
index 0ef7fee0fad..9546bfe674a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h
@@ -7,32 +7,25 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/base/locale_util.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class TermsOfServiceScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between TermsOfServiceScreen and its
// WebUI representation.
-class TermsOfServiceScreenView {
+class TermsOfServiceScreenView
+ : public base::SupportsWeakPtr<TermsOfServiceScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"terms-of-service"};
+ inline constexpr static StaticOobeScreenId kScreenId{"terms-of-service",
+ "TermsOfServiceScreen"};
- virtual ~TermsOfServiceScreenView() {}
-
- // Sets screen this view belongs to.
- virtual void SetScreen(ash::TermsOfServiceScreen* screen) = 0;
+ virtual ~TermsOfServiceScreenView() = default;
// Shows the contents of the screen.
virtual void Show(const std::string& manager) = 0;
- // Hides the contents of the screen.
- virtual void Hide() = 0;
-
// Called when the download of the Terms of Service fails. Show an error
// message to the user.
virtual void OnLoadError() = 0;
@@ -64,35 +57,14 @@ class TermsOfServiceScreenHandler : public BaseScreenHandler,
::login::LocalizedValuesBuilder* builder) override;
// TermsOfServiceScreenView:
- void SetScreen(ash::TermsOfServiceScreen* screen) override;
void Show(const std::string& manager) override;
- void Hide() override;
void OnLoadError() override;
void OnLoadSuccess(const std::string& terms_of_service) override;
bool AreTermsLoaded() override;
private:
- // BaseScreenHandler:
- void InitializeDeprecated() override;
-
- // Update the UI to show an error message or the Terms of Service, depending
- // on whether the download of the Terms of Service was successful. Does
- // nothing if the download is still in progress.
- void UpdateTermsOfServiceInUI();
-
- ash::TermsOfServiceScreen* screen_ = nullptr;
-
- // Whether the screen should be shown right after initialization.
- bool show_on_init_ = false;
-
- // The manager whose Terms of Service are being shown.
- std::string manager_;
-
- // Set to `true` when the download of the Terms of Service fails.
- bool load_error_ = false;
-
- // Set to the Terms of Service when the download is successful.
- std::string terms_of_service_;
+ // Set to `true` when the download of the Terms of Service succeeds.
+ bool terms_loaded_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc
index fc0dc1990af..52b1df42efe 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc
@@ -8,10 +8,10 @@
#include "ash/constants/ash_switches.h"
#include "ash/public/ash_interfaces.h"
#include "ash/public/cpp/tablet_mode.h"
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/bind.h"
#include "base/check.h"
#include "base/logging.h"
+#include "base/notreached.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/ash/login/existing_user_controller.h"
@@ -96,6 +96,9 @@ void OobeTestAPIHandler::GetAdditionalParameters(base::Value::Dict* dict) {
dict->Set("testapi_isOobeInTabletMode",
ash::TabletMode::Get()->InTabletMode() ||
ash::switches::ShouldOobeUseTabletModeFirstRun());
+ dict->Set("testapi_shouldSkipConsolidatedConsent",
+ !features::IsOobeConsolidatedConsentEnabled() ||
+ !BUILDFLAG(GOOGLE_CHROME_BRANDING));
}
void OobeTestAPIHandler::LoginWithPin(const std::string& username,
@@ -112,8 +115,15 @@ void OobeTestAPIHandler::AdvanceToScreen(const std::string& screen) {
}
void OobeTestAPIHandler::SkipToLoginForTesting() {
- ash::WizardController::default_controller()
- ->SkipToLoginForTesting(); // IN-TEST
+ ash::WizardController* controller =
+ ash::WizardController::default_controller();
+ if (!controller || !controller->is_initialized()) {
+ LOG(ERROR)
+ << "SkipToLoginForTesting is called when WizardController is not yet "
+ "initialized. Please report at https://crbug.com/1336940";
+ return;
+ }
+ controller->SkipToLoginForTesting(); // IN-TEST
}
void OobeTestAPIHandler::SkipPostLoginScreens() {
@@ -133,9 +143,10 @@ void OobeTestAPIHandler::LoginAsGuest() {
void OobeTestAPIHandler::ShowGaiaDialog() {
LoginDisplayHost::default_host()->ShowGaiaDialog(EmptyAccountId());
}
+
void OobeTestAPIHandler::HandleGetPrimaryDisplayName(
const std::string& callback_id) {
- mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config;
+ mojo::Remote<crosapi::mojom::CrosDisplayConfigController> cros_display_config;
ash::BindCrosDisplayConfigController(
cros_display_config.BindNewPipeAndPassReceiver());
@@ -147,9 +158,9 @@ void OobeTestAPIHandler::HandleGetPrimaryDisplayName(
void OobeTestAPIHandler::OnGetDisplayUnitInfoList(
const std::string& callback_id,
- std::vector<ash::mojom::DisplayUnitInfoPtr> info_list) {
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> info_list) {
std::string display_name;
- for (const ash::mojom::DisplayUnitInfoPtr& info : info_list) {
+ for (const crosapi::mojom::DisplayUnitInfoPtr& info : info_list) {
if (info->is_primary) {
display_name = info->name;
break;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h
index 8aaf69c6e7c..591d91f8346 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h
@@ -8,9 +8,9 @@
#include <string>
#include <vector>
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
+#include "chromeos/crosapi/mojom/cros_display_config.mojom.h"
namespace chromeos {
@@ -38,7 +38,7 @@ class OobeTestAPIHandler : public BaseWebUIHandler {
void HandleGetPrimaryDisplayName(const std::string& callback_id);
void OnGetDisplayUnitInfoList(
const std::string& callback_id,
- std::vector<ash::mojom::DisplayUnitInfoPtr> info_list);
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> info_list);
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.cc
index 0b8f4fc9d11..f15523f256c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.cc
@@ -12,6 +12,11 @@
#include "components/login/localized_values_builder.h"
namespace chromeos {
+
+namespace {
+constexpr char kSelectedTheme[] = "selectedTheme";
+}
+
constexpr StaticOobeScreenId ThemeSelectionScreenView::kScreenId;
ThemeSelectionScreenHandler::ThemeSelectionScreenHandler()
@@ -19,15 +24,19 @@ ThemeSelectionScreenHandler::ThemeSelectionScreenHandler()
ThemeSelectionScreenHandler::~ThemeSelectionScreenHandler() = default;
-void ThemeSelectionScreenHandler::Show() {
- ShowInWebUI();
+void ThemeSelectionScreenHandler::Show(const std::string& mode) {
+ base::Value::Dict data;
+ data.Set(kSelectedTheme, mode);
+ ShowInWebUI(std::move(data));
}
void ThemeSelectionScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("themeSelectionScreenTitle", IDS_THEME_SELECTION_TITLE);
- builder->Add("themeSelectionScreenDescription",
- IDS_THEME_SELECTION_DESCRIPTION);
+ builder->Add("themeSelectionScreenDescriptionClamshell",
+ IDS_THEME_SELECTION_DESCRIPTION_CLAMSHELL);
+ builder->Add("themeSelectionScreenDescriptionTablet",
+ IDS_THEME_SELECTION_DESCRIPTION_TABLET);
builder->Add("lightThemeLabel", IDS_THEME_LIGHT_LABEL);
builder->Add("lightThemeDescription", IDS_THEME_LIGHT_DESCRIPTION);
builder->Add("darkThemeLabel", IDS_THEME_DARK_LABEL);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.h
index 59a282a8ca2..36e18bde258 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/theme_selection_screen_handler.h
@@ -24,9 +24,13 @@ class ThemeSelectionScreenView
constexpr static StaticOobeScreenId kScreenId{"theme-selection",
"ThemeSelectionScreen"};
+ inline constexpr static char kAutoMode[] = "auto";
+ inline constexpr static char kDarkMode[] = "dark";
+ inline constexpr static char kLightMode[] = "light";
+
virtual ~ThemeSelectionScreenView() = default;
- virtual void Show() = 0;
+ virtual void Show(const std::string& mode) = 0;
};
class ThemeSelectionScreenHandler : public ThemeSelectionScreenView,
@@ -43,7 +47,7 @@ class ThemeSelectionScreenHandler : public ThemeSelectionScreenView,
~ThemeSelectionScreenHandler() override;
// ThemeSelectionScreenView implementation
- void Show() override;
+ void Show(const std::string& mode) override;
// BaseScreenHandler implementation
void DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc
index 8bbb632c385..9d40b33f371 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc
@@ -5,12 +5,9 @@
#include "chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h"
#include "base/values.h"
-#include "chrome/browser/ash/login/oobe_screen.h"
-#include "chrome/browser/ash/login/screens/tpm_error_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace {
@@ -18,17 +15,9 @@ const char kTPMErrorOwnedStep[] = "tpm-owned";
const char kTPMErrorDbusStep[] = "dbus-error";
} // namespace
-constexpr StaticOobeScreenId TpmErrorView::kScreenId;
+TpmErrorScreenHandler::TpmErrorScreenHandler() : BaseScreenHandler(kScreenId) {}
-TpmErrorScreenHandler::TpmErrorScreenHandler() : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.TPMErrorMessageScreen.userActed");
-}
-
-TpmErrorScreenHandler::~TpmErrorScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+TpmErrorScreenHandler::~TpmErrorScreenHandler() = default;
void TpmErrorScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -48,38 +37,16 @@ void TpmErrorScreenHandler::DeclareLocalizedValues(
IDS_INSTALLED_PRODUCT_OS_NAME);
}
-void TpmErrorScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- show_on_init_ = false;
- Show();
- }
-}
-
void TpmErrorScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
void TpmErrorScreenHandler::SetTPMOwnedErrorStep() {
- CallJS("login.TPMErrorMessageScreen.setStep",
- std::string(kTPMErrorOwnedStep));
+ CallExternalAPI("setStep", std::string(kTPMErrorOwnedStep));
}
void TpmErrorScreenHandler::SetTPMDbusErrorStep() {
- CallJS("login.TPMErrorMessageScreen.setStep", std::string(kTPMErrorDbusStep));
-}
-
-void TpmErrorScreenHandler::Bind(TpmErrorScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void TpmErrorScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
+ CallExternalAPI("setStep", std::string(kTPMErrorDbusStep));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h
index df86d2f8321..6d44ea0e2cf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h
@@ -5,31 +5,23 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TPM_ERROR_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TPM_ERROR_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class TpmErrorScreen;
-}
-
namespace chromeos {
// Interface for dependency injection between TpmErrorScreen and its
// WebUI representation.
-class TpmErrorView {
+class TpmErrorView : public base::SupportsWeakPtr<TpmErrorView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"tpm-error-message"};
+ inline constexpr static StaticOobeScreenId kScreenId{"tpm-error-message",
+ "TPMErrorMessageScreen"};
- virtual ~TpmErrorView() {}
+ virtual ~TpmErrorView() = default;
// Shows the contents of the screen.
virtual void Show() = 0;
- // Binds `screen` to the view.
- virtual void Bind(ash::TpmErrorScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
// Sets corresponding error message when taking tpm ownership return an error.
virtual void SetTPMOwnedErrorStep() = 0;
virtual void SetTPMDbusErrorStep() = 0;
@@ -46,19 +38,12 @@ class TpmErrorScreenHandler : public TpmErrorView, public BaseScreenHandler {
private:
void Show() override;
- void Bind(ash::TpmErrorScreen* screen) override;
- void Unbind() override;
void SetTPMOwnedErrorStep() override;
void SetTPMDbusErrorStep() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- bool show_on_init_ = false;
-
- ash::TpmErrorScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
index 3550b06a6d1..70ecbc8ca29 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
@@ -19,17 +19,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId UpdateRequiredView::kScreenId;
-
UpdateRequiredScreenHandler::UpdateRequiredScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.UpdateRequiredScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-UpdateRequiredScreenHandler::~UpdateRequiredScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+UpdateRequiredScreenHandler::~UpdateRequiredScreenHandler() = default;
void UpdateRequiredScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -90,78 +83,53 @@ void UpdateRequiredScreenHandler::DeclareLocalizedValues(
#endif
}
-void UpdateRequiredScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
void UpdateRequiredScreenHandler::SetEnterpriseAndDeviceName(
const std::string& enterpriseDomain,
const std::u16string& deviceName) {
- CallJS("login.UpdateRequiredScreen.setEnterpriseAndDeviceName",
- enterpriseDomain, deviceName);
+ CallExternalAPI("setEnterpriseAndDeviceName", enterpriseDomain, deviceName);
}
void UpdateRequiredScreenHandler::SetEolMessage(const std::string& eolMessage) {
- CallJS("login.UpdateRequiredScreen.setEolMessage", eolMessage);
+ CallExternalAPI("setEolMessage", eolMessage);
}
void UpdateRequiredScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void UpdateRequiredScreenHandler::Hide() {}
-
-void UpdateRequiredScreenHandler::Bind(UpdateRequiredScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void UpdateRequiredScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void UpdateRequiredScreenHandler::SetIsConnected(bool connected) {
- CallJS("login.UpdateRequiredScreen.setIsConnected", connected);
+ CallExternalAPI("setIsConnected", connected);
}
void UpdateRequiredScreenHandler::SetUpdateProgressUnavailable(
bool unavailable) {
- CallJS("login.UpdateRequiredScreen.setUpdateProgressUnavailable",
- unavailable);
+ CallExternalAPI("setUpdateProgressUnavailable", unavailable);
}
void UpdateRequiredScreenHandler::SetUpdateProgressValue(int progress) {
- CallJS("login.UpdateRequiredScreen.setUpdateProgressValue", progress);
+ CallExternalAPI("setUpdateProgressValue", progress);
}
void UpdateRequiredScreenHandler::SetUpdateProgressMessage(
const std::u16string& message) {
- CallJS("login.UpdateRequiredScreen.setUpdateProgressMessage", message);
+ CallExternalAPI("setUpdateProgressMessage", message);
}
void UpdateRequiredScreenHandler::SetEstimatedTimeLeftVisible(bool visible) {
- CallJS("login.UpdateRequiredScreen.setEstimatedTimeLeftVisible", visible);
+ CallExternalAPI("setEstimatedTimeLeftVisible", visible);
}
void UpdateRequiredScreenHandler::SetEstimatedTimeLeft(int seconds_left) {
- CallJS("login.UpdateRequiredScreen.setEstimatedTimeLeft", seconds_left);
+ CallExternalAPI("setEstimatedTimeLeft", seconds_left);
}
void UpdateRequiredScreenHandler::SetUIState(
UpdateRequiredView::UIState ui_state) {
- CallJS("login.UpdateRequiredScreen.setUIState", static_cast<int>(ui_state));
+ CallExternalAPI("setUIState", static_cast<int>(ui_state));
}
void UpdateRequiredScreenHandler::SetIsUserDataPresent(bool data_present) {
- CallJS("login.UpdateRequiredScreen.setIsUserDataPresent", data_present);
+ CallExternalAPI("setIsUserDataPresent", data_present);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h
index 55582573390..a7770583487 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace ash {
@@ -18,7 +19,7 @@ namespace chromeos {
// Interface for dependency injection between UpdateRequiredScreen and its
// WebUI representation.
-class UpdateRequiredView {
+class UpdateRequiredView : public base::SupportsWeakPtr<UpdateRequiredView> {
public:
enum UIState {
UPDATE_REQUIRED_MESSAGE = 0, // 'System update required' message.
@@ -31,22 +32,14 @@ class UpdateRequiredView {
UPDATE_NO_NETWORK // No network available to update
};
- constexpr static StaticOobeScreenId kScreenId{"update-required"};
+ inline constexpr static StaticOobeScreenId kScreenId{"update-required",
+ "UpdateRequiredScreen"};
- virtual ~UpdateRequiredView() {}
+ virtual ~UpdateRequiredView() = default;
// Shows the contents of the screen.
virtual void Show() = 0;
- // Hides the contents of the screen.
- virtual void Hide() = 0;
-
- // Binds `screen` to the view.
- virtual void Bind(ash::UpdateRequiredScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
// Is device connected to some network?
virtual void SetIsConnected(bool connected) = 0;
// Is progress unavailable (e.g. we are checking for updates)?
@@ -83,9 +76,6 @@ class UpdateRequiredScreenHandler : public UpdateRequiredView,
private:
void Show() override;
- void Hide() override;
- void Bind(ash::UpdateRequiredScreen* screen) override;
- void Unbind() override;
void SetIsConnected(bool connected) override;
void SetUpdateProgressUnavailable(bool unavailable) override;
@@ -102,12 +92,6 @@ class UpdateRequiredScreenHandler : public UpdateRequiredView,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::UpdateRequiredScreen* screen_ = nullptr;
-
- // If true, InitializeDeprecated() will call Show().
- bool show_on_init_ = false;
// The domain name for which update required screen is being shown.
std::string domain_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc
index 9afb14ace8e..97db3507603 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc
@@ -6,7 +6,6 @@
#include "base/values.h"
#include "chrome/browser/ash/login/oobe_screen.h"
-#include "chrome/browser/ash/login/screens/user_creation_screen.h"
#include "chrome/browser/ash/login/startup_utils.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -15,17 +14,10 @@
namespace chromeos {
-constexpr StaticOobeScreenId UserCreationView::kScreenId;
-
UserCreationScreenHandler::UserCreationScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated("login.UserCreationScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-UserCreationScreenHandler::~UserCreationScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+UserCreationScreenHandler::~UserCreationScreenHandler() = default;
void UserCreationScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
@@ -63,24 +55,12 @@ void UserCreationScreenHandler::DeclareLocalizedValues(
IDS_OOBE_USER_CREATION_CHILD_SIGN_IN_LEARN_MORE_DIALOG_TEXT);
}
-void UserCreationScreenHandler::InitializeDeprecated() {}
-
void UserCreationScreenHandler::Show() {
ShowInWebUI();
}
-void UserCreationScreenHandler::Bind(UserCreationScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void UserCreationScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void UserCreationScreenHandler::SetIsBackButtonVisible(bool value) {
- CallJS("login.UserCreationScreen.setIsBackButtonVisible", value);
+ CallExternalAPI("setIsBackButtonVisible", value);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h
index 6b170415f56..21e7d092a92 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_CREATION_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_CREATION_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace ash {
@@ -15,21 +16,16 @@ namespace chromeos {
// Interface for dependency injection between UserCreationScreen and its
// WebUI representation.
-class UserCreationView {
+class UserCreationView : public base::SupportsWeakPtr<UserCreationView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"user-creation"};
+ inline constexpr static StaticOobeScreenId kScreenId{"user-creation",
+ "UserCreationScreen"};
- virtual ~UserCreationView() {}
+ virtual ~UserCreationView() = default;
// Shows the contents of the screen.
virtual void Show() = 0;
- // Binds `screen` to the view.
- virtual void Bind(ash::UserCreationScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
-
virtual void SetIsBackButtonVisible(bool value) = 0;
};
@@ -48,16 +44,11 @@ class UserCreationScreenHandler : public UserCreationView,
private:
void Show() override;
- void Bind(ash::UserCreationScreen* screen) override;
- void Unbind() override;
void SetIsBackButtonVisible(bool value) override;
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::UserCreationScreen* screen_ = nullptr;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
index 714dffe50ea..b13c06ee149 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
@@ -358,46 +358,45 @@ void WelcomeScreenHandler::OnAccessibilityStatusChanged(
}
void WelcomeScreenHandler::UpdateA11yState() {
- base::DictionaryValue a11y_info;
- a11y_info.SetBoolKey("highContrastEnabled",
- AccessibilityManager::Get()->IsHighContrastEnabled());
- a11y_info.SetBoolKey("largeCursorEnabled",
- AccessibilityManager::Get()->IsLargeCursorEnabled());
- a11y_info.SetBoolKey("spokenFeedbackEnabled",
- AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- a11y_info.SetBoolKey("selectToSpeakEnabled",
- AccessibilityManager::Get()->IsSelectToSpeakEnabled());
+ base::Value::Dict a11y_info;
+ a11y_info.Set("highContrastEnabled",
+ AccessibilityManager::Get()->IsHighContrastEnabled());
+ a11y_info.Set("largeCursorEnabled",
+ AccessibilityManager::Get()->IsLargeCursorEnabled());
+ a11y_info.Set("spokenFeedbackEnabled",
+ AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
+ a11y_info.Set("selectToSpeakEnabled",
+ AccessibilityManager::Get()->IsSelectToSpeakEnabled());
DCHECK(MagnificationManager::Get());
- a11y_info.SetBoolKey("screenMagnifierEnabled",
- MagnificationManager::Get()->IsMagnifierEnabled());
- a11y_info.SetBoolKey("dockedMagnifierEnabled",
- MagnificationManager::Get()->IsDockedMagnifierEnabled());
- a11y_info.SetBoolKey("virtualKeyboardEnabled",
- AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
+ a11y_info.Set("screenMagnifierEnabled",
+ MagnificationManager::Get()->IsMagnifierEnabled());
+ a11y_info.Set("dockedMagnifierEnabled",
+ MagnificationManager::Get()->IsDockedMagnifierEnabled());
+ a11y_info.Set("virtualKeyboardEnabled",
+ AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
if (screen_ && AccessibilityManager::Get()->IsSpokenFeedbackEnabled())
CancelChromeVoxHintIdleDetection();
CallJS("login.WelcomeScreen.refreshA11yInfo", std::move(a11y_info));
}
// static
-base::ListValue WelcomeScreenHandler::GetTimezoneList() {
+base::Value::List WelcomeScreenHandler::GetTimezoneList() {
std::string current_timezone_id;
CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id);
- base::ListValue timezone_list;
- std::unique_ptr<base::ListValue> timezones = system::GetTimezoneList();
- base::Value::ConstListView timezones_view = timezones->GetListDeprecated();
- for (size_t i = 0; i < timezones_view.size(); ++i) {
- CHECK(timezones_view[i].is_list());
- base::Value::ConstListView timezone = timezones_view[i].GetListDeprecated();
+ base::Value::List timezone_list;
+ base::Value::List timezones = system::GetTimezoneList();
+ for (const auto& value : timezones) {
+ CHECK(value.is_list());
+ const base::Value::List& timezone = value.GetList();
std::string timezone_id = timezone[0].GetString();
std::string timezone_name = timezone[1].GetString();
- base::Value timezone_option(base::Value::Type::DICTIONARY);
- timezone_option.SetStringKey("value", timezone_id);
- timezone_option.SetStringKey("title", timezone_name);
- timezone_option.SetBoolKey("selected", timezone_id == current_timezone_id);
+ base::Value::Dict timezone_option;
+ timezone_option.Set("value", timezone_id);
+ timezone_option.Set("title", timezone_name);
+ timezone_option.Set("selected", timezone_id == current_timezone_id);
timezone_list.Append(std::move(timezone_option));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
index a70d5c1ec3d..22b8901dca3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
@@ -110,7 +110,7 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
void UpdateA11yState();
// Returns available timezones.
- static base::ListValue GetTimezoneList();
+ static base::Value::List GetTimezoneList();
CoreOobeView* core_oobe_view_ = nullptr;
ash::WelcomeScreen* screen_ = nullptr;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
index 338e23c6080..bd6dca5c4ba 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
@@ -11,40 +11,15 @@
namespace chromeos {
-constexpr StaticOobeScreenId WrongHWIDScreenView::kScreenId;
-
WrongHWIDScreenHandler::WrongHWIDScreenHandler()
- : BaseScreenHandler(kScreenId) {
- set_user_acted_method_path_deprecated(
- "login.WrongHWIDMessageScreen.userActed");
-}
+ : BaseScreenHandler(kScreenId) {}
-WrongHWIDScreenHandler::~WrongHWIDScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
+WrongHWIDScreenHandler::~WrongHWIDScreenHandler() = default;
void WrongHWIDScreenHandler::Show() {
- if (!IsJavascriptAllowed()) {
- show_on_init_ = true;
- return;
- }
ShowInWebUI();
}
-void WrongHWIDScreenHandler::Hide() {
-}
-
-void WrongHWIDScreenHandler::Bind(WrongHWIDScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreenDeprecated(screen_);
-}
-
-void WrongHWIDScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreenDeprecated(nullptr);
-}
-
void WrongHWIDScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("wrongHWIDScreenHeader", IDS_WRONG_HWID_SCREEN_HEADER);
@@ -56,11 +31,4 @@ void WrongHWIDScreenHandler::DeclareLocalizedValues(
IDS_WRONG_HWID_SCREEN_SKIP_LINK);
}
-void WrongHWIDScreenHandler::InitializeDeprecated() {
- if (show_on_init_) {
- show_on_init_ = false;
- Show();
- }
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h
index e67880ca784..f07880156b8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h
@@ -5,30 +5,21 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_WRONG_HWID_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_WRONG_HWID_SCREEN_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-namespace ash {
-class WrongHWIDScreen;
-}
-
namespace chromeos {
// Interface between wrong HWID screen and its representation.
// Note, do not forget to call OnViewDestroyed in the dtor.
-class WrongHWIDScreenView {
+class WrongHWIDScreenView : public base::SupportsWeakPtr<WrongHWIDScreenView> {
public:
- constexpr static StaticOobeScreenId kScreenId{"wrong-hwid"};
+ inline constexpr static StaticOobeScreenId kScreenId{
+ "wrong-hwid", "WrongHWIDMessageScreen"};
- virtual ~WrongHWIDScreenView() {}
+ virtual ~WrongHWIDScreenView() = default;
virtual void Show() = 0;
- virtual void Hide() = 0;
-
- // Binds `screen` to the view.
- virtual void Bind(ash::WrongHWIDScreen* screen) = 0;
-
- // Unbinds the screen from the view.
- virtual void Unbind() = 0;
};
// WebUI implementation of WrongHWIDScreenActor.
@@ -47,19 +38,10 @@ class WrongHWIDScreenHandler : public WrongHWIDScreenView,
private:
// WrongHWIDScreenActor implementation:
void Show() override;
- void Hide() override;
- void Bind(ash::WrongHWIDScreen* screen) override;
- void Unbind() override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void InitializeDeprecated() override;
-
- ash::WrongHWIDScreen* screen_ = nullptr;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/BUILD.gn b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/BUILD.gn
new file mode 100644
index 00000000000..d6e6d4b2a71
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/chromeos/ui_mode.gni")
+import("//mojo/public/tools/bindings/mojom.gni")
+import("//tools/typescript/ts_library.gni")
+
+assert(is_chromeos_ash, "Manage MirrorSync dialog is ash-chrome only")
+
+mojom("mojo_bindings") {
+ sources = [ "manage_mirrorsync.mojom" ]
+
+ public_deps = [ "//mojo/public/mojom/base" ]
+ webui_module_path = "/"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/DIR_METADATA
new file mode 100644
index 00000000000..e9400b87752
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/DIR_METADATA
@@ -0,0 +1 @@
+mixins: "//ui/file_manager/COMMON_METADATA"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/OWNERS
new file mode 100644
index 00000000000..e4510da0a92
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/OWNERS
@@ -0,0 +1,4 @@
+file://ui/file_manager/OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom
new file mode 100644
index 00000000000..0b3f9ebb794
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom
@@ -0,0 +1,43 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module chromeos.manage_mirrorsync.mojom;
+
+import "mojo/public/mojom/base/file_path.mojom";
+
+// Lives in the browser process. A renderer uses this to create a page handler
+// that enables communication between a renderer and the browser process.
+interface PageHandlerFactory {
+ // Create a page handler to enable communication with the browser process.
+ CreatePageHandler(pending_receiver<PageHandler> handler);
+};
+
+// Lives in the browser process. A renderer uses this to invoke methods that
+// are implemented in the browser process.
+interface PageHandler {
+ // Returns a list of paths that are children (i.e. direct descendants) of
+ // `path`. The supplied path must be relative to ~/MyFiles then made absolute,
+ // e.g. /foo/bar will return all child folders of ~/MyFiles/foo/bar
+ GetChildFolders(mojo_base.mojom.FilePath path) => (
+ array<mojo_base.mojom.FilePath> paths);
+
+ // A mapping exposed to the chrome://manage-mirrorsync webui to abstract away
+ // 3 classes of errors from their drive::FileError equivalents.
+ // - When the DriveFS service is unavailable.
+ // - Any other error has occurred.
+ // - The syncing paths retrieval was successful.
+ enum GetSyncPathError {
+ kServiceUnavailable,
+ kSuccess,
+ kFailed,
+ };
+
+ // Returns a list of paths that are currently syncing via MirrorSync. These
+ // paths follow the same conventions as `GetChildFolders` such that they
+ // appear as parented at root but represent are actually relative to
+ // ~/MyFiles. See `GetChildFolders` for an example.
+ GetSyncingPaths() => (
+ GetSyncPathError error,
+ array<mojo_base.mojom.FilePath> syncing_paths);
+};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.cc
new file mode 100644
index 00000000000..396234473cc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.cc
@@ -0,0 +1,63 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h"
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h"
+#include "chrome/common/webui_url_constants.h"
+#include "ui/aura/window.h"
+#include "ui/base/ui_base_types.h"
+
+namespace {
+
+// TODO(b/237066325): Update this once UI has landed for this.
+constexpr int kDialogWidth = 768;
+constexpr int kDialogHeight = 608;
+
+GURL GetURL() {
+ return GURL{chrome::kChromeUIManageMirrorSyncURL};
+}
+
+} // namespace
+
+namespace chromeos {
+
+void ManageMirrorSyncDialog::Show(Profile* profile) {
+ auto* instance = SystemWebDialogDelegate::FindInstance(GetURL().spec());
+ if (instance) {
+ instance->Focus();
+ return;
+ }
+
+ instance = new ManageMirrorSyncDialog(profile);
+ instance->ShowSystemDialog();
+}
+
+ManageMirrorSyncDialog::ManageMirrorSyncDialog(Profile* profile)
+ : SystemWebDialogDelegate(GetURL(), /*title=*/{}) {}
+
+ManageMirrorSyncDialog::~ManageMirrorSyncDialog() = default;
+
+void ManageMirrorSyncDialog::GetDialogSize(gfx::Size* size) const {
+ size->SetSize(::kDialogWidth, ::kDialogHeight);
+}
+
+void ManageMirrorSyncDialog::OnDialogShown(content::WebUI* webui) {
+ mirrorsync_ui_ = static_cast<ManageMirrorSyncUI*>(webui->GetController());
+ return SystemWebDialogDelegate::OnDialogShown(webui);
+}
+
+void ManageMirrorSyncDialog::OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) {
+ mirrorsync_ui_ = nullptr;
+ return SystemWebDialogDelegate::OnCloseContents(source, out_close_dialog);
+}
+
+void ManageMirrorSyncDialog::OnWebContentsFinishedLoad() {
+ DCHECK(dialog_window());
+ // TODO(b/237066325): Localize this string.
+ dialog_window()->SetTitle(u"Manage MirrorSync");
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h
new file mode 100644
index 00000000000..c4f22bfb560
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h
@@ -0,0 +1,35 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_DIALOG_H_
+
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+
+class Profile;
+
+namespace chromeos {
+
+class ManageMirrorSyncUI;
+
+class ManageMirrorSyncDialog : public SystemWebDialogDelegate {
+ public:
+ static void Show(Profile* profile);
+
+ private:
+ explicit ManageMirrorSyncDialog(Profile* profile);
+ ~ManageMirrorSyncDialog() override;
+
+ // SystemWebDialogDelegate:
+ void GetDialogSize(gfx::Size* size) const override;
+ void OnDialogShown(content::WebUI* webui) override;
+ void OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) override;
+ void OnWebContentsFinishedLoad() override;
+ ManageMirrorSyncUI* mirrorsync_ui_ = nullptr;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog_browsertest.cc
new file mode 100644
index 00000000000..8e30b0bfc26
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog_browsertest.cc
@@ -0,0 +1,444 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_dialog.h"
+
+#include "ash/constants/ash_features.h"
+#include "base/files/file_util.h"
+#include "base/run_loop.h"
+#include "base/strings/strcat.h"
+#include "base/test/bind.h"
+#include "base/test/gmock_callback_support.h"
+#include "base/test/mock_callback.h"
+#include "base/test/scoped_feature_list.h"
+#include "base/threading/thread_restrictions.h"
+#include "base/values.h"
+#include "chrome/browser/ash/drive/drive_integration_service.h"
+#include "chrome/browser/ash/drive/drivefs_test_support.h"
+#include "chrome/browser/ash/file_manager/path_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom.h"
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "components/drive/drive_pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/test/browser_test.h"
+#include "content/public/test/browser_test_utils.h"
+#include "storage/browser/file_system/external_mount_points.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace chromeos {
+
+using base::test::RunOnceCallback;
+using testing::_;
+using testing::AllOf;
+using testing::ElementsAre;
+using testing::ElementsAreArray;
+using testing::Eq;
+using testing::IsEmpty;
+using testing::SizeIs;
+
+// The Mojo bindings for JS output a `base::FilePath` as an object with a 'path'
+// key. When parsing it in C++ as a `base::Value` this requires a bit of
+// wrangling. To avoid doing this over and over, this MATCHER unwraps the
+// `base::Value` and matches against a supplied `std::vector<std::string>`.
+MATCHER_P(MojoFilePaths, matcher, "") {
+ std::vector<std::string> paths;
+ for (const base::Value& dict_value : arg) {
+ const std::string* path_value = dict_value.GetDict().FindString("path");
+ paths.push_back(*path_value);
+ }
+ return testing::ExplainMatchResult(matcher, paths, result_listener);
+}
+
+// Matcher to unwrap the `base::Value::Dict` from `getSyncingPaths` and extract
+// the "error" key. The value of this is cast into a `GetSyncPathError` to
+// compare.
+MATCHER_P(SyncPathError, matcher, "") {
+ absl::optional<int> error = arg.FindInt("error");
+ EXPECT_TRUE(error.has_value());
+ auto get_sync_path_error =
+ static_cast<manage_mirrorsync::mojom::PageHandler::GetSyncPathError>(
+ error.value());
+ return testing::ExplainMatchResult(matcher, get_sync_path_error,
+ result_listener);
+}
+
+// Matcher to unwrap the `base::Value::Dict` from `getSyncPaths` and extract the
+// "syncingPaths" key. This can be coupled wit the `MojoFilePaths` matcher to
+// perform element comparison on the resultant `base::Value::Dict` in the array.
+MATCHER_P(SyncingPaths, matcher, "") {
+ const base::Value::List* paths = arg.FindList("syncingPaths");
+ EXPECT_NE(paths, nullptr);
+ return testing::ExplainMatchResult(matcher, *paths, result_listener);
+}
+
+// Helper to observe the DriveIntegrationService for when mirroring is enabled.
+class DriveMirrorSyncStatusObserver
+ : public drive::DriveIntegrationServiceObserver {
+ public:
+ explicit DriveMirrorSyncStatusObserver(bool expected_status)
+ : expected_status_(expected_status) {
+ quit_closure_ = run_loop_.QuitClosure();
+ }
+
+ DriveMirrorSyncStatusObserver(const DriveMirrorSyncStatusObserver&) = delete;
+ DriveMirrorSyncStatusObserver& operator=(
+ const DriveMirrorSyncStatusObserver&) = delete;
+
+ ~DriveMirrorSyncStatusObserver() override = default;
+
+ void WaitForStatusChange() { run_loop_.Run(); }
+
+ void OnMirroringEnabled() override {
+ quit_closure_.Run();
+ EXPECT_TRUE(expected_status_);
+ }
+
+ void OnMirroringDisabled() override {
+ quit_closure_.Run();
+ EXPECT_FALSE(expected_status_);
+ }
+
+ private:
+ base::RunLoop run_loop_;
+ base::RepeatingClosure quit_closure_;
+ bool expected_status_ = false;
+};
+
+class ManageMirrorSyncDialogTest : public InProcessBrowserTest {
+ public:
+ ManageMirrorSyncDialogTest() {
+ feature_list_.InitAndEnableFeature(features::kDriveFsMirroring);
+
+ EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
+ }
+
+ ManageMirrorSyncDialogTest(const ManageMirrorSyncDialogTest&) = delete;
+ ManageMirrorSyncDialogTest& operator=(const ManageMirrorSyncDialogTest&) =
+ delete;
+
+ void SetUpInProcessBrowserTestFixture() override {
+ create_drive_integration_service_ = base::BindRepeating(
+ &ManageMirrorSyncDialogTest::CreateDriveIntegrationService,
+ base::Unretained(this));
+ service_factory_for_test_ = std::make_unique<
+ drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>(
+ &create_drive_integration_service_);
+ }
+
+ drive::DriveIntegrationService* CreateDriveIntegrationService(
+ Profile* profile) {
+ base::ScopedAllowBlockingForTesting allow_blocking;
+ base::FilePath mount_point = profile->GetPath().Append("drivefs");
+ fake_drivefs_helpers_[profile] =
+ std::make_unique<drive::FakeDriveFsHelper>(profile, mount_point);
+ auto* integration_service = new drive::DriveIntegrationService(
+ profile, "", mount_point,
+ fake_drivefs_helpers_[profile]->CreateFakeDriveFsListenerFactory());
+ return integration_service;
+ }
+
+ // Show the MirrorSync dialog and wait for it to complete loading.
+ void ShowDialog() {
+ content::WebContentsAddedObserver observer;
+ ManageMirrorSyncDialog::Show(browser()->profile());
+ dialog_contents_ = observer.GetWebContents();
+ EXPECT_TRUE(content::WaitForLoadStop(dialog_contents_));
+ EXPECT_EQ(dialog_contents_->GetLastCommittedURL().host(),
+ chrome::kChromeUIManageMirrorSyncHost);
+ }
+
+ void SetUpMyFilesAndDialog(std::vector<std::string> paths) {
+ // Revoke the existing mount points and setup `temp_dir_` as the mount point
+ // for ~/MyFiles.
+ my_files_dir_ = temp_dir_.GetPath().Append("MyFiles");
+ storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
+ storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
+ file_manager::util::GetDownloadsMountPointName(browser()->profile()),
+ storage::kFileSystemTypeLocal, storage::FileSystemMountOption(),
+ my_files_dir_);
+
+ // Create the supplied paths as individual folders. This ensures a path such
+ // as foo/bar gets foo created and bar created as a child folder.
+ for (const auto& path : paths) {
+ base::FilePath file_path(path);
+ const auto& parts = file_path.GetComponents();
+ base::FilePath base_path = my_files_dir_;
+ for (const auto& path_part : parts) {
+ base_path = base_path.Append(path_part);
+ base::ScopedAllowBlockingForTesting allow_blocking;
+ ASSERT_TRUE(base::CreateDirectory(base_path));
+ }
+ }
+
+ ShowDialog();
+ }
+
+ drivefs::FakeDriveFs& SetUpMirrorSyncAndDialog(bool enabled) {
+ // Revoke the existing mount points and setup `temp_dir_` as the mount point
+ // for ~/MyFiles.
+ my_files_dir_ = temp_dir_.GetPath().Append("MyFiles");
+ storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
+ storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
+ file_manager::util::GetDownloadsMountPointName(browser()->profile()),
+ storage::kFileSystemTypeLocal, storage::FileSystemMountOption(),
+ my_files_dir_);
+
+ // Toggle the MirrorSync preference to enable / disable the feature.
+ auto observer = std::make_unique<DriveMirrorSyncStatusObserver>(enabled);
+ auto* drive_service = drive::DriveIntegrationServiceFactory::FindForProfile(
+ browser()->profile());
+ drive_service->AddObserver(observer.get());
+ browser()->profile()->GetPrefs()->SetBoolean(
+ drive::prefs::kDriveFsEnableMirrorSync, enabled);
+ observer->WaitForStatusChange();
+ drive_service->RemoveObserver(observer.get());
+
+ ShowDialog();
+
+ return fake_drivefs_helpers_[browser()->profile()]->fake_drivefs();
+ }
+
+ // Returns a pair of std::vector where the first element contains a list of
+ // base::FilePaths that represent absolute paths parented at `my_files_dir_`
+ // and the second element contains the expected paths returned from
+ // `getSyncingPaths` i.e. with the leading `my_files_dir_` replaced with a "/"
+ // character. For example: CreateExpectedPaths({{"foo"}}) will have the
+ // following first element:
+ // /MyFiles/foo
+ // And the second element will be:
+ // /foo
+ std::pair<std::vector<base::FilePath>, std::vector<std::string>>
+ CreateExpectedPaths(std::vector<std::string> paths) {
+ std::vector<base::FilePath> absolute_paths;
+ std::vector<std::string> expected_paths;
+ for (const auto& path : paths) {
+ absolute_paths.push_back(my_files_dir_.Append(path));
+ expected_paths.push_back(base::StrCat({"/", path}));
+ }
+ return std::make_pair(absolute_paths, expected_paths);
+ }
+
+ // Helper to invoke the `getChildFolders` method on chrome://manage-mirrorsync
+ // dialog and extract it's response.
+ base::Value::List GetChildFolders(const std::string& path) {
+ const std::string js_expression = base::StrCat(
+ {"((async () => { "
+ "const {BrowserProxy} = await import('./browser_proxy.js');"
+ "const handler = BrowserProxy.getInstance().handler;"
+ "const {paths} = await handler.getChildFolders({path: '",
+ path,
+ "'});"
+ "return paths; })())"});
+ auto response = content::EvalJs(dialog_contents_, js_expression);
+
+ base::Value response_list = response.ExtractList();
+ return response_list.GetList().Clone();
+ }
+
+ // Helper to invoke the `getSyncingPaths` method on chrome://manage-mirrorsync
+ // dialog and extract it's response.
+ base::Value::Dict GetSyncingPaths() {
+ const std::string js_expression =
+ "((async () => { "
+ "const {BrowserProxy} = await import('./browser_proxy.js');"
+ "const handler = BrowserProxy.getInstance().handler;"
+ "const response = await handler.getSyncingPaths();"
+ "return response; })())";
+ auto response = content::EvalJs(dialog_contents_, js_expression);
+ EXPECT_TRUE(response.value.is_dict());
+ return response.value.GetDict().Clone();
+ }
+
+ void TearDown() override {
+ InProcessBrowserTest::TearDown();
+ storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
+ }
+
+ base::test::ScopedFeatureList feature_list_;
+ base::ScopedTempDir temp_dir_;
+ base::FilePath my_files_dir_;
+ content::WebContents* dialog_contents_;
+
+ drive::DriveIntegrationServiceFactory::FactoryCallback
+ create_drive_integration_service_;
+ std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>
+ service_factory_for_test_;
+ std::map<Profile*, std::unique_ptr<drive::FakeDriveFsHelper>>
+ fake_drivefs_helpers_;
+};
+
+IN_PROC_BROWSER_TEST_F(ManageMirrorSyncDialogTest, ExpectedScenarios) {
+ SetUpMyFilesAndDialog({{"foo/bar"}, {"baz"}});
+ {
+ // Only children folders should be returned (i.e. not all descendants).
+ const auto& child_folders = GetChildFolders("/");
+ EXPECT_THAT(child_folders, SizeIs(2));
+ EXPECT_THAT(child_folders, MojoFilePaths(ElementsAre("/baz", "/foo")));
+ }
+
+ {
+ // Paths should be returned as absolute.
+ const auto& child_folders = GetChildFolders("/foo");
+ EXPECT_THAT(child_folders, SizeIs(1));
+ EXPECT_THAT(child_folders, MojoFilePaths(ElementsAre("/foo/bar")));
+ }
+
+ {
+ // Folders with no children should return an empty list.
+ const auto& child_folders = GetChildFolders("/baz");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+}
+
+IN_PROC_BROWSER_TEST_F(ManageMirrorSyncDialogTest, InvalidScenarios) {
+ SetUpMyFilesAndDialog({{"foo/bar"}, {"baz"}});
+
+ {
+ // Not supplying a path should return an empty list.
+ const auto& child_folders = GetChildFolders("");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+
+ {
+ // Path traversals should return an empty list.
+ const auto& child_folders = GetChildFolders("/../../");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+
+ {
+ // Relative paths should are invalid, empty list is returned.
+ const auto& child_folders = GetChildFolders("foo/bar");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+
+ {
+ // Non-existent directories should return an empty list.
+ const auto& child_folders = GetChildFolders("/non-existant");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+}
+
+IN_PROC_BROWSER_TEST_F(ManageMirrorSyncDialogTest, CertainItemsAreIgnored) {
+ SetUpMyFilesAndDialog({{"foo/bar"}, {"baz"}});
+
+ {
+ base::ScopedAllowBlockingForTesting allow_blocking;
+ // Create a file under foo, files should be ignored.
+ ASSERT_TRUE(base::WriteFile(my_files_dir_.Append("foo/test.txt"), "blah"));
+
+ // Any items (files or folders) with a leading dot should be ignored.
+ ASSERT_TRUE(base::CreateDirectory(my_files_dir_.Append("baz/.Trash")));
+
+ // Items nested in dot folders should also be ignored.
+ ASSERT_TRUE(base::CreateDirectory(my_files_dir_.Append("baz/.Trash/dir")));
+ }
+
+ {
+ // File should be ignored as well as any dot folders.
+ const auto& child_folders = GetChildFolders("/");
+ EXPECT_THAT(child_folders, SizeIs(2));
+ EXPECT_THAT(child_folders, MojoFilePaths(ElementsAre("/baz", "/foo")));
+ }
+
+ {
+ // Supplied dot folders should return an empty list.
+ const auto& child_folders = GetChildFolders("/baz/.Trash");
+ EXPECT_THAT(child_folders, IsEmpty());
+ }
+}
+
+using manage_mirrorsync::mojom::PageHandler;
+
+IN_PROC_BROWSER_TEST_F(ManageMirrorSyncDialogTest,
+ GetSyncingPathsMirrorSyncEnabled) {
+ drivefs::FakeDriveFs& fake_drivefs =
+ SetUpMirrorSyncAndDialog(/*enabled=*/true);
+
+ {
+ // No paths currently syncing returns empty.
+ const auto& [mock_paths, expected_paths] = CreateExpectedPaths({});
+ EXPECT_CALL(fake_drivefs, GetSyncingPaths(_))
+ .WillOnce(
+ RunOnceCallback<0>(drive::FileError::FILE_ERROR_OK, mock_paths));
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kSuccess),
+ SyncingPaths(IsEmpty())));
+ }
+
+ {
+ // Single path being synced returns correctly.
+ const auto& [mock_paths, expected_paths] = CreateExpectedPaths({{"foo"}});
+ EXPECT_CALL(fake_drivefs, GetSyncingPaths(_))
+ .WillOnce(
+ RunOnceCallback<0>(drive::FileError::FILE_ERROR_OK, mock_paths));
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(
+ syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kSuccess),
+ SyncingPaths(MojoFilePaths(ElementsAreArray(expected_paths)))));
+ }
+
+ {
+ // Nested syncing path returns itself but not the parents.
+ const auto& [mock_paths, expected_paths] =
+ CreateExpectedPaths({{"foo/bar"}});
+ EXPECT_CALL(fake_drivefs, GetSyncingPaths(_))
+ .WillOnce(
+ RunOnceCallback<0>(drive::FileError::FILE_ERROR_OK, mock_paths));
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(
+ syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kSuccess),
+ SyncingPaths(MojoFilePaths(ElementsAreArray(expected_paths)))));
+ }
+
+ {
+ // Failure from retrieval of paths should return error + empty vector.
+ const auto& [mock_paths, expected_paths] = CreateExpectedPaths({});
+ EXPECT_CALL(fake_drivefs, GetSyncingPaths(_))
+ .WillOnce(RunOnceCallback<0>(drive::FileError::FILE_ERROR_NOT_FOUND,
+ mock_paths));
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kFailed),
+ SyncingPaths(IsEmpty())));
+ }
+
+ {
+ // Paths returned not parented at MyFiles should be ignored.
+ auto [mock_paths, expected_paths] = CreateExpectedPaths({{"baz"}});
+ mock_paths.push_back(base::FilePath("/ignore/dir"));
+ EXPECT_CALL(fake_drivefs, GetSyncingPaths(_))
+ .WillOnce(
+ RunOnceCallback<0>(drive::FileError::FILE_ERROR_OK, mock_paths));
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(
+ syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kSuccess),
+ SyncingPaths(AllOf(SizeIs(1), MojoFilePaths(ElementsAreArray(
+ expected_paths))))));
+ }
+}
+
+IN_PROC_BROWSER_TEST_F(ManageMirrorSyncDialogTest,
+ GetSyncingPathsMirrorSyncDisabled) {
+ SetUpMirrorSyncAndDialog(/*enabled=*/false);
+
+ {
+ // MirrorSync not enabled should return kServiceUnavailable and empty paths.
+ const auto& syncing_paths = GetSyncingPaths();
+ EXPECT_THAT(
+ syncing_paths,
+ AllOf(SyncPathError(PageHandler::GetSyncPathError::kServiceUnavailable),
+ SyncingPaths(IsEmpty())));
+ }
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.cc
new file mode 100644
index 00000000000..2f09b0fef95
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.cc
@@ -0,0 +1,169 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h"
+
+#include <utility>
+
+#include "base/files/file_enumerator.h"
+#include "base/files/file_util.h"
+#include "base/ranges/algorithm.h"
+#include "base/strings/string_piece.h"
+#include "base/task/task_traits.h"
+#include "base/task/thread_pool.h"
+#include "chrome/browser/ash/drive/drive_integration_service.h"
+#include "chrome/browser/ash/file_manager/path_util.h"
+
+namespace chromeos {
+
+namespace {
+
+// Do not surface any dotfiles in the UI to enable syncing. They can be
+// synced as part of an existing directory but don't allow them to be
+// selectable.
+bool PathHasDotFile(const base::FilePath& path) {
+ std::vector<base::FilePath::StringType> components = path.GetComponents();
+ for (const auto& part : components) {
+ if (part.front() == '.') {
+ return true;
+ }
+ }
+ return false;
+}
+
+std::vector<base::FilePath> GetChildFoldersBlocking(
+ const base::FilePath& absolute_path,
+ int remove_prefix_size) {
+ std::vector<base::FilePath> child_folders;
+ base::FileEnumerator enumerator(absolute_path, /*recursive=*/false,
+ base::FileEnumerator::DIRECTORIES);
+ for (base::FilePath path = enumerator.Next(); !path.empty();
+ path = enumerator.Next()) {
+ base::StringPiece child_path(path.value());
+
+ // Paths are absolute in the form /home/chronos/u-HASH/MyFiles/..., to avoid
+ // exposing all the unnecessary parts to the end user remove the prefix that
+ // corresponds to the ~/MyFiles directory.
+ child_path.remove_prefix(remove_prefix_size);
+ base::FilePath stripped_path(child_path);
+ if (PathHasDotFile(stripped_path)) {
+ continue;
+ }
+ child_folders.push_back(std::move(stripped_path));
+ }
+ base::ranges::sort(child_folders);
+ return child_folders;
+}
+
+} // namespace
+
+ManageMirrorSyncPageHandler::ManageMirrorSyncPageHandler(
+ mojo::PendingReceiver<manage_mirrorsync::mojom::PageHandler>
+ pending_page_handler,
+ Profile* profile)
+ : profile_(profile),
+ my_files_dir_(file_manager::util::GetMyFilesFolderForProfile(profile)),
+ receiver_{this, std::move(pending_page_handler)} {}
+
+ManageMirrorSyncPageHandler::~ManageMirrorSyncPageHandler() = default;
+
+void ManageMirrorSyncPageHandler::GetChildFolders(
+ const base::FilePath& path,
+ GetChildFoldersCallback callback) {
+ if (path.empty() || !path.IsAbsolute() || path.ReferencesParent()) {
+ LOG(ERROR) << "Supplied path is invalid";
+ std::move(callback).Run({});
+ return;
+ }
+
+ base::StringPiece path_piece(path.value());
+ if (path_piece[0] != '/') {
+ LOG(ERROR) << "Supplied directory doesn't have leading slash";
+ std::move(callback).Run({});
+ return;
+ }
+
+ path_piece.remove_prefix(1);
+ base::FilePath absolute_path = my_files_dir_.Append(path_piece);
+
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock()},
+ base::BindOnce(&base::DirectoryExists, absolute_path),
+ base::BindOnce(&ManageMirrorSyncPageHandler::OnDirectoryExists,
+ weak_ptr_factory_.GetWeakPtr(), absolute_path,
+ std::move(callback)));
+}
+
+void ManageMirrorSyncPageHandler::OnDirectoryExists(
+ const base::FilePath& absolute_path,
+ GetChildFoldersCallback callback,
+ bool exists) {
+ if (!exists) {
+ LOG(ERROR) << "Directory doesn't exist";
+ std::move(callback).Run({});
+ return;
+ }
+
+ const int dir_prefix_size =
+ my_files_dir_.StripTrailingSeparators().value().size();
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock()},
+ base::BindOnce(&GetChildFoldersBlocking, absolute_path, dir_prefix_size),
+ base::BindOnce(&ManageMirrorSyncPageHandler::OnGetChildFolders,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
+}
+
+void ManageMirrorSyncPageHandler::OnGetChildFolders(
+ GetChildFoldersCallback callback,
+ std::vector<base::FilePath> child_folders) {
+ std::move(callback).Run(std::move(child_folders));
+}
+
+using manage_mirrorsync::mojom::PageHandler;
+
+void ManageMirrorSyncPageHandler::GetSyncingPaths(
+ GetSyncingPathsCallback callback) {
+ drive::DriveIntegrationService* drive_service =
+ drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
+ if (drive_service == nullptr) {
+ LOG(ERROR) << "Drive service is not available";
+ std::move(callback).Run(PageHandler::GetSyncPathError::kServiceUnavailable,
+ {});
+ return;
+ }
+
+ drive_service->GetSyncingPaths(
+ base::BindOnce(&ManageMirrorSyncPageHandler::OnGetSyncingPaths,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
+}
+
+void ManageMirrorSyncPageHandler::OnGetSyncingPaths(
+ GetSyncingPathsCallback callback,
+ drive::FileError status,
+ const std::vector<base::FilePath>& syncing_paths) {
+ if (status != drive::FileError::FILE_ERROR_OK) {
+ LOG(ERROR) << "Failed retrieving sync paths: " << status;
+ const auto error =
+ (status == drive::FileError::FILE_ERROR_SERVICE_UNAVAILABLE)
+ ? PageHandler::GetSyncPathError::kServiceUnavailable
+ : PageHandler::GetSyncPathError::kFailed;
+ std::move(callback).Run(std::move(error), {});
+ return;
+ }
+
+ std::vector<base::FilePath> remapped_paths;
+ for (const base::FilePath& path : syncing_paths) {
+ if (!my_files_dir_.IsParent(path)) {
+ LOG(ERROR) << "Syncing path is not parented at MyFiles";
+ continue;
+ }
+ base::FilePath remapped_path("/");
+ my_files_dir_.AppendRelativePath(path, &remapped_path);
+ remapped_paths.push_back(std::move(remapped_path));
+ }
+ std::move(callback).Run(PageHandler::GetSyncPathError::kSuccess,
+ std::move(remapped_paths));
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h
new file mode 100644
index 00000000000..1337443645f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h
@@ -0,0 +1,67 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_PAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_PAGE_HANDLER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom.h"
+#include "components/drive/file_errors.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
+
+class Profile;
+
+namespace chromeos {
+
+// Handles communication from the chrome://manage-mirrorsync renderer process to
+// the browser process exposing various methods for the JS to invoke.
+class ManageMirrorSyncPageHandler
+ : public manage_mirrorsync::mojom::PageHandler {
+ public:
+ ManageMirrorSyncPageHandler(
+ mojo::PendingReceiver<manage_mirrorsync::mojom::PageHandler>
+ pending_page_handler,
+ Profile* profile);
+
+ ManageMirrorSyncPageHandler(const ManageMirrorSyncPageHandler&) = delete;
+ ManageMirrorSyncPageHandler& operator=(const ManageMirrorSyncPageHandler&) =
+ delete;
+
+ ~ManageMirrorSyncPageHandler() override;
+
+ // chromeos::manage_mirrorsync::mojom::PageHandler:
+ void GetChildFolders(const base::FilePath& path,
+ GetChildFoldersCallback callback) override;
+
+ void GetSyncingPaths(GetSyncingPathsCallback callback) override;
+
+ private:
+ void OnDirectoryExists(const base::FilePath& absolute_path,
+ GetChildFoldersCallback callback,
+ bool exists);
+
+ void OnGetChildFolders(GetChildFoldersCallback callback,
+ std::vector<base::FilePath> child_folders);
+
+ void OnGetSyncingPaths(GetSyncingPathsCallback callback,
+ drive::FileError error,
+ const std::vector<base::FilePath>& syncing_paths);
+
+ raw_ptr<Profile> profile_;
+ const base::FilePath my_files_dir_;
+ mojo::Receiver<manage_mirrorsync::mojom::PageHandler> receiver_;
+ base::WeakPtrFactory<ManageMirrorSyncPageHandler> weak_ptr_factory_{this};
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.cc
new file mode 100644
index 00000000000..e14888f12cf
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.cc
@@ -0,0 +1,51 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/manage_mirrorsync_resources.h"
+#include "chrome/grit/manage_mirrorsync_resources_map.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/webui/mojo_web_ui_controller.h"
+
+namespace chromeos {
+
+ManageMirrorSyncUI::ManageMirrorSyncUI(content::WebUI* web_ui)
+ : ui::MojoWebDialogUI{web_ui} {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIManageMirrorSyncHost);
+ auto* profile = Profile::FromWebUI(web_ui);
+ webui::SetupWebUIDataSource(source,
+ base::make_span(kManageMirrorsyncResources,
+ kManageMirrorsyncResourcesSize),
+ IDR_MANAGE_MIRRORSYNC_INDEX_HTML);
+
+ content::WebUIDataSource::Add(profile, source);
+}
+
+ManageMirrorSyncUI::~ManageMirrorSyncUI() = default;
+
+void ManageMirrorSyncUI::BindInterface(
+ mojo::PendingReceiver<
+ chromeos::manage_mirrorsync::mojom::PageHandlerFactory>
+ pending_receiver) {
+ if (factory_receiver_.is_bound()) {
+ factory_receiver_.reset();
+ }
+ factory_receiver_.Bind(std::move(pending_receiver));
+}
+
+void ManageMirrorSyncUI::CreatePageHandler(
+ mojo::PendingReceiver<chromeos::manage_mirrorsync::mojom::PageHandler>
+ receiver) {
+ page_handler_ = std::make_unique<ManageMirrorSyncPageHandler>(
+ std::move(receiver), Profile::FromWebUI(web_ui()));
+}
+
+WEB_UI_CONTROLLER_TYPE_IMPL(ManageMirrorSyncUI)
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h
new file mode 100644
index 00000000000..3b4027697f1
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_ui.h
@@ -0,0 +1,47 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_UI_H_
+
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync.mojom.h"
+#include "chrome/browser/ui/webui/chromeos/manage_mirrorsync/manage_mirrorsync_page_handler.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+// The WebUI for chrome://manage-mirrorsync.
+class ManageMirrorSyncUI
+ : public ui::MojoWebDialogUI,
+ public chromeos::manage_mirrorsync::mojom::PageHandlerFactory {
+ public:
+ explicit ManageMirrorSyncUI(content::WebUI* web_ui);
+
+ ManageMirrorSyncUI(const ManageMirrorSyncUI&) = delete;
+ ManageMirrorSyncUI& operator=(const ManageMirrorSyncUI&) = delete;
+
+ ~ManageMirrorSyncUI() override;
+
+ // Instantiates implementor of the mojom::PageHandlerFactory
+ // mojo interface passing the pending receiver that will be internally bound.
+ void BindInterface(mojo::PendingReceiver<
+ chromeos::manage_mirrorsync::mojom::PageHandlerFactory>
+ pending_receiver);
+
+ // chromeos::manage_mirrorsync::mojom::PageHandlerFactory:
+ void CreatePageHandler(
+ mojo::PendingReceiver<chromeos::manage_mirrorsync::mojom::PageHandler>
+ pending_page_handler) override;
+
+ private:
+ std::unique_ptr<ManageMirrorSyncPageHandler> page_handler_;
+ mojo::Receiver<chromeos::manage_mirrorsync::mojom::PageHandlerFactory>
+ factory_receiver_{this};
+
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MANAGE_MIRRORSYNC_MANAGE_MIRRORSYNC_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
index 23ba50b72dc..a56abdbfe74 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
@@ -24,15 +24,15 @@ const char kLogMessageSeverityKey[] = "severity";
// Converts |log_message| to a raw dictionary value used as a JSON argument to
// JavaScript functions.
-base::Value LogMessageToDictionary(const LogBuffer::LogMessage& log_message) {
- base::Value dictionary(base::Value::Type::DICTIONARY);
- dictionary.SetStringKey(kLogMessageTextKey, log_message.text);
- dictionary.SetStringKey(
- kLogMessageTimeKey,
- base::TimeFormatTimeOfDayWithMilliseconds(log_message.time));
- dictionary.SetStringKey(kLogMessageFileKey, log_message.file);
- dictionary.SetIntKey(kLogMessageLineKey, log_message.line);
- dictionary.SetIntKey(kLogMessageSeverityKey, log_message.severity);
+base::Value::Dict LogMessageToDictionary(
+ const LogBuffer::LogMessage& log_message) {
+ base::Value::Dict dictionary;
+ dictionary.Set(kLogMessageTextKey, log_message.text);
+ dictionary.Set(kLogMessageTimeKey,
+ base::TimeFormatTimeOfDayWithMilliseconds(log_message.time));
+ dictionary.Set(kLogMessageFileKey, log_message.file);
+ dictionary.Set(kLogMessageLineKey, log_message.line);
+ dictionary.Set(kLogMessageSeverityKey, log_message.severity);
return dictionary;
}
@@ -43,7 +43,7 @@ MultideviceLogsHandler::MultideviceLogsHandler() {}
MultideviceLogsHandler::~MultideviceLogsHandler() = default;
void MultideviceLogsHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getMultideviceLogMessages",
base::BindRepeating(&MultideviceLogsHandler::HandleGetLogMessages,
base::Unretained(this)));
@@ -57,10 +57,11 @@ void MultideviceLogsHandler::OnJavascriptDisallowed() {
observation_.Reset();
}
-void MultideviceLogsHandler::HandleGetLogMessages(const base::ListValue* args) {
+void MultideviceLogsHandler::HandleGetLogMessages(
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
- base::Value list(base::Value::Type::LIST);
+ const base::Value& callback_id = args[0];
+ base::Value::List list;
for (const auto& log : *LogBuffer::GetInstance()->logs()) {
list.Append(LogMessageToDictionary(log));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
index 5591e836696..66f3548960e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
@@ -7,12 +7,9 @@
#include "ash/components/multidevice/logging/log_buffer.h"
#include "base/scoped_observation.h"
+#include "base/values.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-} // namespace base
-
namespace chromeos {
namespace multidevice {
@@ -38,10 +35,10 @@ class MultideviceLogsHandler : public content::WebUIMessageHandler,
private:
// Message handler callback that returns the Log Buffer in dictionary form.
- void HandleGetLogMessages(const base::ListValue* args);
+ void HandleGetLogMessages(const base::Value::List& args);
// Message handler callback that clears the Log Buffer.
- void ClearLogBuffer(const base::ListValue* args);
+ void ClearLogBuffer(const base::Value::List& args);
base::ScopedObservation<LogBuffer, LogBuffer::Observer> observation_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
index 0fb6bc71d3e..ec0b17fe535 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
@@ -152,78 +152,78 @@ MultidevicePhoneHubHandler::~MultidevicePhoneHubHandler() {
}
void MultidevicePhoneHubHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFakePhoneHubManagerEnabled",
base::BindRepeating(
&MultidevicePhoneHubHandler::HandleEnableFakePhoneHubManager,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFeatureStatus",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFeatureStatus,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setShowOnboardingFlow",
base::BindRepeating(
&MultidevicePhoneHubHandler::HandleSetShowOnboardingFlow,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFakePhoneName",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFakePhoneName,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFakePhoneStatus",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFakePhoneStatus,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setBrowserTabs",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetBrowserTabs,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setNotification",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetNotification,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"removeNotification",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleRemoveNotification,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"enableDnd",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleEnableDnd,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFindMyDeviceStatus",
base::BindRepeating(
&MultidevicePhoneHubHandler::HandleSetFindMyDeviceStatus,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setTetherStatus",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetTetherStatus,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"resetShouldShowOnboardingUi",
base::BindRepeating(
&MultidevicePhoneHubHandler::HandleResetShouldShowOnboardingUi,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"resetHasMultideviceFeatureSetupUiBeenDismissed",
base::BindRepeating(
&MultidevicePhoneHubHandler::
HandleResetHasMultideviceFeatureSetupUiBeenDismissed,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setFakeCameraRoll",
base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFakeCameraRoll,
base::Unretained(this)));
@@ -259,7 +259,7 @@ void MultidevicePhoneHubHandler::RemoveObservers() {
void MultidevicePhoneHubHandler::OnNotificationsRemoved(
const base::flat_set<int64_t>& notification_ids) {
- base::ListValue removed_notification_id_js_list;
+ base::Value::List removed_notification_id_js_list;
for (const int64_t& id : notification_ids) {
removed_notification_id_js_list.Append(static_cast<double>(id));
}
@@ -297,15 +297,15 @@ void MultidevicePhoneHubHandler::OnShouldShowOnboardingUiChanged() {
}
void MultidevicePhoneHubHandler::OnCameraRollViewUiStateUpdated() {
- base::Value camera_roll_dict(base::Value::Type::DICTIONARY);
- camera_roll_dict.GetDict().Set(
- "isCameraRollEnabled", fake_phone_hub_manager_->fake_camera_roll_manager()
- ->is_camera_roll_enabled());
+ base::Value::Dict camera_roll_dict;
+ camera_roll_dict.Set("isCameraRollEnabled",
+ fake_phone_hub_manager_->fake_camera_roll_manager()
+ ->is_camera_roll_enabled());
FireWebUIListener("camera-roll-ui-view-state-updated", camera_roll_dict);
}
-void MultidevicePhoneHubHandler::HandleEnableDnd(const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+void MultidevicePhoneHubHandler::HandleEnableDnd(
+ const base::Value::List& list) {
CHECK(!list.empty());
const bool enabled = list[0].GetBool();
PA_LOG(VERBOSE) << "Setting Do Not Disturb state to " << enabled;
@@ -315,8 +315,7 @@ void MultidevicePhoneHubHandler::HandleEnableDnd(const base::ListValue* args) {
}
void MultidevicePhoneHubHandler::HandleSetFindMyDeviceStatus(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
CHECK_GE(list.size(), 1u);
int status_as_int = list[0].GetInt();
@@ -328,8 +327,7 @@ void MultidevicePhoneHubHandler::HandleSetFindMyDeviceStatus(
}
void MultidevicePhoneHubHandler::HandleSetTetherStatus(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
CHECK_GE(list.size(), 1u);
int status_as_int = list[0].GetInt();
@@ -366,9 +364,8 @@ void MultidevicePhoneHubHandler::EnableFakePhoneHubManager() {
}
void MultidevicePhoneHubHandler::HandleEnableFakePhoneHubManager(
- const base::ListValue* args) {
+ const base::Value::List& list) {
AllowJavascript();
- const auto& list = args->GetListDeprecated();
CHECK(!list.empty());
const bool enabled = list[0].GetBool();
if (enabled) {
@@ -379,8 +376,7 @@ void MultidevicePhoneHubHandler::HandleEnableFakePhoneHubManager(
}
void MultidevicePhoneHubHandler::HandleSetFeatureStatus(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
CHECK_GE(list.size(), 1u);
int feature_as_int = list[0].GetInt();
@@ -390,8 +386,7 @@ void MultidevicePhoneHubHandler::HandleSetFeatureStatus(
}
void MultidevicePhoneHubHandler::HandleSetShowOnboardingFlow(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
CHECK(!list.empty());
const bool show_onboarding_flow = list[0].GetBool();
PA_LOG(VERBOSE) << "Setting show onboarding flow to " << show_onboarding_flow;
@@ -400,8 +395,7 @@ void MultidevicePhoneHubHandler::HandleSetShowOnboardingFlow(
}
void MultidevicePhoneHubHandler::HandleSetFakePhoneName(
- const base::ListValue* args) {
- base::Value::ConstListView args_list = args->GetListDeprecated();
+ const base::Value::List& args_list) {
CHECK_GE(args_list.size(), 1u);
std::u16string phone_name = base::UTF8ToUTF16(args_list[0].GetString());
fake_phone_hub_manager_->mutable_phone_model()->SetPhoneName(phone_name);
@@ -409,8 +403,8 @@ void MultidevicePhoneHubHandler::HandleSetFakePhoneName(
}
void MultidevicePhoneHubHandler::HandleSetFakePhoneStatus(
- const base::ListValue* args) {
- const base::Value& phones_status_value = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ const base::Value& phones_status_value = args[0];
CHECK(phones_status_value.is_dict());
absl::optional<int> mobile_status_as_int =
@@ -471,8 +465,8 @@ void MultidevicePhoneHubHandler::HandleSetFakePhoneStatus(
}
void MultidevicePhoneHubHandler::HandleSetBrowserTabs(
- const base::ListValue* args) {
- const base::Value& browser_tab_status_value = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ const base::Value& browser_tab_status_value = args[0];
CHECK(browser_tab_status_value.is_dict());
const base::DictionaryValue* browser_tab_status_dict =
static_cast<const base::DictionaryValue*>(&browser_tab_status_value);
@@ -507,8 +501,8 @@ void MultidevicePhoneHubHandler::HandleSetBrowserTabs(
}
void MultidevicePhoneHubHandler::HandleSetNotification(
- const base::ListValue* args) {
- const base::Value& notification_data_value = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ const base::Value& notification_data_value = args[0];
CHECK(notification_data_value.is_dict());
absl::optional<int> id = notification_data_value.GetDict().FindInt("id");
@@ -583,8 +577,7 @@ void MultidevicePhoneHubHandler::HandleSetNotification(
}
void MultidevicePhoneHubHandler::HandleRemoveNotification(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
CHECK_GE(list.size(), 1u);
int notification_id = list[0].GetInt();
fake_phone_hub_manager_->fake_notification_manager()->RemoveNotification(
@@ -593,7 +586,7 @@ void MultidevicePhoneHubHandler::HandleRemoveNotification(
}
void MultidevicePhoneHubHandler::HandleResetShouldShowOnboardingUi(
- const base::ListValue* args) {
+ const base::Value::List& list) {
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetBoolean(phonehub::prefs::kHideOnboardingUi, false);
PA_LOG(VERBOSE) << "Reset kHideOnboardingUi pref";
@@ -601,15 +594,15 @@ void MultidevicePhoneHubHandler::HandleResetShouldShowOnboardingUi(
void MultidevicePhoneHubHandler::
HandleResetHasMultideviceFeatureSetupUiBeenDismissed(
- const base::ListValue* args) {
+ const base::Value::List& list) {
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetBoolean(phonehub::prefs::kHasDismissedSetupRequiredUi, false);
PA_LOG(VERBOSE) << "Reset kHasDismissedSetupRequiredUi pref";
}
void MultidevicePhoneHubHandler::HandleSetFakeCameraRoll(
- const base::ListValue* args) {
- const base::Value& camera_roll_dict = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ const base::Value& camera_roll_dict = args[0];
CHECK(camera_roll_dict.is_dict());
absl::optional<bool> is_camera_roll_enabled =
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
index 7bfb7b44ca1..68427e9a017 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
@@ -62,21 +62,21 @@ class MultidevicePhoneHubHandler
void EnableRealPhoneHubManager();
void EnableFakePhoneHubManager();
- void HandleEnableFakePhoneHubManager(const base::ListValue* args);
- void HandleSetFeatureStatus(const base::ListValue* args);
- void HandleSetShowOnboardingFlow(const base::ListValue* args);
- void HandleSetFakePhoneName(const base::ListValue* args);
- void HandleSetFakePhoneStatus(const base::ListValue* args);
- void HandleSetBrowserTabs(const base::ListValue* args);
- void HandleSetNotification(const base::ListValue* args);
- void HandleRemoveNotification(const base::ListValue* args);
- void HandleEnableDnd(const base::ListValue* args);
- void HandleSetFindMyDeviceStatus(const base::ListValue* args);
- void HandleSetTetherStatus(const base::ListValue* args);
- void HandleResetShouldShowOnboardingUi(const base::ListValue* args);
+ void HandleEnableFakePhoneHubManager(const base::Value::List& args);
+ void HandleSetFeatureStatus(const base::Value::List& args);
+ void HandleSetShowOnboardingFlow(const base::Value::List& args);
+ void HandleSetFakePhoneName(const base::Value::List& args);
+ void HandleSetFakePhoneStatus(const base::Value::List& args);
+ void HandleSetBrowserTabs(const base::Value::List& args);
+ void HandleSetNotification(const base::Value::List& args);
+ void HandleRemoveNotification(const base::Value::List& args);
+ void HandleEnableDnd(const base::Value::List& args);
+ void HandleSetFindMyDeviceStatus(const base::Value::List& args);
+ void HandleSetTetherStatus(const base::Value::List& args);
+ void HandleResetShouldShowOnboardingUi(const base::Value::List& args);
void HandleResetHasMultideviceFeatureSetupUiBeenDismissed(
- const base::ListValue* args);
- void HandleSetFakeCameraRoll(const base::ListValue* args);
+ const base::Value::List& args);
+ void HandleSetFakeCameraRoll(const base::Value::List& args);
void AddObservers();
void RemoveObservers();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
index 75f0e27b42c..23db4ddb4c4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
@@ -24,11 +24,11 @@ MultideviceSetupHandler::MultideviceSetupHandler() = default;
MultideviceSetupHandler::~MultideviceSetupHandler() = default;
void MultideviceSetupHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getProfileInfo",
base::BindRepeating(&MultideviceSetupHandler::HandleGetProfileInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"openMultiDeviceSettings",
base::BindRepeating(
&MultideviceSetupHandler::HandleOpenMultiDeviceSettings,
@@ -36,30 +36,30 @@ void MultideviceSetupHandler::RegisterMessages() {
}
void MultideviceSetupHandler::HandleGetProfileInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- DCHECK(!args->GetListDeprecated().empty());
- std::string callback_id = args->GetListDeprecated()[0].GetString();
+ DCHECK(!args.empty());
+ std::string callback_id = args[0].GetString();
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(
Profile::FromWebUI(web_ui()));
- base::DictionaryValue response;
- response.SetStringKey("email", user->GetDisplayEmail());
+ base::Value::Dict response;
+ response.Set("email", user->GetDisplayEmail());
scoped_refptr<base::RefCountedMemory> image =
chromeos::UserImageSource::GetUserImage(user->GetAccountId());
- response.SetStringKey("profilePhotoUrl",
- webui::GetPngDataUrl(image->front(), image->size()));
+ response.Set("profilePhotoUrl",
+ webui::GetPngDataUrl(image->front(), image->size()));
ResolveJavascriptCallback(base::Value(callback_id), response);
}
void MultideviceSetupHandler::HandleOpenMultiDeviceSettings(
- const base::ListValue* args) {
- DCHECK(args->GetListDeprecated().empty());
+ const base::Value::List& args) {
+ DCHECK(args.empty());
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
Profile::FromWebUI(web_ui()),
chromeos::settings::mojom::kMultiDeviceFeaturesSubpagePath);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h
index a4c64b12b6b..1db39cfab91 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h
@@ -25,8 +25,8 @@ class MultideviceSetupHandler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler:
void RegisterMessages() override;
- void HandleGetProfileInfo(const base::ListValue* args);
- void HandleOpenMultiDeviceSettings(const base::ListValue* args);
+ void HandleGetProfileInfo(const base::Value::List& args);
+ void HandleOpenMultiDeviceSettings(const base::Value::List& args);
};
} // namespace multidevice_setup
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc
index 117f6243db5..f5c6c8f9fee 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc
@@ -18,8 +18,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
+#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#include "components/policy/core/browser/policy_conversions.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -53,9 +52,9 @@ bool WriteTimestampedFile(const base::FilePath& file_path,
return bytes_written > 0;
}
-bool GetBoolOrFalse(const base::Value& dict, const char* keyname) {
- const base::Value* key = dict.FindKey(keyname);
- return key && key->GetBool();
+bool GetBoolOrFalse(const base::Value::Dict& dict, const char* keyname) {
+ const auto key = dict.FindBool(keyname);
+ return key && *key;
}
} // namespace
@@ -66,10 +65,10 @@ NetworkLogsMessageHandler::~NetworkLogsMessageHandler() = default;
void NetworkLogsMessageHandler::RegisterMessages() {
out_dir_ = GetDownloadsDirectory(web_ui());
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"storeLogs", base::BindRepeating(&NetworkLogsMessageHandler::OnStoreLogs,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setShillDebugging",
base::BindRepeating(&NetworkLogsMessageHandler::OnSetShillDebugging,
base::Unretained(this)));
@@ -78,16 +77,16 @@ void NetworkLogsMessageHandler::RegisterMessages() {
void NetworkLogsMessageHandler::Respond(const std::string& callback_id,
const std::string& result,
bool is_error) {
- base::Value response(base::Value::Type::LIST);
+ base::Value::List response;
response.Append(result);
response.Append(is_error);
ResolveJavascriptCallback(base::Value(callback_id), response);
}
-void NetworkLogsMessageHandler::OnStoreLogs(const base::ListValue* list) {
- CHECK_EQ(2u, list->GetListDeprecated().size());
- std::string callback_id = list->GetListDeprecated()[0].GetString();
- const base::Value& options = list->GetListDeprecated()[1];
+void NetworkLogsMessageHandler::OnStoreLogs(const base::Value::List& list) {
+ CHECK_EQ(2u, list.size());
+ std::string callback_id = list[0].GetString();
+ const base::Value::Dict& options = list[1].GetDict();
AllowJavascript();
if (GetBoolOrFalse(options, "systemLogs")) {
@@ -104,7 +103,7 @@ void NetworkLogsMessageHandler::OnStoreLogs(const base::ListValue* list) {
void NetworkLogsMessageHandler::OnWriteSystemLogs(
const std::string& callback_id,
- base::Value&& options,
+ base::Value::Dict&& options,
absl::optional<base::FilePath> syslogs_path) {
if (!syslogs_path) {
Respond(callback_id, "Error writing system logs file.", /*is_error=*/true);
@@ -115,7 +114,7 @@ void NetworkLogsMessageHandler::OnWriteSystemLogs(
void NetworkLogsMessageHandler::MaybeWriteDebugLogs(
const std::string& callback_id,
- base::Value&& options) {
+ base::Value::Dict&& options) {
if (GetBoolOrFalse(options, "debugLogs")) {
if (!base::SysInfo::IsRunningOnChromeOS()) {
Respond(callback_id, "Debug logs unavailable on Linux build.",
@@ -135,7 +134,7 @@ void NetworkLogsMessageHandler::MaybeWriteDebugLogs(
void NetworkLogsMessageHandler::OnWriteDebugLogs(
const std::string& callback_id,
- base::Value&& options,
+ base::Value::Dict&& options,
absl::optional<base::FilePath> logs_path) {
if (!logs_path) {
Respond(callback_id, "Error writing debug logs.", /*is_error=*/true);
@@ -146,7 +145,7 @@ void NetworkLogsMessageHandler::OnWriteDebugLogs(
void NetworkLogsMessageHandler::MaybeWritePolicies(
const std::string& callback_id,
- base::Value&& options) {
+ base::Value::Dict&& options) {
if (GetBoolOrFalse(options, "policies")) {
std::string json_policies = GetJsonPolicies(web_ui());
base::ThreadPool::PostTaskAndReplyWithResult(
@@ -179,12 +178,12 @@ void NetworkLogsMessageHandler::OnWriteSystemLogsCompleted(
}
void NetworkLogsMessageHandler::OnSetShillDebugging(
- const base::ListValue* list) {
- CHECK_EQ(2u, list->GetListDeprecated().size());
- std::string callback_id = list->GetListDeprecated()[0].GetString();
- std::string subsystem = list->GetListDeprecated()[1].GetString();
+ const base::Value::List& list) {
+ CHECK_EQ(2u, list.size());
+ std::string callback_id = list[0].GetString();
+ std::string subsystem = list[1].GetString();
AllowJavascript();
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->SetDebugMode(
+ chromeos::DebugDaemonClient::Get()->SetDebugMode(
subsystem,
base::BindOnce(&NetworkLogsMessageHandler::OnSetShillDebuggingCompleted,
weak_factory_.GetWeakPtr(), callback_id));
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h
index 3623d37c6bc..42fa3e614e4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.h
@@ -30,20 +30,20 @@ class NetworkLogsMessageHandler : public content::WebUIMessageHandler {
void Respond(const std::string& callback_id,
const std::string& result,
bool is_error);
- void OnStoreLogs(const base::ListValue* list);
+ void OnStoreLogs(const base::Value::List& list);
void OnWriteSystemLogs(const std::string& callback_id,
- base::Value&& options,
+ base::Value::Dict&& options,
absl::optional<base::FilePath> syslogs_path);
void MaybeWriteDebugLogs(const std::string& callback_id,
- base::Value&& options);
+ base::Value::Dict&& options);
void OnWriteDebugLogs(const std::string& callback_id,
- base::Value&& options,
+ base::Value::Dict&& options,
absl::optional<base::FilePath> logs_path);
void MaybeWritePolicies(const std::string& callback_id,
- base::Value&& options);
+ base::Value::Dict&& options);
void OnWritePolicies(const std::string& callback_id, bool result);
void OnWriteSystemLogsCompleted(const std::string& callback_id);
- void OnSetShillDebugging(const base::ListValue* list);
+ void OnSetShillDebugging(const base::Value::List& list);
void OnSetShillDebuggingCompleted(const std::string& callback_id,
bool succeeded);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
index 914ad739812..1ac4078a2b3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
@@ -8,6 +8,7 @@
#include <string>
#include <utility>
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/esim_manager.h"
#include "ash/public/cpp/network_config_service.h"
#include "ash/services/cellular_setup/public/mojom/esim_manager.mojom.h"
@@ -15,6 +16,7 @@
#include "ash/webui/network_ui/network_health_resource_provider.h"
#include "ash/webui/network_ui/traffic_counters_resource_provider.h"
#include "base/bind.h"
+#include "base/json/json_reader.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ash/net/network_health/network_health_service.h"
@@ -32,17 +34,18 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/network_ui_resources.h"
#include "chrome/grit/network_ui_resources_map.h"
+#include "chromeos/ash/components/dbus/shill/shill_manager_client.h"
+#include "chromeos/ash/components/network/cellular_esim_profile_handler.h"
+#include "chromeos/ash/components/network/cellular_esim_profile_handler_impl.h"
+#include "chromeos/ash/components/network/cellular_esim_uninstall_handler.h"
+#include "chromeos/ash/components/network/cellular_utils.h"
+#include "chromeos/ash/components/network/device_state.h"
+#include "chromeos/ash/components/network/managed_network_configuration_handler.h"
+#include "chromeos/ash/components/network/network_configuration_handler.h"
+#include "chromeos/ash/components/network/network_device_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/ash/components/network/onc/network_onc_utils.h"
-#include "chromeos/network/cellular_esim_profile_handler.h"
-#include "chromeos/network/cellular_esim_profile_handler_impl.h"
-#include "chromeos/network/cellular_esim_uninstall_handler.h"
-#include "chromeos/network/cellular_utils.h"
-#include "chromeos/network/device_state.h"
-#include "chromeos/network/managed_network_configuration_handler.h"
-#include "chromeos/network/network_configuration_handler.h"
-#include "chromeos/network/network_device_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "chromeos/services/network_health/public/mojom/network_diagnostics.mojom.h"
#include "chromeos/services/network_health/public/mojom/network_health.mojom.h"
@@ -66,6 +69,8 @@ namespace {
constexpr char kAddNetwork[] = "addNetwork";
constexpr char kDisableESimProfile[] = "disableActiveESimProfile";
constexpr char kGetNetworkProperties[] = "getShillNetworkProperties";
+constexpr char kGetFirstWifiNetworkProperties[] =
+ "getFirstWifiNetworkProperties";
constexpr char kGetDeviceProperties[] = "getShillDeviceProperties";
constexpr char kGetEthernetEAP[] = "getShillEthernetEAP";
constexpr char kOpenCellularActivationUi[] = "openCellularActivationUi";
@@ -76,6 +81,12 @@ constexpr char kShowNetworkConfig[] = "showNetworkConfig";
constexpr char kShowAddNewWifiNetworkDialog[] = "showAddNewWifi";
constexpr char kGetHostname[] = "getHostname";
constexpr char kSetHostname[] = "setHostname";
+constexpr char kGetTetheringCapabilities[] = "getTetheringCapabilities";
+constexpr char kGetTetheringStatus[] = "getTetheringStatus";
+constexpr char kGetTetheringConfig[] = "getTetheringConfig";
+constexpr char kSetTetheringConfig[] = "setTetheringConfig";
+constexpr char kCheckTetheringReadiness[] = "checkTetheringReadiness";
+constexpr char kSetTetheringEnabled[] = "setTetheringEnabled";
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path) {
@@ -88,9 +99,9 @@ bool GetServicePathFromGuid(const std::string& guid,
return true;
}
-void SetDeviceProperties(base::Value* dictionary) {
- const std::string* device =
- dictionary->GetDict().FindString(shill::kDeviceProperty);
+void SetDeviceProperties(base::Value::Dict* dictionary) {
+ DCHECK(dictionary);
+ const std::string* device = dictionary->FindString(shill::kDeviceProperty);
if (!device)
return;
const DeviceState* device_state =
@@ -98,19 +109,17 @@ void SetDeviceProperties(base::Value* dictionary) {
if (!device_state)
return;
- base::Value device_dictionary(device_state->properties().Clone());
- if (!device_state->ip_configs().DictEmpty()) {
+ base::Value::Dict device_dictionary = device_state->properties().Clone();
+ if (!device_state->ip_configs().empty()) {
// Convert IPConfig dictionary to a ListValue.
- base::Value ip_configs(base::Value::Type::LIST);
- for (auto iter : device_state->ip_configs().DictItems()) {
+ base::Value::List ip_configs;
+ for (auto iter : device_state->ip_configs()) {
ip_configs.Append(iter.second.Clone());
}
- device_dictionary.GetDict().Set(shill::kIPConfigsProperty,
- std::move(ip_configs));
+ device_dictionary.Set(shill::kIPConfigsProperty, std::move(ip_configs));
}
- if (!device_dictionary.DictEmpty())
- dictionary->GetDict().Set(shill::kDeviceProperty,
- std::move(device_dictionary));
+ if (!device_dictionary.empty())
+ dictionary->Set(shill::kDeviceProperty, std::move(device_dictionary));
}
bool IsGuestModeActive() {
@@ -214,6 +223,11 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
&NetworkConfigMessageHandler::GetShillNetworkProperties,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ kGetFirstWifiNetworkProperties,
+ base::BindRepeating(
+ &NetworkConfigMessageHandler::GetFirstWifiNetworkProperties,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
kGetDeviceProperties,
base::BindRepeating(
&NetworkConfigMessageHandler::GetShillDeviceProperties,
@@ -263,7 +277,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
}
private:
- void Respond(const std::string& callback_id, const base::Value& response) {
+ void Respond(const std::string& callback_id, const base::ValueView response) {
AllowJavascript();
ResolveJavascriptCallback(base::Value(callback_id), response);
}
@@ -272,7 +286,23 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
CHECK_EQ(2u, arg_list.size());
std::string callback_id = arg_list[0].GetString();
std::string guid = arg_list[1].GetString();
+ ProvideNetworkProperties(callback_id, guid);
+ }
+
+ void GetFirstWifiNetworkProperties(const base::Value::List& arg_list) {
+ std::string callback_id = arg_list[0].GetString();
+ const NetworkState* wifi_network =
+ NetworkHandler::Get()->network_state_handler()->FirstNetworkByType(
+ NetworkTypePattern::WiFi());
+ if (wifi_network) {
+ ProvideNetworkProperties(callback_id, wifi_network->guid());
+ return;
+ }
+ Respond(callback_id, base::Value::List());
+ }
+ void ProvideNetworkProperties(const std::string& callback_id,
+ const std::string& guid) {
std::string service_path;
if (!GetServicePathFromGuid(guid, &service_path)) {
RunErrorCallback(callback_id, guid, kGetNetworkProperties,
@@ -297,8 +327,8 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
// Set the 'service_path' property for debugging.
result->GetDict().Set("service_path", base::Value(service_path));
// Set the device properties for debugging.
- SetDeviceProperties(&result.value());
- base::ListValue return_arg_list;
+ SetDeviceProperties(result->GetIfDict());
+ base::Value::List return_arg_list;
return_arg_list.Append(std::move(*result));
Respond(callback_id, return_arg_list);
}
@@ -333,15 +363,15 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
&list);
if (list.empty()) {
- Respond(callback_id, base::Value(base::Value::Type::LIST));
+ Respond(callback_id, base::Value::List());
return;
}
const NetworkState* eap = list.front();
- base::Value properties(base::Value::Type::DICTIONARY);
- properties.GetDict().Set("guid", eap->guid());
- properties.GetDict().Set("name", eap->name());
- properties.GetDict().Set("type", eap->type());
- base::Value response(base::Value::Type::LIST);
+ base::Value::Dict properties;
+ properties.Set("guid", eap->guid());
+ properties.Set("name", eap->name());
+ properties.Set("type", eap->type());
+ base::Value::List response;
response.Append(std::move(properties));
Respond(callback_id, response);
}
@@ -357,7 +387,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
SystemTrayClientImpl::Get()->ShowSettingsCellularSetup(
/*show_psim_flow=*/true);
}
- base::Value response(base::Value::Type::LIST);
+ base::Value::List response;
response.Append(base::Value(cellular_network != nullptr));
Respond(callback_id, response);
}
@@ -436,7 +466,7 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
// Set the 'device_path' property for debugging.
result->GetDict().Set("device_path", base::Value(device_path));
- base::ListValue return_arg_list;
+ base::Value::List return_arg_list;
return_arg_list.Append(std::move(*result));
Respond(callback_id, return_arg_list);
}
@@ -469,13 +499,13 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
const std::string& function_name,
const std::string& error_name) {
NET_LOG(ERROR) << "Shill Error: " << error_name << " id=" << guid_or_type;
- base::ListValue return_arg_list;
- base::Value dictionary(base::Value::Type::DICTIONARY);
+ base::Value::List return_arg_list;
+ base::Value::Dict dictionary;
std::string key = function_name == kGetDeviceProperties
? shill::kTypeProperty
: shill::kGuidProperty;
- dictionary.GetDict().Set(key, base::Value(guid_or_type));
- dictionary.GetDict().Set("ShillError", base::Value(error_name));
+ dictionary.Set(key, base::Value(guid_or_type));
+ dictionary.Set("ShillError", base::Value(error_name));
return_arg_list.Append(std::move(dictionary));
Respond(callback_id, return_arg_list);
}
@@ -489,6 +519,187 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
base::WeakPtrFactory<NetworkConfigMessageHandler> weak_ptr_factory_{this};
};
+class HotspotConfigMessageHandler : public content::WebUIMessageHandler {
+ public:
+ HotspotConfigMessageHandler() = default;
+ ~HotspotConfigMessageHandler() override = default;
+
+ // WebUIMessageHandler implementation.
+ void RegisterMessages() override {
+ web_ui()->RegisterMessageCallback(
+ kGetTetheringCapabilities,
+ base::BindRepeating(
+ &HotspotConfigMessageHandler::GetTetheringCapabilities,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kGetTetheringStatus,
+ base::BindRepeating(&HotspotConfigMessageHandler::GetTetheringStatus,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kGetTetheringConfig,
+ base::BindRepeating(&HotspotConfigMessageHandler::GetTetheringConfig,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kSetTetheringConfig,
+ base::BindRepeating(&HotspotConfigMessageHandler::SetTetheringConfig,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kCheckTetheringReadiness,
+ base::BindRepeating(
+ &HotspotConfigMessageHandler::CheckTetheringReadiness,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kSetTetheringEnabled,
+ base::BindRepeating(&HotspotConfigMessageHandler::SetTetheringEnabled,
+ base::Unretained(this)));
+ }
+
+ private:
+ void Respond(const std::string& callback_id, const base::ValueView response) {
+ AllowJavascript();
+ ResolveJavascriptCallback(base::Value(callback_id), response);
+ }
+
+ void GetTetheringCapabilities(const base::Value::List& arg_list) {
+ CHECK_EQ(1u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+
+ ShillManagerClient::Get()->GetProperties(base::BindOnce(
+ &HotspotConfigMessageHandler::OnGetShillManagerDictPropertiesByKey,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ shill::kTetheringCapabilitiesProperty));
+ }
+
+ void GetTetheringStatus(const base::Value::List& arg_list) {
+ CHECK_EQ(1u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+
+ ShillManagerClient::Get()->GetProperties(base::BindOnce(
+ &HotspotConfigMessageHandler::OnGetShillManagerDictPropertiesByKey,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ shill::kTetheringStatusProperty));
+ }
+
+ void GetTetheringConfig(const base::Value::List& arg_list) {
+ CHECK_EQ(1u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+
+ ShillManagerClient::Get()->GetProperties(base::BindOnce(
+ &HotspotConfigMessageHandler::OnGetShillManagerDictPropertiesByKey,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ shill::kTetheringConfigProperty));
+ }
+
+ void CheckTetheringReadiness(const base::Value::List& arg_list) {
+ CHECK_EQ(1u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+
+ ShillManagerClient::Get()->CheckTetheringReadiness(
+ base::BindOnce(&HotspotConfigMessageHandler::RespondStringResult,
+ weak_ptr_factory_.GetWeakPtr(), callback_id),
+ base::BindOnce(&HotspotConfigMessageHandler::RespondError,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ kCheckTetheringReadiness));
+ }
+
+ void SetTetheringEnabled(const base::Value::List& arg_list) {
+ CHECK_EQ(2u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+ bool enabled = arg_list[1].GetBool();
+
+ // Enable TetheringAllowed flag in Shill manager before turning on/off
+ // tethering.
+ ShillManagerClient::Get()->SetProperty(
+ shill::kTetheringAllowedProperty, base::Value(true),
+ base::BindOnce(&HotspotConfigMessageHandler::PerformSetTetheringEnabled,
+ weak_ptr_factory_.GetWeakPtr(), callback_id, enabled),
+ base::BindOnce(
+ &HotspotConfigMessageHandler::SetManagerPropertiesErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ shill::kTetheringConfigProperty));
+ }
+
+ void PerformSetTetheringEnabled(const std::string& callback_id,
+ bool enabled) {
+ ShillManagerClient::Get()->SetTetheringEnabled(
+ enabled,
+ base::BindOnce(&HotspotConfigMessageHandler::RespondStringResult,
+ weak_ptr_factory_.GetWeakPtr(), callback_id, "success"),
+ base::BindOnce(&HotspotConfigMessageHandler::RespondError,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ kSetTetheringEnabled));
+ }
+
+ void SetTetheringConfig(const base::Value::List& arg_list) {
+ CHECK_EQ(2u, arg_list.size());
+ std::string callback_id = arg_list[0].GetString();
+ std::string tethering_config = arg_list[1].GetString();
+ absl::optional<base::Value> value =
+ base::JSONReader::Read(tethering_config);
+
+ if (!value || !value->is_dict()) {
+ NET_LOG(ERROR) << "Invalid tethering configuration: " << tethering_config;
+ Respond(callback_id, base::Value("Invalid tethering configuration"));
+ return;
+ }
+ NET_LOG(USER) << "SetManagerProperty: " << shill::kTetheringConfigProperty
+ << ": " << *value;
+ ShillManagerClient::Get()->SetProperty(
+ shill::kTetheringConfigProperty, *value,
+ base::BindOnce(&HotspotConfigMessageHandler::RespondStringResult,
+ weak_ptr_factory_.GetWeakPtr(), callback_id, "success"),
+ base::BindOnce(
+ &HotspotConfigMessageHandler::SetManagerPropertiesErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(), callback_id,
+ shill::kTetheringConfigProperty));
+ }
+
+ void OnGetShillManagerDictPropertiesByKey(
+ const std::string& callback_id,
+ const std::string& dict_key,
+ absl::optional<base::Value> properties) {
+ if (!properties) {
+ NET_LOG(ERROR) << "Error getting Shill manager properties.";
+ Respond(callback_id,
+ base::Value("Error getting Shill manager properties."));
+ return;
+ }
+
+ const base::Value::Dict* value = properties->GetDict().FindDict(dict_key);
+ if (value)
+ Respond(callback_id, *value);
+ else
+ Respond(callback_id, base::Value::Dict());
+ }
+
+ void SetManagerPropertiesErrorCallback(
+ const std::string& callback_id,
+ const std::string& property_name,
+ const std::string& dbus_error_name,
+ const std::string& dbus_error_message) {
+ NET_LOG(ERROR) << "Error setting Shill manager properties: "
+ << property_name << ", error: " << dbus_error_name
+ << ", message: " << dbus_error_message;
+ Respond(callback_id, base::Value(dbus_error_name));
+ }
+
+ void RespondError(const std::string& callback_id,
+ const std::string& operation,
+ const std::string& error_name,
+ const std::string& error_message) {
+ NET_LOG(ERROR) << "Error occured when " << operation << ": " << error_name
+ << ", error message: " << error_message;
+ Respond(callback_id, base::Value(error_name));
+ }
+
+ void RespondStringResult(const std::string& callback_id,
+ const std::string& result) {
+ Respond(callback_id, base::Value(result));
+ }
+
+ base::WeakPtrFactory<HotspotConfigMessageHandler> weak_ptr_factory_{this};
+};
+
} // namespace network_ui
// static
@@ -510,6 +721,12 @@ base::Value::Dict NetworkUI::GetLocalizedStrings() {
localized_strings.Set(
"networkSelectTab",
l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_SELECT));
+ localized_strings.Set(
+ "networkHotspotTab",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_HOTSPOT));
+ localized_strings.Set(
+ "networkMetricsTab",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TAB_NETWORK_METRICS));
localized_strings.Set("autoRefreshText",
l10n_util::GetStringUTF16(IDS_NETWORK_UI_AUTO_REFRESH));
@@ -647,6 +864,64 @@ base::Value::Dict NetworkUI::GetLocalizedStrings() {
localized_strings.Set(
"NetworkDiagnosticsSendFeedback",
l10n_util::GetStringUTF16(IDS_NETWORK_DIAGNOSTICS_SEND_FEEDBACK));
+
+ // Network Metrics
+ localized_strings.Set(
+ "networkMetricsLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_METRICS_LABEL));
+ localized_strings.Set(
+ "renderGraphButtonText",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_METRICS_RENDER_BUTTON));
+ localized_strings.Set(
+ "startPlotsButtonText",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_METRICS_START_BUTTON));
+ localized_strings.Set(
+ "stopPlotsButtonText",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NETWORK_METRICS_STOP_BUTTON));
+ localized_strings.Set(
+ "increaseRateButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_NETWORK_METRICS_INCREASE_RATE_BUTTON));
+ localized_strings.Set(
+ "decreaseRateButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_NETWORK_METRICS_DECREASE_RATE_BUTTON));
+
+ // Network Hotspot
+ localized_strings.Set(
+ "tetheringCapabilitiesLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TETHERING_CAPABILITIES_LABEL));
+ localized_strings.Set(
+ "refreshTetheringCapabilitiesButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_REFRESH_TETHERING_CAPABILITIES_BUTTON_TEXT));
+ localized_strings.Set(
+ "tetheringStatusLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TETHERING_STATUS_LABEL));
+ localized_strings.Set(
+ "refreshTetheringStatusButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_REFRESH_TETHERING_STATUS_BUTTON_TEXT));
+ localized_strings.Set(
+ "tetheringConfigLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TETHERING_CONFIG_LABEL));
+ localized_strings.Set(
+ "refreshTetheringConfigButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_REFRESH_TETHERING_CONFIG_BUTTON_TEXT));
+ localized_strings.Set("setTetheringConfigButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_SET_TETHERING_CONFIG_BUTTON_TEXT));
+ localized_strings.Set(
+ "tetheringReadinessLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_TETHERING_READINESS_LABEL));
+ localized_strings.Set(
+ "checkTetheringReadinessButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_CHECK_TETHERING_READINESS_BUTTON_TEXT));
+ localized_strings.Set(
+ "setTetheringEnabledLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_SET_TETHERING_ENABLED_LABEL));
return localized_strings;
}
@@ -658,6 +933,8 @@ NetworkUI::NetworkUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(std::make_unique<NetworkLogsMessageHandler>());
web_ui->AddMessageHandler(
std::make_unique<NetworkDiagnosticsMessageHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<network_ui::HotspotConfigMessageHandler>());
// Enable extension API calls in the WebUI.
extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
@@ -670,6 +947,10 @@ NetworkUI::NetworkUI(content::WebUI* web_ui)
html->DisableTrustedTypesCSP();
html->AddLocalizedStrings(localized_strings);
+ html->AddBoolean("isGuestModeActive", IsGuestModeActive());
+ html->AddBoolean("isHotspotEnabled", ash::features::IsHotspotEnabled());
+ html->AddString("tetheringStateStarting", shill::kTetheringStateStarting);
+ html->AddString("tetheringStateActive", shill::kTetheringStateActive);
network_health::AddResources(html);
network_diagnostics::AddResources(html);
cellular_setup::AddLocalizedStrings(html);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/DEPS b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/DEPS
new file mode 100644
index 00000000000..3121dba4253
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ui/message_center"
+] \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/OWNERS
new file mode 100644
index 00000000000..0fa385fe5f0
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/OWNERS
@@ -0,0 +1 @@
+leandre@chromium.org \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.cc
new file mode 100644
index 00000000000..80c80901e10
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.cc
@@ -0,0 +1,247 @@
+// Copyright (c) 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h"
+
+#include <string>
+
+#include "ash/constants/notifier_catalogs.h"
+#include "base/bind.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/app/vector_icons/vector_icons.h"
+#include "chrome/grit/chrome_unscaled_resources.h"
+#include "chrome/grit/theme_resources.h"
+#include "ui/base/models/image_model.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/vector_icon_types.h"
+#include "ui/message_center/message_center.h"
+#include "ui/message_center/public/cpp/notification.h"
+
+namespace chromeos {
+
+NotificationTesterHandler::NotificationTesterHandler() = default;
+
+NotificationTesterHandler::~NotificationTesterHandler() = default;
+
+void NotificationTesterHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "generateNotificationForm",
+ base::BindRepeating(
+ &NotificationTesterHandler::HandleGenerateNotificationForm,
+ base::Unretained(this)));
+}
+
+void NotificationTesterHandler::HandleGenerateNotificationForm(
+ const base::Value::List& args) {
+ AllowJavascript();
+
+ // Unpack JS args.
+ const base::Value::Dict* notifObj = args[0].GetIfDict();
+ DCHECK(notifObj);
+
+ // Set notification ID to the system time (always unique) if specified.
+ const std::string* id = notifObj->FindString("id");
+ DCHECK(id);
+ std::string notification_id = *id;
+ if (*id == "random") {
+ auto current_time_in_ms =
+ base::Time::Now().ToDeltaSinceWindowsEpoch().InMilliseconds();
+ notification_id = base::NumberToString(current_time_in_ms);
+ }
+
+ const std::string* title = notifObj->FindString("title");
+ DCHECK(title);
+
+ const std::string* message = notifObj->FindString("message");
+ DCHECK(message);
+
+ const std::string* icon = notifObj->FindString("icon");
+ DCHECK(icon);
+ auto notification_icon = GetNotificationIconFromString(*icon);
+
+ const std::string* image = notifObj->FindString("richDataImage");
+ DCHECK(image);
+
+ const std::string* display_source = notifObj->FindString("displaySource");
+ DCHECK(display_source);
+
+ const std::string* origin_url_str = notifObj->FindString("originURL");
+ DCHECK(origin_url_str);
+ GURL origin_url(*origin_url_str);
+
+ absl::optional<int> warning_level_int = notifObj->FindInt("warningLevel");
+ DCHECK(warning_level_int);
+ auto warning_level =
+ static_cast<message_center::SystemNotificationWarningLevel>(
+ warning_level_int.value());
+
+ absl::optional<int> notification_type_int =
+ notifObj->FindInt("notificationType");
+ DCHECK(notification_type_int);
+ auto notification_type = static_cast<message_center::NotificationType>(
+ notification_type_int.value());
+
+ // notifier_id should be constructed differently if the notifier type is
+ // message_center::NotifierType::WEB_PAGE.
+ absl::optional<int> notifier_type = notifObj->FindInt("notifierType");
+ DCHECK(notifier_type);
+ message_center::NotifierId notifier_id;
+ if (notifier_type.value() ==
+ static_cast<int>(message_center::NotifierType::WEB_PAGE)) {
+ notifier_id = message_center::NotifierId(origin_url);
+ // The profile_id must be non-empty to enable notification grouping.
+ notifier_id.profile_id = "test-profile-id@gmail.com";
+ } else {
+ notifier_id = message_center::NotifierId(
+ static_cast<message_center::NotifierType>(notifier_type.value()),
+ "test notifier id", ash::NotificationCatalogName::kTestCatalogName);
+ }
+
+ // Create RichNotificationData object.
+ message_center::RichNotificationData optional_fields =
+ DictToOptionalFields(notifObj);
+
+ // Delegate does nothing.
+ auto delegate =
+ base::MakeRefCounted<message_center::HandleNotificationClickDelegate>(
+ base::BindRepeating([](absl::optional<int> button_index) {}));
+
+ auto notification = std::make_unique<message_center::Notification>(
+ notification_type, notification_id, base::UTF8ToUTF16(*title),
+ base::UTF8ToUTF16(*message), notification_icon,
+ base::UTF8ToUTF16(*display_source), origin_url, notifier_id,
+ optional_fields, delegate);
+
+ notification->set_system_notification_warning_level(warning_level);
+
+ message_center::MessageCenter::Get()->AddNotification(
+ std::move(notification));
+}
+
+const ui::ImageModel NotificationTesterHandler::GetNotificationIconFromString(
+ const std::string& icon_name) {
+ if (icon_name == "chromium_logo") {
+ return ui::ImageModel::FromResourceId(IDR_PRODUCT_LOGO_32);
+ } else if (icon_name == "google_logo") {
+ return ui::ImageModel::FromResourceId(IDR_LOGO_GOOGLE_COLOR_90);
+ } else if (icon_name == "warning") {
+ return ui::ImageModel::FromResourceId(IDR_RESET_WARNING);
+ }
+
+ return ui::ImageModel();
+}
+
+const gfx::Image NotificationTesterHandler::GetRichDataImageFromString(
+ const std::string& image_name) {
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ if (image_name == "google_logo_small_png") {
+ return rb.GetImageNamed(IDR_LOGO_GOOGLE_COLOR_90);
+ } else if (image_name == "chromium_logo_large_png") {
+ return rb.GetImageNamed(IDR_CHROME_APP_ICON_192);
+ }
+
+ return gfx::Image();
+}
+
+const gfx::VectorIcon&
+NotificationTesterHandler::GetRichDataSmallImageFromString(
+ const std::string& small_image_name) {
+ if (small_image_name == "kTerminalSshIcon") {
+ return kTerminalSshIcon;
+ } else if (small_image_name == "kCreditCardIcon") {
+ return kCreditCardIcon;
+ } else if (small_image_name == "kSmartphoneIcon") {
+ return kSmartphoneIcon;
+ }
+
+ return gfx::kNoneIcon;
+}
+
+std::vector<message_center::ButtonInfo>
+NotificationTesterHandler::GetRichDataButtons(int num_buttons) {
+ std::vector<message_center::ButtonInfo> buttons;
+ for (int i = 0; i < num_buttons; i++) {
+ buttons.emplace_back(u"Test Btn " + base::NumberToString16(i));
+ }
+ return buttons;
+}
+
+std::vector<message_center::NotificationItem>
+NotificationTesterHandler::GetRichDataNotifItems(int num_items) {
+ std::vector<message_center::NotificationItem> items;
+ for (int i = 0; i < num_items; i++) {
+ items.push_back({u"Item " + base::NumberToString16(i), u"item message"});
+ }
+ return items;
+}
+
+message_center::RichNotificationData
+NotificationTesterHandler::DictToOptionalFields(
+ const base::Value::Dict* notifObj) {
+ message_center::RichNotificationData optional_fields;
+ // Unpack notification object and populate optional_fields.
+ const std::string* image = notifObj->FindString("richDataImage");
+ DCHECK(image);
+ optional_fields.image = GetRichDataImageFromString(*image);
+
+ const std::string* small_image = notifObj->FindString("richDataSmallImage");
+ DCHECK(small_image);
+ optional_fields.vector_small_image =
+ &GetRichDataSmallImageFromString(*small_image);
+
+ absl::optional<bool> never_timeout =
+ notifObj->FindBool("richDataNeverTimeout");
+ DCHECK(never_timeout);
+ optional_fields.never_timeout = never_timeout.value();
+
+ absl::optional<int> priority = notifObj->FindInt("richDataPriority");
+ DCHECK(priority);
+ optional_fields.priority = priority.value();
+
+ absl::optional<bool> pinned = notifObj->FindBool("richDataPinned");
+ DCHECK(pinned);
+ optional_fields.pinned = pinned.value();
+
+ absl::optional<bool> show_snooze = notifObj->FindBool("richDataShowSnooze");
+ DCHECK(show_snooze);
+ optional_fields.should_show_snooze_button = show_snooze.value();
+
+ absl::optional<bool> show_settings =
+ notifObj->FindBool("richDataShowSettings");
+ DCHECK(show_settings);
+ optional_fields.settings_button_handler =
+ show_settings.value() ? message_center::SettingsButtonHandler::INLINE
+ : message_center::SettingsButtonHandler::NONE;
+
+ absl::optional<int> num_buttons = notifObj->FindInt("richDataNumButtons");
+ DCHECK(num_buttons);
+ optional_fields.buttons = GetRichDataButtons(num_buttons.value());
+
+ // Set additional fields for specific notification types.
+ absl::optional<int> notification_type = notifObj->FindInt("notificationType");
+ DCHECK(notification_type);
+
+ if (notification_type ==
+ message_center::NotificationType::NOTIFICATION_TYPE_PROGRESS) {
+ absl::optional<int> progress = notifObj->FindInt("richDataProgress");
+ DCHECK(progress);
+ optional_fields.progress = progress.value();
+
+ const std::string* progress_status =
+ notifObj->FindString("richDataProgressStatus");
+ DCHECK(progress_status);
+ optional_fields.progress_status = base::UTF8ToUTF16(*progress_status);
+ } else if (notification_type ==
+ message_center::NotificationType::NOTIFICATION_TYPE_MULTIPLE) {
+ absl::optional<int> num_items = notifObj->FindInt("richDataNumNotifItems");
+ DCHECK(num_items);
+ optional_fields.items = GetRichDataNotifItems(num_items.value());
+ }
+
+ return optional_fields;
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h
new file mode 100644
index 00000000000..064ceab7e11
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h
@@ -0,0 +1,75 @@
+// Copyright (c) 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_NOTIFICATION_TESTER_NOTIFICATION_TESTER_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_NOTIFICATION_TESTER_NOTIFICATION_TESTER_HANDLER_H_
+
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace gfx {
+class Image;
+struct VectorIcon;
+} // namespace gfx
+
+namespace message_center {
+struct ButtonInfo;
+struct NotificationItem;
+class RichNotificationData;
+} // namespace message_center
+
+namespace ui {
+class ImageModel;
+} // namespace ui
+
+namespace chromeos {
+
+// WebUI message handler for chrome://notification-tester from the front-end to
+// the message center.
+class NotificationTesterHandler : public content::WebUIMessageHandler {
+ public:
+ NotificationTesterHandler();
+ NotificationTesterHandler(const NotificationTesterHandler&) = delete;
+ NotificationTesterHandler& operator=(const NotificationTesterHandler&) =
+ delete;
+ ~NotificationTesterHandler() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ private:
+ // MessageHandler callback that fires when the MessageHandler receives a
+ // message to generate a notification from the front-end.
+ void HandleGenerateNotificationForm(const base::Value::List& args);
+
+ // Given the name of an icon (string) within the notification tester
+ // resources, return the corresponding icon.
+ const ui::ImageModel GetNotificationIconFromString(
+ const std::string& icon_name);
+
+ // Given the name of an image (string) within the notification tester
+ // resources, return the corresponding gfx::Image.
+ const gfx::Image GetRichDataImageFromString(const std::string& image_name);
+
+ // Given the name of a small image (string) such as 'kTerminalSshIcon',
+ // return the corresponding gfx::VectorIcon.
+ const gfx::VectorIcon& GetRichDataSmallImageFromString(
+ const std::string& small_image_name);
+
+ // Return a std::vector with 'num_buttons' ButtonInfo objects.
+ std::vector<message_center::ButtonInfo> GetRichDataButtons(int num_buttons);
+
+ // Return a std::vector with 'num_items' NotificationItem structs. Used for
+ // NOTIFICATION_TYPE_MULTIPLE.
+ std::vector<message_center::NotificationItem> GetRichDataNotifItems(
+ int num_items);
+
+ // Return a RichNotificationData object populated with the user-configured
+ // notification object from the front-end.
+ message_center::RichNotificationData DictToOptionalFields(
+ const base::Value::Dict* notifObj);
+};
+
+} // namespace chromeos
+
+#endif
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.cc
index fd439ab6ac1..15f31255c76 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.cc
@@ -3,11 +3,20 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h"
+
+#include "base/containers/span.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/notification_tester_resources.h"
+#include "chrome/grit/notification_tester_resources_map.h"
+#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/web_ui_util.h"
namespace chromeos {
@@ -18,9 +27,16 @@ NotificationTesterUI::NotificationTesterUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUINotificationTesterHost);
// Add required resources.
- html_source->SetDefaultResource(IDR_NOTIFICATION_TESTER_HTML);
+ webui::SetupWebUIDataSource(html_source,
+ base::make_span(kNotificationTesterResources,
+ kNotificationTesterResourcesSize),
+ IDR_NOTIFICATION_TESTER_INDEX_HTML);
+
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
+
+ // Add message handler.
+ web_ui->AddMessageHandler(std::make_unique<NotificationTesterHandler>());
}
NotificationTesterUI::~NotificationTesterUI() = default;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h
index 254370ff788..f91b91373bc 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/notification_tester/notification_tester_ui.h
@@ -5,10 +5,23 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_NOTIFICATION_TESTER_NOTIFICATION_TESTER_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_NOTIFICATION_TESTER_NOTIFICATION_TESTER_UI_H_
+#include "chrome/common/webui_url_constants.h"
#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/webui_config.h"
+#include "content/public/common/url_constants.h"
namespace chromeos {
+class NotificationTesterUI;
+
+class NotificationTesterUIConfig
+ : public content::DefaultWebUIConfig<NotificationTesterUI> {
+ public:
+ NotificationTesterUIConfig()
+ : DefaultWebUIConfig(content::kChromeUIScheme,
+ chrome::kChromeUINotificationTesterHost) {}
+};
+
// The UI controller for NotificationTester page.
class NotificationTesterUI : public content::WebUIController {
public:
diff --git a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc
index 9c764012d26..9d182d87321 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc
@@ -46,7 +46,7 @@ OncImportMessageHandler::OncImportMessageHandler() = default;
OncImportMessageHandler::~OncImportMessageHandler() = default;
void OncImportMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"importONC", base::BindRepeating(&OncImportMessageHandler::OnImportONC,
base::Unretained(this)));
}
@@ -54,16 +54,16 @@ void OncImportMessageHandler::RegisterMessages() {
void OncImportMessageHandler::Respond(const std::string& callback_id,
const std::string& result,
bool is_error) {
- base::Value response(base::Value::Type::LIST);
+ base::Value::List response;
response.Append(result);
response.Append(is_error);
ResolveJavascriptCallback(base::Value(callback_id), response);
}
-void OncImportMessageHandler::OnImportONC(const base::ListValue* list) {
- CHECK_EQ(2u, list->GetListDeprecated().size());
- std::string callback_id = list->GetListDeprecated()[0].GetString();
- std::string onc_blob = list->GetListDeprecated()[1].GetString();
+void OncImportMessageHandler::OnImportONC(const base::Value::List& list) {
+ CHECK_EQ(2u, list.size());
+ std::string callback_id = list[0].GetString();
+ std::string onc_blob = list[1].GetString();
AllowJavascript();
// TODO(https://crbug.com/1186373): Pass the `NssCertDatabaseGetter` to
diff --git a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h
index 834850e6f58..16d3d315c83 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.h
@@ -8,22 +8,17 @@
#include <string>
#include "base/memory/weak_ptr.h"
+#include "base/values.h"
+// TODO(https://crbug.com/1164001): move to forward declaration
+#include "chromeos/ash/components/network/onc/onc_certificate_importer_impl.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-}
-
namespace net {
class NSSCertDatabase;
}
namespace chromeos {
-namespace onc {
-class CertificateImporterImpl;
-}
-
class OncImportMessageHandler : public content::WebUIMessageHandler {
public:
OncImportMessageHandler();
@@ -38,7 +33,7 @@ class OncImportMessageHandler : public content::WebUIMessageHandler {
void Respond(const std::string& callback_id,
const std::string& result,
bool is_error);
- void OnImportONC(const base::ListValue* list);
+ void OnImportONC(const base::Value::List& list);
void ImportONCToNSSDB(const std::string& callback_id,
const std::string& onc_blob,
net::NSSCertDatabase* nssdb);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.proto b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.proto
index 0f01ebfaaa6..9e246c7c333 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.proto
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.proto
@@ -27,20 +27,43 @@ message Timestamp {
// string to the listener. i.e.
// postMessage(base64.encodeByteArray(callback.serializeBinary()))
//
-// Next ID: 3
+// Next ID: 5
message ParentAccessCallback {
oneof callback {
OnParentVerified on_parent_verified = 1;
OnConsentDeclined on_consent_declined = 2;
+ OnPageSizeChanged on_page_size_changed = 3;
+ OnCommunicationEstablished on_communication_established = 4;
}
}
+// Callback invoked when the communication mechanism is verified. Currently this
+// callback is only sent when Android WebMessageChannel is specified.
+message OnCommunicationEstablished {}
+
+// This callback is invoked when the page size has changed, for example when an
+// expandable button is clicked, so the client knows if size adjustments are
+// needed to their container.
+message OnPageSizeChanged {
+ // Width and height of the content area of the parent access view.
+ int32 content_width = 1;
+ int32 content_height = 2;
+}
+
// Callback invoked when the user has passed the parent presence verification.
-// Next ID: 2
+// Next ID: 3
message OnParentVerified {
- // Proof of the verification that the caller should consume later when
- // performing the privileged action. See go/warpstar-sspv.
- ParentAccessToken parent_access_token = 1;
+ oneof verification_proof {
+ // Proof of the verification that the caller should consume later when
+ // performing the privileged action. See go/warpstar-sspv.
+ ParentAccessToken parent_access_token = 1;
+
+ // This empty proto is a success signal returned to the caller when no token
+ // is needed.
+ ParentAccessTokenNotRequested parent_access_token_not_requested = 2;
+ }
+
+ message ParentAccessTokenNotRequested {}
}
// Next ID: 3
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_dialog.cc
index d33cdc25e77..0f956488376 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_dialog.cc
@@ -19,8 +19,8 @@ namespace chromeos {
namespace {
-constexpr int kDialogHeightDp = 512;
-constexpr int kDialogWidthDp = 462;
+constexpr int kDialogHeightDp = 526;
+constexpr int kDialogWidthDp = 600;
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom
index 901987d1273..cd5ff47d13c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom
@@ -10,21 +10,25 @@ enum GetOAuthTokenStatus {
kOnlyOneFetchAtATime,
};
-// Result of the parent access flow returned for either of two kinds of the
-// flow: parent verification and parent consent.
-enum ParentAccessResultStatus {
+// Types of messages sent in the ParentAccessCallback.
+enum ParentAccessServerMessageType {
// Indicates that the parent's identity was verified.
// Returned by either verification or consent flow.
// In consent flow it also means that parent provided the consent and
// that consent was recorded.
kParentVerified,
- // Indicates that the parent's identity was verified and the parent did not
- // consent for the requested action.
- // Can be only returned for the consent flow.
- kConsentDeclined,
// An internal error occurred in any of the flows.
// The user should be prompted with an unrecoverable error in this case.
kError,
+ // Indicates that the result type should be ignored. This can happen if the
+ // server adds a new return type that we don't support.
+ kIgnore,
+};
+
+// Struct returned to the WebUI based on the parsed ParentAccessCallback proto.
+struct ParentAccessServerMessage {
+ // The message type.
+ ParentAccessServerMessageType type;
};
// Interface that supports integration between the ParentAccess WebUI and
@@ -34,7 +38,7 @@ interface ParentAccessUIHandler {
GetOAuthToken() => (GetOAuthTokenStatus status, string oauth_token);
// When called, signals that the server widget has provided a result.
- // Returns an enum indicating the result of parsing the result.
- OnParentAccessResult(string parent_access_result) =>
- (ParentAccessResultStatus status);
+ // Returns a ParentAccessServerMessage parsed from the encoded proto string.
+ OnParentAccessCallbackReceived(string encoded_parent_access_callback_proto) =>
+ (ParentAccessServerMessage message);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.cc b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.cc
index 1d6001cf966..c3d61fe3d9a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.cc
@@ -71,26 +71,31 @@ void ParentAccessUIHandlerImpl::OnAccessTokenFetchComplete(
access_token_info.token);
}
-void ParentAccessUIHandlerImpl::OnParentAccessResult(
- const std::string& parent_access_result,
- OnParentAccessResultCallback callback) {
- std::string decoded_parent_access_result;
- if (!base::Base64Decode(parent_access_result,
- &decoded_parent_access_result)) {
+void ParentAccessUIHandlerImpl::OnParentAccessCallbackReceived(
+ const std::string& encoded_parent_access_callback_proto,
+ OnParentAccessCallbackReceivedCallback callback) {
+ std::string decoded_parent_access_callback;
+ parent_access_ui::mojom::ParentAccessServerMessagePtr message =
+ parent_access_ui::mojom::ParentAccessServerMessage::New();
+ if (!base::Base64Decode(encoded_parent_access_callback_proto,
+ &decoded_parent_access_callback)) {
LOG(ERROR) << "ParentAccessHandler::ParentAccessResult: Error decoding "
"parent_access_result from base64";
- std::move(callback).Run(
- parent_access_ui::mojom::ParentAccessResultStatus::kError);
+ message->type =
+ parent_access_ui::mojom::ParentAccessServerMessageType::kError;
+ std::move(callback).Run(std::move(message));
return;
}
kids::platform::parentaccess::client::proto::ParentAccessCallback
parent_access_callback;
- if (!parent_access_callback.ParseFromString(decoded_parent_access_result)) {
+ if (!parent_access_callback.ParseFromString(decoded_parent_access_callback)) {
LOG(ERROR) << "ParentAccessHandler::ParentAccessResult: Error parsing "
"decoded_parent_access_result to proto";
- std::move(callback).Run(
- parent_access_ui::mojom::ParentAccessResultStatus::kError);
+
+ message->type =
+ parent_access_ui::mojom::ParentAccessServerMessageType::kError;
+ std::move(callback).Run(std::move(message));
return;
}
@@ -99,19 +104,20 @@ void ParentAccessUIHandlerImpl::OnParentAccessResult(
switch (parent_access_callback.callback_case()) {
case kids::platform::parentaccess::client::proto::ParentAccessCallback::
CallbackCase::kOnParentVerified:
- std::move(callback).Run(
- parent_access_ui::mojom::ParentAccessResultStatus::kParentVerified);
- break;
- case kids::platform::parentaccess::client::proto::ParentAccessCallback::
- CallbackCase::kOnConsentDeclined:
- std::move(callback).Run(
- parent_access_ui::mojom::ParentAccessResultStatus::kConsentDeclined);
+
+ message->type = parent_access_ui::mojom::ParentAccessServerMessageType::
+ kParentVerified;
+
+ std::move(callback).Run(std::move(message));
break;
default:
- std::move(callback).Run(
- parent_access_ui::mojom::ParentAccessResultStatus::kError);
- LOG(ERROR) << "ParentAccessHandler::ParentAccessResult: Unknown type of "
- "callback received";
+ LOG(ERROR)
+ << "ParentAccessHandler::OnParentAccessCallback: Unknown type of "
+ "callback received and ignored: "
+ << parent_access_callback.callback_case();
+ message->type =
+ parent_access_ui::mojom::ParentAccessServerMessageType::kIgnore;
+ std::move(callback).Run(std::move(message));
break;
}
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h
index e964559e6c7..4fe65abcaf4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h
@@ -41,8 +41,13 @@ class ParentAccessUIHandlerImpl
// parent_access_ui::mojom::ParentAccessUIHandler overrides:
void GetOAuthToken(GetOAuthTokenCallback callback) override;
- void OnParentAccessResult(const std::string& parent_access_result,
- OnParentAccessResultCallback callback) override;
+ // Called when the message from the parent access server app was received.
+ // encoded_parent_access_callback is a base64 encoded protocol buffer with
+ // the received message. 'callback' is a mojo callback used to pass the
+ // parsed message back to the WebUI.
+ void OnParentAccessCallbackReceived(
+ const std::string& encoded_parent_access_callback_proto,
+ OnParentAccessCallbackReceivedCallback callback) override;
private:
void OnAccessTokenFetchComplete(GetOAuthTokenCallback callback,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl_browsertest.cc
index f413910f6f7..d39adf5edb4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl_browsertest.cc
@@ -4,8 +4,10 @@
#include "chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui_handler_impl.h"
+#include "base/base64.h"
#include "base/bind.h"
#include "chrome/browser/ui/webui/chromeos/parent_access/parent_access_browsertest_base.h"
+#include "chrome/browser/ui/webui/chromeos/parent_access/parent_access_callback.pb.h"
#include "chrome/browser/ui/webui/chromeos/parent_access/parent_access_ui.mojom.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -95,4 +97,157 @@ IN_PROC_BROWSER_TEST_F(ParentAccessUIHandlerImplBrowserTest,
}));
}
+// Verifies that the ParentVerified status is handled correctly.
+IN_PROC_BROWSER_TEST_F(ParentAccessUIHandlerImplBrowserTest,
+ ParentVerifiedParsed) {
+ // Open the Parent Access WebUI URL.
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(
+ browser(), GURL(chrome::kChromeUIParentAccessURL)));
+ EXPECT_TRUE(content::WaitForLoadStop(contents()));
+
+ ParentAccessUIHandlerImpl* handler = static_cast<ParentAccessUIHandlerImpl*>(
+ GetParentAccessUI()->GetHandlerForTest());
+
+ // Make sure the handler isn't null.
+ ASSERT_NE(handler, nullptr);
+
+ // Construct the ParentAccessCallback
+ kids::platform::parentaccess::client::proto::ParentAccessCallback
+ parent_access_callback;
+ kids::platform::parentaccess::client::proto::OnParentVerified*
+ on_parent_verified = parent_access_callback.mutable_on_parent_verified();
+ kids::platform::parentaccess::client::proto::ParentAccessToken* pat =
+ on_parent_verified->mutable_parent_access_token();
+ pat->set_token("TEST_TOKEN");
+ kids::platform::parentaccess::client::proto::Timestamp* expire_time =
+ pat->mutable_expire_time();
+ expire_time->set_seconds(123456);
+ expire_time->set_nanos(567890);
+
+ // Encode the proto in base64.
+ std::string encoded_parent_access_callback;
+ base::Base64Encode(parent_access_callback.SerializeAsString(),
+ &encoded_parent_access_callback);
+
+ handler->OnParentAccessCallbackReceived(
+ encoded_parent_access_callback,
+ base::BindOnce(
+ [](parent_access_ui::mojom::ParentAccessServerMessagePtr message)
+ -> void {
+ // Verify the Parent Verified callback is parsed.
+ // TODO(b/241166361): Verify token value and expire time.
+ EXPECT_EQ(parent_access_ui::mojom::ParentAccessServerMessageType::
+ kParentVerified,
+ message->type);
+ }));
+}
+
+// Verifies that the ConsentDeclined status is ignored.
+IN_PROC_BROWSER_TEST_F(ParentAccessUIHandlerImplBrowserTest,
+ ConsentDeclinedParsed) {
+ // Open the Parent Access WebUI URL.
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(
+ browser(), GURL(chrome::kChromeUIParentAccessURL)));
+ EXPECT_TRUE(content::WaitForLoadStop(contents()));
+
+ ParentAccessUIHandlerImpl* handler = static_cast<ParentAccessUIHandlerImpl*>(
+ GetParentAccessUI()->GetHandlerForTest());
+
+ // Make sure the handler isn't null.
+ ASSERT_NE(handler, nullptr);
+
+ // Construct the ParentAccessCallback
+ kids::platform::parentaccess::client::proto::ParentAccessCallback
+ parent_access_callback;
+ parent_access_callback.mutable_on_consent_declined();
+
+ // Encode the proto in base64.
+ std::string encoded_parent_access_callback;
+ base::Base64Encode(parent_access_callback.SerializeAsString(),
+ &encoded_parent_access_callback);
+
+ handler->OnParentAccessCallbackReceived(
+ encoded_parent_access_callback,
+ base::BindOnce(
+ [](parent_access_ui::mojom::ParentAccessServerMessagePtr message)
+ -> void {
+ // Verify that it is ignored.
+ EXPECT_EQ(
+ parent_access_ui::mojom::ParentAccessServerMessageType::kIgnore,
+ message->type);
+ }));
+}
+
+// Verifies that the OnPageSizeChanged status is ignored.
+IN_PROC_BROWSER_TEST_F(ParentAccessUIHandlerImplBrowserTest,
+ OnPageSizeChangedIgnored) {
+ // Open the Parent Access WebUI URL.
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(
+ browser(), GURL(chrome::kChromeUIParentAccessURL)));
+ EXPECT_TRUE(content::WaitForLoadStop(contents()));
+
+ ParentAccessUIHandlerImpl* handler = static_cast<ParentAccessUIHandlerImpl*>(
+ GetParentAccessUI()->GetHandlerForTest());
+
+ // Make sure the handler isn't null.
+ ASSERT_NE(handler, nullptr);
+
+ // Construct the ParentAccessCallback
+ kids::platform::parentaccess::client::proto::ParentAccessCallback
+ parent_access_callback;
+ parent_access_callback.mutable_on_page_size_changed();
+
+ // Encode the proto in base64.
+ std::string encoded_parent_access_callback;
+ base::Base64Encode(parent_access_callback.SerializeAsString(),
+ &encoded_parent_access_callback);
+
+ handler->OnParentAccessCallbackReceived(
+ encoded_parent_access_callback,
+ base::BindOnce(
+ [](parent_access_ui::mojom::ParentAccessServerMessagePtr message)
+ -> void {
+ // Verify that it is ignored.
+ EXPECT_EQ(
+ parent_access_ui::mojom::ParentAccessServerMessageType::kIgnore,
+ message->type);
+ }));
+}
+
+// Verifies that the OnCommunicationEstablished status is ignored.
+IN_PROC_BROWSER_TEST_F(ParentAccessUIHandlerImplBrowserTest,
+ OnCommunicationEstablishedIgnored) {
+ // Open the Parent Access WebUI URL.
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(
+ browser(), GURL(chrome::kChromeUIParentAccessURL)));
+ EXPECT_TRUE(content::WaitForLoadStop(contents()));
+
+ ParentAccessUIHandlerImpl* handler = static_cast<ParentAccessUIHandlerImpl*>(
+ GetParentAccessUI()->GetHandlerForTest());
+
+ // Make sure the handler isn't null.
+ ASSERT_NE(handler, nullptr);
+
+ // Construct the ParentAccessCallback
+ kids::platform::parentaccess::client::proto::ParentAccessCallback
+ parent_access_callback;
+ parent_access_callback.mutable_on_communication_established();
+
+ // Encode the proto in base64.
+ std::string encoded_parent_access_callback;
+ base::Base64Encode(parent_access_callback.SerializeAsString(),
+ &encoded_parent_access_callback);
+
+ handler->OnParentAccessCallbackReceived(
+ encoded_parent_access_callback,
+ base::BindOnce(
+ [](parent_access_ui::mojom::ParentAccessServerMessagePtr message)
+ -> void {
+ // Verify that it is ignored.
+ EXPECT_EQ(
+ parent_access_ui::mojom::ParentAccessServerMessageType::kIgnore,
+ message->type);
+ }));
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
index 69f96205c40..30141543c3f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
@@ -48,15 +48,14 @@ class PowerMessageHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void OnGetBatteryChargeData(const base::ListValue* value);
- void OnGetCpuIdleData(const base::ListValue* value);
- void OnGetCpuFreqData(const base::ListValue* value);
- void OnGetProcessUsageData(const base::ListValue* value);
- void GetJsStateOccupancyData(
+ void OnGetBatteryChargeData(const base::Value::List& value);
+ void OnGetCpuIdleData(const base::Value::List& value);
+ void OnGetCpuFreqData(const base::Value::List& value);
+ void OnGetProcessUsageData(const base::Value::List& value);
+ base::Value::List GetJsStateOccupancyData(
const std::vector<CpuDataCollector::StateOccupancySampleDeque>& data,
- const std::vector<std::string>& state_names,
- base::ListValue* js_data);
- void GetJsSystemResumedData(base::ListValue* value);
+ const std::vector<std::string>& state_names);
+ base::Value::List GetJsSystemResumedData();
};
PowerMessageHandler::PowerMessageHandler() {
@@ -66,30 +65,31 @@ PowerMessageHandler::~PowerMessageHandler() {
}
void PowerMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kRequestBatteryChargeDataCallback,
base::BindRepeating(&PowerMessageHandler::OnGetBatteryChargeData,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kRequestCpuIdleDataCallback,
base::BindRepeating(&PowerMessageHandler::OnGetCpuIdleData,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kRequestCpuFreqDataCallback,
base::BindRepeating(&PowerMessageHandler::OnGetCpuFreqData,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kRequestProcessUsageDataCallback,
base::BindRepeating(&PowerMessageHandler::OnGetProcessUsageData,
base::Unretained(this)));
}
-void PowerMessageHandler::OnGetBatteryChargeData(const base::ListValue* args) {
+void PowerMessageHandler::OnGetBatteryChargeData(
+ const base::Value::List& args) {
AllowJavascript();
const base::circular_deque<PowerDataCollector::PowerSupplySample>&
power_supply = PowerDataCollector::Get()->power_supply_data();
- base::ListValue js_power_supply_data;
+ base::Value::List js_power_supply_data;
for (size_t i = 0; i < power_supply.size(); ++i) {
const PowerDataCollector::PowerSupplySample& sample = power_supply[i];
base::Value::Dict element;
@@ -98,20 +98,19 @@ void PowerMessageHandler::OnGetBatteryChargeData(const base::ListValue* args) {
element.Set("externalPower", sample.external_power);
element.Set("time", sample.time.ToJsTime());
- js_power_supply_data.Append(base::Value(std::move(element)));
+ js_power_supply_data.Append(std::move(element));
}
- base::ListValue js_system_resumed_data;
- GetJsSystemResumedData(&js_system_resumed_data);
+ base::Value::List js_system_resumed_data = GetJsSystemResumedData();
- base::DictionaryValue data;
- data.SetKey("powerSupplyData", std::move(js_power_supply_data));
- data.SetKey("systemResumedData", std::move(js_system_resumed_data));
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ base::Value::Dict data;
+ data.Set("powerSupplyData", std::move(js_power_supply_data));
+ data.Set("systemResumedData", std::move(js_system_resumed_data));
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(callback_id, data);
}
-void PowerMessageHandler::OnGetCpuIdleData(const base::ListValue* args) {
+void PowerMessageHandler::OnGetCpuIdleData(const base::Value::List& args) {
AllowJavascript();
const CpuDataCollector& cpu_data_collector =
@@ -121,20 +120,19 @@ void PowerMessageHandler::OnGetCpuIdleData(const base::ListValue* args) {
cpu_data_collector.cpu_idle_state_data();
const std::vector<std::string>& idle_state_names =
cpu_data_collector.cpu_idle_state_names();
- base::ListValue js_idle_data;
- GetJsStateOccupancyData(idle_data, idle_state_names, &js_idle_data);
+ base::Value::List js_idle_data =
+ GetJsStateOccupancyData(idle_data, idle_state_names);
- base::ListValue js_system_resumed_data;
- GetJsSystemResumedData(&js_system_resumed_data);
+ base::Value::List js_system_resumed_data = GetJsSystemResumedData();
- base::DictionaryValue data;
- data.SetKey("idleStateData", std::move(js_idle_data));
- data.SetKey("systemResumedData", std::move(js_system_resumed_data));
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ base::Value::Dict data;
+ data.Set("idleStateData", std::move(js_idle_data));
+ data.Set("systemResumedData", std::move(js_system_resumed_data));
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(callback_id, data);
}
-void PowerMessageHandler::OnGetCpuFreqData(const base::ListValue* args) {
+void PowerMessageHandler::OnGetCpuFreqData(const base::Value::List& args) {
AllowJavascript();
const CpuDataCollector& cpu_data_collector =
@@ -144,29 +142,28 @@ void PowerMessageHandler::OnGetCpuFreqData(const base::ListValue* args) {
cpu_data_collector.cpu_freq_state_data();
const std::vector<std::string>& freq_state_names =
cpu_data_collector.cpu_freq_state_names();
- base::ListValue js_freq_data;
- GetJsStateOccupancyData(freq_data, freq_state_names, &js_freq_data);
+ base::Value::List js_freq_data =
+ GetJsStateOccupancyData(freq_data, freq_state_names);
- base::ListValue js_system_resumed_data;
- GetJsSystemResumedData(&js_system_resumed_data);
+ base::Value::List js_system_resumed_data = GetJsSystemResumedData();
- base::DictionaryValue data;
- data.SetKey("freqStateData", std::move(js_freq_data));
- data.SetKey("systemResumedData", std::move(js_system_resumed_data));
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ base::Value::Dict data;
+ data.Set("freqStateData", std::move(js_freq_data));
+ data.Set("systemResumedData", std::move(js_system_resumed_data));
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(callback_id, data);
}
-void PowerMessageHandler::OnGetProcessUsageData(const base::ListValue* args) {
+void PowerMessageHandler::OnGetProcessUsageData(const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetListDeprecated().size());
+ CHECK_EQ(1U, args.size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value& callback_id = args[0];
const std::vector<ProcessDataCollector::ProcessUsageData>& process_list =
ProcessDataCollector::Get()->GetProcessUsages();
- base::ListValue js_process_usages;
+ base::Value::List js_process_usages;
for (const auto& process_info : process_list) {
base::Value::Dict element;
element.Set("pid", process_info.process_data.pid);
@@ -174,14 +171,14 @@ void PowerMessageHandler::OnGetProcessUsageData(const base::ListValue* args) {
element.Set("cmdline", process_info.process_data.cmdline);
element.Set("type", static_cast<int>(process_info.process_data.type));
element.Set("powerUsageFraction", process_info.power_usage_fraction);
- js_process_usages.Append(base::Value(std::move(element)));
+ js_process_usages.Append(std::move(element));
}
ResolveJavascriptCallback(callback_id, js_process_usages);
}
-void PowerMessageHandler::GetJsSystemResumedData(base::ListValue *data) {
- DCHECK(data);
+base::Value::List PowerMessageHandler::GetJsSystemResumedData() {
+ base::Value::List data;
const base::circular_deque<PowerDataCollector::SystemResumedSample>&
system_resumed = PowerDataCollector::Get()->system_resumed_data();
@@ -191,14 +188,15 @@ void PowerMessageHandler::GetJsSystemResumedData(base::ListValue *data) {
element.Set("sleepDuration", sample.sleep_duration.InMillisecondsF());
element.Set("time", sample.time.ToJsTime());
- data->Append(base::Value(std::move(element)));
+ data.Append(std::move(element));
}
+ return data;
}
-void PowerMessageHandler::GetJsStateOccupancyData(
+base::Value::List PowerMessageHandler::GetJsStateOccupancyData(
const std::vector<CpuDataCollector::StateOccupancySampleDeque>& data,
- const std::vector<std::string>& state_names,
- base::ListValue *js_data) {
+ const std::vector<std::string>& state_names) {
+ base::Value::List js_data;
for (unsigned int cpu = 0; cpu < data.size(); ++cpu) {
const CpuDataCollector::StateOccupancySampleDeque& sample_deque = data[cpu];
base::Value::List js_sample_list;
@@ -217,8 +215,9 @@ void PowerMessageHandler::GetJsStateOccupancyData(
js_sample_list.Append(std::move(js_sample));
}
- js_data->Append(base::Value(std::move(js_sample_list)));
+ js_data.Append(std::move(js_sample_list));
}
+ return js_data;
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
index 039a4d4896e..99daa4862d6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -54,19 +54,19 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
// WebUIMessageHandler:
void RegisterMessages() override {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setTimePageReady",
base::BindRepeating(&SetTimeMessageHandler::OnPageReady,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setTimeInSeconds",
base::BindRepeating(&SetTimeMessageHandler::OnSetTime,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setTimezone",
base::BindRepeating(&SetTimeMessageHandler::OnSetTimezone,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"doneClicked", base::BindRepeating(&SetTimeMessageHandler::DoneClicked,
base::Unretained(this)));
}
@@ -82,7 +82,7 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
}
private:
- void OnPageReady(const base::ListValue* args) { AllowJavascript(); }
+ void OnPageReady(const base::Value::List& args) { AllowJavascript(); }
// SystemClockClient::Observer:
void SystemClockUpdated() override {
@@ -102,35 +102,34 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
// Handler for Javascript call to set the system clock when the user sets a
// new time. Expects the time as the number of seconds since the Unix
// epoch, treated as a double.
- void OnSetTime(const base::ListValue* args) {
- double seconds = args->GetListDeprecated()[0].GetDouble();
+ void OnSetTime(const base::Value::List& args) {
+ double seconds = args[0].GetDouble();
SystemClockClient::Get()->SetTime(static_cast<int64_t>(seconds));
}
// Handler for Javascript call to change the system time zone when the user
// selects a new time zone. Expects the time zone ID as a string, as it
// appears in the time zone option values.
- void OnSetTimezone(const base::ListValue* args) {
- if (args->GetListDeprecated().empty() ||
- !args->GetListDeprecated()[0].is_string()) {
+ void OnSetTimezone(const base::Value::List& args) {
+ if (args.empty() || !args[0].is_string()) {
NOTREACHED();
return;
}
- std::string timezone_id = args->GetListDeprecated()[0].GetString();
+ std::string timezone_id = args[0].GetString();
Profile* profile = Profile::FromWebUI(web_ui());
DCHECK(profile);
system::SetTimezoneFromUI(profile, timezone_id);
}
- void DoneClicked(const base::ListValue* args) {
+ void DoneClicked(const base::Value::List& args) {
if (!parent_access::ParentAccessService::IsApprovalRequired(
ash::SupervisedAction::kUpdateClock)) {
OnParentAccessValidation(true);
return;
}
- double seconds = args->GetListDeprecated()[0].GetDouble();
+ double seconds = args[0].GetDouble();
AccountId account_id;
bool is_user_logged_in = user_manager::UserManager::Get()->IsUserLoggedIn();
if (is_user_logged_in) {
@@ -180,8 +179,7 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
base::Value::Dict values;
// List of list of strings: [[ID, name], [ID, name], ...]
- values.Set("timezoneList", base::Value::FromUniquePtrValue(
- chromeos::system::GetTimezoneList()));
+ values.Set("timezoneList", chromeos::system::GetTimezoneList());
// If we are not logged in, we need to show the time zone dropdown.
values.Set("showTimezone", SetTimeDialog::ShouldShowTimezone());
@@ -194,6 +192,8 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
source->AddResourcePath("set_time_browser_proxy.js",
IDR_SET_TIME_BROWSER_PROXY_JS);
+ source->AddResourcePath("set_time_dialog.html.js",
+ IDR_SET_TIME_DIALOG_HTML_JS);
source->AddResourcePath("set_time_dialog.js", IDR_SET_TIME_DIALOG_JS);
source->SetDefaultResource(IDR_SET_TIME_HTML);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
index ff4e1388cdd..32bd22b04aa 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
@@ -52,7 +52,7 @@ void SlowTraceSource::StartDataRequest(
base::Unretained(this), std::move(callback)));
}
-std::string SlowTraceSource::GetMimeType(const std::string& path) {
+std::string SlowTraceSource::GetMimeType(const GURL& url) {
return "application/zip";
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
index 7749d465b10..247e2bdbf2e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h
@@ -36,7 +36,7 @@ class SlowTraceSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool AllowCaching() override;
private:
diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
index 6e945d452a6..f57da4523f3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
@@ -74,9 +74,9 @@ class SlowHandler : public WebUIMessageHandler {
void UpdatePage();
// Handlers for JS WebUI messages.
- void HandleDisable(const base::ListValue* args);
- void HandleEnable(const base::ListValue* args);
- void LoadComplete(const base::ListValue* args);
+ void HandleDisable(const base::Value::List& args);
+ void HandleEnable(const base::Value::List& args);
+ void LoadComplete(const base::Value::List& args);
Profile* profile_;
std::unique_ptr<PrefChangeRegistrar> user_pref_registrar_;
@@ -93,13 +93,13 @@ SlowHandler::~SlowHandler() {
}
void SlowHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kJsApiDisableTracing,
base::BindRepeating(&SlowHandler::HandleDisable, base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kJsApiEnableTracing,
base::BindRepeating(&SlowHandler::HandleEnable, base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kJsApiLoadComplete,
base::BindRepeating(&SlowHandler::LoadComplete, base::Unretained(this)));
}
@@ -114,17 +114,17 @@ void SlowHandler::OnJavascriptDisallowed() {
user_pref_registrar_->RemoveAll();
}
-void SlowHandler::HandleDisable(const base::ListValue* args) {
+void SlowHandler::HandleDisable(const base::Value::List& args) {
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetBoolean(prefs::kPerformanceTracingEnabled, false);
}
-void SlowHandler::HandleEnable(const base::ListValue* args) {
+void SlowHandler::HandleEnable(const base::Value::List& args) {
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetBoolean(prefs::kPerformanceTracingEnabled, true);
}
-void SlowHandler::LoadComplete(const base::ListValue* args) {
+void SlowHandler::LoadComplete(const base::Value::List& args) {
AllowJavascript();
UpdatePage();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.cc
index bfa99b6770c..d97135d09c7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.cc
@@ -24,10 +24,11 @@ smb_client::SmbService* GetSmbService(Profile* profile) {
return service;
}
-base::Value BuildShareList(const std::vector<smb_client::SmbUrl>& shares) {
- base::Value shares_list(base::Value::Type::LIST);
+base::Value::List BuildShareList(
+ const std::vector<smb_client::SmbUrl>& shares) {
+ base::Value::List shares_list;
for (const auto& share : shares) {
- shares_list.Append(base::Value(share.GetWindowsUNCString()));
+ shares_list.Append(share.GetWindowsUNCString());
}
return shares_list;
}
@@ -42,32 +43,31 @@ SmbHandler::SmbHandler(Profile* profile,
SmbHandler::~SmbHandler() = default;
void SmbHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"smbMount",
base::BindRepeating(&SmbHandler::HandleSmbMount, base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"startDiscovery", base::BindRepeating(&SmbHandler::HandleStartDiscovery,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"updateCredentials",
base::BindRepeating(&SmbHandler::HandleUpdateCredentials,
base::Unretained(this)));
}
-void SmbHandler::HandleSmbMount(const base::ListValue* args) {
- CHECK_EQ(8U, args->GetListDeprecated().size());
+void SmbHandler::HandleSmbMount(const base::Value::List& args) {
+ CHECK_EQ(8U, args.size());
- std::string callback_id = args->GetListDeprecated()[0].GetString();
- std::string mount_url = args->GetListDeprecated()[1].GetString();
- std::string mount_name = args->GetListDeprecated()[2].GetString();
- std::string username = args->GetListDeprecated()[3].GetString();
- std::string password = args->GetListDeprecated()[4].GetString();
- bool use_kerberos = args->GetListDeprecated()[5].GetBool();
- bool should_open_file_manager_after_mount =
- args->GetListDeprecated()[6].GetBool();
- bool save_credentials = args->GetListDeprecated()[7].GetBool();
+ std::string callback_id = args[0].GetString();
+ std::string mount_url = args[1].GetString();
+ std::string mount_name = args[2].GetString();
+ std::string username = args[3].GetString();
+ std::string password = args[4].GetString();
+ bool use_kerberos = args[5].GetBool();
+ bool should_open_file_manager_after_mount = args[6].GetBool();
+ bool save_credentials = args[7].GetBool();
smb_client::SmbService* const service = GetSmbService(profile_);
if (!service) {
@@ -99,7 +99,7 @@ void SmbHandler::HandleSmbMountResponse(const std::string& callback_id,
base::Value(static_cast<int>(result)));
}
-void SmbHandler::HandleStartDiscovery(const base::ListValue* args) {
+void SmbHandler::HandleStartDiscovery(const base::Value::List& args) {
smb_client::SmbService* const service = GetSmbService(profile_);
if (!service) {
return;
@@ -127,12 +127,12 @@ void SmbHandler::HandleGatherSharesResponse(
base::Value(done));
}
-void SmbHandler::HandleUpdateCredentials(const base::ListValue* args) {
- CHECK_EQ(3U, args->GetListDeprecated().size());
+void SmbHandler::HandleUpdateCredentials(const base::Value::List& args) {
+ CHECK_EQ(3U, args.size());
- std::string mount_id = args->GetListDeprecated()[0].GetString();
- std::string username = args->GetListDeprecated()[1].GetString();
- std::string password = args->GetListDeprecated()[2].GetString();
+ std::string mount_id = args[0].GetString();
+ std::string username = args[1].GetString();
+ std::string password = args[2].GetString();
DCHECK(update_cred_callback_);
std::move(update_cred_callback_).Run(username, password);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h
index 5304cbf9660..b112e7cce03 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h
@@ -35,13 +35,13 @@ class SmbHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
// WebUI call to mount an Smb Filesystem.
- void HandleSmbMount(const base::ListValue* args);
+ void HandleSmbMount(const base::Value::List& args);
// WebUI call to start file share discovery on the network.
- void HandleStartDiscovery(const base::ListValue* args);
+ void HandleStartDiscovery(const base::Value::List& args);
// WebUI call to update the credentials of a mounted share.
- void HandleUpdateCredentials(const base::ListValue* args);
+ void HandleUpdateCredentials(const base::Value::List& args);
// Callback handler for SmbMount.
void HandleSmbMountResponse(const std::string& callback_id,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
index 916f942d238..7941527f027 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
@@ -77,11 +77,6 @@ SmbShareDialogUI::SmbShareDialogUI(content::WebUI* web_ui)
source->AddBoolean("isActiveDirectoryUser",
user && user->IsActiveDirectoryUser());
- // Check if Kerberos was and still is enabled via policy at the creation time
- // of SmbService. As a result, if Kerberos policy was enabled during a user
- // session, SSO option will not be available/visible.
- // TODO(crbug.com/1040138): subscribe to pref. changes in SmbService and setup
- // Kerberos after it is enabled during a user session.
const ash::smb_client::SmbService* const smb_service =
ash::smb_client::SmbServiceFactory::Get(profile);
bool is_kerberos_enabled =
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.cc
index 1abd0c801ed..5ac964d73e2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.cc
@@ -36,19 +36,19 @@ OSSyncHandler::~OSSyncHandler() {
}
void OSSyncHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"DidNavigateToOsSyncPage",
base::BindRepeating(&OSSyncHandler::HandleDidNavigateToOsSyncPage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"DidNavigateAwayFromOsSyncPage",
base::BindRepeating(&OSSyncHandler::HandleDidNavigateAwayFromOsSyncPage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"OsSyncPrefsDispatch",
base::BindRepeating(&OSSyncHandler::HandleOsSyncPrefsDispatch,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"SetOsSyncDatatypes",
base::BindRepeating(&OSSyncHandler::HandleSetOsSyncDatatypes,
base::Unretained(this)));
@@ -67,24 +67,25 @@ void OSSyncHandler::OnStateChanged(syncer::SyncService* service) {
PushSyncPrefs();
}
-void OSSyncHandler::HandleDidNavigateToOsSyncPage(const base::ListValue* args) {
+void OSSyncHandler::HandleDidNavigateToOsSyncPage(
+ const base::Value::List& args) {
HandleOsSyncPrefsDispatch(args);
}
-void OSSyncHandler::HandleOsSyncPrefsDispatch(const base::ListValue* args) {
+void OSSyncHandler::HandleOsSyncPrefsDispatch(const base::Value::List& args) {
AllowJavascript();
PushSyncPrefs();
}
void OSSyncHandler::HandleDidNavigateAwayFromOsSyncPage(
- const base::ListValue* args) {
+ const base::Value::List& args) {
// TODO(https://crbug.com/1278325): Remove this.
}
-void OSSyncHandler::HandleSetOsSyncDatatypes(const base::ListValue* args) {
- CHECK_EQ(1u, args->GetListDeprecated().size());
- const base::Value& result_value = args->GetListDeprecated()[0];
+void OSSyncHandler::HandleSetOsSyncDatatypes(const base::Value::List& args) {
+ CHECK_EQ(1u, args.size());
+ const base::Value& result_value = args[0];
CHECK(result_value.is_dict());
const base::DictionaryValue& result =
base::Value::AsDictionaryValue(result_value);
@@ -136,26 +137,26 @@ void OSSyncHandler::PushSyncPrefs() {
if (!service || !service->IsEngineInitialized())
return;
- base::DictionaryValue args;
+ base::Value::Dict args;
SyncUserSettings* user_settings = service->GetUserSettings();
// Tell the UI layer which data types are registered/enabled by the user.
- args.SetBoolKey("syncAllOsTypes", user_settings->IsSyncAllOsTypesEnabled());
+ args.Set("syncAllOsTypes", user_settings->IsSyncAllOsTypesEnabled());
UserSelectableOsTypeSet registered_types =
user_settings->GetRegisteredSelectableOsTypes();
UserSelectableOsTypeSet selected_types = user_settings->GetSelectedOsTypes();
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
std::string type_name = syncer::GetUserSelectableOsTypeName(type);
- args.SetBoolPath(type_name + "Registered", registered_types.Has(type));
- args.SetBoolPath(type_name + "Synced", selected_types.Has(type));
+ args.SetByDottedPath(type_name + "Registered", registered_types.Has(type));
+ args.SetByDottedPath(type_name + "Synced", selected_types.Has(type));
}
// Wallpaper sync status is fetched from prefs and is considered enabled if
// all OS types are enabled; this mimics behavior of GetSelectedOsTypes().
- args.SetBoolKey(kWallpaperEnabledKey,
- user_settings->IsSyncAllOsTypesEnabled() ||
- profile_->GetPrefs()->GetBoolean(
- chromeos::settings::prefs::kSyncOsWallpaper));
+ args.Set(kWallpaperEnabledKey,
+ user_settings->IsSyncAllOsTypesEnabled() ||
+ profile_->GetPrefs()->GetBoolean(
+ chromeos::settings::prefs::kSyncOsWallpaper));
FireWebUIListener("os-sync-prefs-changed", args);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h
index 4c2609b5ace..ccbb7b7e270 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h
@@ -5,15 +5,12 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_SYNC_OS_SYNC_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_SYNC_OS_SYNC_HANDLER_H_
+#include "base/values.h"
#include "components/sync/driver/sync_service_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
class Profile;
-namespace base {
-class ListValue;
-} // namespace base
-
namespace syncer {
class SyncService;
} // namespace syncer
@@ -39,10 +36,10 @@ class OSSyncHandler : public content::WebUIMessageHandler,
void OnStateChanged(syncer::SyncService* service) override;
// Callbacks from the page. Visible for testing.
- void HandleDidNavigateToOsSyncPage(const base::ListValue* args);
- void HandleDidNavigateAwayFromOsSyncPage(const base::ListValue* args);
- void HandleOsSyncPrefsDispatch(const base::ListValue* args);
- void HandleSetOsSyncDatatypes(const base::ListValue* args);
+ void HandleDidNavigateToOsSyncPage(const base::Value::List& args);
+ void HandleDidNavigateAwayFromOsSyncPage(const base::Value::List& args);
+ void HandleOsSyncPrefsDispatch(const base::Value::List& args);
+ void HandleSetOsSyncDatatypes(const base::Value::List& args);
void SetWebUIForTest(content::WebUI* web_ui);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc
index d1fd71a401c..1843d9cffde 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc
@@ -170,7 +170,7 @@ class OsSyncHandlerTest : public ChromeRenderViewHostTestHarness {
};
TEST_F(OsSyncHandlerTest, OsSyncPrefsSentOnNavigateToPage) {
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
ASSERT_EQ(1U, web_ui_.call_data().size());
const TestWebUI::CallData& call_data = *web_ui_.call_data().back();
@@ -184,7 +184,7 @@ TEST_F(OsSyncHandlerTest, OpenConfigPageBeforeSyncEngineInitialized) {
sync_service_->SetTransportState(SyncService::TransportState::START_DEFERRED);
// Navigate to the page.
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
// No data is sent yet, because the engine is not initialized.
EXPECT_EQ(0U, web_ui_.call_data().size());
@@ -211,11 +211,11 @@ TEST_F(OsSyncHandlerTest, OnlyStartEngineWhenConfiguringSync) {
}
TEST_F(OsSyncHandlerTest, TestSyncEverything) {
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(CreateOsSyncPrefs(SYNC_ALL_OS_TYPES,
UserSelectableOsTypeSet::All(),
/*wallpaper_enabled=*/true));
- handler_->HandleSetOsSyncDatatypes(&list_args);
+ handler_->HandleSetOsSyncDatatypes(list_args);
EXPECT_TRUE(user_settings_->IsSyncAllOsTypesEnabled());
}
@@ -224,30 +224,30 @@ TEST_F(OsSyncHandlerTest, TestSyncEverything) {
TEST_F(OsSyncHandlerTest, TestSyncIndividualTypes) {
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
UserSelectableOsTypeSet types = {type};
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(CreateOsSyncPrefs(CHOOSE_WHAT_TO_SYNC, types,
/*wallpaper_enabled=*/false));
- handler_->HandleSetOsSyncDatatypes(&list_args);
+ handler_->HandleSetOsSyncDatatypes(list_args);
EXPECT_FALSE(user_settings_->IsSyncAllOsTypesEnabled());
EXPECT_EQ(types, user_settings_->GetSelectedOsTypes());
}
// Special case for wallpaper.
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(CreateOsSyncPrefs(CHOOSE_WHAT_TO_SYNC, /*types=*/{},
/*wallpaper_enabled=*/true));
- handler_->HandleSetOsSyncDatatypes(&list_args);
+ handler_->HandleSetOsSyncDatatypes(list_args);
EXPECT_FALSE(user_settings_->IsSyncAllOsTypesEnabled());
EXPECT_TRUE(GetWallperEnabledPref());
}
TEST_F(OsSyncHandlerTest, TestSyncAllManually) {
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(CreateOsSyncPrefs(CHOOSE_WHAT_TO_SYNC,
UserSelectableOsTypeSet::All(),
/*wallpaper_enabled=*/true));
- handler_->HandleSetOsSyncDatatypes(&list_args);
+ handler_->HandleSetOsSyncDatatypes(list_args);
EXPECT_FALSE(user_settings_->IsSyncAllOsTypesEnabled());
EXPECT_EQ(UserSelectableOsTypeSet::All(),
user_settings_->GetSelectedOsTypes());
@@ -258,7 +258,7 @@ TEST_F(OsSyncHandlerTest, ShowSetupSyncEverything) {
user_settings_->SetSelectedOsTypes(/*sync_all_os_types=*/true,
UserSelectableOsTypeSet::All());
SetWallperEnabledPref(true);
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
const DictionaryValue* dictionary;
ExpectOsSyncPrefsSent(&dictionary);
@@ -275,7 +275,7 @@ TEST_F(OsSyncHandlerTest, ShowSetupManuallySyncAll) {
user_settings_->SetSelectedOsTypes(/*sync_all_os_types=*/false,
UserSelectableOsTypeSet::All());
SetWallperEnabledPref(true);
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
const DictionaryValue* dictionary;
ExpectOsSyncPrefsSent(&dictionary);
@@ -288,7 +288,7 @@ TEST_F(OsSyncHandlerTest, ShowSetupSyncForAllTypesIndividually) {
for (UserSelectableOsType type : UserSelectableOsTypeSet::All()) {
UserSelectableOsTypeSet types(type);
user_settings_->SetSelectedOsTypes(/*sync_all_os_types=*/false, types);
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
const DictionaryValue* dictionary;
ExpectOsSyncPrefsSent(&dictionary);
@@ -299,7 +299,7 @@ TEST_F(OsSyncHandlerTest, ShowSetupSyncForAllTypesIndividually) {
// Special case for wallpaper.
user_settings_->SetSelectedOsTypes(/*sync_all_os_types=*/false, /*types=*/{});
SetWallperEnabledPref(true);
- handler_->HandleDidNavigateToOsSyncPage(nullptr);
+ handler_->HandleDidNavigateToOsSyncPage(base::Value::List());
const DictionaryValue* dictionary;
ExpectOsSyncPrefsSent(&dictionary);
CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, /*types=*/{},
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.cc
index 6421ab5f73c..b429bf03055 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.cc
@@ -101,24 +101,25 @@ bool GetCpuInfo(std::vector<CpuInfo>* infos) {
return true;
}
-void SetConstValue(base::Value* result) {
+void SetConstValue(base::Value::Dict* result) {
DCHECK(result);
int counter_max = static_cast<int>(COUNTER_MAX);
- result->SetPath({"const", "counterMax"}, base::Value(counter_max));
+ result->SetByDottedPath("const.counterMax", counter_max);
}
-void SetCpusValue(const std::vector<CpuInfo>& infos, base::Value* result) {
+void SetCpusValue(const std::vector<CpuInfo>& infos,
+ base::Value::Dict* result) {
DCHECK(result);
- base::Value cpu_results(base::Value::Type::LIST);
+ base::Value::List cpu_results;
for (const CpuInfo& cpu : infos) {
- base::Value cpu_result(base::Value::Type::DICTIONARY);
- cpu_result.SetKey("user", base::Value(cpu.user));
- cpu_result.SetKey("kernel", base::Value(cpu.kernel));
- cpu_result.SetKey("idle", base::Value(cpu.idle));
- cpu_result.SetKey("total", base::Value(cpu.total));
+ base::Value::Dict cpu_result;
+ cpu_result.Set("user", cpu.user);
+ cpu_result.Set("kernel", cpu.kernel);
+ cpu_result.Set("idle", cpu.idle);
+ cpu_result.Set("total", cpu.total);
cpu_results.Append(std::move(cpu_result));
}
- result->SetKey("cpus", std::move(cpu_results));
+ result->Set("cpus", std::move(cpu_results));
}
const double kBytesInKB = 1024;
@@ -132,44 +133,41 @@ double GetAvailablePhysicalMemory(const base::SystemMemoryInfoKB& info) {
void SetMemValue(const base::SystemMemoryInfoKB& info,
const base::VmStatInfo& vmstat,
- base::Value* result) {
+ base::Value::Dict* result) {
DCHECK(result);
- base::Value mem_result(base::Value::Type::DICTIONARY);
+ base::Value::Dict mem_result;
// For values that may exceed the range of 32-bit signed integer, use double.
double total = static_cast<double>(info.total) * kBytesInKB;
- mem_result.SetKey("total", base::Value(total));
- mem_result.SetKey("available", base::Value(GetAvailablePhysicalMemory(info)));
+ mem_result.Set("total", total);
+ mem_result.Set("available", GetAvailablePhysicalMemory(info));
double swap_total = static_cast<double>(info.swap_total) * kBytesInKB;
- mem_result.SetKey("swapTotal", base::Value(swap_total));
+ mem_result.Set("swapTotal", swap_total);
double swap_free = static_cast<double>(info.swap_free) * kBytesInKB;
- mem_result.SetKey("swapFree", base::Value(swap_free));
+ mem_result.Set("swapFree", swap_free);
- mem_result.SetKey("pswpin", base::Value(ToCounter(vmstat.pswpin)));
- mem_result.SetKey("pswpout", base::Value(ToCounter(vmstat.pswpout)));
+ mem_result.Set("pswpin", ToCounter(vmstat.pswpin));
+ mem_result.Set("pswpout", ToCounter(vmstat.pswpout));
- result->SetKey("memory", std::move(mem_result));
+ result->Set("memory", std::move(mem_result));
}
-void SetZramValue(const base::SwapInfo& info, base::Value* result) {
+void SetZramValue(const base::SwapInfo& info, base::Value::Dict* result) {
DCHECK(result);
- base::Value zram_result(base::Value::Type::DICTIONARY);
+ base::Value::Dict zram_result;
- zram_result.SetKey("numReads", base::Value(ToCounter(info.num_reads)));
- zram_result.SetKey("numWrites", base::Value(ToCounter(info.num_writes)));
+ zram_result.Set("numReads", ToCounter(info.num_reads));
+ zram_result.Set("numWrites", ToCounter(info.num_writes));
// For values that may exceed the range of 32-bit signed integer, use double.
- zram_result.SetKey("comprDataSize",
- base::Value(static_cast<double>(info.compr_data_size)));
- zram_result.SetKey("origDataSize",
- base::Value(static_cast<double>(info.orig_data_size)));
- zram_result.SetKey("memUsedTotal",
- base::Value(static_cast<double>(info.mem_used_total)));
-
- result->SetKey("zram", std::move(zram_result));
+ zram_result.Set("comprDataSize", static_cast<double>(info.compr_data_size));
+ zram_result.Set("origDataSize", static_cast<double>(info.orig_data_size));
+ zram_result.Set("memUsedTotal", static_cast<double>(info.mem_used_total));
+
+ result->Set("zram", std::move(zram_result));
}
-base::Value GetSysInfo() {
+base::Value::Dict GetSysInfo() {
std::vector<CpuInfo> cpu_infos(base::SysInfo::NumberOfProcessors());
if (!GetCpuInfo(&cpu_infos)) {
DLOG(WARNING) << "Failed to get system CPU info.";
@@ -188,7 +186,7 @@ base::Value GetSysInfo() {
DLOG(WARNING) << ("Failed to get system zram info.");
}
- base::Value result(base::Value::Type::DICTIONARY);
+ base::Value::Dict result;
SetConstValue(&result);
SetCpusValue(cpu_infos, &result);
SetMemValue(mem_info, vmstat_info, &result);
@@ -204,18 +202,17 @@ SysInternalsMessageHandler::SysInternalsMessageHandler() {}
SysInternalsMessageHandler::~SysInternalsMessageHandler() {}
void SysInternalsMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getSysInfo",
base::BindRepeating(&SysInternalsMessageHandler::HandleGetSysInfo,
base::Unretained(this)));
}
-void SysInternalsMessageHandler::HandleGetSysInfo(const base::ListValue* args) {
+void SysInternalsMessageHandler::HandleGetSysInfo(
+ const base::Value::List& list) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- DCHECK(args);
AllowJavascript();
- base::Value::ConstListView list = args->GetListDeprecated();
if (list.size() != 1 || !list[0].is_string()) {
NOTREACHED();
return;
@@ -229,7 +226,7 @@ void SysInternalsMessageHandler::HandleGetSysInfo(const base::ListValue* args) {
}
void SysInternalsMessageHandler::ReplySysInfo(base::Value callback_id,
- base::Value result) {
+ base::Value::Dict result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
ResolveJavascriptCallback(callback_id, result);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
index f79ea300131..95263766627 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
@@ -28,7 +28,7 @@ class SysInternalsMessageHandler : public content::WebUIMessageHandler {
private:
// Handle the Javascript message |getSysInfo|. The message is sent to get
// system information.
- void HandleGetSysInfo(const base::ListValue* args);
+ void HandleGetSysInfo(const base::Value::List& args);
// The callback function to handle the returning data.
//
@@ -60,7 +60,7 @@ class SysInternalsMessageHandler : public content::WebUIMessageHandler {
// total (counter)
// }
//
- void ReplySysInfo(base::Value callback_id, base::Value result);
+ void ReplySysInfo(base::Value callback_id, base::Value::Dict result);
base::WeakPtrFactory<SysInternalsMessageHandler> weak_ptr_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc
index b52628d6290..ff372dc2832 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc
@@ -190,7 +190,7 @@ void UserImageSource::StartDataRequest(
std::move(callback).Run(GetUserImageInternal(account_id, frame));
}
-std::string UserImageSource::GetMimeType(const std::string& path) {
+std::string UserImageSource::GetMimeType(const GURL& url) {
// We need to explicitly return a mime type, otherwise if the user tries to
// drag the image they get no extension.
return "image/png";
diff --git a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h
index 63ddfcc64dd..32daa4d42fa 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h
@@ -37,7 +37,7 @@ class UserImageSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
// Returns PNG encoded image for user with specified |account_id|. If there's
// no user with such an id, returns the first default image. Always returns
diff --git a/chromium/chrome/browser/ui/webui/chromeos/video_source.cc b/chromium/chrome/browser/ui/webui/chromeos/video_source.cc
deleted file mode 100644
index b4cfa71823f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/video_source.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chromeos/video_source.h"
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/location.h"
-#include "base/memory/ref_counted_memory.h"
-#include "base/task/sequenced_task_runner.h"
-#include "base/task/single_thread_task_runner.h"
-#include "base/task/task_runner_util.h"
-#include "base/task/thread_pool.h"
-#include "base/task/thread_pool/thread_pool_instance.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "chrome/common/url_constants.h"
-#include "net/base/mime_util.h"
-
-namespace chromeos {
-namespace {
-
-const char kAllowlistedDirectory[] = "oobe_videos";
-
-bool IsAllowlisted(const std::string& path) {
- base::FilePath file_path(path);
- if (file_path.ReferencesParent())
- return false;
-
- // Check if the path starts with a allowlisted directory.
- std::vector<std::string> components = file_path.GetComponents();
- if (components.empty())
- return false;
- return components[0] == kAllowlistedDirectory;
-}
-
-// Callback for user_manager::UserImageLoader.
-void VideoLoaded(content::URLDataSource::GotDataCallback got_data_callback,
- std::unique_ptr<std::string> video_data,
- bool did_load_file) {
- if (video_data->size() && did_load_file) {
- std::move(got_data_callback)
- .Run(new base::RefCountedBytes(
- reinterpret_cast<const unsigned char*>(video_data->data()),
- video_data->size()));
- } else {
- std::move(got_data_callback).Run(nullptr);
- }
-}
-
-} // namespace
-
-VideoSource::VideoSource() {
- task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
-}
-
-VideoSource::~VideoSource() {}
-
-std::string VideoSource::GetSource() {
- return chrome::kChromeOSAssetHost;
-}
-
-void VideoSource::StartDataRequest(
- const GURL& url,
- const content::WebContents::Getter& wc_getter,
- content::URLDataSource::GotDataCallback got_data_callback) {
- const std::string path = content::URLDataSource::URLToRequestPath(url);
- if (!IsAllowlisted(path)) {
- std::move(got_data_callback).Run(nullptr);
- return;
- }
-
- const base::FilePath asset_dir(chrome::kChromeOSAssetPath);
- const base::FilePath video_path = asset_dir.AppendASCII(path);
- base::ThreadPool::PostTaskAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::BindOnce(&base::PathExists, video_path),
- base::BindOnce(&VideoSource::StartDataRequestAfterPathExists,
- weak_factory_.GetWeakPtr(), video_path,
- std::move(got_data_callback)));
-}
-
-std::string VideoSource::GetMimeType(const std::string& path) {
- std::string mime_type;
- std::string ext = base::FilePath(path).Extension();
- if (!ext.empty())
- net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type);
- return mime_type;
-}
-
-void VideoSource::StartDataRequestAfterPathExists(
- const base::FilePath& video_path,
- content::URLDataSource::GotDataCallback got_data_callback,
- bool path_exists) {
- if (path_exists) {
- auto video_data = std::make_unique<std::string>();
- std::string* data = video_data.get();
- base::PostTaskAndReplyWithResult(
- task_runner_.get(), FROM_HERE,
- base::BindOnce(&base::ReadFileToString, video_path, data),
- base::BindOnce(&VideoLoaded, std::move(got_data_callback),
- std::move(video_data)));
-
- } else {
- std::move(got_data_callback).Run(nullptr);
- }
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/video_source.h b/chromium/chrome/browser/ui/webui/chromeos/video_source.h
deleted file mode 100644
index 5bb16904a3b..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/video_source.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_
-
-#include <string>
-
-#include "base/memory/scoped_refptr.h"
-#include "base/memory/weak_ptr.h"
-#include "content/public/browser/url_data_source.h"
-
-namespace base {
-class FilePath;
-class SequencedTaskRunner;
-} // namespace base
-
-namespace chromeos {
-
-// Data source that reads videos from the file system.
-// It provides resources from chrome urls of type:
-// chrome://chromeos-asset/<allowlisted directories>/*.webm
-class VideoSource : public content::URLDataSource {
- public:
- VideoSource();
-
- VideoSource(const VideoSource&) = delete;
- VideoSource& operator=(const VideoSource&) = delete;
-
- ~VideoSource() override;
-
- // content::URLDataSource:
- std::string GetSource() override;
- void StartDataRequest(
- const GURL& url,
- const content::WebContents::Getter& wc_getter,
- content::URLDataSource::GotDataCallback got_data_callback) override;
- std::string GetMimeType(const std::string& path) override;
-
- private:
- // Continuation from StartDataRequest().
- void StartDataRequestAfterPathExists(
- const base::FilePath& video_path,
- content::URLDataSource::GotDataCallback got_data_callback,
- bool path_exists);
-
- // The background task runner on which file I/O is performed.
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
-
- base::WeakPtrFactory<VideoSource> weak_factory_{this};
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_handler.cc b/chromium/chrome/browser/ui/webui/commander/commander_handler.cc
index 85063eb4d1f..ca6369bc9da 100644
--- a/chromium/chrome/browser/ui/webui/commander/commander_handler.cc
+++ b/chromium/chrome/browser/ui/webui/commander/commander_handler.cc
@@ -37,22 +37,22 @@ CommanderHandler::CommanderHandler() = default;
CommanderHandler::~CommanderHandler() = default;
void CommanderHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kTextChangedMessage,
base::BindRepeating(&CommanderHandler::HandleTextChanged,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kOptionSelectedMessage,
base::BindRepeating(&CommanderHandler::HandleOptionSelected,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kCompositeCommandCancelledMessage,
base::BindRepeating(&CommanderHandler::HandleCompositeCommandCancelled,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kDismissMessage, base::BindRepeating(&CommanderHandler::HandleDismiss,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
kHeightChangedMessage,
base::BindRepeating(&CommanderHandler::HandleHeightChanged,
base::Unretained(this)));
@@ -68,73 +68,73 @@ void CommanderHandler::OnJavascriptAllowed() {
delegate_->OnHandlerEnabled(true);
}
-void CommanderHandler::HandleTextChanged(const base::ListValue* args) {
+void CommanderHandler::HandleTextChanged(const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1u, args->GetListDeprecated().size());
- std::string text = args->GetListDeprecated()[0].GetString();
+ CHECK_EQ(1u, args.size());
+ std::string text = args[0].GetString();
if (delegate_)
delegate_->OnTextChanged(base::UTF8ToUTF16(text));
}
-void CommanderHandler::HandleOptionSelected(const base::ListValue* args) {
+void CommanderHandler::HandleOptionSelected(const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(2u, args->GetListDeprecated().size());
- int index = args->GetListDeprecated()[0].GetInt();
- int result_set_id = args->GetListDeprecated()[1].GetInt();
+ CHECK_EQ(2u, args.size());
+ int index = args[0].GetInt();
+ int result_set_id = args[1].GetInt();
if (delegate_)
delegate_->OnOptionSelected(index, result_set_id);
}
void CommanderHandler::HandleCompositeCommandCancelled(
- const base::ListValue* args) {
+ const base::Value::List& args) {
if (!delegate_)
return;
AllowJavascript();
delegate_->OnCompositeCommandCancelled();
}
-void CommanderHandler::HandleDismiss(const base::ListValue* args) {
+void CommanderHandler::HandleDismiss(const base::Value::List& args) {
if (delegate_)
delegate_->OnDismiss();
}
-void CommanderHandler::HandleHeightChanged(const base::ListValue* args) {
- CHECK_EQ(1u, args->GetListDeprecated().size());
- int new_height = args->GetListDeprecated()[0].GetInt();
+void CommanderHandler::HandleHeightChanged(const base::Value::List& args) {
+ CHECK_EQ(1u, args.size());
+ int new_height = args[0].GetInt();
if (delegate_)
delegate_->OnHeightChanged(new_height);
}
void CommanderHandler::ViewModelUpdated(
commander::CommanderViewModel view_model) {
- base::DictionaryValue vm;
- vm.GetDict().Set(kActionKey, view_model.action);
- vm.GetDict().Set(kResultSetIdKey, view_model.result_set_id);
+ base::Value::Dict vm;
+ vm.Set(kActionKey, view_model.action);
+ vm.Set(kResultSetIdKey, view_model.result_set_id);
if (view_model.action ==
commander::CommanderViewModel::Action::kDisplayResults) {
- base::ListValue option_list;
+ base::Value::List option_list;
for (commander::CommandItemViewModel& item : view_model.items) {
- base::DictionaryValue option;
- option.GetDict().Set(kTitleKey, item.title);
- option.GetDict().Set(kEntityKey, item.entity_type);
+ base::Value::Dict option;
+ option.Set(kTitleKey, item.title);
+ option.Set(kEntityKey, item.entity_type);
if (!item.annotation.empty())
- option.GetDict().Set(kAnnotationKey, item.annotation);
- base::ListValue ranges;
+ option.Set(kAnnotationKey, item.annotation);
+ base::Value::List ranges;
for (const gfx::Range& range : item.matched_ranges) {
- base::ListValue range_value;
+ base::Value::List range_value;
range_value.Append(static_cast<int>(range.start()));
range_value.Append(static_cast<int>(range.end()));
ranges.Append(std::move(range_value));
}
- option.GetDict().Set(kMatchedRangesKey, std::move(ranges));
+ option.Set(kMatchedRangesKey, std::move(ranges));
option_list.Append(std::move(option));
}
- vm.GetDict().Set(kOptionsKey, std::move(option_list));
+ vm.Set(kOptionsKey, std::move(option_list));
} else {
// kDismiss is handled higher in the stack.
DCHECK_EQ(view_model.action,
commander::CommanderViewModel::Action::kPrompt);
- vm.GetDict().Set(kPromptTextKey, view_model.prompt_text);
+ vm.Set(kPromptTextKey, view_model.prompt_text);
}
FireWebUIListener(kViewModelUpdatedEvent, vm);
}
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_handler.h b/chromium/chrome/browser/ui/webui/commander/commander_handler.h
index d793cbad393..1f79855f21c 100644
--- a/chromium/chrome/browser/ui/webui/commander/commander_handler.h
+++ b/chromium/chrome/browser/ui/webui/commander/commander_handler.h
@@ -53,24 +53,24 @@ class CommanderHandler : public content::WebUIMessageHandler {
// Handles text changes in the primary textfield. Expects a single string
// argument.
- void HandleTextChanged(const base::ListValue* args);
+ void HandleTextChanged(const base::Value::List& args);
// Handles the user selecting one of the available command options.
// Expects two numeric argument representing the index of the chosen command,
// and the result set id of the active view model (see documentation in
// commander::CommanderViewModel).
- void HandleOptionSelected(const base::ListValue* args);
+ void HandleOptionSelected(const base::Value::List& args);
// Handles the user cancelling a composite command. No arguments expected.
- void HandleCompositeCommandCancelled(const base::ListValue* args);
+ void HandleCompositeCommandCancelled(const base::Value::List& args);
// Handles the user pressing "Escape", or otherwise indicating they would
// like to dismiss the UI. No arguments expected.
- void HandleDismiss(const base::ListValue* args);
+ void HandleDismiss(const base::Value::List& args);
// Handles the display height of the UI changing. Expects one numeric argument
// representing the new height.
- void HandleHeightChanged(const base::ListValue* args);
+ void HandleHeightChanged(const base::Value::List& args);
raw_ptr<Delegate> delegate_ = nullptr;
};
diff --git a/chromium/chrome/browser/ui/webui/components/components_handler.cc b/chromium/chrome/browser/ui/webui/components/components_handler.cc
index 36086851182..943cb57ff64 100644
--- a/chromium/chrome/browser/ui/webui/components/components_handler.cc
+++ b/chromium/chrome/browser/ui/webui/components/components_handler.cc
@@ -35,17 +35,17 @@ ComponentsHandler::ComponentsHandler(
ComponentsHandler::~ComponentsHandler() = default;
void ComponentsHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestComponentsData",
base::BindRepeating(&ComponentsHandler::HandleRequestComponentsData,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"checkUpdate", base::BindRepeating(&ComponentsHandler::HandleCheckUpdate,
base::Unretained(this)));
#if BUILDFLAG(IS_CHROMEOS)
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"crosUrlComponentsRedirect",
base::BindRepeating(&ComponentsHandler::HandleCrosUrlComponentsRedirect,
base::Unretained(this)));
@@ -61,13 +61,12 @@ void ComponentsHandler::OnJavascriptDisallowed() {
}
void ComponentsHandler::HandleRequestComponentsData(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value& callback_id = args[0];
- base::DictionaryValue result;
- result.GetDict().Set("components",
- base::Value::FromUniquePtrValue(LoadComponents()));
+ base::Value::Dict result;
+ result.Set("components", LoadComponents());
#if BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -75,7 +74,7 @@ void ComponentsHandler::HandleRequestComponentsData(
#else
const bool showSystemFlagsLink = true;
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- result.GetDict().Set("showOsLink", showSystemFlagsLink);
+ result.Set("showOsLink", showSystemFlagsLink);
#endif // BUILDFLAG(IS_CHROMEOS)
ResolveJavascriptCallback(callback_id, result);
@@ -85,32 +84,31 @@ void ComponentsHandler::HandleRequestComponentsData(
// TODO(shrikant): We need to make this button available based on current
// state e.g. If component state is currently updating then we need to disable
// button. (https://code.google.com/p/chromium/issues/detail?id=272540)
-void ComponentsHandler::HandleCheckUpdate(const base::ListValue* args) {
- if (args->GetListDeprecated().size() != 1) {
+void ComponentsHandler::HandleCheckUpdate(const base::Value::List& args) {
+ if (args.size() != 1) {
NOTREACHED();
return;
}
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
NOTREACHED();
return;
}
- const std::string& component_id = args->GetListDeprecated()[0].GetString();
+ const std::string& component_id = args[0].GetString();
OnDemandUpdate(component_id);
}
void ComponentsHandler::OnEvent(Events event, const std::string& id) {
- base::DictionaryValue parameters;
- parameters.GetDict().Set("event", ComponentEventToString(event));
+ base::Value::Dict parameters;
+ parameters.Set("event", ComponentEventToString(event));
if (!id.empty()) {
if (event == Events::COMPONENT_UPDATED) {
update_client::CrxUpdateItem item;
if (component_updater_->GetComponentDetails(id, &item) && item.component)
- parameters.GetDict().Set("version",
- item.component->version.GetString());
+ parameters.Set("version", item.component->version.GetString());
}
- parameters.GetDict().Set("id", id);
+ parameters.Set("id", id);
}
FireWebUIListener("component-event", parameters);
}
@@ -127,8 +125,9 @@ std::u16string ComponentsHandler::ComponentEventToString(Events event) {
return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_READY);
case Events::COMPONENT_UPDATED:
return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_UPDATED);
- case Events::COMPONENT_NOT_UPDATED:
- return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_NOTUPDATED);
+ case Events::COMPONENT_ALREADY_UP_TO_DATE:
+ return l10n_util::GetStringUTF16(
+ IDS_COMPONENTS_EVT_STATUS_ALREADY_UP_TO_DATE);
case Events::COMPONENT_UPDATE_ERROR:
return l10n_util::GetStringUTF16(IDS_COMPONENTS_EVT_STATUS_UPDATE_ERROR);
case Events::COMPONENT_UPDATE_DOWNLOADING:
@@ -175,7 +174,7 @@ std::u16string ComponentsHandler::ServiceStatusToString(
#if BUILDFLAG(IS_CHROMEOS)
void ComponentsHandler::HandleCrosUrlComponentsRedirect(
- const base::ListValue* args) {
+ const base::Value::List& args) {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
lacros_url_handling::NavigateInAsh(GURL(chrome::kOsUIComponentsURL));
#else
@@ -194,12 +193,12 @@ void ComponentsHandler::OnDemandUpdate(const std::string& component_id) {
component_updater::Callback());
}
-std::unique_ptr<base::ListValue> ComponentsHandler::LoadComponents() {
+base::Value::List ComponentsHandler::LoadComponents() {
const std::vector<std::string> component_ids =
component_updater_->GetComponentIDs();
// Construct DictionaryValues to return to UI.
- auto component_list = std::make_unique<base::ListValue>();
+ base::Value::List component_list;
for (const auto& component_id : component_ids) {
update_client::CrxUpdateItem item;
if (component_updater_->GetComponentDetails(component_id, &item)) {
@@ -210,7 +209,7 @@ std::unique_ptr<base::ListValue> ComponentsHandler::LoadComponents() {
component_entry.Set("name", item.component->name);
component_entry.Set("version", item.component->version.GetString());
}
- component_list->GetList().Append(std::move(component_entry));
+ component_list.Append(std::move(component_entry));
}
}
diff --git a/chromium/chrome/browser/ui/webui/components/components_handler.h b/chromium/chrome/browser/ui/webui/components/components_handler.h
index 05205dc4dca..a793bbe9cbc 100644
--- a/chromium/chrome/browser/ui/webui/components/components_handler.h
+++ b/chromium/chrome/browser/ui/webui/components/components_handler.h
@@ -15,10 +15,6 @@
#include "components/update_client/update_client.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-}
-
// The handler for Javascript messages for the chrome://components/ page.
class ComponentsHandler : public content::WebUIMessageHandler,
public component_updater::ServiceObserver {
@@ -35,17 +31,17 @@ class ComponentsHandler : public content::WebUIMessageHandler,
void OnJavascriptDisallowed() override;
// Callback for the "requestComponentsData" message.
- void HandleRequestComponentsData(const base::ListValue* args);
+ void HandleRequestComponentsData(const base::Value::List& args);
// Callback for the "checkUpdate" message.
- void HandleCheckUpdate(const base::ListValue* args);
+ void HandleCheckUpdate(const base::Value::List& args);
// ServiceObserver implementation.
void OnEvent(Events event, const std::string& id) override;
#if BUILDFLAG(IS_CHROMEOS)
// Callback for the "crosUrlComponentsRedirect" message.
- void HandleCrosUrlComponentsRedirect(const base::ListValue* args);
+ void HandleCrosUrlComponentsRedirect(const base::Value::List& args);
#endif
private:
@@ -53,7 +49,7 @@ class ComponentsHandler : public content::WebUIMessageHandler,
static std::u16string ServiceStatusToString(
update_client::ComponentState state);
- std::unique_ptr<base::ListValue> LoadComponents();
+ base::Value::List LoadComponents();
void OnDemandUpdate(const std::string& component_id);
// Weak pointer; injected for testing.
diff --git a/chromium/chrome/browser/ui/webui/components/components_handler_unittest.cc b/chromium/chrome/browser/ui/webui/components/components_handler_unittest.cc
index d86e93bad46..35313457b13 100644
--- a/chromium/chrome/browser/ui/webui/components/components_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/components/components_handler_unittest.cc
@@ -27,8 +27,8 @@ TEST(ComponentsHandlerTest, RemovesObserver) {
{
TestComponentsHandler handler(&mock_service);
- base::ListValue args;
+ base::Value::List args;
args.Append("unused");
- handler.HandleRequestComponentsData(&args);
+ handler.HandleRequestComponentsData(args);
}
}
diff --git a/chromium/chrome/browser/ui/webui/components/components_ui.cc b/chromium/chrome/browser/ui/webui/components/components_ui.cc
index a3b3720637f..849b47965d4 100644
--- a/chromium/chrome/browser/ui/webui/components/components_ui.cc
+++ b/chromium/chrome/browser/ui/webui/components/components_ui.cc
@@ -36,7 +36,7 @@
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-#include "chromeos/startup/browser_init_params.h"
+#include "chromeos/startup/browser_params_proxy.h"
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
namespace {
@@ -74,7 +74,7 @@ content::WebUIDataSource* CreateComponentsUIHTMLSource(Profile* profile) {
user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
user_manager::UserManager::Get()->IsLoggedInAsPublicAccount()
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
- chromeos::BrowserInitParams::Get()->session_type ==
+ chromeos::BrowserParamsProxy::Get()->SessionType() ==
crosapi::mojom::SessionType::kPublicSession ||
profile->IsGuestSession()
#else
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
index bb88e436cdc..9836ca0acbe 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
@@ -8,7 +8,6 @@
#include <utility>
#include "base/strings/string_util.h"
-#include "base/values.h"
#include "base/win/windows_version.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/win/conflicts/module_database.h"
@@ -329,14 +328,13 @@ std::string GetThirdPartyFeaturesStatusString(ThirdPartyFeaturesStatus status) {
void OnConflictsDataFetched(
ConflictsDataFetcher::OnConflictsDataFetchedCallback
on_conflicts_data_fetched_callback,
- base::DictionaryValue results,
+ base::Value::Dict results,
ThirdPartyFeaturesStatus third_party_features_status) {
// Third-party conflicts status.
- results.SetBoolKey("thirdPartyFeatureEnabled",
- IsThirdPartyFeatureEnabled(third_party_features_status));
- results.SetStringKey(
- "thirdPartyFeatureStatus",
- GetThirdPartyFeaturesStatusString(third_party_features_status));
+ results.Set("thirdPartyFeatureEnabled",
+ IsThirdPartyFeatureEnabled(third_party_features_status));
+ results.Set("thirdPartyFeatureStatus",
+ GetThirdPartyFeaturesStatusString(third_party_features_status));
std::move(on_conflicts_data_fetched_callback).Run(std::move(results));
}
@@ -344,7 +342,7 @@ void OnConflictsDataFetched(
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
void OnModuleDataFetched(ConflictsDataFetcher::OnConflictsDataFetchedCallback
on_conflicts_data_fetched_callback,
- base::DictionaryValue results,
+ base::Value::Dict results,
absl::optional<ThirdPartyConflictsManager::State>
third_party_conflicts_manager_state) {
OnConflictsDataFetched(
@@ -358,7 +356,7 @@ void OnModuleDataFetched(ConflictsDataFetcher::OnConflictsDataFetchedCallback
ConflictsDataFetcher::~ConflictsDataFetcher() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- if (module_list_)
+ if (module_list_.has_value())
ModuleDatabase::GetInstance()->RemoveObserver(this);
}
@@ -421,7 +419,7 @@ void ConflictsDataFetcher::GetListOfModules() {
// The request is handled asynchronously, filling up the |module_list_|,
// and will callback via OnModuleDatabaseIdle() on completion.
- module_list_ = std::make_unique<base::ListValue>();
+ module_list_ = base::Value::List();
auto* module_database = ModuleDatabase::GetInstance();
module_database->ForceStartInspection();
@@ -469,7 +467,7 @@ void ConflictsDataFetcher::OnNewModuleFound(const ModuleInfoKey& module_key,
data.Set("code_id", GenerateCodeId(module_key));
data.Set("process_types", GetProcessTypesString(module_data));
- module_list_->GetList().Append(std::move(data));
+ module_list_->Append(std::move(data));
}
void ConflictsDataFetcher::OnModuleDatabaseIdle() {
@@ -478,9 +476,10 @@ void ConflictsDataFetcher::OnModuleDatabaseIdle() {
ModuleDatabase::GetInstance()->RemoveObserver(this);
- base::DictionaryValue results;
- results.GetDict().Set("moduleCount", int(module_list_->GetList().size()));
- results.Set("moduleList", std::move(module_list_));
+ base::Value::Dict results;
+ results.Set("moduleCount", int(module_list_->size()));
+ results.Set("moduleList", std::move(*module_list_));
+ module_list_ = absl::nullopt;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// The state of third-party features must be determined on the UI thread.
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
index 3aabb5b2c82..799d26e1398 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/sequence_checker.h"
#include "base/task/sequenced_task_runner.h"
+#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/win/conflicts/module_database_observer.h"
@@ -19,11 +20,6 @@
#include "chrome/browser/win/conflicts/third_party_conflicts_manager.h"
#endif
-namespace base {
-class DictionaryValue;
-class ListValue;
-} // namespace base
-
// This class is responsible for gathering the list of modules for the
// chrome://conflicts page and the state of the third-party features on the
// ModuleDatabase task runner and sending it back to the UI thread. The instance
@@ -33,7 +29,7 @@ class ConflictsDataFetcher : public ModuleDatabaseObserver {
using UniquePtr =
std::unique_ptr<ConflictsDataFetcher, base::OnTaskRunnerDeleter>;
using OnConflictsDataFetchedCallback =
- base::OnceCallback<void(base::DictionaryValue results)>;
+ base::OnceCallback<void(base::Value::Dict results)>;
ConflictsDataFetcher(const ConflictsDataFetcher&) = delete;
ConflictsDataFetcher& operator=(const ConflictsDataFetcher&) = delete;
@@ -71,7 +67,7 @@ class ConflictsDataFetcher : public ModuleDatabaseObserver {
// Temporarily holds the module list while the modules are being
// enumerated.
- std::unique_ptr<base::ListValue> module_list_;
+ absl::optional<base::Value::List> module_list_;
SEQUENCE_CHECKER(sequence_checker_);
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
index da26c8701d8..112891b0c75 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
@@ -20,15 +20,15 @@ ConflictsHandler::~ConflictsHandler() = default;
void ConflictsHandler::RegisterMessages() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestModuleList",
base::BindRepeating(&ConflictsHandler::HandleRequestModuleList,
base::Unretained(this)));
}
-void ConflictsHandler::HandleRequestModuleList(const base::ListValue* args) {
+void ConflictsHandler::HandleRequestModuleList(
+ const base::Value::List& args_list) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value::ConstListView args_list = args->GetListDeprecated();
// Make sure the JS doesn't call 'requestModuleList' more than once.
// TODO(739291): It would be better to kill the renderer instead of the
@@ -41,7 +41,7 @@ void ConflictsHandler::HandleRequestModuleList(const base::ListValue* args) {
weak_ptr_factory_.GetWeakPtr()));
}
-void ConflictsHandler::OnConflictsDataFetched(base::DictionaryValue results) {
+void ConflictsHandler::OnConflictsDataFetched(base::Value::Dict results) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!module_list_callback_id_.empty());
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
index 1ade309cc6f..e15878117ce 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
@@ -8,14 +8,10 @@
#include <string>
#include "base/memory/weak_ptr.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class DictionaryValue;
-class Listvalue;
-}
-
// This class takes care of sending the list of all loaded modules to the
// chrome://conflicts WebUI page when it is requested.
class ConflictsHandler : public content::WebUIMessageHandler {
@@ -32,9 +28,9 @@ class ConflictsHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
// Callback for the "requestModuleList" message.
- void HandleRequestModuleList(const base::ListValue* args);
+ void HandleRequestModuleList(const base::Value::List& args);
- void OnConflictsDataFetched(base::DictionaryValue results);
+ void OnConflictsDataFetched(base::Value::Dict results);
// The ID of the callback that will get invoked with the module list.
std::string module_list_callback_id_;
diff --git a/chromium/chrome/browser/ui/webui/connectors_internals/connectors_internals.mojom b/chromium/chrome/browser/ui/webui/connectors_internals/connectors_internals.mojom
index deb393f0316..b71b7c86c6f 100644
--- a/chromium/chrome/browser/ui/webui/connectors_internals/connectors_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/connectors_internals/connectors_internals.mojom
@@ -15,7 +15,7 @@ enum KeyManagerInitializedValue {
// Trust level of the signing key which is equivalent to the key provider type.
enum KeyTrustLevel {
UNSPECIFIED = 0,
- TPM = 1,
+ HW = 1,
OS = 2,
};
diff --git a/chromium/chrome/browser/ui/webui/connectors_internals/zero_trust_utils.cc b/chromium/chrome/browser/ui/webui/connectors_internals/zero_trust_utils.cc
index 84862c77171..298fda69e24 100644
--- a/chromium/chrome/browser/ui/webui/connectors_internals/zero_trust_utils.cc
+++ b/chromium/chrome/browser/ui/webui/connectors_internals/zero_trust_utils.cc
@@ -27,8 +27,8 @@ namespace {
connectors_internals::mojom::KeyTrustLevel ParseTrustLevel(
BPKUR::KeyTrustLevel trust_level) {
switch (trust_level) {
- case BPKUR::CHROME_BROWSER_TPM_KEY:
- return connectors_internals::mojom::KeyTrustLevel::TPM;
+ case BPKUR::CHROME_BROWSER_HW_KEY:
+ return connectors_internals::mojom::KeyTrustLevel::HW;
case BPKUR::CHROME_BROWSER_OS_KEY:
return connectors_internals::mojom::KeyTrustLevel::OS;
default:
diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.cc b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.cc
index f6098966f5b..7a3fbc44629 100644
--- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.cc
+++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.cc
@@ -66,7 +66,7 @@ ConstrainedWebDialogUI::~ConstrainedWebDialogUI() = default;
void ConstrainedWebDialogUI::WebUIRenderFrameCreated(
RenderFrameHost* render_frame_host) {
// Add a "dialogClose" callback which matches WebDialogUI behavior.
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"dialogClose",
base::BindRepeating(&ConstrainedWebDialogUI::OnDialogCloseMessage,
base::Unretained(this)));
@@ -87,15 +87,16 @@ void ConstrainedWebDialogUI::WebUIRenderFrameCreated(
dialog_delegate->OnDialogShown(web_ui());
}
-void ConstrainedWebDialogUI::OnDialogCloseMessage(const base::ListValue* args) {
+void ConstrainedWebDialogUI::OnDialogCloseMessage(
+ const base::Value::List& args) {
ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
if (!delegate)
return;
std::string json_retval;
- if (!args->GetListDeprecated().empty()) {
- if (args->GetListDeprecated()[0].is_string()) {
- json_retval = args->GetListDeprecated()[0].GetString();
+ if (!args.empty()) {
+ if (args[0].is_string()) {
+ json_retval = args[0].GetString();
} else {
NOTREACHED() << "Could not read JSON argument";
}
diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.h b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.h
index 73fa3c02293..16fe05c2d82 100644
--- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.h
+++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui.h
@@ -85,7 +85,7 @@ class ConstrainedWebDialogUI : public content::WebUIController {
private:
// JS Message Handler
- void OnDialogCloseMessage(const base::ListValue* args);
+ void OnDialogCloseMessage(const base::Value::List& args);
};
// Create and show a constrained HTML dialog. The actual object that gets
diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_unittest.cc b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_unittest.cc
index 8e091fc2a19..fd6eb95fba9 100644
--- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_unittest.cc
@@ -138,9 +138,8 @@ TEST_F(ConstrainedWebDialogUITest, DialogCloseWithEmptyArgs) {
ASSERT_EQ(json_retval, "");
run_loop.Quit();
}));
- base::Value args(base::Value::Type::LIST);
- web_ui()->HandleReceivedMessage("dialogClose",
- &base::Value::AsListValue(args));
+ base::Value::List args;
+ web_ui()->HandleReceivedMessage("dialogClose", args);
run_loop.Run();
}
@@ -153,10 +152,9 @@ TEST_F(ConstrainedWebDialogUITest, DialogCloseWithJsonInArgs) {
json_retval = cb_json_retval;
run_loop.Quit();
}));
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kJsonRetval);
- web_ui()->HandleReceivedMessage("dialogClose",
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage("dialogClose", args);
run_loop.Run();
ASSERT_EQ(json_retval, kJsonRetval);
}
diff --git a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
index 6bf20951fba..39aece9bce1 100644
--- a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
+++ b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
@@ -80,13 +80,8 @@ std::string CookiesTreeModelUtil::GetTreeNodeId(const CookieTreeNode* node) {
}
absl::optional<base::Value::Dict>
-CookiesTreeModelUtil::GetCookieTreeNodeDictionary(const CookieTreeNode& node,
- bool include_quota_nodes) {
+CookiesTreeModelUtil::GetCookieTreeNodeDictionary(const CookieTreeNode& node) {
base::Value::Dict dict;
- // Use node's address as an id for WebUI to look it up.
- dict.Set(kKeyId, GetTreeNodeId(&node));
- dict.Set(kKeyTitle, node.GetTitle());
- dict.Set(kKeyHasChildren, !node.children().empty());
switch (node.GetDetailedInfo().node_type) {
case CookieTreeNode::DetailedInfo::TYPE_HOST: {
@@ -177,9 +172,6 @@ CookiesTreeModelUtil::GetCookieTreeNodeDictionary(const CookieTreeNode& node,
break;
}
case CookieTreeNode::DetailedInfo::TYPE_QUOTA: {
- if (!include_quota_nodes)
- return absl::nullopt;
-
dict.Set(kKeyType, "quota");
const BrowsingDataQuotaHelper::QuotaInfo& quota_info =
@@ -229,17 +221,6 @@ CookiesTreeModelUtil::GetCookieTreeNodeDictionary(const CookieTreeNode& node,
base::TimeFormatFriendlyDateAndTime(usage_info.last_modified));
break;
}
- case CookieTreeNode::DetailedInfo::TYPE_MEDIA_LICENSE: {
- dict.Set(kKeyType, "media_license");
-
- const content::StorageUsageInfo& usage_info =
- *node.GetDetailedInfo().media_license_usage_info;
- dict.Set(kKeyOrigin, usage_info.origin.GetURL().spec());
- dict.Set(kKeySize, ui::FormatBytes(usage_info.total_size_bytes));
- dict.Set(kKeyModified,
- base::TimeFormatFriendlyDateAndTime(usage_info.last_modified));
- break;
- }
default:
break;
}
@@ -259,26 +240,44 @@ CookiesTreeModelUtil::GetCookieTreeNodeDictionary(const CookieTreeNode& node,
}
#endif
+ // Only node types with detailed information above result in a dict.
+ if (dict.empty())
+ return absl::nullopt;
+
+ dict.Set(kKeyId, GetTreeNodeId(&node));
+ dict.Set(kKeyTitle, node.GetTitle());
+ dict.Set(kKeyHasChildren, !node.children().empty());
+
return dict;
}
-base::Value::List CookiesTreeModelUtil::GetChildNodeDetails(
- const CookieTreeNode* parent,
- bool include_quota_nodes) {
+base::Value::List CookiesTreeModelUtil::GetChildNodeDetailsDeprecated(
+ const CookieTreeNode* parent) {
base::Value::List list;
std::string id_path = GetTreeNodeId(parent);
for (const auto& child : parent->children()) {
- std::string cookie_id_path =
- id_path + "," + GetTreeNodeId(child.get()) + ",";
+ // Node types of interest either live at this level, or the level below.
+ // Whether a node is of interest is determined by
+ // GetCookieTreeNodeDictionary().
+ std::string cookie_id_path = id_path + "," + GetTreeNodeId(child.get());
+ absl::optional<base::Value::Dict> child_dict =
+ GetCookieTreeNodeDictionary(*child);
+ if (child_dict) {
+ child_dict->Set("idPath", cookie_id_path);
+ list.Append(std::move(*child_dict));
+ }
+ cookie_id_path += ",";
+
for (const auto& details : child->children()) {
- absl::optional<base::Value::Dict> dict =
- GetCookieTreeNodeDictionary(*details, include_quota_nodes);
- if (dict) {
+ absl::optional<base::Value::Dict> details_dict =
+ GetCookieTreeNodeDictionary(*details);
+ if (details_dict) {
// TODO(dschuyler): This ID path is an artifact from using tree nodes to
// hold the cookies. Can this be changed to a dictionary with a key
// lookup (and remove use of id_map_)?
- dict->Set("idPath", cookie_id_path + GetTreeNodeId(details.get()));
- list.Append(std::move(*dict));
+ details_dict->Set("idPath",
+ cookie_id_path + GetTreeNodeId(details.get()));
+ list.Append(std::move(*details_dict));
}
}
}
@@ -290,7 +289,7 @@ const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath(
const std::string& path) {
const CookieTreeNode* child = NULL;
const CookieTreeNode* parent = root;
- int child_index = -1;
+ absl::optional<size_t> child_index;
// Validate the tree path and get the node pointer.
for (const base::StringPiece& cur_node : base::SplitStringPiece(
@@ -301,13 +300,13 @@ const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath(
child = id_map_.Lookup(node_id);
child_index = parent->GetIndexOf(child);
- if (child_index == -1)
+ if (!child_index.has_value())
break;
parent = child;
}
- return child_index >= 0 ? child : NULL;
+ return child_index.has_value() ? child : nullptr;
}
const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromTitle(
diff --git a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.h b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.h
index 89ed8c11977..ed5558e28ec 100644
--- a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.h
+++ b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.h
@@ -29,8 +29,10 @@ class CookiesTreeModelUtil {
std::string GetTreeNodeId(const CookieTreeNode* node);
// Return the details of the child nodes of `parent`.
- base::Value::List GetChildNodeDetails(const CookieTreeNode* parent,
- bool include_quota_nodes);
+ // DEPRECATED(crbug.com/1271155): The cookies tree model is slowly being
+ // deprecated, during this process the semantics of the model are nuanced
+ // w.r.t partitioned storage, and should not be used in new locations.
+ base::Value::List GetChildNodeDetailsDeprecated(const CookieTreeNode* parent);
// Gets tree node from |path| under |root|. |path| is comma separated list of
// ids. |id_map| translates ids into object pointers. Return NULL if |path|
@@ -51,8 +53,7 @@ class CookiesTreeModelUtil {
// maps a CookieTreeNode to an ID and creates a new ID if `node` is not in the
// maps. Returns nullopt if the `node` does not need to be shown.
absl::optional<base::Value::Dict> GetCookieTreeNodeDictionary(
- const CookieTreeNode& node,
- bool include_quota_nodes);
+ const CookieTreeNode& node);
// IDMap to create unique ID and look up the object for an ID.
CookiesTreeNodeIdMap id_map_;
diff --git a/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.cc b/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.cc
index 35beebe445a..65ec371a09b 100644
--- a/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.cc
+++ b/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.cc
@@ -16,10 +16,12 @@
// Static
void HistoryClustersUtil::PopulateSource(content::WebUIDataSource* source,
- Profile* profile) {
+ Profile* profile,
+ bool in_side_panel) {
PrefService* prefs = profile->GetPrefs();
source->AddBoolean("allowDeletingHistory",
prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory));
+ source->AddBoolean("inSidePanel", in_side_panel);
auto* history_clusters_service =
HistoryClustersServiceFactory::GetForBrowserContext(profile);
source->AddBoolean("isHistoryClustersEnabled",
@@ -40,9 +42,11 @@ void HistoryClustersUtil::PopulateSource(content::WebUIDataSource* source,
{"historyClustersTabLabel", IDS_HISTORY_CLUSTERS_JOURNEYS_TAB_LABEL},
{"historyListTabLabel", IDS_HISTORY_CLUSTERS_LIST_TAB_LABEL},
{"loadMoreButtonLabel", IDS_HISTORY_CLUSTERS_LOAD_MORE_BUTTON_LABEL},
+ {"noSearchResults", IDS_HISTORY_CLUSTERS_NO_SEARCH_RESULTS},
{"openAllInTabGroup", IDS_HISTORY_CLUSTERS_OPEN_ALL_IN_TABGROUP},
{"relatedSearchesHeader", IDS_HISTORY_CLUSTERS_RELATED_SEARCHES_HEADER},
{"removeAllFromHistory", IDS_HISTORY_CLUSTERS_REMOVE_ALL_ITEMS},
+ {"removeFromHistory", IDS_HISTORY_CLUSTERS_REMOVE_PAGE},
{"removeFromHistoryToast", IDS_HISTORY_CLUSTERS_REMOVE_ITEM_TOAST},
{"savedInTabGroup", IDS_HISTORY_CLUSTERS_SAVED_IN_TABGROUP_LABEL},
{"toggleButtonLabelLess", IDS_HISTORY_CLUSTERS_SHOW_LESS_BUTTON_LABEL},
diff --git a/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h b/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h
index 2bf10b550f4..15ea4d88f03 100644
--- a/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h
+++ b/chromium/chrome/browser/ui/webui/cr_components/history_clusters/history_clusters_util.h
@@ -18,7 +18,8 @@ class WebUIDataSource;
class HistoryClustersUtil {
public:
static void PopulateSource(content::WebUIDataSource* source,
- Profile* profile);
+ Profile* profile,
+ bool in_side_panel);
};
#endif // CHROME_BROWSER_UI_WEBUI_CR_COMPONENTS_HISTORY_CLUSTERS_HISTORY_CLUSTERS_UTIL_H_
diff --git a/chromium/chrome/browser/ui/webui/crashes_ui.cc b/chromium/chrome/browser/ui/webui/crashes_ui.cc
index 2c78c979b93..a436b98dac2 100644
--- a/chromium/chrome/browser/ui/webui/crashes_ui.cc
+++ b/chromium/chrome/browser/ui/webui/crashes_ui.cc
@@ -38,8 +38,7 @@
#include "ui/base/resource/resource_bundle.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "chromeos/dbus/dbus_thread_manager.h" // nogncheck
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
+#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
@@ -160,8 +159,7 @@ void CrashesDOMHandler::HandleRequestCrashes(const base::Value::List& args) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
void CrashesDOMHandler::HandleRequestUploads(const base::Value::List& args) {
- chromeos::DebugDaemonClient* debugd_client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
+ ash::DebugDaemonClient* debugd_client = ash::DebugDaemonClient::Get();
DCHECK(debugd_client);
debugd_client->UploadCrashes(base::BindOnce([](bool success) {
@@ -231,8 +229,7 @@ void CrashesDOMHandler::UpdateUI() {
result.Set("os", base::SysInfo::OperatingSystemName() + " " +
base::SysInfo::OperatingSystemVersion());
result.Set("isGoogleAccount", is_internal);
- FireWebUIListener(crash_reporter::kCrashesUIUpdateCrashList,
- base::Value(std::move(result)));
+ FireWebUIListener(crash_reporter::kCrashesUIUpdateCrashList, result);
}
void CrashesDOMHandler::HandleRequestSingleCrashUpload(
diff --git a/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc
index 6003a83cb23..9078d9b4688 100644
--- a/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc
+++ b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc
@@ -8,16 +8,18 @@
#include "chrome/browser/new_tab_page/chrome_colors/chrome_colors_service.h"
#include "chrome/browser/new_tab_page/chrome_colors/generated_colors_info.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/common/themes/autogenerated_theme_util.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/color/color_id.h"
+#include "ui/color/color_provider.h"
#include "ui/gfx/color_palette.h"
#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
@@ -141,17 +143,16 @@ void ChromeCustomizeThemesHandler::UpdateTheme() {
// logic that returns a placeholder color.
const BrowserWindow* browser_window =
BrowserWindow::FindBrowserWindowWithWebContents(web_contents_);
- const ui::ThemeProvider* theme_provider =
- browser_window ? browser_window->GetThemeProvider() : nullptr;
+ const ui::ColorProvider* color_provider =
+ browser_window ? browser_window->GetColorProvider() : nullptr;
theme->type = customize_themes::mojom::ThemeType::kAutogenerated;
auto theme_colors = customize_themes::mojom::ThemeColors::New();
- if (theme_provider) {
- theme_colors->frame =
- theme_provider->GetColor(ThemeProperties::COLOR_FRAME_ACTIVE);
+ if (color_provider) {
+ theme_colors->frame = color_provider->GetColor(ui::kColorFrameActive);
theme_colors->active_tab =
- theme_provider->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
+ color_provider->GetColor(kColorNewTabPageBackground);
theme_colors->active_tab_text =
- theme_provider->GetColor(ThemeProperties::COLOR_NTP_TEXT);
+ color_provider->GetColor(kColorNewTabPageText);
} else {
theme_colors->frame = gfx::kPlaceholderColor;
theme_colors->active_tab = gfx::kPlaceholderColor;
diff --git a/chromium/chrome/browser/ui/webui/device_log_ui.cc b/chromium/chrome/browser/ui/webui/device_log_ui.cc
index fde9d081bd5..80eb6a3f01e 100644
--- a/chromium/chrome/browser/ui/webui/device_log_ui.cc
+++ b/chromium/chrome/browser/ui/webui/device_log_ui.cc
@@ -36,25 +36,25 @@ class DeviceLogMessageHandler : public content::WebUIMessageHandler {
// WebUIMessageHandler implementation.
void RegisterMessages() override {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getLog", base::BindRepeating(&DeviceLogMessageHandler::GetLog,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"clearLog", base::BindRepeating(&DeviceLogMessageHandler::ClearLog,
base::Unretained(this)));
}
private:
- void GetLog(const base::ListValue* value) {
+ void GetLog(const base::Value::List& value) {
AllowJavascript();
- std::string callback_id = value->GetListDeprecated()[0].GetString();
+ std::string callback_id = value[0].GetString();
base::Value data(device_event_log::GetAsString(
device_event_log::NEWEST_FIRST, "json", "",
device_event_log::LOG_LEVEL_DEBUG, 0));
ResolveJavascriptCallback(base::Value(callback_id), data);
}
- void ClearLog(const base::ListValue* value) const {
+ void ClearLog(const base::Value::List& value) const {
device_event_log::ClearAll();
}
};
diff --git a/chromium/chrome/browser/ui/webui/devtools_ui_data_source.cc b/chromium/chrome/browser/ui/webui/devtools_ui_data_source.cc
index 113d38323af..a79bc9f9a5c 100644
--- a/chromium/chrome/browser/ui/webui/devtools_ui_data_source.cc
+++ b/chromium/chrome/browser/ui/webui/devtools_ui_data_source.cc
@@ -48,8 +48,8 @@ scoped_refptr<base::RefCountedMemory> CreateNotFoundResponse() {
// DevToolsDataSource ---------------------------------------------------------
-std::string GetMimeTypeForPath(const std::string& path) {
- std::string filename = PathWithoutParams(path);
+std::string GetMimeTypeForUrl(const GURL& url) {
+ std::string filename = url.ExtractFileName();
if (base::EndsWith(filename, ".html", base::CompareCase::INSENSITIVE_ASCII)) {
return "text/html";
} else if (base::EndsWith(filename, ".css",
@@ -207,8 +207,8 @@ void DevToolsDataSource::StartDataRequest(
std::move(callback).Run(CreateNotFoundResponse());
}
-std::string DevToolsDataSource::GetMimeType(const std::string& path) {
- return GetMimeTypeForPath(path);
+std::string DevToolsDataSource::GetMimeType(const GURL& url) {
+ return GetMimeTypeForUrl(url);
}
bool DevToolsDataSource::ShouldAddContentSecurityPolicy() {
diff --git a/chromium/chrome/browser/ui/webui/devtools_ui_data_source.h b/chromium/chrome/browser/ui/webui/devtools_ui_data_source.h
index c10406dbe6d..992cd5d6f5e 100644
--- a/chromium/chrome/browser/ui/webui/devtools_ui_data_source.h
+++ b/chromium/chrome/browser/ui/webui/devtools_ui_data_source.h
@@ -52,7 +52,7 @@ class DevToolsDataSource : public content::URLDataSource {
struct PendingRequest;
// content::URLDataSource overrides.
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool ShouldAddContentSecurityPolicy() override;
bool ShouldDenyXFrameOptions() override;
bool ShouldServeMimeTypeAsContentTypeHeader() override;
diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
index 6e117dfbafe..09411c027f4 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
+++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
@@ -209,24 +209,31 @@ class DiscardsDetailsProviderImpl : public discards::mojom::DetailsProvider {
std::move(callback).Run();
}
- void ToggleLocalStatePref(const std::string& pref_name) {
- bool val = g_browser_process->local_state()->GetBoolean(pref_name);
- g_browser_process->local_state()->SetBoolean(pref_name, !val);
- }
-
void ToggleHighEfficiencyMode() override {
if (base::FeatureList::IsEnabled(
performance_manager::features::kHighEfficiencyModeAvailable)) {
- ToggleLocalStatePref(
+ bool enabled = g_browser_process->local_state()->GetBoolean(
performance_manager::user_tuning::prefs::kHighEfficiencyModeEnabled);
+ g_browser_process->local_state()->SetBoolean(
+ performance_manager::user_tuning::prefs::kHighEfficiencyModeEnabled,
+ !enabled);
}
}
void ToggleBatterySaverMode() override {
if (base::FeatureList::IsEnabled(
performance_manager::features::kBatterySaverModeAvailable)) {
- ToggleLocalStatePref(
- performance_manager::user_tuning::prefs::kBatterySaverModeEnabled);
+ performance_manager::user_tuning::prefs::BatterySaverModeState state =
+ performance_manager::user_tuning::prefs::
+ GetCurrentBatterySaverModeState(g_browser_process->local_state());
+ g_browser_process->local_state()->SetInteger(
+ performance_manager::user_tuning::prefs::kBatterySaverModeState,
+ static_cast<int>(state == performance_manager::user_tuning::prefs::
+ BatterySaverModeState::kDisabled
+ ? performance_manager::user_tuning::prefs::
+ BatterySaverModeState::kEnabled
+ : performance_manager::user_tuning::prefs::
+ BatterySaverModeState::kDisabled));
}
}
diff --git a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc b/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
deleted file mode 100644
index e8371b1f2c7..00000000000
--- a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/domain_reliability_internals_ui.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/dev_ui_browser_resources.h"
-#include "content/public/browser/storage_partition.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "services/network/public/mojom/content_security_policy.mojom.h"
-#include "services/network/public/mojom/network_context.mojom.h"
-
-DomainReliabilityInternalsUI::DomainReliabilityInternalsUI(
- content::WebUI* web_ui)
- : content::WebUIController(web_ui) {
- content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
- chrome::kChromeUIDomainReliabilityInternalsHost);
- html_source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources 'self' 'unsafe-eval';");
- html_source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::TrustedTypes,
- "trusted-types jstemplate;");
- html_source->AddResourcePath("domain_reliability_internals.css",
- IDR_DOMAIN_RELIABILITY_INTERNALS_CSS);
- html_source->AddResourcePath("domain_reliability_internals.js",
- IDR_DOMAIN_RELIABILITY_INTERNALS_JS);
- html_source->SetDefaultResource(IDR_DOMAIN_RELIABILITY_INTERNALS_HTML);
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, html_source);
-
- web_ui->AddMessageHandler(
- std::make_unique<DomainReliabilityInternalsHandler>());
-}
-
-DomainReliabilityInternalsUI::~DomainReliabilityInternalsUI() = default;
-
-DomainReliabilityInternalsHandler::DomainReliabilityInternalsHandler() =
- default;
-DomainReliabilityInternalsHandler::~DomainReliabilityInternalsHandler() =
- default;
-
-void DomainReliabilityInternalsHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
- "updateData",
- base::BindRepeating(&DomainReliabilityInternalsHandler::HandleUpdateData,
- base::Unretained(this)));
-}
-
-void DomainReliabilityInternalsHandler::HandleUpdateData(
- const base::ListValue* args) {
- DCHECK_EQ(1u, args->GetListDeprecated().size());
- AllowJavascript();
- callback_id_ = args->GetListDeprecated()[0].GetString();
-
- Profile* profile = Profile::FromWebUI(web_ui());
- network::mojom::NetworkContext* network_context =
- profile->GetDefaultStoragePartition()->GetNetworkContext();
- network_context->GetDomainReliabilityJSON(
- base::BindOnce(&DomainReliabilityInternalsHandler::OnDataUpdated,
- weak_factory_.GetWeakPtr()));
-}
-
-void DomainReliabilityInternalsHandler::OnDataUpdated(base::Value data) {
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)), data);
- callback_id_.clear();
-}
diff --git a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h b/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h
deleted file mode 100644
index c6b5ec51948..00000000000
--- a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOMAIN_RELIABILITY_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_DOMAIN_RELIABILITY_INTERNALS_UI_H_
-
-#include <memory>
-#include <string>
-
-#include "base/memory/weak_ptr.h"
-#include "content/public/browser/web_ui_controller.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace base {
-class ListValue;
-class Value;
-} // namespace base
-
-// The WebUI for chrome://domain-reliability-internals
-class DomainReliabilityInternalsUI : public content::WebUIController {
- public:
- explicit DomainReliabilityInternalsUI(content::WebUI* web_ui);
-
- DomainReliabilityInternalsUI(const DomainReliabilityInternalsUI&) = delete;
- DomainReliabilityInternalsUI& operator=(const DomainReliabilityInternalsUI&) =
- delete;
-
- ~DomainReliabilityInternalsUI() override;
-};
-
-class DomainReliabilityInternalsHandler : public content::WebUIMessageHandler {
- public:
- DomainReliabilityInternalsHandler();
-
- DomainReliabilityInternalsHandler(const DomainReliabilityInternalsHandler&) =
- delete;
- DomainReliabilityInternalsHandler& operator=(
- const DomainReliabilityInternalsHandler&) = delete;
-
- ~DomainReliabilityInternalsHandler() override;
-
- // content::WebUIMessageHandler:
- void RegisterMessages() override;
-
- private:
- void HandleUpdateData(const base::ListValue* args);
- void OnDataUpdated(base::Value data);
-
- std::string callback_id_;
- base::WeakPtrFactory<DomainReliabilityInternalsHandler> weak_factory_{this};
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOMAIN_RELIABILITY_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.cc b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.cc
index b17f35f8ab2..acd34bb82b3 100644
--- a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.cc
@@ -26,17 +26,17 @@ DownloadInternalsUIMessageHandler::~DownloadInternalsUIMessageHandler() {
}
void DownloadInternalsUIMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getServiceStatus",
base::BindRepeating(
&DownloadInternalsUIMessageHandler::HandleGetServiceStatus,
weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getServiceDownloads",
base::BindRepeating(
&DownloadInternalsUIMessageHandler::HandleGetServiceDownloads,
weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"startDownload",
base::BindRepeating(
&DownloadInternalsUIMessageHandler::HandleStartDownload,
@@ -49,7 +49,7 @@ void DownloadInternalsUIMessageHandler::RegisterMessages() {
}
void DownloadInternalsUIMessageHandler::OnServiceStatusChanged(
- const base::Value& service_status) {
+ const base::Value::Dict& service_status) {
if (!IsJavascriptAllowed())
return;
@@ -57,7 +57,7 @@ void DownloadInternalsUIMessageHandler::OnServiceStatusChanged(
}
void DownloadInternalsUIMessageHandler::OnServiceDownloadsAvailable(
- const base::Value& service_downloads) {
+ const base::Value::List& service_downloads) {
if (!IsJavascriptAllowed())
return;
@@ -65,7 +65,7 @@ void DownloadInternalsUIMessageHandler::OnServiceDownloadsAvailable(
}
void DownloadInternalsUIMessageHandler::OnServiceDownloadChanged(
- const base::Value& service_download) {
+ const base::Value::Dict& service_download) {
if (!IsJavascriptAllowed())
return;
@@ -73,7 +73,7 @@ void DownloadInternalsUIMessageHandler::OnServiceDownloadChanged(
}
void DownloadInternalsUIMessageHandler::OnServiceDownloadFailed(
- const base::Value& service_download) {
+ const base::Value::Dict& service_download) {
if (!IsJavascriptAllowed())
return;
@@ -81,7 +81,7 @@ void DownloadInternalsUIMessageHandler::OnServiceDownloadFailed(
}
void DownloadInternalsUIMessageHandler::OnServiceRequestMade(
- const base::Value& service_request) {
+ const base::Value::Dict& service_request) {
if (!IsJavascriptAllowed())
return;
@@ -89,26 +89,25 @@ void DownloadInternalsUIMessageHandler::OnServiceRequestMade(
}
void DownloadInternalsUIMessageHandler::HandleGetServiceStatus(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(callback_id,
download_service_->GetLogger()->GetServiceStatus());
}
void DownloadInternalsUIMessageHandler::HandleGetServiceDownloads(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(
callback_id, download_service_->GetLogger()->GetServiceDownloads());
}
void DownloadInternalsUIMessageHandler::HandleStartDownload(
- const base::ListValue* args) {
- CHECK_GT(args->GetListDeprecated().size(), 1u)
- << "Missing argument download URL.";
- GURL url = GURL(args->GetListDeprecated()[1].GetString());
+ const base::Value::List& args) {
+ CHECK_GT(args.size(), 1u) << "Missing argument download URL.";
+ GURL url = GURL(args[1].GetString());
if (!url.is_valid()) {
LOG(WARNING) << "Can't parse download URL, try to enter a valid URL.";
return;
diff --git a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.h b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.h
index 2671c81d883..5723fbc3309 100644
--- a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui_message_handler.h
@@ -33,20 +33,22 @@ class DownloadInternalsUIMessageHandler : public content::WebUIMessageHandler,
void RegisterMessages() override;
// download::Logger::Observer implementation.
- void OnServiceStatusChanged(const base::Value& service_status) override;
+ void OnServiceStatusChanged(const base::Value::Dict& service_status) override;
void OnServiceDownloadsAvailable(
- const base::Value& service_downloads) override;
- void OnServiceDownloadChanged(const base::Value& service_download) override;
- void OnServiceDownloadFailed(const base::Value& service_download) override;
- void OnServiceRequestMade(const base::Value& service_request) override;
+ const base::Value::List& service_downloads) override;
+ void OnServiceDownloadChanged(
+ const base::Value::Dict& service_download) override;
+ void OnServiceDownloadFailed(
+ const base::Value::Dict& service_download) override;
+ void OnServiceRequestMade(const base::Value::Dict& service_request) override;
private:
// Get the current DownloadService and sub component statuses.
- void HandleGetServiceStatus(const base::ListValue* args);
- void HandleGetServiceDownloads(const base::ListValue* args);
+ void HandleGetServiceStatus(const base::Value::List& args);
+ void HandleGetServiceDownloads(const base::Value::List& args);
// Starts a background download.
- void HandleStartDownload(const base::ListValue* args);
+ void HandleStartDownload(const base::Value::List& args);
raw_ptr<download::BackgroundDownloadService> download_service_;
diff --git a/chromium/chrome/browser/ui/webui/downloads/BUILD.gn b/chromium/chrome/browser/ui/webui/downloads/BUILD.gn
index 627774c320f..412534b8bb7 100644
--- a/chromium/chrome/browser/ui/webui/downloads/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/downloads/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(!is_android)
+
mojom("mojo_bindings") {
sources = [ "downloads.mojom" ]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads.mojom b/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
index 873cdbdc5d6..79c1a780c6c 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
@@ -10,6 +10,7 @@ struct Data {
bool file_externally_removed;
bool is_dangerous;
bool is_mixed_content;
+ bool is_reviewable;
// |otr| stands for off-the-record and is true when a download entry is
// created during an incognito or guest profile session.
bool otr;
@@ -64,6 +65,11 @@ interface PageHandler {
// Browsing. This completes the scan early. This requires a user gesture on
// the WebUI.
OpenDuringScanningRequiringGesture(string id);
+
+ // Opens a review dialog for the download with the given |id| after it has
+ // received a warning deep scanning verdict. This requires a user gesture on
+ // the WebUI.
+ ReviewDangerousRequiringGesture(string id);
};
interface Page {
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
index e1851d45149..92837d91264 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
@@ -74,6 +74,7 @@ enum DownloadsDOMEvent {
DOWNLOADS_DOM_EVENT_RESUME = 11,
DOWNLOADS_DOM_EVENT_RETRY_DOWNLOAD = 12,
DOWNLOADS_DOM_EVENT_OPEN_DURING_SCANNING = 13,
+ DOWNLOADS_DOM_EVENT_REVIEW_DANGEROUS = 14,
DOWNLOADS_DOM_EVENT_MAX
};
@@ -372,7 +373,24 @@ void DownloadsDOMHandler::OpenDuringScanningRequiringGesture(
if (download) {
DownloadItemModel model(download);
model.SetOpenWhenComplete(true);
+#if BUILDFLAG(FULL_SAFE_BROWSING)
model.CompleteSafeBrowsingScan();
+#endif
+ }
+}
+
+void DownloadsDOMHandler::ReviewDangerousRequiringGesture(
+ const std::string& id) {
+ if (!GetWebUIWebContents()->HasRecentInteractiveInputEvent()) {
+ LOG(ERROR) << __func__ << " received without recent user interaction";
+ return;
+ }
+
+ CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_REVIEW_DANGEROUS);
+ download::DownloadItem* download = GetDownloadByStringId(id);
+ if (download) {
+ DownloadItemModel model(download);
+ model.ReviewScanningVerdict(GetWebUIWebContents());
}
}
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.h b/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.h
index ab2cfa64744..e6cbb061dbe 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.h
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.h
@@ -67,6 +67,7 @@ class DownloadsDOMHandler : public content::WebContentsObserver,
void ClearAll() override;
void OpenDownloadsFolderRequiringGesture() override;
void OpenDuringScanningRequiringGesture(const std::string& id) override;
+ void ReviewDangerousRequiringGesture(const std::string& id) override;
protected:
// These methods are for mocking so that most of this class does not actually
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
index ab3b0ce2898..9bc30ebee54 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_query.h"
+#include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/downloads/downloads.mojom.h"
@@ -336,6 +337,12 @@ downloads::mojom::DataPtr DownloadsListTracker::CreateDownloadData(
file_value->danger_type = danger_type;
file_value->is_dangerous = download_item->IsDangerous();
file_value->is_mixed_content = download_item->IsMixedContent();
+ file_value->is_reviewable =
+ enterprise_connectors::ShouldPromptReviewForDownload(
+ Profile::FromBrowserContext(
+ content::DownloadItemUtils::GetBrowserContext(download_item)),
+ download_item->GetDangerType());
+
file_value->last_reason_text = base::UTF16ToUTF8(last_reason_text);
file_value->percent = percent;
file_value->progress_status_text = base::UTF16ToUTF8(progress_status_text);
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
index 02802dbc616..0c6e7cb0469 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
@@ -94,6 +94,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
{"dangerSave", IDS_CONFIRM_DOWNLOAD},
{"dangerRestore", IDS_CONFIRM_DOWNLOAD_RESTORE},
{"dangerDiscard", IDS_DISCARD_DOWNLOAD},
+ {"dangerReview", IDS_REVIEW_DOWNLOAD},
// Deep scanning strings.
{"deepScannedSafeDesc", IDS_DEEP_SCANNED_SAFE_DESCRIPTION},
diff --git a/chromium/chrome/browser/ui/webui/extensions/ash/kiosk_apps_handler.cc b/chromium/chrome/browser/ui/webui/extensions/ash/kiosk_apps_handler.cc
index 7f39fba6784..16ffc7c5ef4 100644
--- a/chromium/chrome/browser/ui/webui/extensions/ash/kiosk_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/ash/kiosk_apps_handler.cc
@@ -193,15 +193,14 @@ void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus(
is_auto_launch_enabled_ = false;
}
- base::DictionaryValue kiosk_params;
- kiosk_params.GetDict().Set("kioskEnabled", is_kiosk_enabled_);
- kiosk_params.GetDict().Set("autoLaunchEnabled", is_auto_launch_enabled_);
+ base::Value::Dict kiosk_params;
+ kiosk_params.Set("kioskEnabled", is_kiosk_enabled_);
+ kiosk_params.Set("autoLaunchEnabled", is_auto_launch_enabled_);
ResolveJavascriptCallback(base::Value(callback_id), kiosk_params);
}
void KioskAppsHandler::OnKioskAppsSettingsChanged() {
- FireWebUIListener("kiosk-app-settings-changed",
- base::Value(GetSettingsDictionary()));
+ FireWebUIListener("kiosk-app-settings-changed", GetSettingsDictionary());
}
base::Value::Dict KioskAppsHandler::GetSettingsDictionary() {
@@ -250,8 +249,7 @@ void KioskAppsHandler::HandleGetKioskAppSettings(
CHECK_EQ(1U, args.size());
const std::string& callback_id = args.front().GetString();
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(GetSettingsDictionary()));
+ ResolveJavascriptCallback(base::Value(callback_id), GetSettingsDictionary());
}
void KioskAppsHandler::HandleAddKioskApp(const base::Value::List& args) {
@@ -320,8 +318,7 @@ void KioskAppsHandler::UpdateApp(const std::string& app_id) {
if (!kiosk_app_manager_->GetApp(app_id, &app_data))
return;
- FireWebUIListener("kiosk-app-updated",
- base::Value(PopulateAppDict(app_data)));
+ FireWebUIListener("kiosk-app-updated", PopulateAppDict(app_data));
}
void KioskAppsHandler::ShowError(const std::string& app_id) {
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.cc
index 3a7fdaedc83..e0dcc6ccb21 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.cc
@@ -111,7 +111,7 @@ std::string ExtensionIconSource::GetSource() {
return chrome::kChromeUIExtensionIconHost;
}
-std::string ExtensionIconSource::GetMimeType(const std::string&) {
+std::string ExtensionIconSource::GetMimeType(const GURL&) {
// We need to explicitly return a mime type, otherwise if the user tries to
// drag the image they get no extension.
return "image/png";
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h
index aa8ce51fe43..17e06480074 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h
@@ -77,7 +77,7 @@ class ExtensionIconSource : public content::URLDataSource,
// content::URLDataSource implementation.
std::string GetSource() override;
- std::string GetMimeType(const std::string&) override;
+ std::string GetMimeType(const GURL&) override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
index 27824bd3a38..8ed972e28e4 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -213,7 +214,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsUIBrowserTest, ListenerRegistration) {
TabStripModel* tab_strip = browser()->tab_strip_model();
tab_strip->CloseWebContentsAt(tab_strip->active_index(),
- TabStripModel::CLOSE_NONE);
+ TabCloseTypes::CLOSE_NONE);
base::RunLoop().RunUntilIdle();
content::RunAllTasksUntilIdle();
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
index c881ce0e056..9b92463fa08 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
@@ -473,7 +473,7 @@ std::string ExtensionsInternalsSource::GetSource() {
return chrome::kChromeUIExtensionsInternalsHost;
}
-std::string ExtensionsInternalsSource::GetMimeType(const std::string& path) {
+std::string ExtensionsInternalsSource::GetMimeType(const GURL& url) {
return "text/plain";
}
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
index 410b5ce4c30..eb53000e64f 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
@@ -24,7 +24,7 @@ class ExtensionsInternalsSource : public content::URLDataSource {
// content::URLDataSource:
std::string GetSource() override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
index c65009de228..4c3f9b2c3fb 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -207,6 +207,8 @@ content::WebUIDataSource* CreateExtensionsSource(Profile* profile,
{"itemSiteAccessAddHost", IDS_EXTENSIONS_ITEM_SITE_ACCESS_ADD_HOST},
{"itemSiteAccessEmpty", IDS_EXTENSIONS_ITEM_SITE_ACCESS_EMPTY},
{"itemSource", IDS_EXTENSIONS_ITEM_SOURCE},
+ {"itemSourceInstalledByDefault",
+ IDS_EXTENSIONS_ITEM_SOURCE_INSTALLED_BY_DEFAULT},
{"itemSourcePolicy", IDS_EXTENSIONS_ITEM_SOURCE_POLICY},
{"itemSourceSideloaded", IDS_EXTENSIONS_ITEM_SOURCE_SIDELOADED},
{"itemSourceUnpacked", IDS_EXTENSIONS_ITEM_SOURCE_UNPACKED},
@@ -260,6 +262,8 @@ content::WebUIDataSource* CreateExtensionsSource(Profile* profile,
{"sitePermissions", IDS_EXTENSIONS_SITE_PERMISSIONS},
{"sitePermissionsAllSitesPageTitle",
IDS_EXTENSIONS_SITE_PERMISSIONS_ALL_SITES_PAGE_TITLE},
+ {"sitePermissionsAllSitesExtensionCount",
+ IDS_EXTENSIONS_SITE_PERMISSIONS_ALL_SITES_EXTENSION_COUNT},
{"sitePermissionsPageTitle", IDS_EXTENSIONS_SITE_PERMISSIONS_PAGE_TITLE},
{"sitePermissionsAddSiteDialogTitle",
IDS_EXTENSIONS_SITE_PERMISSIONS_ADD_SITE_DIALOG_TITLE},
diff --git a/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc
index a42b1ff0ddf..4431bf983e2 100644
--- a/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/string_piece.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
@@ -36,38 +37,38 @@ namespace {
// consisting of a title and a list of fields. Returns a pointer to the new
// section's contents, for use with |AddSectionEntry| below. Note that
// |parent_list|, not the caller, owns the newly added section.
-base::ListValue* AddSection(base::ListValue* parent_list,
- const std::string& title) {
- std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue);
- std::unique_ptr<base::ListValue> section_contents(new base::ListValue);
- section->SetStringKey("title", title);
+base::Value::List* AddSection(base::Value::List* parent_list,
+ base::StringPiece title) {
+ base::Value::Dict section;
+ base::Value::List section_contents;
+ section.Set("title", title);
// Grab a raw pointer to the result before |Pass()|ing it on.
- base::ListValue* result =
- section->SetList("data", std::move(section_contents));
- parent_list->Append(base::Value::FromUniquePtrValue(std::move(section)));
+ base::Value::List* result =
+ section.Set("data", std::move(section_contents))->GetIfList();
+ parent_list->Append(std::move(section));
return result;
}
// Adds a bool entry to a section (created with |AddSection| above).
-void AddSectionEntry(base::ListValue* section_list,
- const std::string& name,
+void AddSectionEntry(base::Value::List* section_list,
+ base::StringPiece name,
bool value) {
base::Value::Dict entry;
entry.Set("stat_name", name);
entry.Set("stat_value", value);
entry.Set("is_valid", true);
- section_list->GetList().Append(std::move(entry));
+ section_list->Append(std::move(entry));
}
// Adds a string entry to a section (created with |AddSection| above).
-void AddSectionEntry(base::ListValue* section_list,
- const std::string& name,
- const std::string& value) {
+void AddSectionEntry(base::Value::List* section_list,
+ base::StringPiece name,
+ base::StringPiece value) {
base::Value::Dict entry;
entry.Set("stat_name", name);
entry.Set("stat_value", value);
entry.Set("is_valid", true);
- section_list->GetList().Append(std::move(entry));
+ section_list->Append(std::move(entry));
}
std::string FilteringBehaviorToString(
@@ -123,19 +124,19 @@ FamilyLinkUserInternalsMessageHandler::
void FamilyLinkUserInternalsMessageHandler::RegisterMessages() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"registerForEvents",
base::BindRepeating(
&FamilyLinkUserInternalsMessageHandler::HandleRegisterForEvents,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getBasicInfo",
base::BindRepeating(
&FamilyLinkUserInternalsMessageHandler::HandleGetBasicInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"tryURL",
base::BindRepeating(&FamilyLinkUserInternalsMessageHandler::HandleTryURL,
base::Unretained(this)));
@@ -158,8 +159,8 @@ FamilyLinkUserInternalsMessageHandler::GetSupervisedUserService() {
}
void FamilyLinkUserInternalsMessageHandler::HandleRegisterForEvents(
- const base::ListValue* args) {
- DCHECK(args->GetListDeprecated().empty());
+ const base::Value::List& args) {
+ DCHECK(args.empty());
AllowJavascript();
if (scoped_observation_.IsObserving())
return;
@@ -168,18 +169,17 @@ void FamilyLinkUserInternalsMessageHandler::HandleRegisterForEvents(
}
void FamilyLinkUserInternalsMessageHandler::HandleGetBasicInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
SendBasicInfo();
}
void FamilyLinkUserInternalsMessageHandler::HandleTryURL(
- const base::ListValue* args) {
- DCHECK_EQ(2u, args->GetListDeprecated().size());
- if (!args->GetListDeprecated()[0].is_string() ||
- !args->GetListDeprecated()[1].is_string())
+ const base::Value::List& args) {
+ DCHECK_EQ(2u, args.size());
+ if (!args[0].is_string() || !args[1].is_string())
return;
- const std::string& callback_id = args->GetListDeprecated()[0].GetString();
- const std::string& url_str = args->GetListDeprecated()[1].GetString();
+ const std::string& callback_id = args[0].GetString();
+ const std::string& url_str = args[1].GetString();
GURL url = url_formatter::FixupURL(url_str, std::string());
if (!url.is_valid())
@@ -203,21 +203,21 @@ void FamilyLinkUserInternalsMessageHandler::HandleTryURL(
}
void FamilyLinkUserInternalsMessageHandler::SendBasicInfo() {
- base::ListValue section_list;
+ base::Value::List section_list;
- base::ListValue* section_general = AddSection(&section_list, "General");
+ base::Value::List* section_general = AddSection(&section_list, "General");
AddSectionEntry(section_general, "Child detection enabled",
ChildAccountService::IsChildAccountDetectionEnabled());
Profile* profile = Profile::FromWebUI(web_ui());
- base::ListValue* section_profile = AddSection(&section_list, "Profile");
+ base::Value::List* section_profile = AddSection(&section_list, "Profile");
AddSectionEntry(section_profile, "Account", profile->GetProfileUserName());
AddSectionEntry(section_profile, "Child", profile->IsChild());
SupervisedUserURLFilter* filter = GetSupervisedUserService()->GetURLFilter();
- base::ListValue* section_filter = AddSection(&section_list, "Filter");
+ base::Value::List* section_filter = AddSection(&section_list, "Filter");
AddSectionEntry(section_filter, "Denylist active", filter->HasDenylist());
AddSectionEntry(section_filter, "Online checks active",
filter->HasAsyncURLChecker());
@@ -232,7 +232,7 @@ void FamilyLinkUserInternalsMessageHandler::SendBasicInfo() {
for (const auto& account :
identity_manager
->GetExtendedAccountInfoForAccountsWithRefreshToken()) {
- base::ListValue* section_user = AddSection(
+ base::Value::List* section_user = AddSection(
&section_list, "User Information for " + account.full_name);
AddSectionEntry(section_user, "Account id",
account.account_id.ToString());
@@ -247,8 +247,8 @@ void FamilyLinkUserInternalsMessageHandler::SendBasicInfo() {
}
}
- base::DictionaryValue result;
- result.SetKey("sections", std::move(section_list));
+ base::Value::Dict result;
+ result.Set("sections", std::move(section_list));
FireWebUIListener("basic-info-received", result);
// Trigger retrieval of the user settings
@@ -272,11 +272,10 @@ void FamilyLinkUserInternalsMessageHandler::OnTryURLResult(
SupervisedUserURLFilter::FilteringBehavior behavior,
supervised_user_error_page::FilteringBehaviorReason reason,
bool uncertain) {
- base::DictionaryValue result;
- result.SetStringKey("allowResult",
- FilteringBehaviorToString(behavior, uncertain));
- result.SetBoolKey("manual", reason == supervised_user_error_page::MANUAL &&
- behavior == SupervisedUserURLFilter::ALLOW);
+ base::Value::Dict result;
+ result.Set("allowResult", FilteringBehaviorToString(behavior, uncertain));
+ result.Set("manual", reason == supervised_user_error_page::MANUAL &&
+ behavior == SupervisedUserURLFilter::ALLOW);
ResolveJavascriptCallback(base::Value(callback_id), result);
}
@@ -288,9 +287,9 @@ void FamilyLinkUserInternalsMessageHandler::OnURLChecked(
supervised_user_error_page::FilteringBehaviorReason reason,
bool uncertain) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::DictionaryValue result;
- result.SetStringKey("url", url.possibly_invalid_spec());
- result.SetStringKey("result", FilteringBehaviorToString(behavior, uncertain));
- result.SetStringKey("reason", FilteringBehaviorReasonToString(reason));
+ base::Value::Dict result;
+ result.Set("url", url.possibly_invalid_spec());
+ result.Set("result", FilteringBehaviorToString(behavior, uncertain));
+ result.Set("reason", FilteringBehaviorReasonToString(reason));
FireWebUIListener("filtering-result-received", result);
}
diff --git a/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h
index ba9760415c6..e3f00321874 100644
--- a/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h
@@ -14,10 +14,6 @@
#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-} // namespace base
-
// The implementation for the chrome://family-link-user-internals page.
class FamilyLinkUserInternalsMessageHandler
: public content::WebUIMessageHandler,
@@ -43,9 +39,9 @@ class FamilyLinkUserInternalsMessageHandler
SupervisedUserService* GetSupervisedUserService();
- void HandleRegisterForEvents(const base::ListValue* args);
- void HandleGetBasicInfo(const base::ListValue* args);
- void HandleTryURL(const base::ListValue* args);
+ void HandleRegisterForEvents(const base::Value::List& args);
+ void HandleGetBasicInfo(const base::Value::List& args);
+ void HandleTryURL(const base::Value::List& args);
void SendBasicInfo();
void SendFamilyLinkUserSettings(const base::DictionaryValue* settings);
diff --git a/chromium/chrome/browser/ui/webui/favicon_source.cc b/chromium/chrome/browser/ui/webui/favicon_source.cc
index 604f7e1b6b6..92eec9871d1 100644
--- a/chromium/chrome/browser/ui/webui/favicon_source.cc
+++ b/chromium/chrome/browser/ui/webui/favicon_source.cc
@@ -199,7 +199,7 @@ void FaviconSource::StartDataRequest(
}
}
-std::string FaviconSource::GetMimeType(const std::string&) {
+std::string FaviconSource::GetMimeType(const GURL&) {
// We need to explicitly return a mime type, otherwise if the user tries to
// drag the image they get no extension.
return "image/png";
diff --git a/chromium/chrome/browser/ui/webui/favicon_source.h b/chromium/chrome/browser/ui/webui/favicon_source.h
index 3518ba67bf9..9bb5b510239 100644
--- a/chromium/chrome/browser/ui/webui/favicon_source.h
+++ b/chromium/chrome/browser/ui/webui/favicon_source.h
@@ -52,7 +52,7 @@ class FaviconSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string&) override;
+ std::string GetMimeType(const GURL&) override;
bool AllowCaching() override;
bool ShouldReplaceExistingSource() override;
bool ShouldServiceRequest(const GURL& url,
diff --git a/chromium/chrome/browser/ui/webui/favicon_source_unittest.cc b/chromium/chrome/browser/ui/webui/favicon_source_unittest.cc
index 9207a27ee50..64fadb2ebe2 100644
--- a/chromium/chrome/browser/ui/webui/favicon_source_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/favicon_source_unittest.cc
@@ -48,8 +48,6 @@ const char kDummyPrefix[] = "chrome://any-host/";
} // namespace
-void Noop(scoped_refptr<base::RefCountedMemory>) {}
-
class MockHistoryUiFaviconRequestHandler
: public favicon::HistoryUiFaviconRequestHandler {
public:
@@ -178,14 +176,14 @@ TEST_F(FaviconSourceTestWithLegacyFormat, DarkDefault) {
SetDarkMode(true);
EXPECT_CALL(*source(), LoadIconBytes(_, IDR_DEFAULT_FAVICON_DARK));
source()->StartDataRequest(GURL(kDummyPrefix), test_web_contents_getter_,
- base::BindOnce(&Noop));
+ base::DoNothing());
}
TEST_F(FaviconSourceTestWithLegacyFormat, LightDefault) {
SetDarkMode(false);
EXPECT_CALL(*source(), LoadIconBytes(_, IDR_DEFAULT_FAVICON));
source()->StartDataRequest(GURL(kDummyPrefix), test_web_contents_getter_,
- base::BindOnce(&Noop));
+ base::DoNothing());
}
TEST_F(FaviconSourceTestWithLegacyFormat,
@@ -199,7 +197,7 @@ TEST_F(FaviconSourceTestWithLegacyFormat,
source()->StartDataRequest(
GURL(base::StrCat({kDummyPrefix, "size/16@1x/https://www.google.com"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ test_web_contents_getter_, base::DoNothing());
}
TEST_F(FaviconSourceTestWithLegacyFormat,
@@ -232,7 +230,7 @@ TEST_F(FaviconSourceTestWithFavicon2Format,
base::HistogramTester tester;
source()->StartDataRequest(
GURL(base::StrCat({kDummyPrefix, "size/16@1x/https://www.google.com"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ test_web_contents_getter_, base::DoNothing());
std::unique_ptr<base::HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(
"Extensions.FaviconResourceUsed"));
@@ -244,14 +242,14 @@ TEST_F(FaviconSourceTestWithFavicon2Format, DarkDefault) {
SetDarkMode(true);
EXPECT_CALL(*source(), LoadIconBytes(_, IDR_DEFAULT_FAVICON_DARK));
source()->StartDataRequest(GURL(kDummyPrefix), test_web_contents_getter_,
- base::BindOnce(&Noop));
+ base::DoNothing());
}
TEST_F(FaviconSourceTestWithFavicon2Format, LightDefault) {
SetDarkMode(false);
EXPECT_CALL(*source(), LoadIconBytes(_, IDR_DEFAULT_FAVICON));
source()->StartDataRequest(GURL(kDummyPrefix), test_web_contents_getter_,
- base::BindOnce(&Noop));
+ base::DoNothing());
}
TEST_F(FaviconSourceTestWithFavicon2Format,
@@ -266,9 +264,9 @@ TEST_F(FaviconSourceTestWithFavicon2Format,
source()->StartDataRequest(
GURL(base::StrCat(
{kDummyPrefix,
- "?size=16&scale_factor=1x&page_url=https%3A%2F%2Fwww.google."
- "com&allow_google_server_fallback=0"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ "?size=16&scale_factor=1x&pageUrl=https%3A%2F%2Fwww.google."
+ "com&allowGoogleServerFallback=0"})),
+ test_web_contents_getter_, base::DoNothing());
}
TEST_F(FaviconSourceTestWithFavicon2Format,
@@ -283,9 +281,9 @@ TEST_F(FaviconSourceTestWithFavicon2Format,
source()->StartDataRequest(
GURL(base::StrCat(
{kDummyPrefix,
- "?size=16&scale_factor=1x&page_url=https%3A%2F%2Fwww.google."
- "com&allow_google_server_fallback=1"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ "?size=16&scale_factor=1x&pageUrl=https%3A%2F%2Fwww.google."
+ "com&allowGoogleServerFallback=1"})),
+ test_web_contents_getter_, base::DoNothing());
}
TEST_F(
@@ -301,9 +299,9 @@ TEST_F(
source()->StartDataRequest(
GURL(base::StrCat(
{kDummyPrefix,
- "?size=16&scale_factor=1x&page_url=https%3A%2F%2Fwww.google."
- "com&allow_google_server_fallback=1"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ "?size=16&scale_factor=1x&pageUrl=https%3A%2F%2Fwww.google."
+ "com&allowGoogleServerFallback=1"})),
+ test_web_contents_getter_, base::DoNothing());
}
TEST_F(FaviconSourceTestWithFavicon2Format,
@@ -317,5 +315,5 @@ TEST_F(FaviconSourceTestWithFavicon2Format,
// 100x scale factor runs into the max cap.
source()->StartDataRequest(
GURL(base::StrCat({kDummyPrefix, "size/16@100x/https://www.google.com"})),
- test_web_contents_getter_, base::BindOnce(&Noop));
+ test_web_contents_getter_, base::DoNothing());
}
diff --git a/chromium/chrome/browser/ui/webui/feed/feed_ui.cc b/chromium/chrome/browser/ui/webui/feed/feed_ui.cc
index 352d0e6fda2..e74a9f45c78 100644
--- a/chromium/chrome/browser/ui/webui/feed/feed_ui.cc
+++ b/chromium/chrome/browser/ui/webui/feed/feed_ui.cc
@@ -19,7 +19,8 @@
namespace feed {
-FeedUI::FeedUI(content::WebUI* web_ui) : ui::MojoBubbleWebUIController(web_ui) {
+FeedUI::FeedUI(content::WebUI* web_ui)
+ : ui::UntrustedBubbleWebUIController(web_ui) {
web_ui->AddRequestableScheme("https");
// TODO(crbug.com/1292623): We should disable http requests before launching.
web_ui->AddRequestableScheme("http");
@@ -31,47 +32,19 @@ FeedUI::FeedUI(content::WebUI* web_ui) : ui::MojoBubbleWebUIController(web_ui) {
source, base::make_span(kFeedResources, kFeedResourcesSize),
IDR_FEED_FEED_HTML);
- // TODO(crbug.com/1292623): CSP is weak during development and will be
- // tightened once the final architecture is decided.
- // - Unsafe-eval/unsafe-inline is used by wasm code and is likely that we can
- // avoid this for the final production version.
-
if (kWebUiDisableContentSecurityPolicy.Get()) {
source->DisableContentSecurityPolicy();
} else {
- std::string default_script_policy =
- " 'self' chrome-untrusted://resources http://localhost:8000 "
- "https://*.google.com https://google.com;";
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- base::StrCat({"script-src 'unsafe-eval' 'unsafe-inline'",
- default_script_policy}));
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::FrameSrc,
- base::StrCat({"frame-src", default_script_policy}));
+ "frame-src https://www.google.com;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc,
- base::StrCat({"style-src", default_script_policy}));
-
- std::string default_content_policy =
- " 'self' chrome-untrusted://resources https: http://localhost:8000;";
-
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ConnectSrc,
- base::StrCat({"connect-src", default_content_policy}));
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ImgSrc,
- base::StrCat({"img-src", default_content_policy}));
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::MediaSrc,
- base::StrCat({"media-src", default_content_policy}));
-
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::DefaultSrc, "default-src 'self';");
+ "style-src 'unsafe-inline' 'self';");
}
// Configurable javascript for prototyping purposes.
- source->AddString("scriptUrl", kWebUiScriptFetchUrl.Get());
+ source->AddString("feedUrl", kWebUiFeedUrl.Get());
// Register the URLDataSource
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
diff --git a/chromium/chrome/browser/ui/webui/feed/feed_ui.h b/chromium/chrome/browser/ui/webui/feed/feed_ui.h
index 15b8c5f2ae9..9e29aa6180b 100644
--- a/chromium/chrome/browser/ui/webui/feed/feed_ui.h
+++ b/chromium/chrome/browser/ui/webui/feed/feed_ui.h
@@ -12,11 +12,11 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
-#include "ui/webui/mojo_bubble_web_ui_controller.h"
+#include "ui/webui/untrusted_bubble_web_ui_controller.h"
namespace feed {
-class FeedUI : public ui::MojoBubbleWebUIController,
+class FeedUI : public ui::UntrustedBubbleWebUIController,
public feed::mojom::FeedSidePanelHandlerFactory {
public:
explicit FeedUI(content::WebUI* web_ui);
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
index e26aed51fa8..a842b1d6be9 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
@@ -31,9 +31,8 @@ struct Properties {
// Whether debugging the WebFeed follow intro is enabled.
bool is_web_feed_follow_intro_debug_enabled;
- // Whether the legacy feed endpoint should be used for Web Feed content
- // fetches.
- bool use_feed_query_requests_for_web_feeds;
+ // Whether the legacy feed endpoint should be used.
+ bool use_feed_query_requests;
// Last load stream status, human readable.
string load_stream_status;
@@ -117,7 +116,7 @@ interface PageHandler {
// Sets whether the legacy feed endpoint should be used for Web Feed content
// fetches.
- SetUseFeedQueryRequestsForWebFeeds(bool use_legacy);
+ SetUseFeedQueryRequests(bool use_legacy);
// Sets the Following feed order in local preferences.
SetFollowingFeedOrder(FeedOrder order);
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc
index 7641e07be1b..90edb766920 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc
@@ -64,8 +64,7 @@ void FeedV2InternalsPageHandler::GetGeneralProperties(
offline_pages::prefetch_prefs::IsEnabled(pref_service_);
properties->is_web_feed_follow_intro_debug_enabled =
IsWebFeedFollowIntroDebugEnabled();
- properties->use_feed_query_requests_for_web_feeds =
- ShouldUseFeedQueryRequestsForWebFeeds();
+ properties->use_feed_query_requests = ShouldUseFeedQueryRequests();
if (debug_data.fetch_info)
properties->feed_fetch_url = debug_data.fetch_info->base_request_url;
if (debug_data.upload_info)
@@ -157,13 +156,13 @@ void FeedV2InternalsPageHandler::SetWebFeedFollowIntroDebugEnabled(
enabled);
}
-bool FeedV2InternalsPageHandler::ShouldUseFeedQueryRequestsForWebFeeds() {
- return feed::GetFeedConfig().use_feed_query_requests_for_web_feeds;
+bool FeedV2InternalsPageHandler::ShouldUseFeedQueryRequests() {
+ return feed::GetFeedConfig().use_feed_query_requests;
}
-void FeedV2InternalsPageHandler::SetUseFeedQueryRequestsForWebFeeds(
+void FeedV2InternalsPageHandler::SetUseFeedQueryRequests(
const bool use_legacy) {
- feed::SetUseFeedQueryRequestsForWebFeeds(use_legacy);
+ feed::SetUseFeedQueryRequests(use_legacy);
}
feed_internals::mojom::FeedOrder
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h b/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h
index 35d759b91ce..34efba4caab 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h
@@ -46,14 +46,14 @@ class FeedV2InternalsPageHandler : public feed_internals::mojom::PageHandler {
void OverrideDiscoverApiEndpoint(const GURL& endpoint_url) override;
void OverrideFeedStreamData(const std::vector<uint8_t>& data) override;
void SetWebFeedFollowIntroDebugEnabled(const bool enabled) override;
- void SetUseFeedQueryRequestsForWebFeeds(const bool use_legacy) override;
+ void SetUseFeedQueryRequests(const bool use_legacy) override;
void SetFollowingFeedOrder(
const feed_internals::mojom::FeedOrder new_order) override;
private:
bool IsFeedAllowed();
bool IsWebFeedFollowIntroDebugEnabled();
- bool ShouldUseFeedQueryRequestsForWebFeeds();
+ bool ShouldUseFeedQueryRequests();
feed_internals::mojom::FeedOrder GetFollowingFeedOrder();
mojo::Receiver<feed_internals::mojom::PageHandler> receiver_;
diff --git a/chromium/chrome/browser/ui/webui/feedback/feedback_handler.cc b/chromium/chrome/browser/ui/webui/feedback/feedback_handler.cc
index 0ec014430b6..22a60fb95a9 100644
--- a/chromium/chrome/browser/ui/webui/feedback/feedback_handler.cc
+++ b/chromium/chrome/browser/ui/webui/feedback/feedback_handler.cc
@@ -55,40 +55,42 @@ FeedbackHandler::FeedbackHandler(const FeedbackDialog* dialog)
FeedbackHandler::~FeedbackHandler() = default;
void FeedbackHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showDialog", base::BindRepeating(&FeedbackHandler::HandleShowDialog,
base::Unretained(this)));
#if BUILDFLAG(IS_CHROMEOS)
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showAssistantLogsInfo",
base::BindRepeating(&FeedbackHandler::HandleShowAssistantLogsInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showBluetoothLogsInfo",
base::BindRepeating(&FeedbackHandler::HandleShowBluetoothLogsInfo,
base::Unretained(this)));
#endif // BUILDFLAG(IS_CHROMEOS)
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showSystemInfo",
base::BindRepeating(&FeedbackHandler::HandleShowSystemInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showMetrics", base::BindRepeating(&FeedbackHandler::HandleShowMetrics,
base::Unretained(this)));
}
-void FeedbackHandler::HandleShowDialog(const base::ListValue* args) {
+void FeedbackHandler::HandleShowDialog(const base::Value::List& args) {
dialog_->Show();
}
#if BUILDFLAG(IS_CHROMEOS)
-void FeedbackHandler::HandleShowAssistantLogsInfo(const base::ListValue* args) {
+void FeedbackHandler::HandleShowAssistantLogsInfo(
+ const base::Value::List& args) {
ShowChildPage(Profile::FromWebUI(web_ui()), dialog_,
ChildPageURL("html/assistant_logs_info.html"), std::u16string(),
/*dialog_width=*/400, /*dialog_height=*/120,
/*can_resize=*/false, /*can_minimize=*/false);
}
-void FeedbackHandler::HandleShowBluetoothLogsInfo(const base::ListValue* args) {
+void FeedbackHandler::HandleShowBluetoothLogsInfo(
+ const base::Value::List& args) {
ShowChildPage(Profile::FromWebUI(web_ui()), dialog_,
ChildPageURL("html/bluetooth_logs_info.html"), std::u16string(),
/*dialog_width=*/400, /*dialog_height=*/120,
@@ -96,13 +98,13 @@ void FeedbackHandler::HandleShowBluetoothLogsInfo(const base::ListValue* args) {
}
#endif // BUILDFLAG(IS_CHROMEOS)
-void FeedbackHandler::HandleShowSystemInfo(const base::ListValue* args) {
+void FeedbackHandler::HandleShowSystemInfo(const base::Value::List& args) {
ShowChildPage(Profile::FromWebUI(web_ui()), dialog_,
ChildPageURL("html/sys_info.html"),
l10n_util::GetStringUTF16(IDS_FEEDBACK_SYSINFO_PAGE_TITLE));
}
-void FeedbackHandler::HandleShowMetrics(const base::ListValue* args) {
+void FeedbackHandler::HandleShowMetrics(const base::Value::List& args) {
ShowChildPage(Profile::FromWebUI(web_ui()), dialog_,
GURL("chrome://histograms"), std::u16string());
}
diff --git a/chromium/chrome/browser/ui/webui/feedback/feedback_handler.h b/chromium/chrome/browser/ui/webui/feedback/feedback_handler.h
index 0628b66b522..0f233b36074 100644
--- a/chromium/chrome/browser/ui/webui/feedback/feedback_handler.h
+++ b/chromium/chrome/browser/ui/webui/feedback/feedback_handler.h
@@ -10,10 +10,6 @@
#include "chrome/browser/ui/webui/feedback/feedback_dialog.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-} // namespace base
-
class FeedbackHandler : public content::WebUIMessageHandler {
public:
explicit FeedbackHandler(const FeedbackDialog* dialog);
@@ -25,13 +21,13 @@ class FeedbackHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void HandleShowDialog(const base::ListValue* args);
+ void HandleShowDialog(const base::Value::List& args);
#if BUILDFLAG(IS_CHROMEOS)
- void HandleShowAssistantLogsInfo(const base::ListValue* args);
- void HandleShowBluetoothLogsInfo(const base::ListValue* args);
+ void HandleShowAssistantLogsInfo(const base::Value::List& args);
+ void HandleShowBluetoothLogsInfo(const base::Value::List& args);
#endif // BUILDFLAG(IS_CHROMEOS)
- void HandleShowMetrics(const base::ListValue* args);
- void HandleShowSystemInfo(const base::ListValue* args);
+ void HandleShowMetrics(const base::Value::List& args);
+ void HandleShowSystemInfo(const base::Value::List& args);
raw_ptr<const FeedbackDialog> dialog_;
};
diff --git a/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc
index df24fd6ea95..38b93f06958 100644
--- a/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc
+++ b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc
@@ -8,8 +8,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
-#include "chrome/grit/feedback_webui_resources.h"
-#include "chrome/grit/feedback_webui_resources_map.h"
+#include "chrome/grit/feedback_resources.h"
+#include "chrome/grit/feedback_resources_map.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
@@ -72,8 +72,8 @@ content::WebUIDataSource* CreateFeedbackHTMLSource(const Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost);
source->AddResourcePaths(
- base::make_span(kFeedbackWebuiResources, kFeedbackWebuiResourcesSize));
- source->AddResourcePath("", IDR_FEEDBACK_WEBUI_HTML_DEFAULT_HTML);
+ base::make_span(kFeedbackResources, kFeedbackResourcesSize));
+ source->AddResourcePath("", IDR_FEEDBACK_HTML_DEFAULT_HTML);
// Register the CSS file from chrome://system manually as that style is
// re-used by chrome://feedback/html/sys_info.html.
diff --git a/chromium/chrome/browser/ui/webui/fileicon_source.cc b/chromium/chrome/browser/ui/webui/fileicon_source.cc
index 9b9c63aaf07..29f044aff41 100644
--- a/chromium/chrome/browser/ui/webui/fileicon_source.cc
+++ b/chromium/chrome/browser/ui/webui/fileicon_source.cc
@@ -123,7 +123,7 @@ void FileIconSource::StartDataRequest(
FetchFileIcon(file_path, scale_factor, icon_size, std::move(callback));
}
-std::string FileIconSource::GetMimeType(const std::string&) {
+std::string FileIconSource::GetMimeType(const GURL&) {
// Rely on image decoder inferring the correct type.
return std::string();
}
diff --git a/chromium/chrome/browser/ui/webui/fileicon_source.h b/chromium/chrome/browser/ui/webui/fileicon_source.h
index 3bc048125e7..56843cf626c 100644
--- a/chromium/chrome/browser/ui/webui/fileicon_source.h
+++ b/chromium/chrome/browser/ui/webui/fileicon_source.h
@@ -33,7 +33,7 @@ class FileIconSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string&) override;
+ std::string GetMimeType(const GURL&) override;
bool AllowCaching() override;
protected:
diff --git a/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc
index cf6ec1c1c69..67cd7afd3c7 100644
--- a/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc
@@ -84,10 +84,10 @@ void FlagsUIHandler::HandleRequestExperimentalFeatures(
}
void FlagsUIHandler::SendExperimentalFeatures() {
- base::DictionaryValue results;
+ base::Value::Dict results;
- base::Value::ListStorage supported_features;
- base::Value::ListStorage unsupported_features;
+ base::Value::List supported_features;
+ base::Value::List unsupported_features;
if (deprecated_features_only_) {
about_flags::GetFlagFeatureEntriesForDeprecatedPage(
@@ -99,32 +99,31 @@ void FlagsUIHandler::SendExperimentalFeatures() {
unsupported_features);
}
- results.SetKey(flags_ui::kSupportedFeatures, base::Value(supported_features));
- results.SetKey(flags_ui::kUnsupportedFeatures,
- base::Value(unsupported_features));
- results.SetBoolKey(flags_ui::kNeedsRestart,
- about_flags::IsRestartNeededToCommitChanges());
- results.SetBoolKey(flags_ui::kShowOwnerWarning,
- access_ == flags_ui::kGeneralAccessFlagsOnly);
+ results.Set(flags_ui::kSupportedFeatures, std::move(supported_features));
+ results.Set(flags_ui::kUnsupportedFeatures, std::move(unsupported_features));
+ results.Set(flags_ui::kNeedsRestart,
+ about_flags::IsRestartNeededToCommitChanges());
+ results.Set(flags_ui::kShowOwnerWarning,
+ access_ == flags_ui::kGeneralAccessFlagsOnly);
#if BUILDFLAG(IS_CHROMEOS_ASH)
- const bool showSystemFlagsLink = crosapi::browser_util::IsLacrosEnabled();
+ const bool show_system_flags_link = crosapi::browser_util::IsLacrosEnabled();
#else
- const bool showSystemFlagsLink = true;
+ const bool show_system_flags_link = true;
#endif
- results.SetBoolKey(flags_ui::kShowSystemFlagsLink, showSystemFlagsLink);
+ results.Set(flags_ui::kShowSystemFlagsLink, show_system_flags_link);
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH)
version_info::Channel channel = chrome::GetChannel();
- results.SetBoolKey(
+ results.Set(
flags_ui::kShowBetaChannelPromotion,
channel == version_info::Channel::STABLE && !deprecated_features_only_);
- results.SetBoolKey(
+ results.Set(
flags_ui::kShowDevChannelPromotion,
channel == version_info::Channel::BETA && !deprecated_features_only_);
#else
- results.SetBoolKey(flags_ui::kShowBetaChannelPromotion, false);
- results.SetBoolKey(flags_ui::kShowDevChannelPromotion, false);
+ results.Set(flags_ui::kShowBetaChannelPromotion, false);
+ results.Set(flags_ui::kShowDevChannelPromotion, false);
#endif
ResolveJavascriptCallback(base::Value(experimental_features_callback_id_),
results);
diff --git a/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc b/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
index 6c275a96314..88f92e0f26f 100644
--- a/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
@@ -51,10 +51,10 @@ class GcmInternalsUIMessageHandler : public content::WebUIMessageHandler {
const gcm::GCMClient::GCMStatistics* stats);
// Request all of the GCM related infos through gcm profile service.
- void RequestAllInfo(const base::ListValue* args);
+ void RequestAllInfo(const base::Value::List& args);
// Enables/disables GCM activity recording through gcm profile service.
- void SetRecording(const base::ListValue* args);
+ void SetRecording(const base::Value::List& args);
// Callback function of the request for all gcm related infos.
void RequestGCMStatisticsFinished(const gcm::GCMClient::GCMStatistics& args);
@@ -71,16 +71,14 @@ void GcmInternalsUIMessageHandler::ReturnResults(
Profile* profile,
gcm::GCMProfileService* profile_service,
const gcm::GCMClient::GCMStatistics* stats) {
- base::DictionaryValue results;
- gcm_driver::SetGCMInternalsInfo(stats, profile_service, profile->GetPrefs(),
- &results);
+ base::Value::Dict results = gcm_driver::SetGCMInternalsInfo(
+ stats, profile_service, profile->GetPrefs());
FireWebUIListener(gcm_driver::kSetGcmInternalsInfo, results);
}
void GcmInternalsUIMessageHandler::RequestAllInfo(
- const base::ListValue* args) {
+ const base::Value::List& list) {
AllowJavascript();
- const auto& list = args->GetListDeprecated();
if (list.size() != 1) {
NOTREACHED();
return;
@@ -105,8 +103,7 @@ void GcmInternalsUIMessageHandler::RequestAllInfo(
}
}
-void GcmInternalsUIMessageHandler::SetRecording(const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+void GcmInternalsUIMessageHandler::SetRecording(const base::Value::List& list) {
if (list.size() != 1) {
NOTREACHED();
return;
@@ -142,11 +139,11 @@ void GcmInternalsUIMessageHandler::RequestGCMStatisticsFinished(
void GcmInternalsUIMessageHandler::RegisterMessages() {
// It is safe to use base::Unretained here, since web_ui owns this message
// handler.
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
gcm_driver::kGetGcmInternalsInfo,
base::BindRepeating(&GcmInternalsUIMessageHandler::RequestAllInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
gcm_driver::kSetGcmInternalsRecording,
base::BindRepeating(&GcmInternalsUIMessageHandler::SetRecording,
base::Unretained(this)));
diff --git a/chromium/chrome/browser/ui/webui/help/test_version_updater.h b/chromium/chrome/browser/ui/webui/help/test_version_updater.h
index ec8ca19cac3..d2249021e7f 100644
--- a/chromium/chrome/browser/ui/webui/help/test_version_updater.h
+++ b/chromium/chrome/browser/ui/webui/help/test_version_updater.h
@@ -43,6 +43,7 @@ class TestVersionUpdater : public VersionUpdater {
void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override {}
+ void ApplyDeferredUpdate() override {}
#endif
private:
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater.h b/chromium/chrome/browser/ui/webui/help/version_updater.h
index 2c2450a2e89..28111383ef0 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater.h
@@ -12,7 +12,7 @@
#include "build/chromeos_buildflags.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "chromeos/dbus/update_engine/update_engine_client.h"
+#include "chromeos/ash/components/dbus/update_engine/update_engine_client.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@@ -37,7 +37,8 @@ class VersionUpdater {
FAILED_HTTP,
FAILED_DOWNLOAD,
DISABLED,
- DISABLED_BY_ADMIN
+ DISABLED_BY_ADMIN,
+ DEFERRED
};
// Promotion state (Mac-only).
@@ -53,7 +54,7 @@ class VersionUpdater {
#if BUILDFLAG(IS_CHROMEOS_ASH)
typedef base::OnceCallback<void(const std::string&)> ChannelCallback;
using EolInfoCallback =
- base::OnceCallback<void(chromeos::UpdateEngineClient::EolInfo eol_info)>;
+ base::OnceCallback<void(ash::UpdateEngineClient::EolInfo eol_info)>;
using IsFeatureEnabledCallback =
base::OnceCallback<void(absl::optional<bool>)>;
#endif
@@ -127,6 +128,9 @@ class VersionUpdater {
StatusCallback callback,
const std::string& update_version,
int64_t update_size) = 0;
+
+ // If an update is downloaded but deferred, apply the deferred update.
+ virtual void ApplyDeferredUpdate() = 0;
#endif
};
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
index ccedbab78fd..f89dae8e578 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -20,12 +20,12 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/update_engine/update_engine_client.h"
+#include "chromeos/ash/components/network/network_handler.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_type_pattern.h"
#include "chromeos/dbus/power/power_manager_client.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
-#include "chromeos/network/network_type_pattern.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_contents.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@@ -34,10 +34,9 @@
namespace {
-using ::chromeos::DBusThreadManager;
+using ::ash::UpdateEngineClient;
using ::chromeos::OwnerSettingsServiceAsh;
using ::chromeos::OwnerSettingsServiceAshFactory;
-using ::chromeos::UpdateEngineClient;
// Network status in the context of device update.
enum NetworkStatus {
@@ -52,7 +51,7 @@ enum NetworkStatus {
const bool kDefaultAutoUpdateDisabled = false;
NetworkStatus GetNetworkStatus(bool interactive,
- const chromeos::NetworkState* network,
+ const ash::NetworkState* network,
bool metered) {
if (!network || !network->IsConnectedState()) // Offline state.
return NETWORK_STATUS_OFFLINE;
@@ -79,19 +78,19 @@ bool IsAutoUpdateDisabled() {
return update_disabled;
}
-std::u16string GetConnectionTypeAsUTF16(const chromeos::NetworkState* network,
+std::u16string GetConnectionTypeAsUTF16(const ash::NetworkState* network,
bool metered) {
const std::string type = network->type();
- if (chromeos::NetworkTypePattern::WiFi().MatchesType(type)) {
+ if (ash::NetworkTypePattern::WiFi().MatchesType(type)) {
if (metered)
return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_METERED_WIFI);
return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI);
}
- if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type))
+ if (ash::NetworkTypePattern::Ethernet().MatchesType(type))
return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET);
- if (chromeos::NetworkTypePattern::Mobile().MatchesType(type))
+ if (ash::NetworkTypePattern::Mobile().MatchesType(type))
return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_MOBILE_DATA);
- if (chromeos::NetworkTypePattern::VPN().MatchesType(type))
+ if (ash::NetworkTypePattern::VPN().MatchesType(type))
return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN);
NOTREACHED();
return std::u16string();
@@ -109,10 +108,9 @@ bool EnsureCanUpdate(bool interactive,
return false;
}
- chromeos::NetworkStateHandler* network_state_handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- const chromeos::NetworkState* network =
- network_state_handler->DefaultNetwork();
+ ash::NetworkStateHandler* network_state_handler =
+ ash::NetworkHandler::Get()->network_state_handler();
+ const ash::NetworkState* network = network_state_handler->DefaultNetwork();
const bool metered = network_state_handler->default_network_is_metered();
// Don't allow an update if we're currently offline or connected
// to a network for which updates are disallowed.
@@ -145,13 +143,20 @@ void VersionUpdaterCros::GetUpdateStatus(StatusCallback callback) {
if (!EnsureCanUpdate(false /* interactive */, callback_))
return;
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
+ UpdateEngineClient* update_engine_client = UpdateEngineClient::Get();
if (!update_engine_client->HasObserver(this))
update_engine_client->AddObserver(this);
- this->UpdateStatusChanged(
- DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus());
+ this->UpdateStatusChanged(update_engine_client->GetLastStatus());
+}
+
+void VersionUpdaterCros::ApplyDeferredUpdate() {
+ UpdateEngineClient* update_engine_client = UpdateEngineClient::Get();
+
+ DCHECK(update_engine_client->GetLastStatus().current_operation() ==
+ update_engine::Operation::UPDATED_BUT_DEFERRED);
+
+ update_engine_client->ApplyDeferredUpdate(base::DoNothing());
}
void VersionUpdaterCros::CheckForUpdate(StatusCallback callback,
@@ -162,8 +167,7 @@ void VersionUpdaterCros::CheckForUpdate(StatusCallback callback,
if (!EnsureCanUpdate(true /* interactive */, callback_))
return;
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
+ UpdateEngineClient* update_engine_client = UpdateEngineClient::Get();
if (!update_engine_client->HasObserver(this))
update_engine_client->AddObserver(this);
@@ -192,8 +196,7 @@ void VersionUpdaterCros::SetChannel(const std::string& channel,
// For local owner set the field in the policy blob.
if (service)
service->SetString(ash::kReleaseChannel, channel);
- DBusThreadManager::Get()->GetUpdateEngineClient()->
- SetChannel(channel, is_powerwash_allowed);
+ UpdateEngineClient::Get()->SetChannel(channel, is_powerwash_allowed);
}
void VersionUpdaterCros::SetUpdateOverCellularOneTimePermission(
@@ -201,13 +204,11 @@ void VersionUpdaterCros::SetUpdateOverCellularOneTimePermission(
const std::string& update_version,
int64_t update_size) {
callback_ = std::move(callback);
- DBusThreadManager::Get()
- ->GetUpdateEngineClient()
- ->SetUpdateOverCellularOneTimePermission(
- update_version, update_size,
- base::BindOnce(
- &VersionUpdaterCros::OnSetUpdateOverCellularOneTimePermission,
- weak_ptr_factory_.GetWeakPtr()));
+ UpdateEngineClient::Get()->SetUpdateOverCellularOneTimePermission(
+ update_version, update_size,
+ base::BindOnce(
+ &VersionUpdaterCros::OnSetUpdateOverCellularOneTimePermission,
+ weak_ptr_factory_.GetWeakPtr()));
}
void VersionUpdaterCros::OnSetUpdateOverCellularOneTimePermission(
@@ -226,12 +227,9 @@ void VersionUpdaterCros::OnSetUpdateOverCellularOneTimePermission(
void VersionUpdaterCros::GetChannel(bool get_current_channel,
ChannelCallback cb) {
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
-
// Request the channel information. Bind to a weak_ptr bound method rather
// than passing |cb| directly so that |cb| does not outlive |this|.
- update_engine_client->GetChannel(
+ UpdateEngineClient::Get()->GetChannel(
get_current_channel,
base::BindOnce(&VersionUpdaterCros::OnGetChannel,
weak_ptr_factory_.GetWeakPtr(), std::move(cb)));
@@ -243,36 +241,26 @@ void VersionUpdaterCros::OnGetChannel(ChannelCallback cb,
}
void VersionUpdaterCros::GetEolInfo(EolInfoCallback cb) {
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
-
// Request the EolInfo. Bind to a weak_ptr bound method rather than passing
// |cb| directly so that |cb| does not outlive |this|.
- update_engine_client->GetEolInfo(
+ UpdateEngineClient::Get()->GetEolInfo(
base::BindOnce(&VersionUpdaterCros::OnGetEolInfo,
weak_ptr_factory_.GetWeakPtr(), std::move(cb)));
}
-void VersionUpdaterCros::OnGetEolInfo(
- EolInfoCallback cb,
- chromeos::UpdateEngineClient::EolInfo eol_info) {
+void VersionUpdaterCros::OnGetEolInfo(EolInfoCallback cb,
+ UpdateEngineClient::EolInfo eol_info) {
std::move(cb).Run(std::move(eol_info));
}
void VersionUpdaterCros::ToggleFeature(const std::string& feature,
bool enable) {
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
-
- update_engine_client->ToggleFeature(feature, enable);
+ UpdateEngineClient::Get()->ToggleFeature(feature, enable);
}
void VersionUpdaterCros::IsFeatureEnabled(const std::string& feature,
IsFeatureEnabledCallback callback) {
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
-
- update_engine_client->IsFeatureEnabled(
+ UpdateEngineClient::Get()->IsFeatureEnabled(
feature,
base::BindOnce(&VersionUpdaterCros::OnIsFeatureEnabled,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
@@ -293,9 +281,7 @@ VersionUpdaterCros::VersionUpdaterCros(content::WebContents* web_contents)
check_for_update_when_idle_(false) {}
VersionUpdaterCros::~VersionUpdaterCros() {
- UpdateEngineClient* update_engine_client =
- DBusThreadManager::Get()->GetUpdateEngineClient();
- update_engine_client->RemoveObserver(this);
+ UpdateEngineClient::Get()->RemoveObserver(this);
}
void VersionUpdaterCros::UpdateStatusChanged(
@@ -326,6 +312,7 @@ void VersionUpdaterCros::UpdateStatusChanged(
case update_engine::Operation::ERROR:
case update_engine::Operation::REPORTING_ERROR_EVENT:
case update_engine::Operation::ATTEMPTING_ROLLBACK:
+ case update_engine::Operation::CLEANUP_PREVIOUS_UPDATE:
// Update engine reports errors for some conditions that shouldn't
// actually be displayed as errors to users so leave the status as
// UPDATED. However for some specific errors use the specific FAILED
@@ -368,6 +355,9 @@ void VersionUpdaterCros::UpdateStatusChanged(
case update_engine::Operation::UPDATED_NEED_REBOOT:
my_status = NEARLY_UPDATED;
break;
+ case update_engine::Operation::UPDATED_BUT_DEFERRED:
+ my_status = DEFERRED;
+ break;
default:
NOTREACHED();
}
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h
index 8eaa9404f0f..5d6577520f5 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h
@@ -15,7 +15,7 @@ class WebContents;
}
class VersionUpdaterCros : public VersionUpdater,
- public chromeos::UpdateEngineClient::Observer {
+ public ash::UpdateEngineClient::Observer {
public:
VersionUpdaterCros(const VersionUpdaterCros&) = delete;
VersionUpdaterCros& operator=(const VersionUpdaterCros&) = delete;
@@ -33,6 +33,7 @@ class VersionUpdaterCros : public VersionUpdater,
void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override;
+ void ApplyDeferredUpdate() override;
// Gets the last update status, without triggering a new check or download.
void GetUpdateStatus(StatusCallback callback);
@@ -49,7 +50,7 @@ class VersionUpdaterCros : public VersionUpdater,
void UpdateStatusChanged(const update_engine::StatusResult& status) override;
// Callback from UpdateEngineClient::RequestUpdateCheck().
- void OnUpdateCheck(chromeos::UpdateEngineClient::UpdateCheckResult result);
+ void OnUpdateCheck(ash::UpdateEngineClient::UpdateCheckResult result);
// Callback from UpdateEngineClient::SetUpdateOverCellularOneTimePermission().
void OnSetUpdateOverCellularOneTimePermission(bool success);
@@ -59,7 +60,7 @@ class VersionUpdaterCros : public VersionUpdater,
// Callback from UpdateEngineClient::GetEolInfo().
void OnGetEolInfo(EolInfoCallback cb,
- chromeos::UpdateEngineClient::EolInfo eol_info);
+ ash::UpdateEngineClient::EolInfo eol_info);
// Callback from UpdateEngineClient::IsFeatureEnabled().
void OnIsFeatureEnabled(IsFeatureEnabledCallback callback,
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
index 4fc3fc91388..97daac5e51f 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
@@ -13,10 +13,9 @@
#include "base/test/mock_callback.h"
#include "chrome/browser/ash/login/users/mock_user_manager.h"
#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/shill/shill_service_client.h"
-#include "chromeos/dbus/update_engine/fake_update_engine_client.h"
-#include "chromeos/network/network_handler_test_helper.h"
+#include "chromeos/ash/components/dbus/shill/shill_service_client.h"
+#include "chromeos/ash/components/dbus/update_engine/fake_update_engine_client.h"
+#include "chromeos/ash/components/network/network_handler_test_helper.h"
#include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -60,10 +59,8 @@ class VersionUpdaterCrosTest : public ::testing::Test {
~VersionUpdaterCrosTest() override {}
void SetUp() override {
- fake_update_engine_client_ = new FakeUpdateEngineClient();
- DBusThreadManager::Initialize();
- DBusThreadManager::GetSetterForTesting()->SetUpdateEngineClient(
- std::unique_ptr<UpdateEngineClient>(fake_update_engine_client_));
+ fake_update_engine_client_ =
+ ash::UpdateEngineClient::InitializeFakeForTest();
EXPECT_CALL(*mock_user_manager_, IsCurrentUserOwner())
.WillRepeatedly(Return(false));
@@ -74,7 +71,7 @@ class VersionUpdaterCrosTest : public ::testing::Test {
}
void SetEthernetService() {
- ShillServiceClient::TestInterface* service_test =
+ ash::ShillServiceClient::TestInterface* service_test =
network_handler_test_helper_->service_test();
service_test->ClearServices();
service_test->AddService("/service/eth",
@@ -86,7 +83,7 @@ class VersionUpdaterCrosTest : public ::testing::Test {
}
void SetCellularService() {
- ShillServiceClient::TestInterface* service_test =
+ ash::ShillServiceClient::TestInterface* service_test =
network_handler_test_helper_->service_test();
service_test->ClearServices();
service_test->AddService("/service/cell", "cell" /* guid */, "cell",
@@ -98,14 +95,14 @@ class VersionUpdaterCrosTest : public ::testing::Test {
void TearDown() override {
network_handler_test_helper_.reset();
version_updater_.reset();
- DBusThreadManager::Shutdown();
+ ash::UpdateEngineClient::Shutdown();
}
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<NetworkHandlerTestHelper> network_handler_test_helper_;
std::unique_ptr<VersionUpdater> version_updater_;
VersionUpdaterCros* version_updater_cros_ptr_;
- FakeUpdateEngineClient* fake_update_engine_client_; // Not owned.
+ ash::FakeUpdateEngineClient* fake_update_engine_client_; // Not owned.
MockUserManager* mock_user_manager_; // Not owned.
user_manager::ScopedUserManager user_manager_enabler_;
@@ -241,4 +238,15 @@ TEST_F(VersionUpdaterCrosTest, IsFeatureEnabled) {
EXPECT_EQ(1, fake_update_engine_client_->is_feature_enabled_count());
}
+TEST_F(VersionUpdaterCrosTest, ApplyDeferredUpdate) {
+ update_engine::StatusResult status;
+ status.set_current_operation(update_engine::Operation::UPDATED_BUT_DEFERRED);
+ fake_update_engine_client_->set_default_status(status);
+ fake_update_engine_client_->NotifyObserversThatStatusChanged(status);
+
+ EXPECT_EQ(0, fake_update_engine_client_->apply_deferred_update_count());
+ version_updater_cros_ptr_->ApplyDeferredUpdate();
+ EXPECT_EQ(1, fake_update_engine_client_->apply_deferred_update_count());
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_mac.h b/chromium/chrome/browser/ui/webui/help/version_updater_mac.h
index 83ec14e1d83..1168a058f5c 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_mac.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_mac.h
@@ -16,9 +16,9 @@
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/updater/update_service.h" // nogncheck
+#include "chrome/updater/update_service.h"
+#include "chrome/updater/updater_scope.h"
-class BrowserUpdaterClient;
class BrowserUpdaterHelperClientMac;
#endif // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
@@ -58,10 +58,12 @@ class VersionUpdaterMac : public VersionUpdater {
void UpdateStatusFromChromiumUpdater(
VersionUpdater::StatusCallback status_callback,
VersionUpdater::PromoteCallback promote_callback,
+ updater::UpdaterScope scope,
updater::UpdateService::UpdateState update_state);
void UpdatePromotionStatusFromChromiumUpdater(
VersionUpdater::PromoteCallback promote_callback,
+ updater::UpdaterScope scope,
bool enable_promote_button,
const std::string& version);
#endif // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
@@ -79,9 +81,6 @@ class VersionUpdaterMac : public VersionUpdater {
base::scoped_nsobject<KeystoneObserver> keystone_observer_;
#if BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
- // Instance of the BrowserUpdaterClient used to update the browser with the
- // new updater.
- scoped_refptr<BrowserUpdaterClient> update_client_;
scoped_refptr<BrowserUpdaterHelperClientMac> update_helper_client_;
base::WeakPtrFactory<VersionUpdaterMac> weak_factory_{this};
#endif // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm b/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm
index 0078b54cdd1..90f926310d1 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/help/version_updater_mac.h"
+#include "base/memory/raw_ptr.h"
+
#import <Foundation/Foundation.h>
#import <ServiceManagement/ServiceManagement.h>
@@ -11,6 +13,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
@@ -44,7 +47,7 @@
// updates. It will be created and managed by VersionUpdaterMac.
@interface KeystoneObserver : NSObject {
@private
- VersionUpdaterMac* _versionUpdater; // Weak.
+ raw_ptr<VersionUpdaterMac> _versionUpdater; // Weak.
}
// Initialize an observer with an updater. The updater owns this object.
@@ -107,14 +110,19 @@ VersionUpdaterMac::~VersionUpdaterMac() {}
void VersionUpdaterMac::CheckForUpdate(StatusCallback status_callback,
PromoteCallback promote_callback) {
#if BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
- if (!update_client_)
- update_client_ = BrowserUpdaterClient::Create();
-
- update_client_->CheckForUpdate(base::BindRepeating(
- &VersionUpdaterMac::UpdateStatusFromChromiumUpdater,
- weak_factory_.GetWeakPtr(), std::move(status_callback),
- std::move(promote_callback)));
- return;
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock()}, base::BindOnce(&GetUpdaterScope),
+ base::BindOnce(
+ [](base::RepeatingCallback<void(updater::UpdaterScope,
+ updater::UpdateService::UpdateState)>
+ status_callback,
+ updater::UpdaterScope scope) {
+ BrowserUpdaterClient::Create(scope)->CheckForUpdate(
+ base::BindRepeating(status_callback, scope));
+ },
+ base::BindRepeating(
+ &VersionUpdaterMac::UpdateStatusFromChromiumUpdater,
+ weak_factory_.GetWeakPtr(), status_callback, promote_callback)));
#else
status_callback_ = std::move(status_callback);
promote_callback_ = std::move(promote_callback);
@@ -302,11 +310,11 @@ void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) {
}
}
- if (!status_callback_.is_null())
+ if (status_callback_)
status_callback_.Run(status, 0, false, false, std::string(), 0, message);
PromotionState promotion_state;
- if (!promote_callback_.is_null()) {
+ if (promote_callback_) {
KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue];
if (keystone_glue && [keystone_glue isAutoupdateEnabledForAllUsers]) {
promotion_state = PROMOTED;
@@ -352,6 +360,7 @@ void VersionUpdaterMac::UpdateShowPromoteButton() {
void VersionUpdaterMac::UpdateStatusFromChromiumUpdater(
VersionUpdater::StatusCallback status_callback,
VersionUpdater::PromoteCallback promote_callback,
+ updater::UpdaterScope scope,
updater::UpdateService::UpdateState update_state) {
VersionUpdater::Status status = VersionUpdater::Status::CHECKING;
int progress = 0;
@@ -405,39 +414,35 @@ void VersionUpdaterMac::UpdateStatusFromChromiumUpdater(
// update_clent with system scope and attempt to get version. If the version
// is empty, then the updater can be assumed to not be installed. If the
// version returns a value, then the updater is installed.
- if (!promote_callback.is_null() && ShouldPromoteUpdater()) {
- update_client_->ResetConnection(updater::UpdaterScope::kSystem);
- update_client_->GetUpdaterVersion(base::BindOnce(
- &VersionUpdaterMac::UpdatePromotionStatusFromChromiumUpdater,
- weak_factory_.GetWeakPtr(), std::move(promote_callback),
- enable_promote_button));
+ if (promote_callback) {
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock()}, base::BindOnce(&ShouldPromoteUpdater),
+ base::BindOnce(
+ [](base::OnceCallback<void(const std::string&)> promotion,
+ bool should_promote) {
+ if (should_promote) {
+ BrowserUpdaterClient::Create(updater::UpdaterScope::kSystem)
+ ->GetUpdaterVersion(std::move(promotion));
+ }
+ },
+ base::BindOnce(
+ &VersionUpdaterMac::UpdatePromotionStatusFromChromiumUpdater,
+ weak_factory_.GetWeakPtr(), promote_callback, scope,
+ enable_promote_button)));
}
}
void VersionUpdaterMac::UpdatePromotionStatusFromChromiumUpdater(
VersionUpdater::PromoteCallback promote_callback,
+ updater::UpdaterScope scope,
bool enable_promote_button,
const std::string& version) {
- if (promote_callback.is_null())
- return;
-
- VersionUpdater::PromotionState promotion_state =
- VersionUpdater::PROMOTE_HIDDEN;
- // If the version is not empty and the current path is owned by root (which
- // is reflected in ShouldUseSystemLevelUpdater()), then the updater had
- // already been promoted.
- if (!version.empty() && ShouldUseSystemLevelUpdater()) {
- promotion_state = VersionUpdater::PROMOTED;
- update_client_->ResetConnection(updater::UpdaterScope::kSystem);
- } else {
- promotion_state = enable_promote_button ? VersionUpdater::PROMOTE_ENABLED
- : VersionUpdater::PROMOTE_DISABLED;
- if (!enable_promote_button) {
- update_client_->ResetConnection(updater::UpdaterScope::kUser);
- }
- }
-
- promote_callback.Run(promotion_state);
+ promote_callback.Run(
+ !version.empty() && scope == updater::UpdaterScope::kSystem
+ ? VersionUpdater::PROMOTED // Successfully communicated with the
+ // system updater.
+ : (enable_promote_button ? VersionUpdater::PROMOTE_ENABLED
+ : VersionUpdater::PROMOTE_DISABLED));
}
#endif // BUILDFLAG(ENABLE_CHROMIUM_UPDATER)
diff --git a/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc b/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc
index f2bd891195a..d050337a1d0 100644
--- a/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc
@@ -169,7 +169,7 @@ bool IsEntryInRemoteUserData(
}
// Converts `entry` to a base::Value::Dict to be owned by the caller.
-base::Value HistoryEntryToValue(
+base::Value::Dict HistoryEntryToValue(
const BrowsingHistoryService::HistoryEntry& entry,
BookmarkModel* bookmark_model,
Profile* profile,
@@ -196,7 +196,7 @@ base::Value HistoryEntryToValue(
result.Set("time", entry.time.ToJsTime());
// Pass the timestamps in a list.
- base::Value timestamps(base::Value::Type::LIST);
+ base::Value::List timestamps;
for (int64_t timestamp : entry.all_timestamps) {
timestamps.Append(base::Time::FromInternalValue(timestamp).ToJsTime());
}
@@ -273,7 +273,7 @@ base::Value HistoryEntryToValue(
result.Set("debug", std::move(debug));
}
- return base::Value(std::move(result));
+ return result;
}
} // namespace
@@ -285,7 +285,7 @@ BrowsingHistoryHandler::BrowsingHistoryHandler()
BrowsingHistoryHandler::~BrowsingHistoryHandler() = default;
void BrowsingHistoryHandler::OnJavascriptAllowed() {
- if (!browsing_history_service_ && initial_results_.is_none()) {
+ if (!browsing_history_service_ && !initial_results_) {
// Page was refreshed, so need to call StartQueryHistory here
StartQueryHistory();
}
@@ -299,7 +299,7 @@ void BrowsingHistoryHandler::OnJavascriptAllowed() {
void BrowsingHistoryHandler::OnJavascriptDisallowed() {
weak_factory_.InvalidateWeakPtrs();
browsing_history_service_ = nullptr;
- initial_results_ = base::Value();
+ initial_results_ = absl::nullopt;
deferred_callbacks_.clear();
query_history_callback_id_.clear();
remove_visits_callback_.clear();
@@ -312,20 +312,20 @@ void BrowsingHistoryHandler::RegisterMessages() {
profile, std::make_unique<FaviconSource>(
profile, chrome::FaviconUrlFormat::kFavicon2));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"queryHistory",
base::BindRepeating(&BrowsingHistoryHandler::HandleQueryHistory,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"queryHistoryContinuation",
base::BindRepeating(
&BrowsingHistoryHandler::HandleQueryHistoryContinuation,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"removeVisits",
base::BindRepeating(&BrowsingHistoryHandler::HandleRemoveVisits,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"clearBrowsingData",
base::BindRepeating(&BrowsingHistoryHandler::HandleClearBrowsingData,
base::Unretained(this)));
@@ -348,12 +348,12 @@ void BrowsingHistoryHandler::StartQueryHistory() {
SendHistoryQuery(150, std::u16string());
}
-void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) {
+void BrowsingHistoryHandler::HandleQueryHistory(const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
- if (!initial_results_.is_none()) {
- ResolveJavascriptCallback(callback_id, std::move(initial_results_));
- initial_results_ = base::Value();
+ const base::Value& callback_id = args[0];
+ if (initial_results_.has_value()) {
+ ResolveJavascriptCallback(callback_id, *initial_results_);
+ initial_results_ = absl::nullopt;
return;
}
@@ -373,9 +373,9 @@ void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) {
// - the text to search for (may be empty)
// - the maximum number of results to return (may be 0, meaning that there
// is no maximum).
- const base::Value& search_text = args->GetListDeprecated()[1];
+ const base::Value& search_text = args[1];
- const base::Value& count = args->GetListDeprecated()[2];
+ const base::Value& count = args[2];
if (!count.is_int()) {
NOTREACHED() << "Failed to convert argument 2.";
return;
@@ -401,9 +401,9 @@ void BrowsingHistoryHandler::SendHistoryQuery(int max_count,
}
void BrowsingHistoryHandler::HandleQueryHistoryContinuation(
- const base::ListValue* args) {
- CHECK_EQ(args->GetListDeprecated().size(), 1U);
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ const base::Value::List& args) {
+ CHECK_EQ(args.size(), 1U);
+ const base::Value& callback_id = args[0];
// Cancel the previous query if it is still in flight.
if (!query_history_callback_id_.empty()) {
RejectJavascriptCallback(base::Value(query_history_callback_id_),
@@ -415,15 +415,15 @@ void BrowsingHistoryHandler::HandleQueryHistoryContinuation(
std::move(query_history_continuation_).Run();
}
-void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) {
- CHECK_EQ(args->GetListDeprecated().size(), 2U);
- const base::Value& callback_id = args->GetListDeprecated()[0];
+void BrowsingHistoryHandler::HandleRemoveVisits(const base::Value::List& args) {
+ CHECK_EQ(args.size(), 2U);
+ const base::Value& callback_id = args[0];
CHECK(remove_visits_callback_.empty());
remove_visits_callback_ = callback_id.GetString();
std::vector<BrowsingHistoryService::HistoryEntry> items_to_remove;
- const base::Value& items = args->GetListDeprecated()[1];
- base::Value::ConstListView list = items.GetListDeprecated();
+ const base::Value& items = args[1];
+ const base::Value::List& list = items.GetList();
items_to_remove.reserve(list.size());
for (size_t i = 0; i < list.size(); ++i) {
// Each argument is a dictionary with properties "url" and "timestamps".
@@ -461,7 +461,7 @@ void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) {
}
void BrowsingHistoryHandler::HandleClearBrowsingData(
- const base::ListValue* args) {
+ const base::Value::List& args) {
// TODO(beng): This is an improper direct dependency on Browser. Route this
// through some sort of delegate.
Browser* browser =
@@ -493,23 +493,23 @@ void BrowsingHistoryHandler::OnQueryComplete(
// Convert the result vector into a ListValue.
DCHECK(tracker);
- base::Value results_value(base::Value::Type::LIST);
+ base::Value::List results_value;
for (const BrowsingHistoryService::HistoryEntry& entry : results) {
results_value.Append(
HistoryEntryToValue(entry, bookmark_model, profile, tracker, clock_));
}
- base::Value results_info(base::Value::Type::DICTIONARY);
+ base::Value::Dict results_info;
// The items which are to be written into results_info_value_ are also
// described in chrome/browser/resources/history/history.js in @typedef for
// HistoryQuery. Please update it whenever you add or remove any keys in
// results_info_value_.
- results_info.GetDict().Set("term", query_results_info.search_text);
- results_info.GetDict().Set("finished", query_results_info.reached_beginning);
+ results_info.Set("term", query_results_info.search_text);
+ results_info.Set("finished", query_results_info.reached_beginning);
- base::Value final_results(base::Value::Type::DICTIONARY);
- final_results.GetDict().Set("info", std::move(results_info));
- final_results.GetDict().Set("value", std::move(results_value));
+ base::Value::Dict final_results;
+ final_results.Set("info", std::move(results_info));
+ final_results.Set("value", std::move(results_value));
if (query_history_callback_id_.empty()) {
// This can happen if JS isn't ready yet when the first query comes back.
@@ -518,7 +518,7 @@ void BrowsingHistoryHandler::OnQueryComplete(
}
ResolveJavascriptCallback(base::Value(query_history_callback_id_),
- std::move(final_results));
+ final_results);
query_history_callback_id_.clear();
}
diff --git a/chromium/chrome/browser/ui/webui/history/browsing_history_handler.h b/chromium/chrome/browser/ui/webui/history/browsing_history_handler.h
index 27574970104..ed936115816 100644
--- a/chromium/chrome/browser/ui/webui/history/browsing_history_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/browsing_history_handler.h
@@ -40,16 +40,16 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
void StartQueryHistory();
// Handler for the "queryHistory" message.
- void HandleQueryHistory(const base::ListValue* args);
+ void HandleQueryHistory(const base::Value::List& args);
// Handler for the "queryHistoryContinuation" message.
- void HandleQueryHistoryContinuation(const base::ListValue* args);
+ void HandleQueryHistoryContinuation(const base::Value::List& args);
// Handler for the "removeVisits" message.
- void HandleRemoveVisits(const base::ListValue* args);
+ void HandleRemoveVisits(const base::Value::List& args);
// Handler for "clearBrowsingData" message.
- void HandleClearBrowsingData(const base::ListValue* args);
+ void HandleClearBrowsingData(const base::Value::List& args);
// Handler for "removeBookmark" message.
void HandleRemoveBookmark(const base::Value::List& args);
@@ -93,7 +93,7 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
std::vector<base::OnceClosure> deferred_callbacks_;
- base::Value initial_results_;
+ absl::optional<base::Value::Dict> initial_results_;
std::string query_history_callback_id_;
diff --git a/chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc b/chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc
index 8de9b6a277d..41b43f71b3d 100644
--- a/chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc
@@ -143,11 +143,11 @@ class BrowsingHistoryHandlerTest : public ChromeRenderViewHostTestHarness {
void InitializeWebUI(BrowsingHistoryHandlerWithWebUIForTesting& handler) {
// Send historyLoaded so that JS will be allowed.
- base::Value init_args(base::Value::Type::LIST);
+ base::Value::List init_args;
init_args.Append("query-history-callback-id");
init_args.Append("");
init_args.Append(150);
- handler.HandleQueryHistory(&base::Value::AsListValue(init_args));
+ handler.HandleQueryHistory(init_args);
}
syncer::TestSyncService* sync_service() { return sync_service_; }
@@ -251,17 +251,17 @@ TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
EXPECT_EQ(10U, web_ui()->call_data().size());
// Simulate a delete request.
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("remove-visits-callback-id");
- base::Value to_remove(base::Value::Type::LIST);
- base::Value visit(base::Value::Type::DICTIONARY);
- visit.SetStringKey("url", "https://www.google.com");
- base::Value timestamps(base::Value::Type::LIST);
+ base::Value::List to_remove;
+ base::Value::Dict visit;
+ visit.Set("url", "https://www.google.com");
+ base::Value::List timestamps;
timestamps.Append(12345678.0);
- visit.SetKey("timestamps", std::move(timestamps));
+ visit.Set("timestamps", std::move(timestamps));
to_remove.Append(std::move(visit));
args.Append(std::move(to_remove));
- handler.HandleRemoveVisits(&base::Value::AsListValue(args));
+ handler.HandleRemoveVisits(args);
EXPECT_EQ(11U, web_ui()->call_data().size());
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -301,11 +301,11 @@ TEST_F(BrowsingHistoryHandlerTest, HostPrefixParameter) {
QueryHistory(query,
::testing::Field(&history::QueryOptions::host_only, true)));
- base::Value init_args(base::Value::Type::LIST);
+ base::Value::List init_args;
init_args.Append("query-history-callback-id");
init_args.Append("host:www.chromium.org");
init_args.Append(150);
- handler.HandleQueryHistory(&base::Value::AsListValue(init_args));
+ handler.HandleQueryHistory(init_args);
}
TEST_F(BrowsingHistoryHandlerTest, WithoutHostPrefixParameter) {
@@ -318,11 +318,11 @@ TEST_F(BrowsingHistoryHandlerTest, WithoutHostPrefixParameter) {
QueryHistory(query,
::testing::Field(&history::QueryOptions::host_only, false)));
- base::Value init_args(base::Value::Type::LIST);
+ base::Value::List init_args;
init_args.Append("query-history-callback-id");
init_args.Append("www.chromium.org");
init_args.Append(150);
- handler.HandleQueryHistory(&base::Value::AsListValue(init_args));
+ handler.HandleQueryHistory(init_args);
}
TEST_F(BrowsingHistoryHandlerTest, MisplacedHostPrefixParameter) {
@@ -335,11 +335,11 @@ TEST_F(BrowsingHistoryHandlerTest, MisplacedHostPrefixParameter) {
QueryHistory(
query, ::testing::Field(&history::QueryOptions::host_only, false)));
- base::Value init_args(base::Value::Type::LIST);
+ base::Value::List init_args;
init_args.Append("query-history-callback-id");
init_args.Append("whost:ww.chromium.org");
init_args.Append(150);
- handler.HandleQueryHistory(&base::Value::AsListValue(init_args));
+ handler.HandleQueryHistory(init_args);
}
{
@@ -349,11 +349,11 @@ TEST_F(BrowsingHistoryHandlerTest, MisplacedHostPrefixParameter) {
QueryHistory(
query, ::testing::Field(&history::QueryOptions::host_only, false)));
- base::Value init_args(base::Value::Type::LIST);
+ base::Value::List init_args;
init_args.Append("query-history-callback-id");
init_args.Append("www.chromium.orghost:");
init_args.Append(150);
- handler.HandleQueryHistory(&base::Value::AsListValue(init_args));
+ handler.HandleQueryHistory(init_args);
}
}
diff --git a/chromium/chrome/browser/ui/webui/history/foreign_session_handler.cc b/chromium/chrome/browser/ui/webui/history/foreign_session_handler.cc
index 2381f537d25..c4c1da497b7 100644
--- a/chromium/chrome/browser/ui/webui/history/foreign_session_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/foreign_session_handler.cc
@@ -70,9 +70,10 @@ std::string DeviceTypeToString(sync_pb::SyncEnums::DeviceType device_type) {
}
// Helper method to create JSON compatible objects from Session objects.
-base::Value SessionTabToValue(const ::sessions::SessionTab& tab) {
+absl::optional<base::Value::Dict> SessionTabToValue(
+ const ::sessions::SessionTab& tab) {
if (tab.navigations.empty())
- return base::Value();
+ return absl::nullopt;
int selected_index = std::min(tab.current_navigation_index,
static_cast<int>(tab.navigations.size() - 1));
@@ -80,7 +81,7 @@ base::Value SessionTabToValue(const ::sessions::SessionTab& tab) {
tab.navigations.at(selected_index);
GURL tab_url = current_navigation.virtual_url();
if (!tab_url.is_valid() || tab_url.spec() == chrome::kChromeUINewTabURL)
- return base::Value();
+ return absl::nullopt;
base::Value::Dict dictionary;
NewTabUI::SetUrlTitleAndDirection(&dictionary, current_navigation.title(),
@@ -94,42 +95,46 @@ base::Value SessionTabToValue(const ::sessions::SessionTab& tab) {
// confusion with the ID corresponding to a session. Investigate all the
// places (C++ and JS) where this is being used. (http://crbug.com/154865).
dictionary.Set("sessionId", tab.tab_id.id());
- return base::Value(std::move(dictionary));
+ return dictionary;
}
// Helper for initializing a boilerplate SessionWindow JSON compatible object.
-base::Value BuildWindowData(base::Time modification_time, SessionID window_id) {
- base::Value dictionary(base::Value::Type::DICTIONARY);
+base::Value::Dict BuildWindowData(base::Time modification_time,
+ SessionID window_id) {
+ base::Value::Dict dictionary;
// The items which are to be written into |dictionary| are also described in
// chrome/browser/resources/ntp4/other_sessions.js in @typedef for WindowData.
// Please update it whenever you add or remove any keys here.
- dictionary.SetStringKey("type", "window");
- dictionary.SetDoubleKey("timestamp", modification_time.ToInternalValue());
+ dictionary.Set("type", "window");
+ dictionary.Set("timestamp",
+ static_cast<double>(modification_time.ToInternalValue()));
- dictionary.SetIntKey("sessionId", window_id.id());
+ dictionary.Set("sessionId", window_id.id());
return dictionary;
}
// Helper method to create JSON compatible objects from SessionWindow objects.
-base::Value SessionWindowToValue(const ::sessions::SessionWindow& window) {
+absl::optional<base::Value::Dict> SessionWindowToValue(
+ const ::sessions::SessionWindow& window) {
if (window.tabs.empty())
- return base::Value();
+ return absl::nullopt;
- base::Value tab_values(base::Value::Type::LIST);
+ base::Value::List tab_values;
// Calculate the last |modification_time| for all entries within a window.
base::Time modification_time = window.timestamp;
for (const std::unique_ptr<sessions::SessionTab>& tab : window.tabs) {
- base::Value tab_value = SessionTabToValue(*tab.get());
- if (!tab_value.is_none()) {
+ auto tab_value = SessionTabToValue(*tab.get());
+ if (tab_value.has_value()) {
modification_time = std::max(modification_time, tab->timestamp);
- tab_values.Append(std::move(tab_value));
+ tab_values.Append(std::move(*tab_value));
}
}
- if (tab_values.GetListDeprecated().empty())
- return base::Value();
+ if (tab_values.empty())
+ return absl::nullopt;
- base::Value dictionary = BuildWindowData(window.timestamp, window.window_id);
- dictionary.SetKey("tabs", std::move(tab_values));
+ base::Value::Dict dictionary =
+ BuildWindowData(window.timestamp, window.window_id);
+ dictionary.Set("tabs", std::move(tab_values));
return dictionary;
}
@@ -221,19 +226,19 @@ sync_sessions::OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate(
}
void ForeignSessionHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"deleteForeignSession",
base::BindRepeating(&ForeignSessionHandler::HandleDeleteForeignSession,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getForeignSessions",
base::BindRepeating(&ForeignSessionHandler::HandleGetForeignSessions,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"openForeignSession",
base::BindRepeating(&ForeignSessionHandler::HandleOpenForeignSession,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setForeignSessionCollapsed",
base::BindRepeating(
&ForeignSessionHandler::HandleSetForeignSessionCollapsed,
@@ -242,7 +247,7 @@ void ForeignSessionHandler::RegisterMessages() {
void ForeignSessionHandler::OnJavascriptAllowed() {
// This can happen if the page is refreshed.
- if (initial_session_list_.is_none())
+ if (!initial_session_list_)
initial_session_list_ = GetForeignSessions();
Profile* profile = Profile::FromWebUI(web_ui());
@@ -288,67 +293,67 @@ std::u16string ForeignSessionHandler::FormatSessionTime(
}
void ForeignSessionHandler::HandleGetForeignSessions(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK(!initial_session_list_.is_none());
- const base::Value& callback_id = args->GetListDeprecated()[0];
- ResolveJavascriptCallback(callback_id, std::move(initial_session_list_));
+ CHECK(initial_session_list_);
+ const base::Value& callback_id = args[0];
+ ResolveJavascriptCallback(callback_id, *initial_session_list_);
// Clear the initial list so that it will be reset in AllowJavascript if the
// page is refreshed.
- initial_session_list_ = base::Value(base::Value::Type::NONE);
+ initial_session_list_ = absl::nullopt;
}
-base::Value ForeignSessionHandler::GetForeignSessions() {
+base::Value::List ForeignSessionHandler::GetForeignSessions() {
sync_sessions::OpenTabsUIDelegate* open_tabs =
GetOpenTabsUIDelegate(web_ui());
std::vector<const sync_sessions::SyncedSession*> sessions;
- base::Value session_list(base::Value::Type::LIST);
+ base::Value::List session_list;
if (open_tabs && open_tabs->GetAllForeignSessions(&sessions)) {
// Use a pref to keep track of sessions that were collapsed by the user.
// To prevent the pref from accumulating stale sessions, clear it each time
// and only add back sessions that are still current.
DictionaryPrefUpdate pref_update(Profile::FromWebUI(web_ui())->GetPrefs(),
prefs::kNtpCollapsedForeignSessions);
- base::Value* current_collapsed_sessions = pref_update.Get();
- base::Value collapsed_sessions = current_collapsed_sessions->Clone();
- current_collapsed_sessions->DictClear();
+ base::Value::Dict& current_collapsed_sessions =
+ pref_update.Get()->GetDict();
+ base::Value::Dict collapsed_sessions = current_collapsed_sessions.Clone();
+ current_collapsed_sessions.clear();
// Note: we don't own the SyncedSessions themselves.
for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) {
const sync_sessions::SyncedSession* session = sessions[i];
const std::string& session_tag = session->session_tag;
- base::Value session_data(base::Value::Type::DICTIONARY);
+ base::Value::Dict session_data;
// The items which are to be written into |session_data| are also
// described in chrome/browser/resources/history/externs.js
// @typedef for ForeignSession. Please update it whenever you add or
// remove any keys here.
- session_data.SetStringKey("tag", session_tag);
- session_data.SetStringKey("name", session->session_name);
- session_data.SetStringKey("deviceType",
- DeviceTypeToString(session->device_type));
- session_data.SetStringKey("modifiedTime",
- FormatSessionTime(session->modified_time));
- session_data.SetDoubleKey("timestamp", session->modified_time.ToJsTime());
-
- bool is_collapsed = collapsed_sessions.FindKey(session_tag);
- session_data.SetBoolKey("collapsed", is_collapsed);
+ session_data.Set("tag", session_tag);
+ session_data.Set("name", session->session_name);
+ session_data.Set("deviceType", DeviceTypeToString(session->device_type));
+ session_data.Set("modifiedTime",
+ FormatSessionTime(session->modified_time));
+ session_data.Set("timestamp", session->modified_time.ToJsTime());
+
+ bool is_collapsed = collapsed_sessions.Find(session_tag);
+ session_data.Set("collapsed", is_collapsed);
if (is_collapsed)
- current_collapsed_sessions->SetBoolKey(session_tag, true);
+ current_collapsed_sessions.Set(session_tag, true);
- base::Value window_list(base::Value::Type::LIST);
+ base::Value::List window_list;
// Order tabs by visual order within window.
for (const auto& window_pair : session->windows) {
- base::Value window_data =
+ auto window_data =
SessionWindowToValue(window_pair.second->wrapped_window);
- if (!window_data.is_none()) {
- window_list.Append(std::move(window_data));
+ if (window_data.has_value()) {
+ window_list.Append(std::move(*window_data));
}
}
- session_data.SetKey("windows", std::move(window_list));
+ session_data.Set("windows", std::move(window_list));
session_list.Append(std::move(session_data));
}
}
@@ -356,33 +361,30 @@ base::Value ForeignSessionHandler::GetForeignSessions() {
}
void ForeignSessionHandler::HandleOpenForeignSession(
- const base::ListValue* args) {
- size_t num_args = args->GetListDeprecated().size();
+ const base::Value::List& args) {
+ size_t num_args = args.size();
// Expect either 1 or 8 args. For restoring an entire session, only
// one argument is required -- the session tag. To restore a tab,
// the additional args required are the window id, the tab id,
// and 4 properties of the event object (button, altKey, ctrlKey,
// metaKey, shiftKey) for determining how to open the tab.
if (num_args != 8U && num_args != 1U) {
- LOG(ERROR) << "openForeignSession called with "
- << args->GetListDeprecated().size() << " arguments.";
+ LOG(ERROR) << "openForeignSession called with " << args.size()
+ << " arguments.";
return;
}
// Extract the session tag (always provided).
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
LOG(ERROR) << "Failed to extract session tag.";
return;
}
- const std::string& session_string_value =
- args->GetListDeprecated()[0].GetString();
+ const std::string& session_string_value = args[0].GetString();
// Extract window number.
int window_num = -1;
- if (num_args >= 2 &&
- (!args->GetListDeprecated()[1].is_string() ||
- !base::StringToInt(args->GetListDeprecated()[1].GetString(),
- &window_num))) {
+ if (num_args >= 2 && (!args[1].is_string() ||
+ !base::StringToInt(args[1].GetString(), &window_num))) {
LOG(ERROR) << "Failed to extract window number.";
return;
}
@@ -390,9 +392,8 @@ void ForeignSessionHandler::HandleOpenForeignSession(
// Extract tab id.
SessionID::id_type tab_id_value = 0;
if (num_args >= 3 &&
- (!args->GetListDeprecated()[2].is_string() ||
- !base::StringToInt(args->GetListDeprecated()[2].GetString(),
- &tab_id_value))) {
+ (!args[2].is_string() ||
+ !base::StringToInt(args[2].GetString(), &tab_id_value))) {
LOG(ERROR) << "Failed to extract tab SessionID.";
return;
}
@@ -408,18 +409,18 @@ void ForeignSessionHandler::HandleOpenForeignSession(
}
void ForeignSessionHandler::HandleDeleteForeignSession(
- const base::ListValue* args) {
- if (args->GetListDeprecated().size() != 1U) {
+ const base::Value::List& args) {
+ if (args.size() != 1U) {
LOG(ERROR) << "Wrong number of args to deleteForeignSession";
return;
}
// Get the session tag argument (required).
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
LOG(ERROR) << "Unable to extract session tag";
return;
}
- const std::string& session_tag = args->GetListDeprecated()[0].GetString();
+ const std::string& session_tag = args[0].GetString();
sync_sessions::OpenTabsUIDelegate* open_tabs =
GetOpenTabsUIDelegate(web_ui());
@@ -428,34 +429,33 @@ void ForeignSessionHandler::HandleDeleteForeignSession(
}
void ForeignSessionHandler::HandleSetForeignSessionCollapsed(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
- if (list.size() != 2U) {
+ const base::Value::List& args) {
+ if (args.size() != 2U) {
LOG(ERROR) << "Wrong number of args to setForeignSessionCollapsed";
return;
}
// Get the session tag argument (required).
- if (!args->GetListDeprecated()[0].is_string()) {
+ if (!args[0].is_string()) {
LOG(ERROR) << "Unable to extract session tag";
return;
}
- const std::string& session_tag = args->GetListDeprecated()[0].GetString();
+ const std::string& session_tag = args[0].GetString();
- if (!list[1].is_bool()) {
+ if (!args[1].is_bool()) {
LOG(ERROR) << "Unable to extract boolean argument";
return;
}
- const bool is_collapsed = list[1].GetBool();
+ const bool is_collapsed = args[1].GetBool();
// Store session tags for collapsed sessions in a preference so that the
// collapsed state persists.
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions);
if (is_collapsed)
- update.Get()->SetBoolKey(session_tag, true);
+ update.Get()->GetDict().Set(session_tag, true);
else
- update.Get()->RemoveKey(session_tag);
+ update.Get()->GetDict().Remove(session_tag);
}
} // namespace browser_sync
diff --git a/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h b/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h
index b4659c32f21..4c4b0454e22 100644
--- a/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h
@@ -82,7 +82,7 @@ class ForeignSessionHandler : public content::WebUIMessageHandler {
private:
void OnForeignSessionUpdated();
- base::Value GetForeignSessions();
+ base::Value::List GetForeignSessions();
// Returns a string used to show the user when a session was last modified.
std::u16string FormatSessionTime(const base::Time& time);
@@ -90,22 +90,22 @@ class ForeignSessionHandler : public content::WebUIMessageHandler {
// Determines which session is to be opened, and then calls
// OpenForeignSession, to begin the process of opening a new browser window.
// This is a javascript callback handler.
- void HandleOpenForeignSession(const base::ListValue* args);
+ void HandleOpenForeignSession(const base::Value::List& args);
// Determines whether foreign sessions should be obtained from the sync model.
// This is a javascript callback handler, and it is also called when the sync
// model has changed and the new tab page needs to reflect the changes.
- void HandleGetForeignSessions(const base::ListValue* args);
+ void HandleGetForeignSessions(const base::Value::List& args);
// Delete a foreign session. This will remove it from the list of foreign
// sessions on all devices. It will reappear if the session is re-activated
// on the original device.
// This is a javascript callback handler.
- void HandleDeleteForeignSession(const base::ListValue* args);
+ void HandleDeleteForeignSession(const base::Value::List& args);
- void HandleSetForeignSessionCollapsed(const base::ListValue* args);
+ void HandleSetForeignSessionCollapsed(const base::Value::List& args);
- base::Value initial_session_list_;
+ absl::optional<base::Value::List> initial_session_list_;
base::CallbackListSubscription foreign_session_updated_subscription_;
};
diff --git a/chromium/chrome/browser/ui/webui/history/history_login_handler.cc b/chromium/chrome/browser/ui/webui/history/history_login_handler.cc
index 6c0f9104e55..db059542e23 100644
--- a/chromium/chrome/browser/ui/webui/history/history_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/history_login_handler.cc
@@ -25,14 +25,14 @@ HistoryLoginHandler::HistoryLoginHandler(base::RepeatingClosure signin_callback)
HistoryLoginHandler::~HistoryLoginHandler() {}
void HistoryLoginHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"otherDevicesInitialized",
base::BindRepeating(&HistoryLoginHandler::HandleOtherDevicesInitialized,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
- "startSignInFlow",
- base::BindRepeating(&HistoryLoginHandler::HandleStartSignInFlow,
+ web_ui()->RegisterMessageCallback(
+ "startTurnOnSyncFlow",
+ base::BindRepeating(&HistoryLoginHandler::HandleTurnOnSyncFlow,
base::Unretained(this)));
}
@@ -49,7 +49,7 @@ void HistoryLoginHandler::OnJavascriptDisallowed() {
}
void HistoryLoginHandler::HandleOtherDevicesInitialized(
- const base::ListValue* /*args*/) {
+ const base::Value::List& /*args*/) {
AllowJavascript();
}
@@ -61,8 +61,8 @@ void HistoryLoginHandler::ProfileInfoChanged() {
FireWebUIListener("sign-in-state-changed", base::Value(signed_in));
}
-void HistoryLoginHandler::HandleStartSignInFlow(
- const base::ListValue* /*args*/) {
+void HistoryLoginHandler::HandleTurnOnSyncFlow(
+ const base::Value::List& /*args*/) {
Profile* profile = Profile::FromWebUI(web_ui());
signin_ui_util::EnableSyncFromSingleAccountPromo(
profile,
diff --git a/chromium/chrome/browser/ui/webui/history/history_login_handler.h b/chromium/chrome/browser/ui/webui/history/history_login_handler.h
index f45782cf0aa..ec1f2458d66 100644
--- a/chromium/chrome/browser/ui/webui/history/history_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/history_login_handler.h
@@ -29,10 +29,10 @@ class HistoryLoginHandler : public content::WebUIMessageHandler {
private:
// Handler for the "otherDevicesInitialized" message. No args.
- void HandleOtherDevicesInitialized(const base::ListValue* args);
+ void HandleOtherDevicesInitialized(const base::Value::List& args);
- // Handler for the "startSignInFlow" message. No args.
- void HandleStartSignInFlow(const base::ListValue* args);
+ // Handler for the "startTurnOnSyncFlow" message. No args.
+ void HandleTurnOnSyncFlow(const base::Value::List& args);
// Called by |profile_info_watcher_| on desktop if profile info changes.
void ProfileInfoChanged();
diff --git a/chromium/chrome/browser/ui/webui/history/history_ui.cc b/chromium/chrome/browser/ui/webui/history/history_ui.cc
index 983eb8545e8..8f17a4a1123 100644
--- a/chromium/chrome/browser/ui/webui/history/history_ui.cc
+++ b/chromium/chrome/browser/ui/webui/history/history_ui.cc
@@ -99,9 +99,9 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
{"searchPrompt", IDS_HISTORY_SEARCH_PROMPT},
{"searchResult", IDS_HISTORY_SEARCH_RESULT},
{"searchResults", IDS_HISTORY_SEARCH_RESULTS},
- {"signInButton", IDS_HISTORY_SIGN_IN_BUTTON},
- {"signInPromo", IDS_HISTORY_SIGN_IN_PROMO},
- {"signInPromoDesc", IDS_HISTORY_SIGN_IN_PROMO_DESC},
+ {"turnOnSyncButton", IDS_HISTORY_TURN_ON_SYNC_BUTTON},
+ {"turnOnSyncPromo", IDS_HISTORY_TURN_ON_SYNC_PROMO},
+ {"turnOnSyncPromoDesc", IDS_HISTORY_TURN_ON_SYNC_PROMO_DESC},
{"title", IDS_HISTORY_TITLE},
};
source->AddLocalizedStrings(kStrings);
@@ -125,7 +125,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile));
// History clusters
- HistoryClustersUtil::PopulateSource(source, profile);
+ HistoryClustersUtil::PopulateSource(source, profile, /*in_side_panel=*/false);
webui::SetupWebUIDataSource(
source, base::make_span(kHistoryResources, kHistoryResourcesSize),
diff --git a/chromium/chrome/browser/ui/webui/history/navigation_handler.cc b/chromium/chrome/browser/ui/webui/history/navigation_handler.cc
index 71337fe3fbe..643b9e7038d 100644
--- a/chromium/chrome/browser/ui/webui/history/navigation_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/navigation_handler.cc
@@ -19,14 +19,13 @@ NavigationHandler::NavigationHandler() {}
NavigationHandler::~NavigationHandler() {}
void NavigationHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"navigateToUrl",
base::BindRepeating(&NavigationHandler::HandleNavigateToUrl,
base::Unretained(this)));
}
-void NavigationHandler::HandleNavigateToUrl(const base::ListValue* args) {
- base::Value::ConstListView list = args->GetListDeprecated();
+void NavigationHandler::HandleNavigateToUrl(const base::Value::List& list) {
const std::string& url_string = list[0].GetString();
const std::string& target_string = list[1].GetString();
double button = list[2].GetDouble();
diff --git a/chromium/chrome/browser/ui/webui/history/navigation_handler.h b/chromium/chrome/browser/ui/webui/history/navigation_handler.h
index a1cd828bc35..643cb1012a6 100644
--- a/chromium/chrome/browser/ui/webui/history/navigation_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/navigation_handler.h
@@ -7,10 +7,6 @@
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-}
-
namespace webui {
// A place to add handlers for messages shared across all WebUI pages.
@@ -27,7 +23,7 @@ class NavigationHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void HandleNavigateToUrl(const base::ListValue* args);
+ void HandleNavigateToUrl(const base::Value::List& args);
};
} // namespace webui
diff --git a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc
index 1d5cb9b5e07..902d8df94fd 100644
--- a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc
@@ -15,6 +15,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history_clusters/history_clusters_metrics_logger.h"
#include "chrome/browser/history_clusters/history_clusters_service_factory.h"
@@ -23,6 +24,8 @@
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/hats/hats_service.h"
+#include "chrome/browser/ui/hats/hats_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h"
@@ -35,10 +38,15 @@
#include "components/prefs/pref_service.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/l10n/time_format.h"
+#include "ui/base/models/simple_menu_model.h"
+#include "ui/base/mojom/window_open_disposition.mojom.h"
+#include "ui/base/window_open_disposition.h"
#include "ui/webui/mojo_bubble_web_ui_controller.h"
#include "ui/webui/resources/cr_components/history_clusters/history_clusters.mojom.h"
#include "url/gurl.h"
@@ -47,6 +55,66 @@ namespace history_clusters {
namespace {
+class HistoryClustersSidePanelContextMenu
+ : public ui::SimpleMenuModel,
+ public ui::SimpleMenuModel::Delegate {
+ public:
+ HistoryClustersSidePanelContextMenu(Browser* browser, GURL url)
+ : ui::SimpleMenuModel(this), browser_(browser), url_(url) {
+ AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB,
+ IDS_HISTORY_CLUSTERS_OPEN_IN_NEW_TAB);
+ AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW,
+ IDS_HISTORY_CLUSTERS_OPEN_IN_NEW_WINDOW);
+ AddItemWithStringId(IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD,
+ IDS_HISTORY_CLUSTERS_OPEN_INCOGNITO);
+ AddSeparator(ui::NORMAL_SEPARATOR);
+
+ AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYLINKLOCATION,
+ IDS_HISTORY_CLUSTERS_COPY_LINK);
+ }
+ ~HistoryClustersSidePanelContextMenu() override = default;
+
+ void ExecuteCommand(int command_id, int event_flags) override {
+ switch (command_id) {
+ case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: {
+ content::OpenURLParams params(url_, content::Referrer(),
+ WindowOpenDisposition::NEW_BACKGROUND_TAB,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
+ browser_->OpenURL(params);
+ break;
+ }
+
+ case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: {
+ content::OpenURLParams params(url_, content::Referrer(),
+ WindowOpenDisposition::NEW_WINDOW,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
+ browser_->OpenURL(params);
+ break;
+ }
+
+ case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: {
+ content::OpenURLParams params(url_, content::Referrer(),
+ WindowOpenDisposition::OFF_THE_RECORD,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
+ browser_->OpenURL(params);
+ break;
+ }
+ case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: {
+ ui::ScopedClipboardWriter scw(ui::ClipboardBuffer::kCopyPaste);
+ scw.WriteText(base::UTF8ToUTF16(url_.spec()));
+ break;
+ }
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+
+ private:
+ const raw_ptr<Browser> browser_;
+ GURL url_;
+};
+
// Creates a `mojom::VisitPtr` from a `history_clusters::Visit`.
mojom::URLVisitPtr VisitToMojom(Profile* profile,
const history::ClusterVisit& visit) {
@@ -166,6 +234,10 @@ mojom::QueryResultPtr QueryClustersResultToMojom(
}
}
+ if (GetConfig().user_visible_debug && cluster.from_persistence) {
+ cluster_mojom->debug_info = "persisted";
+ }
+
for (const auto& visit : cluster.visits) {
cluster_mojom->visits.push_back(VisitToMojom(profile, visit));
}
@@ -220,6 +292,27 @@ void HistoryClustersHandler::SetSidePanelUIEmbedder(
history_clusters_side_panel_embedder_ = side_panel_embedder;
}
+void HistoryClustersHandler::OpenHistoryCluster(
+ const GURL& url,
+ ui::mojom::ClickModifiersPtr click_modifiers) {
+ Browser* browser = chrome::FindLastActive();
+ if (!browser)
+ return;
+
+ // Used to determine if default behavior should be open in current tab or new
+ // tab since it differs for side panel.
+ const bool in_side_panel = history_clusters_side_panel_embedder_ != nullptr;
+
+ WindowOpenDisposition open_location = ui::DispositionFromClick(
+ /*middle_button=*/!in_side_panel, click_modifiers->alt_key,
+ click_modifiers->ctrl_key, click_modifiers->meta_key,
+ click_modifiers->shift_key);
+ content::OpenURLParams params(url, content::Referrer(), open_location,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK,
+ /*is_renderer_initiated=*/false);
+ browser->OpenURL(params);
+}
+
void HistoryClustersHandler::SetPage(
mojo::PendingRemote<mojom::Page> pending_page) {
page_.Bind(std::move(pending_page));
@@ -238,7 +331,8 @@ void HistoryClustersHandler::ToggleVisibility(
std::move(callback).Run(visible);
}
-void HistoryClustersHandler::StartQueryClusters(const std::string& query) {
+void HistoryClustersHandler::StartQueryClusters(const std::string& query,
+ bool recluster) {
if (!query.empty()) {
// If the query string is not empty, we assume that this clusters query
// is user generated.
@@ -252,7 +346,7 @@ void HistoryClustersHandler::StartQueryClusters(const std::string& query) {
auto* history_clusters_service =
HistoryClustersServiceFactory::GetForBrowserContext(profile_);
query_clusters_state_ = std::make_unique<QueryClustersState>(
- history_clusters_service->GetWeakPtr(), query);
+ history_clusters_service->GetWeakPtr(), query, recluster);
LoadMoreClusters(query);
}
@@ -308,6 +402,11 @@ void HistoryClustersHandler::RemoveVisits(
void HistoryClustersHandler::OpenVisitUrlsInTabGroup(
std::vector<mojom::URLVisitPtr> visits) {
+ // Sometimes WebUI passes an empty vector, and TabStripModel::AddToNewGroup
+ // requires a non-empty vector (Fixes https://crbug.com/1339140)
+ if (visits.empty()) {
+ return;
+ }
const auto* browser = chrome::FindTabbedBrowser(profile_, false);
if (!browser) {
return;
@@ -379,6 +478,49 @@ Profile* HistoryClustersHandler::GetProfile() {
void HistoryClustersHandler::OnClustersQueryResult(
mojom::QueryResultPtr query_result) {
page_->OnClustersQueryResult(std::move(query_result));
+
+ // The user loading their first set of clusters should start the timer for
+ // launching the Journeys survey.
+ LaunchJourneysSurvey();
+}
+
+void HistoryClustersHandler::LaunchJourneysSurvey() {
+ // All the below is to attempt launch a survey, after loading the first set of
+ // clusters.
+ if (survey_launch_attempted_) {
+ return;
+ }
+ survey_launch_attempted_ = true;
+
+ HatsService* hats_service = HatsServiceFactory::GetForProfile(profile_, true);
+ if (!hats_service) {
+ return;
+ }
+
+ auto* logger =
+ history_clusters::HistoryClustersMetricsLogger::GetOrCreateForPage(
+ web_contents_->GetPrimaryPage());
+ auto initial_state = logger->initial_state();
+ if (!initial_state) {
+ return;
+ }
+
+ if (*initial_state ==
+ history_clusters::HistoryClustersInitialState::kSameDocument &&
+ base::FeatureList::IsEnabled(kJourneysSurveyForHistoryEntrypoint)) {
+ // Same document navigation basically means clicking over from History.
+ hats_service->LaunchDelayedSurveyForWebContents(
+ kHatsSurveyTriggerJourneysHistoryEntrypoint, web_contents_,
+ kJourneysSurveyForHistoryEntrypointDelay.Get().InMilliseconds());
+ } else if (*initial_state == history_clusters::HistoryClustersInitialState::
+ kIndirectNavigation &&
+ base::FeatureList::IsEnabled(
+ kJourneysSurveyForOmniboxEntrypoint)) {
+ // Indirect navigation basically means from the omnibox.
+ hats_service->LaunchDelayedSurveyForWebContents(
+ kHatsSurveyTriggerJourneysOmniboxEntrypoint, web_contents_,
+ kJourneysSurveyForOmniboxEntrypointDelay.Get().InMilliseconds());
+ }
}
void HistoryClustersHandler::RecordVisitAction(mojom::VisitAction visit_action,
@@ -414,4 +556,14 @@ void HistoryClustersHandler::RecordToggledVisibility(bool visible) {
->RecordToggledVisibility(visible);
}
+void HistoryClustersHandler::ShowContextMenuForURL(const GURL& url,
+ const gfx::Point& point) {
+ Browser* browser = chrome::FindLastActive();
+ if (history_clusters_side_panel_embedder_) {
+ history_clusters_side_panel_embedder_->ShowContextMenu(
+ point,
+ std::make_unique<HistoryClustersSidePanelContextMenu>(browser, url));
+ }
+}
+
} // namespace history_clusters
diff --git a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h
index 796da584a39..657aa28a412 100644
--- a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h
+++ b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h
@@ -64,11 +64,14 @@ class HistoryClustersHandler : public mojom::PageHandler,
side_panel_embedder);
// mojom::PageHandler:
+ void OpenHistoryCluster(
+ const GURL& url,
+ ui::mojom::ClickModifiersPtr click_modifiers) override;
void SetPage(mojo::PendingRemote<mojom::Page> pending_page) override;
void ShowSidePanelUI() override;
void ToggleVisibility(bool visible,
ToggleVisibilityCallback callback) override;
- void StartQueryClusters(const std::string& query) override;
+ void StartQueryClusters(const std::string& query, bool recluster) override;
void LoadMoreClusters(const std::string& query) override;
void RemoveVisits(std::vector<mojom::URLVisitPtr> visits,
RemoveVisitsCallback callback) override;
@@ -81,6 +84,7 @@ class HistoryClustersHandler : public mojom::PageHandler,
void RecordClusterAction(mojom::ClusterAction cluster_action,
uint32_t cluster_index) override;
void RecordToggledVisibility(bool visible) override;
+ void ShowContextMenuForURL(const GURL& url, const gfx::Point& point) override;
// HistoryClustersService::Observer:
void OnDebugMessage(const std::string& message) override;
@@ -96,6 +100,9 @@ class HistoryClustersHandler : public mojom::PageHandler,
// is sent to the JS to update the UI.
void OnClustersQueryResult(mojom::QueryResultPtr query_result);
+ // Launches the Journeys survey, if user is eligible.
+ void LaunchJourneysSurvey();
+
base::WeakPtr<ui::MojoBubbleWebUIController::Embedder>
history_clusters_side_panel_embedder_;
@@ -124,6 +131,11 @@ class HistoryClustersHandler : public mojom::PageHandler,
std::vector<mojom::URLVisitPtr> pending_remove_visits_;
RemoveVisitsCallback pending_remove_visits_callback_;
+ // Flag used to launch survey once (at most) for each WebUI instance. The
+ // survey service itself has a limiter, but we also want to skip all the work
+ // to enqueue the request, so we have a separate flag here too.
+ bool survey_launch_attempted_ = false;
+
base::WeakPtrFactory<HistoryClustersHandler> weak_ptr_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler_browsertest.cc
index 07f18219bec..e7f81015614 100644
--- a/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/history_clusters/history_clusters_handler_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/history_clusters/history_clusters_metrics_logger.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/webui/history/history_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -76,8 +77,15 @@ IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
tab_strip_model->GetWebContentsAt(2)->GetVisibleURL());
}
+// TODO(https://crbug.com/1335515): Flaky.
+#if BUILDFLAG(IS_WIN)
+#define MAYBE_OpenVisitUrlsInTabGroupHardCap \
+ DISABLED_OpenVisitUrlsInTabGroupHardCap
+#else
+#define MAYBE_OpenVisitUrlsInTabGroupHardCap OpenVisitUrlsInTabGroupHardCap
+#endif
IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
- OpenVisitUrlsInTabGroupHardCap) {
+ MAYBE_OpenVisitUrlsInTabGroupHardCap) {
auto* tab_strip_model = browser()->tab_strip_model();
ASSERT_EQ(1, tab_strip_model->GetTabCount());
@@ -116,7 +124,7 @@ IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
content::WebContentsDestroyedWatcher destroyed_watcher(
tab_strip_model->GetWebContentsAt(0));
- tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_USER_GESTURE);
+ tab_strip_model->CloseWebContentsAt(0, TabCloseTypes::CLOSE_USER_GESTURE);
destroyed_watcher.Wait();
histogram_tester.ExpectUniqueSample(
@@ -144,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
content::WebContentsDestroyedWatcher destroyed_watcher(
tab_strip_model->GetWebContentsAt(0));
- tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_USER_GESTURE);
+ tab_strip_model->CloseWebContentsAt(0, TabCloseTypes::CLOSE_USER_GESTURE);
destroyed_watcher.Wait();
histogram_tester.ExpectUniqueSample(
@@ -166,7 +174,7 @@ IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
content::WebContentsDestroyedWatcher destroyed_watcher(
tab_strip_model->GetWebContentsAt(0));
- tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_USER_GESTURE);
+ tab_strip_model->CloseWebContentsAt(0, TabCloseTypes::CLOSE_USER_GESTURE);
destroyed_watcher.Wait();
histogram_tester.ExpectUniqueSample(
@@ -188,7 +196,7 @@ IN_PROC_BROWSER_TEST_F(HistoryClustersHandlerBrowserTest,
content::WebContentsDestroyedWatcher destroyed_watcher(
tab_strip_model->GetWebContentsAt(0));
- tab_strip_model->CloseWebContentsAt(0, TabStripModel::CLOSE_USER_GESTURE);
+ tab_strip_model->CloseWebContentsAt(0, TabCloseTypes::CLOSE_USER_GESTURE);
destroyed_watcher.Wait();
histogram_tester.ExpectUniqueSample(
diff --git a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
index 7dbf63013be..f96b416387c 100644
--- a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
@@ -79,12 +79,12 @@ class IdentityInternalsUIMessageHandler : public content::WebUIMessageHandler {
// Gets all of the tokens stored in IdentityAPI token cache and returns them
// to the caller using Javascript callback function
// |identity_internals.returnTokens()|.
- void GetInfoForAllTokens(const base::ListValue* args);
+ void GetInfoForAllTokens(const base::Value::List& args);
// Initiates revoking of the token, based on the extension ID and token
// passed as entries in the |args| list. Updates the caller of completion
// using Javascript callback function |identity_internals.tokenRevokeDone()|.
- void RevokeToken(const base::ListValue* args);
+ void RevokeToken(const base::Value::List& args);
// A vector of token revokers that are currently revoking tokens.
std::vector<std::unique_ptr<IdentityInternalsTokenRevoker>> token_revokers_;
@@ -225,8 +225,8 @@ base::Value::Dict IdentityInternalsUIMessageHandler::GetInfoForToken(
}
void IdentityInternalsUIMessageHandler::GetInfoForAllTokens(
- const base::ListValue* args) {
- const std::string& callback_id = args->GetListDeprecated()[0].GetString();
+ const base::Value::List& args) {
+ const std::string& callback_id = args[0].GetString();
CHECK(!callback_id.empty());
AllowJavascript();
@@ -243,37 +243,33 @@ void IdentityInternalsUIMessageHandler::GetInfoForAllTokens(
results.Append(GetInfoForToken(key_tokens.first, token));
}
}
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(results)));
+ ResolveJavascriptCallback(base::Value(callback_id), results);
}
void IdentityInternalsUIMessageHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"identityInternalsGetTokens",
base::BindRepeating(
&IdentityInternalsUIMessageHandler::GetInfoForAllTokens,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"identityInternalsRevokeToken",
base::BindRepeating(&IdentityInternalsUIMessageHandler::RevokeToken,
base::Unretained(this)));
}
void IdentityInternalsUIMessageHandler::RevokeToken(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
const std::string& callback_id = list[0].GetString();
CHECK(!callback_id.empty());
std::string extension_id;
std::string access_token;
if (!list.empty() && list[kRevokeTokenExtensionOffset].is_string()) {
- extension_id =
- args->GetListDeprecated()[kRevokeTokenExtensionOffset].GetString();
+ extension_id = list[kRevokeTokenExtensionOffset].GetString();
}
if (list.size() > kRevokeTokenTokenOffset &&
list[kRevokeTokenTokenOffset].is_string()) {
- access_token =
- args->GetListDeprecated()[kRevokeTokenTokenOffset].GetString();
+ access_token = list[kRevokeTokenTokenOffset].GetString();
}
token_revokers_.push_back(std::make_unique<IdentityInternalsTokenRevoker>(
diff --git a/chromium/chrome/browser/ui/webui/image_editor/image_editor_ui.cc b/chromium/chrome/browser/ui/webui/image_editor/image_editor_ui.cc
index 2236b1cdba4..8ca6af2ebe7 100644
--- a/chromium/chrome/browser/ui/webui/image_editor/image_editor_ui.cc
+++ b/chromium/chrome/browser/ui/webui/image_editor/image_editor_ui.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/webui/image_editor/image_editor_ui.h"
-#include "base/files/file_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
@@ -15,7 +14,6 @@
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/url_constants.h"
-#include "ui/webui/webui_allowlist.h"
namespace image_editor {
diff --git a/chromium/chrome/browser/ui/webui/internals/internals_ui.cc b/chromium/chrome/browser/ui/webui/internals/internals_ui.cc
index 287a16ef75a..90e4b7e9164 100644
--- a/chromium/chrome/browser/ui/webui/internals/internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/internals/internals_ui.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/internals/internals_ui.h"
+#include <vector>
+
#include "build/build_config.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/dev_ui_browser_resources.h"
@@ -18,8 +20,10 @@
#include "chrome/browser/ui/webui/internals/notifications/notifications_internals_ui_message_handler.h"
#include "chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h"
#else
+#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
+#include "ui/base/interaction/element_identifier.h"
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
@@ -52,7 +56,12 @@ void HandleWebUIRequestCallback(
} // namespace
InternalsUI::InternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) {
+ : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true)
+#if !BUILDFLAG(IS_ANDROID)
+ ,
+ help_bubble_handler_factory_receiver_(this)
+#endif
+{
profile_ = Profile::FromWebUI(web_ui);
source_ = content::WebUIDataSource::Create(chrome::kChromeUIInternalsHost);
source_->AddResourcePaths(
@@ -116,7 +125,9 @@ void InternalsUI::AddQueryTilesInternals(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<QueryTilesInternalsUIMessageHandler>(profile_));
}
+
#else // BUILDFLAG(IS_ANDROID)
+
void InternalsUI::BindInterface(
mojo::PendingReceiver<
mojom::user_education_internals::UserEducationInternalsPageHandler>
@@ -125,6 +136,25 @@ void InternalsUI::BindInterface(
std::make_unique<UserEducationInternalsPageHandlerImpl>(
web_ui(), profile_, std::move(receiver));
}
+
+void InternalsUI::BindInterface(
+ mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandlerFactory>
+ pending_receiver) {
+ if (help_bubble_handler_factory_receiver_.is_bound())
+ help_bubble_handler_factory_receiver_.reset();
+ help_bubble_handler_factory_receiver_.Bind(std::move(pending_receiver));
+}
+
+void InternalsUI::CreateHelpBubbleHandler(
+ mojo::PendingRemote<help_bubble::mojom::HelpBubbleClient> pending_client,
+ mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandler>
+ pending_handler) {
+ help_bubble_handler_ = std::make_unique<user_education::HelpBubbleHandler>(
+ std::move(pending_handler), std::move(pending_client),
+ web_ui()->GetWebContents(),
+ std::vector<ui::ElementIdentifier>{kWebUIIPHDemoElementIdentifier});
+}
+
#endif // BUILDFLAG(IS_ANDROID)
WEB_UI_CONTROLLER_TYPE_IMPL(InternalsUI)
diff --git a/chromium/chrome/browser/ui/webui/internals/internals_ui.h b/chromium/chrome/browser/ui/webui/internals/internals_ui.h
index e065282f586..50c5b0e1d8e 100644
--- a/chromium/chrome/browser/ui/webui/internals/internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/internals/internals_ui.h
@@ -15,6 +15,8 @@
// gn check doesn't understand "#if !BUILDFLAG(IS_ANDROID)" and fails this
// non-Android include on Android.
#include "chrome/browser/ui/webui/internals/user_education/user_education_internals.mojom.h" // nogncheck
+#include "components/user_education/webui/help_bubble_handler.h"
+#include "ui/webui/resources/cr_components/help_bubble/help_bubble.mojom.h"
#endif
namespace content {
@@ -23,7 +25,12 @@ class WebUI;
// Client could put debug WebUI as sub-URL under chrome://internals/.
// e.g. chrome://internals/your-feature.
-class InternalsUI : public ui::MojoWebUIController {
+class InternalsUI : public ui::MojoWebUIController
+#if !BUILDFLAG(IS_ANDROID)
+ ,
+ public help_bubble::mojom::HelpBubbleHandlerFactory
+#endif // !BUILDFLAG(IS_ANDROID)
+{
public:
explicit InternalsUI(content::WebUI* web_ui);
~InternalsUI() override;
@@ -33,6 +40,18 @@ class InternalsUI : public ui::MojoWebUIController {
mojo::PendingReceiver<
mojom::user_education_internals::UserEducationInternalsPageHandler>
receiver);
+
+ // The HelpBubbleHandlerFactory provides support for help bubbles in this
+ // WebUI. Also see CreateHelpBubbleHandler() below.
+ void BindInterface(
+ mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandlerFactory>
+ pending_receiver);
+
+ // help_bubble::mojom::HelpBubbleHandlerFactory:
+ void CreateHelpBubbleHandler(
+ mojo::PendingRemote<help_bubble::mojom::HelpBubbleClient> pending_client,
+ mojo::PendingReceiver<help_bubble::mojom::HelpBubbleHandler>
+ pending_handler) override;
#endif // !BUILDFLAG(IS_ANDROID)
private:
@@ -53,6 +72,10 @@ class InternalsUI : public ui::MojoWebUIController {
std::unique_ptr<
mojom::user_education_internals::UserEducationInternalsPageHandler>
user_education_handler_;
+
+ std::unique_ptr<user_education::HelpBubbleHandler> help_bubble_handler_;
+ mojo::Receiver<help_bubble::mojom::HelpBubbleHandlerFactory>
+ help_bubble_handler_factory_receiver_;
#endif // !BUILDFLAG(IS_ANDROID)
};
diff --git a/chromium/chrome/browser/ui/webui/internals/lens/lens_internals_ui_message_handler.cc b/chromium/chrome/browser/ui/webui/internals/lens/lens_internals_ui_message_handler.cc
index cdeb3277bbf..56162e29e39 100644
--- a/chromium/chrome/browser/ui/webui/internals/lens/lens_internals_ui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/internals/lens/lens_internals_ui_message_handler.cc
@@ -61,20 +61,18 @@ void LensInternalsUIMessageHandler::HandleRefreshDebugData(
base::android::Java2dStringArrayTo2dStringVector(env, j_debug_data,
&debug_data);
- std::vector<base::Value> debug_data_as_vector_of_values;
+ base::Value::List debug_data_as_vector_of_values;
for (auto const& row : debug_data) {
- std::vector<base::Value> row_as_list_storage;
+ base::Value::List row_as_list_storage;
// Convert to base::Value array.
for (std::u16string const& cell_string : row) {
- row_as_list_storage.emplace_back(base::Value(cell_string));
+ row_as_list_storage.Append(cell_string);
}
- debug_data_as_vector_of_values.emplace_back(
- base::Value(row_as_list_storage));
+ debug_data_as_vector_of_values.Append(std::move(row_as_list_storage));
}
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id,
- base::Value(debug_data_as_vector_of_values));
+ ResolveJavascriptCallback(callback_id, debug_data_as_vector_of_values);
}
void LensInternalsUIMessageHandler::HandleStopDebugMode(
diff --git a/chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h b/chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h
index 038c2b7126a..a860aea267e 100644
--- a/chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h
+++ b/chromium/chrome/browser/ui/webui/internals/user_education/user_education_internals_page_handler_impl.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_INTERNALS_USER_EDUCATION_USER_EDUCATION_INTERNALS_PAGE_HANDLER_IMPL_H_
#define CHROME_BROWSER_UI_WEBUI_INTERNALS_USER_EDUCATION_USER_EDUCATION_INTERNALS_PAGE_HANDLER_IMPL_H_
+#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/internals/user_education/user_education_internals.mojom.h"
@@ -13,10 +14,6 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
-namespace base {
-struct Feature;
-} // namespace base
-
namespace content {
class WebUI;
} // namespace content
diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index 30c8daae625..fce8b09d115 100644
--- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -35,7 +35,6 @@
#include "components/security_interstitials/content/https_only_mode_blocking_page.h"
#include "components/security_interstitials/content/insecure_form_blocking_page.h"
#include "components/security_interstitials/content/mitm_software_blocking_page.h"
-#include "components/security_interstitials/content/origin_policy_ui.h"
#include "components/security_interstitials/content/security_interstitial_page.h"
#include "components/security_interstitials/content/unsafe_resource_util.h"
#include "components/security_interstitials/core/ssl_error_options_mask.h"
@@ -55,7 +54,6 @@
#include "net/cert/x509_util.h"
#include "net/ssl/ssl_info.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
-#include "services/network/public/cpp/origin_policy.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
@@ -105,7 +103,7 @@ class InterstitialHTMLSource : public content::URLDataSource {
~InterstitialHTMLSource() override = default;
// content::URLDataSource:
- std::string GetMimeType(const std::string& mime_type) override;
+ std::string GetMimeType(const GURL& url) override;
std::string GetSource() override;
std::string GetContentSecurityPolicy(
const network::mojom::CSPDirectiveName directive) override;
@@ -432,14 +430,6 @@ std::unique_ptr<CaptivePortalBlockingPage> CreateCaptivePortalBlockingPage(
}
#endif
-std::unique_ptr<security_interstitials::SecurityInterstitialPage>
-CreateOriginPolicyInterstitialPage(content::WebContents* web_contents) {
- return base::WrapUnique<security_interstitials::SecurityInterstitialPage>(
- security_interstitials::OriginPolicyUI::GetBlockingPage(
- network::OriginPolicyState::kCannotLoadPolicy, web_contents,
- GURL("https://example.com/broken/origin/policy")));
-}
-
} // namespace
InterstitialUI::InterstitialUI(content::WebUI* web_ui)
@@ -452,7 +442,7 @@ InterstitialUI::~InterstitialUI() = default;
// InterstitialHTMLSource
-std::string InterstitialHTMLSource::GetMimeType(const std::string& mime_type) {
+std::string InterstitialHTMLSource::GetMimeType(const GURL&) {
return "text/html";
}
@@ -512,8 +502,6 @@ void InterstitialHTMLSource::StartDataRequest(
} else if (path_without_query == "/captiveportal") {
interstitial_delegate = CreateCaptivePortalBlockingPage(web_contents);
#endif
- } else if (path_without_query == "/origin_policy") {
- interstitial_delegate = CreateOriginPolicyInterstitialPage(web_contents);
} else if (path_without_query == "/insecure_form") {
interstitial_delegate = CreateInsecureFormPage(web_contents);
} else if (path_without_query == "/https_only") {
diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
index a77b44b8f65..4e6fc0884b9 100644
--- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
@@ -179,12 +179,6 @@ IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitialWifi) {
"Connect to Wi-Fi");
}
-IN_PROC_BROWSER_TEST_F(InterstitialUITest, OriginPolicyErrorInterstitial) {
- TestInterstitial(GURL("chrome://interstitials/origin_policy"),
- "Origin Policy Error",
- u"has requested that an origin policy");
-}
-
IN_PROC_BROWSER_TEST_F(InterstitialUITest, BlockedInterceptionInterstitial) {
TestInterstitial(GURL("chrome://interstitials/blocked-interception"),
"Your activity on example.com is being monitored",
diff --git a/chromium/chrome/browser/ui/webui/intro/DIR_METADATA b/chromium/chrome/browser/ui/webui/intro/DIR_METADATA
new file mode 100644
index 00000000000..3a626e17937
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/DIR_METADATA
@@ -0,0 +1 @@
+mixins: "//chrome/browser/profiles/COMMON_METADATA"
diff --git a/chromium/chrome/browser/ui/webui/intro/OWNERS b/chromium/chrome/browser/ui/webui/intro/OWNERS
new file mode 100644
index 00000000000..4bd1a53763e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/OWNERS
@@ -0,0 +1,2 @@
+file://chrome/browser/profiles/OWNERS
+dgn@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/intro/intro_handler.cc b/chromium/chrome/browser/ui/webui/intro/intro_handler.cc
new file mode 100644
index 00000000000..b2e1327d743
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/intro_handler.cc
@@ -0,0 +1,28 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/intro/intro_handler.h"
+
+#include "base/logging.h"
+
+void IntroHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "continueWithoutAccount",
+ base::BindRepeating(&IntroHandler::HandleContinueWithoutAccount,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "continueWithAccount",
+ base::BindRepeating(&IntroHandler::HandleContinueWithAccount,
+ base::Unretained(this)));
+}
+
+void IntroHandler::HandleContinueWithAccount(const base::Value::List& args) {
+ CHECK(args.empty());
+ DVLOG(1) << "HandleContinueWithAccount - To be implemented.";
+}
+
+void IntroHandler::HandleContinueWithoutAccount(const base::Value::List& args) {
+ CHECK(args.empty());
+ DVLOG(1) << "HandleContinueWithoutAccount - To be implemented.";
+}
diff --git a/chromium/chrome/browser/ui/webui/intro/intro_handler.h b/chromium/chrome/browser/ui/webui/intro/intro_handler.h
new file mode 100644
index 00000000000..ad071c198f4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/intro_handler.h
@@ -0,0 +1,27 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_HANDLER_H_
+
+#include "content/public/browser/web_ui_message_handler.h"
+
+class IntroHandler : public content::WebUIMessageHandler {
+ public:
+ IntroHandler() = default;
+
+ IntroHandler(const IntroHandler&) = delete;
+ IntroHandler& operator=(const IntroHandler&) = delete;
+
+ ~IntroHandler() override = default;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ private:
+ void HandleContinueWithAccount(const base::Value::List& args);
+ void HandleContinueWithoutAccount(const base::Value::List& args);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/intro/intro_ui.cc b/chromium/chrome/browser/ui/webui/intro/intro_ui.cc
new file mode 100644
index 00000000000..d3988bf1477
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/intro_ui.cc
@@ -0,0 +1,36 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/intro/intro_ui.h"
+
+#include "base/feature_list.h"
+#include "chrome/browser/signin/signin_features.h"
+#include "chrome/browser/ui/webui/intro/intro_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/intro_resources.h"
+#include "chrome/grit/intro_resources_map.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+namespace {} // namespace
+
+IntroUI::IntroUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
+ DCHECK(base::FeatureList::IsEnabled(kForYouFre));
+ web_ui->AddMessageHandler(std::make_unique<IntroHandler>());
+
+ content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd(
+ web_ui->GetWebContents()->GetBrowserContext(),
+ chrome::kChromeUIIntroHost);
+
+ webui::SetupWebUIDataSource(
+ source, base::make_span(kIntroResources, kIntroResourcesSize),
+ IDR_INTRO_INTRO_HTML);
+
+ source->AddString("message", "Under construction.");
+}
+
+IntroUI::~IntroUI() = default;
+
+WEB_UI_CONTROLLER_TYPE_IMPL(IntroUI)
diff --git a/chromium/chrome/browser/ui/webui/intro/intro_ui.h b/chromium/chrome/browser/ui/webui/intro/intro_ui.h
new file mode 100644
index 00000000000..a20cc65a5fc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/intro/intro_ui.h
@@ -0,0 +1,24 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+
+// The WebUI controller for `chrome://intro`.
+class IntroUI : public content::WebUIController {
+ public:
+ explicit IntroUI(content::WebUI* web_ui);
+
+ IntroUI(const IntroUI&) = delete;
+ IntroUI& operator=(const IntroUI&) = delete;
+
+ ~IntroUI() override;
+
+ private:
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_INTRO_INTRO_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc
index d485a8038d2..82489ac23ac 100644
--- a/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc
@@ -87,7 +87,7 @@ void InvalidationsMessageHandler::UpdateContent(const base::Value::List& args) {
void InvalidationsMessageHandler::OnRegistrationChange(
const std::set<std::string>& registered_handlers) {
- base::ListValue list_of_handlers;
+ base::Value::List list_of_handlers;
for (const auto& registered_handler : registered_handlers) {
list_of_handlers.Append(registered_handler);
}
@@ -117,11 +117,10 @@ void InvalidationsMessageHandler::OnUpdatedTopics(
dict.Set("totalCount", topic_item.second);
list_of_objects.Append(std::move(dict));
}
- FireWebUIListener("update-ids", base::Value(handler_name),
- base::Value(std::move(list_of_objects)));
+ FireWebUIListener("update-ids", base::Value(handler_name), list_of_objects);
}
void InvalidationsMessageHandler::OnDebugMessage(
- const base::DictionaryValue& details) {}
+ const base::Value::Dict& details) {}
void InvalidationsMessageHandler::OnInvalidation(
const invalidation::TopicInvalidationMap& new_invalidations) {
@@ -131,6 +130,6 @@ void InvalidationsMessageHandler::OnInvalidation(
}
void InvalidationsMessageHandler::OnDetailedStatus(
- const base::DictionaryValue& network_details) {
+ base::Value::Dict network_details) {
FireWebUIListener("detailed-status-updated", network_details);
}
diff --git a/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h
index 60993ddbef4..42a64f5dbd6 100644
--- a/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h
@@ -39,10 +39,10 @@ class InvalidationsMessageHandler
void OnUpdatedTopics(
const std::string& handler_name,
const invalidation::TopicCountMap& topics_counts) override;
- void OnDebugMessage(const base::DictionaryValue& details) override;
+ void OnDebugMessage(const base::Value::Dict& details) override;
void OnInvalidation(
const invalidation::TopicInvalidationMap& new_invalidations) override;
- void OnDetailedStatus(const base::DictionaryValue& network_details) override;
+ void OnDetailedStatus(base::Value::Dict network_details) override;
// Implementation of WebUIMessageHandler.
void RegisterMessages() override;
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
index 1bd323658cc..a4512f2e830 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
@@ -53,13 +53,14 @@ ManagedUIHandler::~ManagedUIHandler() {
}
void ManagedUIHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"observeManagedUI",
base::BindRepeating(&ManagedUIHandler::HandleObserveManagedUI,
base::Unretained(this)));
}
-void ManagedUIHandler::HandleObserveManagedUI(const base::ListValue* /*args*/) {
+void ManagedUIHandler::HandleObserveManagedUI(
+ const base::Value::List& /*args*/) {
AllowJavascript();
AddObservers();
}
@@ -110,13 +111,11 @@ void ManagedUIHandler::RemoveObservers() {
base::Value::Dict ManagedUIHandler::GetDataSourceUpdate() const {
base::Value::Dict update;
- update.Set("browserManagedByOrg",
- base::Value(chrome::GetManagedUiWebUILabel(profile_)));
+ update.Set("browserManagedByOrg", chrome::GetManagedUiWebUILabel(profile_));
#if BUILDFLAG(IS_CHROMEOS_ASH)
- update.Set("deviceManagedByOrg",
- base::Value(chrome::GetDeviceManagedUiWebUILabel()));
+ update.Set("deviceManagedByOrg", chrome::GetDeviceManagedUiWebUILabel());
#endif
- update.Set("isManaged", base::Value(managed_));
+ update.Set("isManaged", managed_);
return update;
}
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler.h b/chromium/chrome/browser/ui/webui/managed_ui_handler.h
index cd07abcfda9..84e0e377ae4 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler.h
@@ -56,7 +56,7 @@ class ManagedUIHandler : public content::WebUIMessageHandler,
void OnJavascriptDisallowed() override;
// Handles the "observeManagedUI" message. No arguments.
- void HandleObserveManagedUI(const base::ListValue* args);
+ void HandleObserveManagedUI(const base::Value::List& args);
// Add/remove observers on the PolicyService.
void AddObservers();
diff --git a/chromium/chrome/browser/ui/webui/management/management_ui.cc b/chromium/chrome/browser/ui/webui/management/management_ui.cc
index 85fd04a3c92..aa38e0e93b1 100644
--- a/chromium/chrome/browser/ui/webui/management/management_ui.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui.cc
@@ -52,7 +52,7 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
ManagementUI::GetManagementPageSubtitle(profile));
static constexpr webui::LocalizedString kLocalizedStrings[] = {
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
{"learnMore", IDS_LEARN_MORE},
{"localTrustRoots", IDS_MANAGEMENT_LOCAL_TRUST_ROOTS},
{"managementTrustRootsConfigured", IDS_MANAGEMENT_TRUST_ROOTS_CONFIGURED},
@@ -85,7 +85,10 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
IDS_MANAGEMENT_REPORT_ANDROID_APPLICATIONS},
{"proxyServerPrivacyDisclosure",
IDS_MANAGEMENT_PROXY_SERVER_PRIVACY_DISCLOSURE},
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ {kManagementOnFileTransferEvent, IDS_MANAGEMENT_FILE_TRANSFER_EVENT},
+ {kManagementOnFileTransferVisibleData,
+ IDS_MANAGEMENT_FILE_TRANSFER_VISIBLE_DATA},
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
{"browserReporting", IDS_MANAGEMENT_BROWSER_REPORTING},
{"browserReportingExplanation",
IDS_MANAGEMENT_BROWSER_REPORTING_EXPLANATION},
@@ -144,10 +147,6 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
chrome::kLearnMoreEnterpriseURL);
source->AddString("managementAccountLearnMoreUrl",
chrome::kManagedUiLearnMoreUrl);
- source->AddString("pluginVmDataCollection",
- l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_REPORT_PLUGIN_VM,
- l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME)));
const size_t dlp_events_count =
policy::DlpRulesManagerFactory::GetForPrimaryProfile() &&
policy::DlpRulesManagerFactory::GetForPrimaryProfile()
@@ -161,6 +160,13 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
IDS_MANAGEMENT_REPORT_DLP_EVENTS, dlp_events_count));
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ source->AddString("pluginVmDataCollection",
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_REPORT_PLUGIN_VM,
+ l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME)));
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+
webui::SetupWebUIDataSource(
source, base::make_span(kManagementResources, kManagementResourcesSize),
IDR_MANAGEMENT_MANAGEMENT_HTML);
diff --git a/chromium/chrome/browser/ui/webui/management/management_ui_handler.cc b/chromium/chrome/browser/ui/webui/management/management_ui_handler.cc
index a083acdd0ff..01ff530e677 100644
--- a/chromium/chrome/browser/ui/webui/management/management_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler.cc
@@ -15,8 +15,10 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
+#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -29,6 +31,7 @@
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/managed_ui.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/pref_names.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/strings/grit/components_strings.h"
@@ -41,6 +44,12 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chrome/browser/policy/networking/policy_cert_service.h"
+#include "chrome/browser/policy/networking/policy_cert_service_factory.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#endif
+
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/settings/cros_settings_names.h"
#include "chrome/browser/ash/crostini/crostini_features.h"
@@ -57,14 +66,11 @@
#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager_factory.h"
-#include "chrome/browser/policy/networking/policy_cert_service.h"
-#include "chrome/browser/policy/networking/policy_cert_service_factory.h"
#include "chrome/browser/ui/webui/management/management_ui_handler_chromeos.h"
-#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/chromium_strings.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/ash/components/network/proxy/proxy_config_handler.h"
#include "chromeos/ash/components/network/proxy/ui_proxy_config_service.h"
-#include "chromeos/network/network_state_handler.h"
#include "components/enterprise/browser/reporting/common_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
@@ -160,7 +166,7 @@ enum class ReportingType {
kUserActivity
};
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
const char kManagementLogUploadEnabled[] = "managementLogUploadEnabled";
const char kManagementReportActivityTimes[] = "managementReportActivityTimes";
const char kManagementReportDeviceAudioStatus[] =
@@ -180,6 +186,9 @@ const char kManagementReportPrintJobs[] = "managementReportPrintJobs";
const char kManagementReportLoginLogout[] = "managementReportLoginLogout";
const char kManagementReportCRDSessions[] = "managementReportCRDSessions";
const char kManagementReportDlpEvents[] = "managementReportDlpEvents";
+const char kManagementOnFileTransferEvent[] = "managementOnFileTransferEvent";
+const char kManagementOnFileTransferVisibleData[] =
+ "managementOnFileTransferVisibleData";
const char kManagementPrinting[] = "managementPrinting";
const char kManagementCrostini[] = "managementCrostini";
const char kManagementCrostiniContainerConfiguration[] =
@@ -187,7 +196,7 @@ const char kManagementCrostiniContainerConfiguration[] =
const char kAccountManagedInfo[] = "accountManagedInfo";
const char kDeviceManagedInfo[] = "deviceManagedInfo";
const char kOverview[] = "overview";
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
const char kCustomerLogo[] = "customerLogo";
@@ -199,20 +208,11 @@ bool IsProfileManaged(Profile* profile) {
return profile->GetProfilePolicyConnector()->IsManaged();
}
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+
bool IsDeviceManaged() {
return webui::IsEnterpriseManaged();
}
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-
-#if !BUILDFLAG(IS_CHROMEOS_ASH)
-bool IsBrowserManaged() {
- return g_browser_process->browser_policy_connector()
- ->HasMachineLevelPolicies();
-}
-#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
-
-#if BUILDFLAG(IS_CHROMEOS_ASH)
enum class DeviceReportingType {
kSupervisedUser,
@@ -234,6 +234,17 @@ enum class DeviceReportingType {
kPeripherals,
};
+#else
+
+bool IsBrowserManaged() {
+ return g_browser_process->browser_policy_connector()
+ ->HasMachineLevelPolicies();
+}
+
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+
// Corresponds to DeviceReportingType in management_browser_proxy.js
std::string ToJSDeviceReportingType(const DeviceReportingType& type) {
switch (type) {
@@ -281,15 +292,143 @@ void AddDeviceReportingElement(base::Value::List* report_sources,
const std::string& message_id,
const DeviceReportingType& type) {
base::Value::Dict data;
- data.Set("messageId", base::Value(message_id));
- data.Set("reportingType", base::Value(ToJSDeviceReportingType(type)));
+ data.Set("messageId", message_id);
+ data.Set("reportingType", ToJSDeviceReportingType(type));
report_sources->Append(std::move(data));
}
+
+const policy::DlpRulesManager* GetDlpRulesManager() {
+ return policy::DlpRulesManagerFactory::GetForPrimaryProfile();
+}
+
+// If you are adding a privacy note, please also add it to
+// go/chrome-policy-privacy-note-mappings.
+void AddDeviceReportingInfo(base::Value::List* report_sources,
+ const policy::StatusCollector* collector,
+ const policy::SystemLogUploader* uploader,
+ Profile* profile) {
+ if (!collector || !profile || !uploader)
+ return;
+
+ // Elements appear on the page in the order they are added.
+ if (collector->IsReportingActivityTimes() ||
+ profile->GetPrefs()->GetBoolean(::prefs::kInsightsExtensionEnabled)) {
+ AddDeviceReportingElement(report_sources, kManagementReportActivityTimes,
+ DeviceReportingType::kDeviceActivity);
+ } else {
+ if (collector->IsReportingUsers()) {
+ AddDeviceReportingElement(report_sources, kManagementReportUsers,
+ DeviceReportingType::kSupervisedUser);
+ }
+ }
+ if (collector->IsReportingNetworkData() ||
+ profile->GetPrefs()->GetBoolean(::prefs::kInsightsExtensionEnabled)) {
+ AddDeviceReportingElement(report_sources, kManagementReportNetworkData,
+ DeviceReportingType::kDevice);
+ }
+ if (collector->IsReportingHardwareData()) {
+ AddDeviceReportingElement(report_sources, kManagementReportHardwareData,
+ DeviceReportingType::kDeviceStatistics);
+ }
+ if (collector->IsReportingCrashReportInfo()) {
+ AddDeviceReportingElement(report_sources, kManagementReportCrashReports,
+ DeviceReportingType::kCrashReport);
+ }
+ if (collector->IsReportingAppInfoAndActivity()) {
+ AddDeviceReportingElement(report_sources,
+ kManagementReportAppInfoAndActivity,
+ DeviceReportingType::kAppInfoAndActivity);
+ }
+ if (uploader->upload_enabled()) {
+ AddDeviceReportingElement(report_sources, kManagementLogUploadEnabled,
+ DeviceReportingType::kLogs);
+ }
+
+ bool report_audio_status = false;
+ chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceAudioStatus,
+ &report_audio_status);
+ if (report_audio_status) {
+ AddDeviceReportingElement(report_sources,
+ kManagementReportDeviceAudioStatus,
+ DeviceReportingType::kDevice);
+ }
+
+ bool report_device_peripherals = false;
+ chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePeripherals,
+ &report_device_peripherals);
+ if (report_device_peripherals) {
+ AddDeviceReportingElement(report_sources,
+ kManagementReportDevicePeripherals,
+ DeviceReportingType::kPeripherals);
+ }
+
+ bool report_print_jobs = false;
+ chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePrintJobs,
+ &report_print_jobs);
+ if (report_print_jobs) {
+ AddDeviceReportingElement(report_sources, kManagementReportPrintJobs,
+ DeviceReportingType::kPrintJobs);
+ }
+
+ bool report_print_username = profile->GetPrefs()->GetBoolean(
+ prefs::kPrintingSendUsernameAndFilenameEnabled);
+ if (report_print_username && !report_print_jobs) {
+ AddDeviceReportingElement(report_sources, kManagementPrinting,
+ DeviceReportingType::kPrint);
+ }
+
+ if (GetDlpRulesManager() && GetDlpRulesManager()->IsReportingEnabled()) {
+ AddDeviceReportingElement(report_sources, kManagementReportDlpEvents,
+ DeviceReportingType::kDlpEvents);
+ }
+
+ if (crostini::CrostiniFeatures::Get()->IsAllowedNow(profile)) {
+ if (!profile->GetPrefs()
+ ->GetFilePath(crostini::prefs::kCrostiniAnsiblePlaybookFilePath)
+ .empty()) {
+ AddDeviceReportingElement(report_sources,
+ kManagementCrostiniContainerConfiguration,
+ DeviceReportingType::kCrostini);
+ } else if (profile->GetPrefs()->GetBoolean(
+ crostini::prefs::kReportCrostiniUsageEnabled)) {
+ AddDeviceReportingElement(report_sources, kManagementCrostini,
+ DeviceReportingType::kCrostini);
+ }
+ }
+
+ if (g_browser_process->local_state()->GetBoolean(
+ enterprise_reporting::kCloudReportingEnabled)) {
+ AddDeviceReportingElement(report_sources,
+ kManagementExtensionReportUsername,
+ DeviceReportingType::kUsername);
+ AddDeviceReportingElement(report_sources, kManagementReportExtensions,
+ DeviceReportingType::kExtensions);
+ AddDeviceReportingElement(report_sources,
+ kManagementReportAndroidApplications,
+ DeviceReportingType::kAndroidApplication);
+ }
+
+ bool report_login_logout = false;
+ chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceLoginLogout,
+ &report_login_logout);
+ if (report_login_logout) {
+ AddDeviceReportingElement(report_sources, kManagementReportLoginLogout,
+ DeviceReportingType::kLoginLogout);
+ }
+
+ bool report_crd_sessions = false;
+ chromeos::CrosSettings::Get()->GetBoolean(ash::kReportCRDSessions,
+ &report_crd_sessions);
+ if (report_crd_sessions) {
+ AddDeviceReportingElement(report_sources, kManagementReportCRDSessions,
+ DeviceReportingType::kCRDSessions);
+ }
+}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-std::vector<base::Value> GetPermissionsForExtension(
+base::Value::List GetPermissionsForExtension(
scoped_refptr<const extensions::Extension> extension) {
- std::vector<base::Value> permission_messages;
+ base::Value::List permission_messages;
// Only consider force installed extensions
if (!extensions::Manifest::IsPolicyLocation(extension->location()))
return permission_messages;
@@ -305,30 +444,30 @@ std::vector<base::Value> GetPermissionsForExtension(
permissions);
for (const auto& message : messages)
- permission_messages.push_back(base::Value(message.message()));
+ permission_messages.Append(message.message());
return permission_messages;
}
-base::Value GetPowerfulExtensions(const extensions::ExtensionSet& extensions) {
+base::Value::List GetPowerfulExtensions(
+ const extensions::ExtensionSet& extensions) {
base::Value::List powerful_extensions;
for (const auto& extension : extensions) {
- std::vector<base::Value> permission_messages =
+ base::Value::List permission_messages =
GetPermissionsForExtension(extension);
// Only show extension on page if there is at least one permission
// message to show.
if (!permission_messages.empty()) {
- std::unique_ptr<base::DictionaryValue> extension_to_add =
+ base::Value::Dict extension_to_add =
extensions::util::GetExtensionInfo(extension.get());
- extension_to_add->SetKey("permissions",
- base::Value(std::move(permission_messages)));
- powerful_extensions.Append(std::move(*extension_to_add));
+ extension_to_add.Set("permissions", std::move(permission_messages));
+ powerful_extensions.Append(std::move(extension_to_add));
}
}
- return base::Value(std::move(powerful_extensions));
+ return powerful_extensions;
}
const char* GetReportingTypeValue(ReportingType reportingType) {
@@ -358,7 +497,14 @@ void AddThreatProtectionPermission(const char* title,
}
std::string GetAccountManager(Profile* profile) {
- return chrome::GetAccountManagerIdentity(profile).value_or(std::string());
+ absl::optional<std::string> manager =
+ chrome::GetAccountManagerIdentity(profile);
+ if (!manager &&
+ base::FeatureList::IsEnabled(features::kFlexOrgManagementDisclosure)) {
+ manager = chrome::GetDeviceManagerIdentity();
+ }
+
+ return manager.value_or(std::string());
}
} // namespace
@@ -366,6 +512,20 @@ std::string GetAccountManager(Profile* profile) {
ManagementUIHandler::ManagementUIHandler() {
reporting_extension_ids_ = {kOnPremReportingExtensionStableId,
kOnPremReportingExtensionBetaId};
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ chromeos::LacrosService* service = chromeos::LacrosService::Get();
+ // Get device report sources.
+ if (service->IsAvailable<crosapi::mojom::DeviceSettingsService>() &&
+ service->GetInterfaceVersion(
+ crosapi::mojom::DeviceSettingsService::Uuid_) >=
+ static_cast<int>(crosapi::mojom::DeviceSettingsService::
+ kGetDeviceReportSourcesMinVersion)) {
+ service->GetRemote<crosapi::mojom::DeviceSettingsService>()
+ ->GetDeviceReportSources(
+ base::BindOnce(&ManagementUIHandler::OnGotDeviceReportSources,
+ weak_factory_.GetWeakPtr()));
+ }
+#endif
}
ManagementUIHandler::~ManagementUIHandler() {
@@ -382,49 +542,49 @@ void ManagementUIHandler::InitializeInternal(content::WebUI* web_ui,
Profile* profile) {
auto handler = std::make_unique<ManagementUIHandler>();
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
handler->account_managed_ = IsProfileManaged(profile);
handler->device_managed_ = IsDeviceManaged();
#else
handler->account_managed_ = IsProfileManaged(profile) || IsBrowserManaged();
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
web_ui->AddMessageHandler(std::move(handler));
}
void ManagementUIHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getContextualManagedData",
base::BindRepeating(&ManagementUIHandler::HandleGetContextualManagedData,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getExtensions",
base::BindRepeating(&ManagementUIHandler::HandleGetExtensions,
base::Unretained(this)));
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- web_ui()->RegisterDeprecatedMessageCallback(
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ web_ui()->RegisterMessageCallback(
"getLocalTrustRootsInfo",
base::BindRepeating(&ManagementUIHandler::HandleGetLocalTrustRootsInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getDeviceReportingInfo",
base::BindRepeating(&ManagementUIHandler::HandleGetDeviceReportingInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getPluginVmDataCollectionStatus",
base::BindRepeating(
&ManagementUIHandler::HandleGetPluginVmDataCollectionStatus,
base::Unretained(this)));
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- web_ui()->RegisterDeprecatedMessageCallback(
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ web_ui()->RegisterMessageCallback(
"getThreatProtectionInfo",
base::BindRepeating(&ManagementUIHandler::HandleGetThreatProtectionInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getManagedWebsites",
base::BindRepeating(&ManagementUIHandler::HandleGetManagedWebsites,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"initBrowserReportingInfo",
base::BindRepeating(&ManagementUIHandler::HandleInitBrowserReportingInfo,
base::Unretained(this)));
@@ -526,11 +686,10 @@ void ManagementUIHandler::AddReportingInfo(base::Value::List* report_sources) {
}
base::Value::Dict data;
- data.Set("messageId", base::Value(report_definition.message));
- data.Set(
- "reportingType",
- base::Value(GetReportingTypeValue(report_definition.reporting_type)));
- report_sources->Append(base::Value(std::move(data)));
+ data.Set("messageId", report_definition.message);
+ data.Set("reportingType",
+ GetReportingTypeValue(report_definition.reporting_type));
+ report_sources->Append(std::move(data));
}
}
@@ -546,135 +705,6 @@ ManagementUIHandler::GetDeviceCloudPolicyManager() const {
return connector->GetDeviceCloudPolicyManager();
}
-const policy::DlpRulesManager* ManagementUIHandler::GetDlpRulesManager() const {
- return policy::DlpRulesManagerFactory::GetForPrimaryProfile();
-}
-
-// If you are adding a privacy note, please also add it to
-// go/chrome-policy-privacy-note-mappings.
-void ManagementUIHandler::AddDeviceReportingInfo(
- base::Value::List* report_sources,
- const policy::StatusCollector* collector,
- const policy::SystemLogUploader* uploader,
- Profile* profile) const {
- if (!collector || !profile || !uploader)
- return;
-
- // Elements appear on the page in the order they are added.
- if (collector->IsReportingActivityTimes() ||
- profile->GetPrefs()->GetBoolean(::prefs::kInsightsExtensionEnabled)) {
- AddDeviceReportingElement(report_sources, kManagementReportActivityTimes,
- DeviceReportingType::kDeviceActivity);
- } else {
- if (collector->IsReportingUsers()) {
- AddDeviceReportingElement(report_sources, kManagementReportUsers,
- DeviceReportingType::kSupervisedUser);
- }
- }
- if (collector->IsReportingNetworkData() ||
- profile->GetPrefs()->GetBoolean(::prefs::kInsightsExtensionEnabled)) {
- AddDeviceReportingElement(report_sources, kManagementReportNetworkData,
- DeviceReportingType::kDevice);
- }
- if (collector->IsReportingHardwareData()) {
- AddDeviceReportingElement(report_sources, kManagementReportHardwareData,
- DeviceReportingType::kDeviceStatistics);
- }
- if (collector->IsReportingCrashReportInfo()) {
- AddDeviceReportingElement(report_sources, kManagementReportCrashReports,
- DeviceReportingType::kCrashReport);
- }
- if (collector->IsReportingAppInfoAndActivity()) {
- AddDeviceReportingElement(report_sources,
- kManagementReportAppInfoAndActivity,
- DeviceReportingType::kAppInfoAndActivity);
- }
- if (uploader->upload_enabled()) {
- AddDeviceReportingElement(report_sources, kManagementLogUploadEnabled,
- DeviceReportingType::kLogs);
- }
-
- bool report_audio_status = false;
- chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceAudioStatus,
- &report_audio_status);
- if (report_audio_status) {
- AddDeviceReportingElement(report_sources,
- kManagementReportDeviceAudioStatus,
- DeviceReportingType::kDevice);
- }
-
- bool report_device_peripherals = false;
- chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePeripherals,
- &report_device_peripherals);
- if (report_device_peripherals) {
- AddDeviceReportingElement(report_sources,
- kManagementReportDevicePeripherals,
- DeviceReportingType::kPeripherals);
- }
-
- bool report_print_jobs = false;
- chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePrintJobs,
- &report_print_jobs);
- if (report_print_jobs) {
- AddDeviceReportingElement(report_sources, kManagementReportPrintJobs,
- DeviceReportingType::kPrintJobs);
- }
-
- bool report_print_username = profile->GetPrefs()->GetBoolean(
- prefs::kPrintingSendUsernameAndFilenameEnabled);
- if (report_print_username && !report_print_jobs) {
- AddDeviceReportingElement(report_sources, kManagementPrinting,
- DeviceReportingType::kPrint);
- }
-
- if (GetDlpRulesManager() && GetDlpRulesManager()->IsReportingEnabled()) {
- AddDeviceReportingElement(report_sources, kManagementReportDlpEvents,
- DeviceReportingType::kDlpEvents);
- }
-
- if (crostini::CrostiniFeatures::Get()->IsAllowedNow(profile)) {
- if (!profile->GetPrefs()
- ->GetFilePath(crostini::prefs::kCrostiniAnsiblePlaybookFilePath)
- .empty()) {
- AddDeviceReportingElement(report_sources,
- kManagementCrostiniContainerConfiguration,
- DeviceReportingType::kCrostini);
- } else if (profile->GetPrefs()->GetBoolean(
- crostini::prefs::kReportCrostiniUsageEnabled)) {
- AddDeviceReportingElement(report_sources, kManagementCrostini,
- DeviceReportingType::kCrostini);
- }
- }
-
- if (g_browser_process->local_state()->GetBoolean(
- enterprise_reporting::kCloudReportingEnabled)) {
- AddDeviceReportingElement(report_sources,
- kManagementExtensionReportUsername,
- DeviceReportingType::kUsername);
- AddDeviceReportingElement(report_sources, kManagementReportExtensions,
- DeviceReportingType::kExtensions);
- AddDeviceReportingElement(report_sources,
- kManagementReportAndroidApplications,
- DeviceReportingType::kAndroidApplication);
- }
-
- bool report_login_logout = false;
- chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceLoginLogout,
- &report_login_logout);
- if (report_login_logout) {
- AddDeviceReportingElement(report_sources, kManagementReportLoginLogout,
- DeviceReportingType::kLoginLogout);
- }
-
- bool report_crd_sessions = false;
- chromeos::CrosSettings::Get()->GetBoolean(ash::kReportCRDSessions,
- &report_crd_sessions);
- if (report_crd_sessions) {
- AddDeviceReportingElement(report_sources, kManagementReportCRDSessions,
- DeviceReportingType::kCRDSessions);
- }
-}
-
bool ManagementUIHandler::IsUpdateRequiredEol() const {
const policy::BrowserPolicyConnectorAsh* connector =
g_browser_process->platform_part()->browser_policy_connector_ash();
@@ -703,34 +733,70 @@ void ManagementUIHandler::AddUpdateRequiredEolInfo(
void ManagementUIHandler::AddProxyServerPrivacyDisclosure(
base::Value::Dict* response) const {
bool showProxyDisclosure = false;
- chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get();
- base::Value proxy_settings(base::Value::Type::DICTIONARY);
+ ash::NetworkHandler* network_handler = ash::NetworkHandler::Get();
+ base::Value::Dict proxy_settings;
// |ui_proxy_config_service| may be missing in tests. If the device is offline
// (no network connected) the |DefaultNetwork| is null.
- if (chromeos::NetworkHandler::HasUiProxyConfigService() &&
+ if (ash::NetworkHandler::HasUiProxyConfigService() &&
network_handler->network_state_handler()->DefaultNetwork()) {
// Check if proxy is enforced by user policy, a forced install extension or
// ONC policies. This will only read managed settings.
- chromeos::NetworkHandler::GetUiProxyConfigService()
- ->MergeEnforcedProxyConfig(
- network_handler->network_state_handler()->DefaultNetwork()->guid(),
- &proxy_settings);
+ ash::NetworkHandler::GetUiProxyConfigService()->MergeEnforcedProxyConfig(
+ network_handler->network_state_handler()->DefaultNetwork()->guid(),
+ &proxy_settings);
}
- if (!proxy_settings.DictEmpty()) {
+ if (!proxy_settings.empty()) {
// Proxies can be specified by web server url, via a PAC script or via the
// web proxy auto-discovery protocol. Chrome also supports the "direct"
// mode, in which no proxy is used.
- base::Value* proxy_specification_mode = proxy_settings.FindPath(
- {::onc::network_config::kType, ::onc::kAugmentationActiveSetting});
- showProxyDisclosure =
- proxy_specification_mode &&
- proxy_specification_mode->GetString() != ::onc::proxy::kDirect;
+ std::string* proxy_specification_mode =
+ proxy_settings.FindStringByDottedPath(base::JoinString(
+ {::onc::network_config::kType, ::onc::kAugmentationActiveSetting},
+ "."));
+ showProxyDisclosure = proxy_specification_mode &&
+ *proxy_specification_mode != ::onc::proxy::kDirect;
}
response->Set("showProxyServerPrivacyDisclosure", showProxyDisclosure);
}
-#endif
-base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
+// static
+base::Value::List ManagementUIHandler::GetDeviceReportingInfo(
+ const policy::DeviceCloudPolicyManagerAsh* manager,
+ Profile* profile) {
+ base::Value::List report_sources;
+ policy::StatusUploader* uploader = nullptr;
+ policy::SystemLogUploader* syslog_uploader = nullptr;
+ policy::StatusCollector* collector = nullptr;
+ if (manager) {
+ uploader = manager->GetStatusUploader();
+ syslog_uploader = manager->GetSystemLogUploader();
+ if (uploader)
+ collector = uploader->status_collector();
+ }
+ AddDeviceReportingInfo(&report_sources, collector, syslog_uploader, profile);
+ return report_sources;
+}
+
+// static
+void ManagementUIHandler::AddDlpDeviceReportingElementForTesting(
+ base::Value::List* report_sources,
+ const std::string& message_id) {
+ AddDeviceReportingElement(report_sources, message_id,
+ DeviceReportingType::kDlpEvents);
+}
+
+// static
+void ManagementUIHandler::AddDeviceReportingInfoForTesting(
+ base::Value::List* report_sources,
+ const policy::StatusCollector* collector,
+ const policy::SystemLogUploader* uploader,
+ Profile* profile) {
+ AddDeviceReportingInfo(report_sources, collector, uploader, profile);
+}
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+
+base::Value::Dict ManagementUIHandler::GetContextualManagedData(
+ Profile* profile) {
base::Value::Dict response;
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string enterprise_manager = GetDeviceManager();
@@ -806,10 +872,11 @@ base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
AsyncUpdateLogo();
if (!fetched_image_.empty())
response.Set(kCustomerLogo, base::Value(fetched_image_));
- return base::Value(std::move(response));
+ return response;
}
-base::Value ManagementUIHandler::GetThreatProtectionInfo(Profile* profile) {
+base::Value::Dict ManagementUIHandler::GetThreatProtectionInfo(
+ Profile* profile) {
base::Value::List info;
constexpr struct {
@@ -817,14 +884,18 @@ base::Value ManagementUIHandler::GetThreatProtectionInfo(Profile* profile) {
const char* title;
const char* permission;
} analysis_connector_permissions[] = {
- {enterprise_connectors::FILE_ATTACHED, kManagementOnFileAttachedEvent,
- kManagementOnFileAttachedVisibleData},
- {enterprise_connectors::FILE_DOWNLOADED, kManagementOnFileDownloadedEvent,
- kManagementOnFileDownloadedVisibleData},
- {enterprise_connectors::BULK_DATA_ENTRY, kManagementOnBulkDataEntryEvent,
- kManagementOnBulkDataEntryVisibleData},
- {enterprise_connectors::PRINT, kManagementOnPrintEvent,
- kManagementOnPrintVisibleData},
+ {enterprise_connectors::FILE_ATTACHED, kManagementOnFileAttachedEvent,
+ kManagementOnFileAttachedVisibleData},
+ {enterprise_connectors::FILE_DOWNLOADED, kManagementOnFileDownloadedEvent,
+ kManagementOnFileDownloadedVisibleData},
+ {enterprise_connectors::BULK_DATA_ENTRY, kManagementOnBulkDataEntryEvent,
+ kManagementOnBulkDataEntryVisibleData},
+ {enterprise_connectors::PRINT, kManagementOnPrintEvent,
+ kManagementOnPrintVisibleData},
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {enterprise_connectors::FILE_TRANSFER, kManagementOnFileTransferEvent,
+ kManagementOnFileTransferVisibleData},
+#endif
};
auto* connectors_service =
enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext(
@@ -863,7 +934,7 @@ base::Value ManagementUIHandler::GetThreatProtectionInfo(Profile* profile) {
IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION_BY,
base::UTF8ToUTF16(enterprise_manager)));
result.Set("info", std::move(info));
- return base::Value(std::move(result));
+ return result;
}
base::Value::List ManagementUIHandler::GetManagedWebsitesInfo(
@@ -962,7 +1033,7 @@ const std::string ManagementUIHandler::GetDeviceManager() const {
void ManagementUIHandler::GetManagementStatus(Profile* profile,
base::Value::Dict* status) const {
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
status->Set(kDeviceManagedInfo, base::Value());
status->Set(kAccountManagedInfo, base::Value());
status->Set(kOverview, base::Value());
@@ -971,6 +1042,7 @@ void ManagementUIHandler::GetManagementStatus(Profile* profile,
IDS_MANAGEMENT_DEVICE_NOT_MANAGED)));
return;
}
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string account_manager = GetAccountManager(profile);
auto* primary_user = user_manager::UserManager::Get()->GetPrimaryUser();
auto* primary_profile =
@@ -988,30 +1060,39 @@ void ManagementUIHandler::GetManagementStatus(Profile* profile,
status, device_managed_, account_managed_ || primary_user_managed,
device_manager, account_manager);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
}
-void ManagementUIHandler::HandleGetExtensions(const base::ListValue* args) {
+void ManagementUIHandler::HandleGetExtensions(const base::Value::List& args) {
AllowJavascript();
// List of all enabled extensions
const extensions::ExtensionSet& extensions =
extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
->enabled_extensions();
- base::Value powerful_extensions = GetPowerfulExtensions(extensions);
+ base::Value::List powerful_extensions = GetPowerfulExtensions(extensions);
// The number of extensions to be reported in chrome://management with
// powerful permissions.
base::UmaHistogramCounts1000(kPowerfulExtensionsCountHistogram,
- powerful_extensions.GetListDeprecated().size());
+ powerful_extensions.size());
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- powerful_extensions);
+ ResolveJavascriptCallback(args[0] /* callback_id */, powerful_extensions);
}
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+void ManagementUIHandler::OnGotDeviceReportSources(
+ base::Value::List report_sources,
+ bool plugin_vm_data_collection_enabled) {
+ report_sources_ = std::move(report_sources);
+ plugin_vm_data_collection_enabled_ = plugin_vm_data_collection_enabled;
+}
+#endif
+
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
void ManagementUIHandler::HandleGetLocalTrustRootsInfo(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetListDeprecated().size());
+ const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
base::Value trust_roots_configured(false);
AllowJavascript();
@@ -1021,85 +1102,74 @@ void ManagementUIHandler::HandleGetLocalTrustRootsInfo(
if (policy_service && policy_service->has_policy_certificates())
trust_roots_configured = base::Value(true);
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- trust_roots_configured);
+ ResolveJavascriptCallback(args[0] /* callback_id */, trust_roots_configured);
}
void ManagementUIHandler::HandleGetDeviceReportingInfo(
- const base::ListValue* args) {
- base::Value::List report_sources;
+ const base::Value::List& args) {
AllowJavascript();
-
- const policy::DeviceCloudPolicyManagerAsh* manager =
- GetDeviceCloudPolicyManager();
- policy::StatusUploader* uploader = nullptr;
- policy::SystemLogUploader* syslog_uploader = nullptr;
- policy::StatusCollector* collector = nullptr;
- if (manager) {
- uploader = manager->GetStatusUploader();
- syslog_uploader = manager->GetSystemLogUploader();
- if (uploader)
- collector = uploader->status_collector();
- }
- AddDeviceReportingInfo(&report_sources, collector, syslog_uploader,
- Profile::FromWebUI(web_ui()));
-
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- base::Value(std::move(report_sources)));
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ base::Value::List report_sources = GetDeviceReportingInfo(
+ GetDeviceCloudPolicyManager(), Profile::FromWebUI(web_ui()));
+ ResolveJavascriptCallback(args[0] /* callback_id */, report_sources);
+#else
+ ResolveJavascriptCallback(args[0] /* callback_id */, report_sources_);
+#endif
}
void ManagementUIHandler::HandleGetPluginVmDataCollectionStatus(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetListDeprecated().size());
+ const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
+#if BUILDFLAG(IS_CHROMEOS_ASH)
base::Value plugin_vm_data_collection_enabled(
Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
plugin_vm::prefs::kPluginVmDataCollectionAllowed));
+#else
+ base::Value plugin_vm_data_collection_enabled(
+ plugin_vm_data_collection_enabled_);
+#endif
AllowJavascript();
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
+ ResolveJavascriptCallback(args[0] /* callback_id */,
plugin_vm_data_collection_enabled);
}
-
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
void ManagementUIHandler::HandleGetContextualManagedData(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
auto result = GetContextualManagedData(Profile::FromWebUI(web_ui()));
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- std::move(result));
+ ResolveJavascriptCallback(args[0] /* callback_id */, result);
}
void ManagementUIHandler::HandleGetThreatProtectionInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
ResolveJavascriptCallback(
- args->GetListDeprecated()[0] /* callback_id */,
+ args[0] /* callback_id */,
GetThreatProtectionInfo(Profile::FromWebUI(web_ui())));
}
void ManagementUIHandler::HandleGetManagedWebsites(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
ResolveJavascriptCallback(
- args->GetListDeprecated()[0] /* callback_id */,
- base::Value(GetManagedWebsitesInfo(Profile::FromWebUI(web_ui()))));
+ args[0] /* callback_id */,
+ GetManagedWebsitesInfo(Profile::FromWebUI(web_ui())));
}
void ManagementUIHandler::HandleInitBrowserReportingInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
base::Value::List report_sources;
AllowJavascript();
AddReportingInfo(&report_sources);
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- base::Value(std::move(report_sources)));
+ ResolveJavascriptCallback(args[0] /* callback_id */, report_sources);
}
void ManagementUIHandler::NotifyBrowserReportingInfoUpdated() {
base::Value::List report_sources;
AddReportingInfo(&report_sources);
- FireWebUIListener("browser-reporting-info-updated",
- base::Value(std::move(report_sources)));
+ FireWebUIListener("browser-reporting-info-updated", report_sources);
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -1138,7 +1208,7 @@ void ManagementUIHandler::OnExtensionUnloaded(
void ManagementUIHandler::UpdateManagedState() {
auto* profile = Profile::FromWebUI(web_ui());
bool managed_state_changed = false;
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
managed_state_changed |= account_managed_ != IsProfileManaged(profile);
managed_state_changed |= device_managed_ != IsDeviceManaged();
account_managed_ = IsProfileManaged(profile);
@@ -1147,7 +1217,7 @@ void ManagementUIHandler::UpdateManagedState() {
managed_state_changed |=
account_managed_ != (IsProfileManaged(profile) || IsBrowserManaged());
account_managed_ = IsProfileManaged(profile) || IsBrowserManaged();
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
if (managed_state_changed)
FireWebUIListener("managed_data_changed");
diff --git a/chromium/chrome/browser/ui/webui/management/management_ui_handler.h b/chromium/chrome/browser/ui/webui/management/management_ui_handler.h
index 8cff5683606..230ef0b45b3 100644
--- a/chromium/chrome/browser/ui/webui/management/management_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler.h
@@ -10,6 +10,7 @@
#include <string>
#include "base/gtest_prod_util.h"
+#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
#include "chrome/common/url_constants.h"
@@ -23,7 +24,7 @@
#include "extensions/common/extension_id.h"
#include "url/gurl.h"
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
// Constants defining the IDs for the localized strings sent to the page as
// load time data.
extern const char kManagementLogUploadEnabled[];
@@ -44,7 +45,9 @@ extern const char kManagementCrostini[];
extern const char kManagementCrostiniContainerConfiguration[];
extern const char kManagementReportExtensions[];
extern const char kManagementReportAndroidApplications[];
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+extern const char kManagementOnFileTransferEvent[];
+extern const char kManagementOnFileTransferVisibleData[];
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
extern const char kOnPremReportingExtensionStableId[];
extern const char kOnPremReportingExtensionBetaId[];
@@ -90,17 +93,12 @@ extern const char kReportingTypeSecurity[];
extern const char kReportingTypeUser[];
extern const char kReportingTypeUserActivity[];
-namespace base {
-class ListValue;
-} // namespace base
-
namespace extensions {
class Extension;
} // namespace extensions
namespace policy {
class DeviceCloudPolicyManagerAsh;
-class DlpRulesManager;
class PolicyService;
class StatusCollector;
class SystemLogUploader;
@@ -133,6 +131,21 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // Returns the list of device reporting items for a given profile.
+ static base::Value::List GetDeviceReportingInfo(
+ const policy::DeviceCloudPolicyManagerAsh* manager,
+ Profile* profile);
+ static void AddDlpDeviceReportingElementForTesting(
+ base::Value::List* report_sources,
+ const std::string& message_id);
+ static void AddDeviceReportingInfoForTesting(
+ base::Value::List* report_sources,
+ const policy::StatusCollector* collector,
+ const policy::SystemLogUploader* uploader,
+ Profile* profile);
+#endif
+
protected:
// Protected for testing.
static void InitializeInternal(content::WebUI* web_ui,
@@ -140,8 +153,8 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
Profile* profile);
void AddReportingInfo(base::Value::List* report_sources);
- base::Value GetContextualManagedData(Profile* profile);
- base::Value GetThreatProtectionInfo(Profile* profile);
+ base::Value::Dict GetContextualManagedData(Profile* profile);
+ base::Value::Dict GetThreatProtectionInfo(Profile* profile);
base::Value::List GetManagedWebsitesInfo(Profile* profile) const;
virtual policy::PolicyService* GetPolicyService();
@@ -150,11 +163,6 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
virtual const std::string GetDeviceManager() const;
virtual const policy::DeviceCloudPolicyManagerAsh*
GetDeviceCloudPolicyManager() const;
- virtual const policy::DlpRulesManager* GetDlpRulesManager() const;
- void AddDeviceReportingInfo(base::Value::List* report_sources,
- const policy::StatusCollector* collector,
- const policy::SystemLogUploader* uploader,
- Profile* profile) const;
// Virtual for testing
virtual bool IsUpdateRequiredEol() const;
// Adds device return instructions for a managed user as an update is required
@@ -170,17 +178,22 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
private:
void GetManagementStatus(Profile* profile, base::Value::Dict* status) const;
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- void HandleGetDeviceReportingInfo(const base::ListValue* args);
- void HandleGetPluginVmDataCollectionStatus(const base::ListValue* args);
- void HandleGetLocalTrustRootsInfo(const base::ListValue* args);
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ void HandleGetDeviceReportingInfo(const base::Value::List& args);
+ void HandleGetPluginVmDataCollectionStatus(const base::Value::List& args);
+ void HandleGetLocalTrustRootsInfo(const base::Value::List& args);
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
- void HandleGetExtensions(const base::ListValue* args);
- void HandleGetContextualManagedData(const base::ListValue* args);
- void HandleGetThreatProtectionInfo(const base::ListValue* args);
- void HandleGetManagedWebsites(const base::ListValue* args);
- void HandleInitBrowserReportingInfo(const base::ListValue* args);
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ void OnGotDeviceReportSources(base::Value::List report_sources,
+ bool plugin_vm_data_collection_enabled);
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
+ void HandleGetExtensions(const base::Value::List& args);
+ void HandleGetContextualManagedData(const base::Value::List& args);
+ void HandleGetThreatProtectionInfo(const base::Value::List& args);
+ void HandleGetManagedWebsites(const base::Value::List& args);
+ void HandleInitBrowserReportingInfo(const base::Value::List& args);
void AsyncUpdateLogo();
@@ -224,6 +237,12 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
GURL logo_url_;
std::string fetched_image_;
std::unique_ptr<BitmapFetcher> icon_fetcher_;
+
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ base::Value::List report_sources_;
+ bool plugin_vm_data_collection_enabled_;
+ base::WeakPtrFactory<ManagementUIHandler> weak_factory_{this};
+#endif
};
#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
index 3e763602dbf..3d530cf6a3b 100644
--- a/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
@@ -42,7 +42,6 @@
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "ash/components/tpm/stub_install_attributes.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/time.h"
#include "chrome/browser/ash/crostini/crostini_features.h"
@@ -63,14 +62,14 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "chromeos/ash/components/dbus/shill/shill_service_client.h"
+#include "chromeos/ash/components/install_attributes/stub_install_attributes.h"
+#include "chromeos/ash/components/network/network_handler_test_helper.h"
+#include "chromeos/ash/components/network/network_metadata_store.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/ash/components/network/proxy/proxy_config_handler.h"
#include "chromeos/ash/components/network/proxy/ui_proxy_config_service.h"
-#include "chromeos/dbus/dbus_thread_manager.h" // nogncheck
#include "chromeos/dbus/power/power_manager_client.h"
-#include "chromeos/dbus/shill/shill_service_client.h"
-#include "chromeos/network/network_handler_test_helper.h"
-#include "chromeos/network/network_metadata_store.h"
-#include "chromeos/network/network_state_handler.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "components/account_id/account_id.h"
#include "components/enterprise/browser/reporting/common_pref_names.h"
@@ -96,6 +95,10 @@
#include "services/network/test/test_network_connection_tracker.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chromeos/lacros/lacros_test_helper.h"
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
using testing::_;
using testing::AnyNumber;
using testing::AssertionFailure;
@@ -196,23 +199,15 @@ class TestManagementUIHandler : public ManagementUIHandler {
public:
TestManagementUIHandler() = default;
explicit TestManagementUIHandler(policy::PolicyService* policy_service)
- : policy_service_(policy_service) {
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- dlp_rules_manager_ = new policy::MockDlpRulesManager();
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- }
+ : policy_service_(policy_service) {}
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- ~TestManagementUIHandler() override { delete dlp_rules_manager_; }
-#else
~TestManagementUIHandler() override = default;
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void EnableUpdateRequiredEolInfo(bool enable) {
update_required_eol_ = enable;
}
- base::Value GetContextualManagedDataForTesting(Profile* profile) {
+ base::Value::Dict GetContextualManagedDataForTesting(Profile* profile) {
return GetContextualManagedData(profile);
}
@@ -226,7 +221,7 @@ class TestManagementUIHandler : public ManagementUIHandler {
return ManagementUIHandler::GetManagedWebsitesInfo(profile);
}
- base::Value GetThreatProtectionInfo(Profile* profile) {
+ base::Value::Dict GetThreatProtectionInfo(Profile* profile) {
return ManagementUIHandler::GetThreatProtectionInfo(profile);
}
@@ -239,20 +234,7 @@ class TestManagementUIHandler : public ManagementUIHandler {
(const, override));
bool IsUpdateRequiredEol() const override { return update_required_eol_; }
- base::Value GetDeviceReportingInfo(
- const TestDeviceCloudPolicyManagerAsh* manager,
- const TestDeviceStatusCollector* collector,
- const policy::SystemLogUploader* uploader,
- Profile* profile) {
- base::Value::List report_sources;
- AddDeviceReportingInfo(&report_sources, collector, uploader, profile);
- return base::Value(std::move(report_sources));
- }
-
const std::string GetDeviceManager() const override { return device_domain; }
- const policy::DlpRulesManager* GetDlpRulesManager() const override {
- return dlp_rules_manager_;
- }
void SetDeviceDomain(const std::string& domain) { device_domain = domain; }
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@@ -260,9 +242,6 @@ class TestManagementUIHandler : public ManagementUIHandler {
raw_ptr<policy::PolicyService> policy_service_ = nullptr;
bool update_required_eol_ = false;
std::string device_domain = "devicedomain.com";
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- policy::DlpRulesManager* dlp_rules_manager_ = nullptr;
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
};
// We need to use a different base class for ChromeOS and non ChromeOS case.
@@ -278,10 +257,10 @@ class ManagementUIHandlerTests : public TestingBaseClass {
#if BUILDFLAG(IS_CHROMEOS_ASH)
ManagementUIHandlerTests()
: TestingBaseClass(),
- handler_(&policy_service_),
device_domain_(u"devicedomain.com"),
task_runner_(base::MakeRefCounted<base::TestSimpleTaskRunner>()),
- state_keys_broker_(&session_manager_client_) {
+ state_keys_broker_(&session_manager_client_),
+ handler_(&policy_service_) {
ON_CALL(policy_service_, GetPolicies(_))
.WillByDefault(ReturnRef(empty_policy_map_));
}
@@ -324,15 +303,15 @@ class ManagementUIHandlerTests : public TestingBaseClass {
std::move(policy_value.value()), nullptr);
}
- std::u16string ExtractPathFromDict(const base::Value& data,
+ std::u16string ExtractPathFromDict(const base::Value::Dict& data,
const std::string path) {
- const std::string* buf = data.FindStringPath(path);
+ const std::string* buf = data.FindStringByDottedPath(path);
if (!buf)
return std::u16string();
return base::UTF8ToUTF16(*buf);
}
- void ExtractContextualSourceUpdate(const base::Value& data) {
+ void ExtractContextualSourceUpdate(const base::Value::Dict& data) {
extracted_.extension_reporting_title =
ExtractPathFromDict(data, "extensionReportingTitle");
extracted_.managed_websites_title =
@@ -342,14 +321,14 @@ class ManagementUIHandlerTests : public TestingBaseClass {
extracted_.management_overview = ExtractPathFromDict(data, "overview");
extracted_.update_required_eol = ExtractPathFromDict(data, "eolMessage");
absl::optional<bool> showProxyDisclosure =
- data.FindBoolPath("showProxyServerPrivacyDisclosure");
+ data.FindBool("showProxyServerPrivacyDisclosure");
extracted_.show_proxy_server_privacy_disclosure =
showProxyDisclosure.has_value() && showProxyDisclosure.value();
#else
extracted_.browser_management_notice =
ExtractPathFromDict(data, "browserManagementNotice");
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- absl::optional<bool> managed = data.FindBoolPath("managed");
+ absl::optional<bool> managed = data.FindBool("managed");
extracted_.managed = managed.has_value() && managed.value();
}
@@ -406,12 +385,9 @@ class ManagementUIHandlerTests : public TestingBaseClass {
crostini_features_ = std::make_unique<crostini::FakeCrostiniFeatures>();
SetUpConnectManager();
- // DBusThreadManager::Initialize() has to be called before creating
- // NetworkHandlerTestHelper.
- chromeos::DBusThreadManager::Initialize();
network_handler_test_helper_ =
- std::make_unique<chromeos::NetworkHandlerTestHelper>();
- chromeos::NetworkMetadataStore::RegisterPrefs(user_prefs_.registry());
+ std::make_unique<ash::NetworkHandlerTestHelper>();
+ ash::NetworkMetadataStore::RegisterPrefs(user_prefs_.registry());
// The |DeviceSettingsTestBase| setup above instantiates
// |FakeShillManagerClient| with a default environment which will post
// tasks on the current thread to setup a initial network configuration with
@@ -421,7 +397,6 @@ class ManagementUIHandlerTests : public TestingBaseClass {
void TearDown() override {
network_handler_test_helper_.reset();
profile_.reset();
- chromeos::DBusThreadManager::Shutdown();
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
DeviceSettingsTestBase::TearDown();
}
@@ -438,7 +413,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
manager_.get()->Initialize(&local_state_);
}
- base::Value SetUpForReportingInfo() {
+ base::Value::List SetUpForReportingInfo() {
GetTestConfig().override_policy_connector_is_managed = true;
GetTestConfig().managed_device = true;
SetUpProfileAndHandler();
@@ -474,12 +449,14 @@ class ManagementUIHandlerTests : public TestingBaseClass {
/*task_runner=*/task_runner_);
ON_CALL(testing::Const(handler_), GetDeviceCloudPolicyManager())
.WillByDefault(Return(manager_.get()));
- EXPECT_CALL(*static_cast<const policy::MockDlpRulesManager*>(
- handler_.GetDlpRulesManager()),
- IsReportingEnabled)
- .WillRepeatedly(testing::Return(GetTestConfig().report_dlp_events));
- return handler_.GetDeviceReportingInfo(manager_.get(), &status_collector,
- &system_log_uploader, GetProfile());
+ base::Value::List result;
+ ManagementUIHandler::AddDeviceReportingInfoForTesting(
+ &result, &status_collector, &system_log_uploader, GetProfile());
+ if (GetTestConfig().report_dlp_events) {
+ ManagementUIHandler::AddDlpDeviceReportingElementForTesting(
+ &result, kManagementReportDlpEvents);
+ }
+ return result;
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@@ -495,7 +472,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
#if BUILDFLAG(IS_CHROMEOS_ASH)
handler_.SetDeviceDomain(GetTestConfig().device_domain);
#endif
- base::Value data =
+ base::Value::Dict data =
handler_.GetContextualManagedDataForTesting(profile_.get());
ExtractContextualSourceUpdate(data);
}
@@ -582,14 +559,12 @@ class ManagementUIHandlerTests : public TestingBaseClass {
protected:
TestConfig setup_config_;
- TestManagementUIHandler handler_;
policy::MockPolicyService policy_service_;
policy::PolicyMap empty_policy_map_;
std::u16string device_domain_;
ContextualManagementSourceUpdate extracted_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
- std::unique_ptr<chromeos::NetworkHandlerTestHelper>
- network_handler_test_helper_;
+ std::unique_ptr<ash::NetworkHandlerTestHelper> network_handler_test_helper_;
std::unique_ptr<ash::ScopedStubInstallAttributes> install_attributes_;
std::unique_ptr<crostini::FakeCrostiniFeatures> crostini_features_;
TestingPrefServiceSimple local_state_;
@@ -603,6 +578,11 @@ class ManagementUIHandlerTests : public TestingBaseClass {
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<TestingProfile> profile_;
#endif
+
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ chromeos::ScopedLacrosServiceTestHelper scoped_lacros_test_helper_;
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+ TestManagementUIHandler handler_;
};
AssertionResult MessagesToBeEQ(const char* infolist_expr,
@@ -652,7 +632,7 @@ AssertionResult MessagesToBeEQ(const char* infolist_expr,
AssertionResult ReportingElementsToBeEQ(
const char* elements_expr,
const char* expected_elements_expr,
- base::Value::ConstListView elements,
+ const base::Value::List& elements,
const std::map<std::string, std::string> expected_elements) {
std::map<std::string, std::string> tmp_expected(expected_elements);
for (const base::Value& element : elements) {
@@ -675,8 +655,7 @@ AssertionResult ReportingElementsToBeEQ(
tmp_expected.erase(tmp_reporting_type);
} else {
return AssertionFailure()
- << " couldn't find key messageId or reportingType in "
- << elements.data();
+ << " couldn't find key messageId or reportingType in " << elements;
}
}
if (!tmp_expected.empty()) {
@@ -1014,16 +993,16 @@ TEST_F(ManagementUIHandlerTests, NoDeviceReportingInfo) {
GetTestConfig().managed_account = false;
SetUpProfileAndHandler();
- base::Value info =
- handler_.GetDeviceReportingInfo(nullptr, nullptr, nullptr, GetProfile());
+ base::Value::List info =
+ ManagementUIHandler::GetDeviceReportingInfo(nullptr, GetProfile());
- EXPECT_EQ(info.GetListDeprecated().size(), 0u);
+ EXPECT_EQ(info.size(), 0u);
}
TEST_F(ManagementUIHandlerTests, AllEnabledDeviceReportingInfo) {
ResetTestConfig(true);
GetTestConfig().report_users = false;
- const base::Value info = SetUpForReportingInfo();
+ const base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {
{kManagementReportActivityTimes, "device activity"},
{kManagementReportNetworkData, "device"},
@@ -1038,8 +1017,7 @@ TEST_F(ManagementUIHandlerTests, AllEnabledDeviceReportingInfo) {
{kManagementReportAndroidApplications, "android application"},
{kManagementReportDlpEvents, "dlp events"}};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests,
@@ -1047,7 +1025,7 @@ TEST_F(ManagementUIHandlerTests,
ResetTestConfig(true);
GetTestConfig().report_dlp_events = false;
GetTestConfig().crostini_ansible_playbook_filepath = base::FilePath("/tmp/");
- const base::Value info = SetUpForReportingInfo();
+ const base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {
{kManagementReportActivityTimes, "device activity"},
{kManagementReportNetworkData, "device"},
@@ -1061,60 +1039,55 @@ TEST_F(ManagementUIHandlerTests,
{kManagementReportExtensions, "extension"},
{kManagementReportAndroidApplications, "android application"}};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests, OnlyReportDlpEvents) {
ResetTestConfig(false);
GetTestConfig().report_dlp_events = true;
- base::Value info = SetUpForReportingInfo();
+ base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {
{kManagementReportDlpEvents, "dlp events"}};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests, OnlyReportUsersDeviceReportingInfo) {
ResetTestConfig(false);
GetTestConfig().report_users = true;
- base::Value info = SetUpForReportingInfo();
+ base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {
{kManagementReportUsers, "supervised user"}};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests, AllDisabledDeviceReportingInfo) {
ResetTestConfig(false);
- const base::Value info = SetUpForReportingInfo();
+ const base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests,
DeviceReportingInfoWhenInsightsExtensionEnabled) {
ResetTestConfig(false);
GetTestConfig().insights_extension_enabled = true;
- const base::Value info = SetUpForReportingInfo();
+ const base::Value::List info = SetUpForReportingInfo();
const std::map<std::string, std::string> expected_elements = {
{kManagementReportActivityTimes, "device activity"},
{kManagementReportNetworkData, "device"}};
- ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info.GetListDeprecated(),
- expected_elements);
+ ASSERT_PRED_FORMAT2(ReportingElementsToBeEQ, info, expected_elements);
}
TEST_F(ManagementUIHandlerTests, ShowProxyServerDisclosure) {
ResetTestConfig();
// Set pref to use a proxy.
PrefProxyConfigTrackerImpl::RegisterProfilePrefs(user_prefs_.registry());
- chromeos::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
- &local_state_);
+ ash::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
+ &local_state_);
base::Value policy_prefs_config = ProxyConfigDictionary::CreateAutoDetect();
user_prefs_.SetUserPref(
proxy_config::prefs::kProxy,
@@ -1131,18 +1104,17 @@ TEST_F(ManagementUIHandlerTests, ProxyServerDisclosureDeviceOffline) {
ResetTestConfig();
// Simulate network disconnected state.
PrefProxyConfigTrackerImpl::RegisterProfilePrefs(user_prefs_.registry());
- chromeos::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
- &local_state_);
- chromeos::NetworkStateHandler::NetworkStateList networks;
- chromeos::NetworkHandler::Get()
- ->network_state_handler()
- ->GetNetworkListByType(chromeos::NetworkTypePattern::Default(),
- true, // configured_only
- false, // visible_only,
- 0, // no limit to number of results
- &networks);
- chromeos::ShillServiceClient::TestInterface* service =
- chromeos::ShillServiceClient::Get()->GetTestInterface();
+ ash::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
+ &local_state_);
+ ash::NetworkStateHandler::NetworkStateList networks;
+ ash::NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
+ ash::NetworkTypePattern::Default(),
+ true, // configured_only
+ false, // visible_only,
+ 0, // no limit to number of results
+ &networks);
+ ash::ShillServiceClient::TestInterface* service =
+ ash::ShillServiceClient::Get()->GetTestInterface();
for (const auto* const network : networks) {
service->SetServiceProperty(network->path(), shill::kStateProperty,
base::Value(shill::kStateOffline));
@@ -1154,15 +1126,15 @@ TEST_F(ManagementUIHandlerTests, ProxyServerDisclosureDeviceOffline) {
EXPECT_FALSE(GetShowProxyServerPrivacyDisclosure());
- chromeos::NetworkHandler::Get()->NetworkHandler::ShutdownPrefServices();
+ ash::NetworkHandler::Get()->NetworkHandler::ShutdownPrefServices();
}
TEST_F(ManagementUIHandlerTests, HideProxyServerDisclosureForDirectProxy) {
ResetTestConfig();
// Set pref not to use proxy.
PrefProxyConfigTrackerImpl::RegisterProfilePrefs(user_prefs_.registry());
- chromeos::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
- &local_state_);
+ ash::NetworkHandler::Get()->InitializePrefServices(&user_prefs_,
+ &local_state_);
base::Value policy_prefs_config = ProxyConfigDictionary::CreateDirect();
user_prefs_.SetUserPref(
proxy_config::prefs::kProxy,
@@ -1174,7 +1146,7 @@ TEST_F(ManagementUIHandlerTests, HideProxyServerDisclosureForDirectProxy) {
EXPECT_FALSE(GetShowProxyServerPrivacyDisclosure());
- chromeos::NetworkHandler::Get()->NetworkHandler::ShutdownPrefServices();
+ ash::NetworkHandler::Get()->NetworkHandler::ShutdownPrefServices();
}
#endif
@@ -1294,12 +1266,10 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
// When no policies are set, nothing to report.
auto info = handler_.GetThreatProtectionInfo(profile_no_domain.get());
- ASSERT_TRUE(info.is_dict());
- const base::Value::Dict* threat_protection_info = info.GetIfDict();
- EXPECT_TRUE(threat_protection_info->FindList("info")->empty());
+ EXPECT_TRUE(info.FindList("info")->empty());
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION),
- base::UTF8ToUTF16(*threat_protection_info->FindString("description")));
+ base::UTF8ToUTF16(*info.FindString("description")));
// When policies are set to uninteresting values, nothing to report.
SetConnectorPolicyValue(policy::key::kOnFileAttachedEnterpriseConnector, "[]",
@@ -1310,18 +1280,20 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
"[]", chrome_policies);
SetConnectorPolicyValue(policy::key::kOnPrintEnterpriseConnector, "[]",
chrome_policies);
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ SetConnectorPolicyValue(policy::key::kOnFileTransferEnterpriseConnector, "[]",
+ chrome_policies);
+#endif
SetConnectorPolicyValue(policy::key::kOnSecurityEventEnterpriseConnector,
"[]", chrome_policies);
profile_no_domain->GetPrefs()->SetInteger(
prefs::kSafeBrowsingEnterpriseRealTimeUrlCheckMode, 0);
info = handler_.GetThreatProtectionInfo(profile_no_domain.get());
- ASSERT_TRUE(info.is_dict());
- threat_protection_info = info.GetIfDict();
- EXPECT_TRUE(threat_protection_info->FindList("info")->empty());
+ EXPECT_TRUE(info.FindList("info")->empty());
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION),
- base::UTF8ToUTF16(*threat_protection_info->FindString("description")));
+ base::UTF8ToUTF16(*info.FindString("description")));
// When policies are set to values that enable the feature without a usable DM
// token, nothing to report.
@@ -1338,6 +1310,11 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
safe_browsing::SetAnalysisConnector(profile_no_domain->GetPrefs(),
enterprise_connectors::PRINT,
"[{\"service_provider\":\"google\"}]");
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ safe_browsing::SetAnalysisConnector(profile_no_domain->GetPrefs(),
+ enterprise_connectors::FILE_TRANSFER,
+ "[{\"service_provider\":\"google\"}]");
+#endif
safe_browsing::SetOnSecurityEventReporting(profile_no_domain->GetPrefs(),
true);
profile_no_domain->GetPrefs()->SetInteger(
@@ -1347,12 +1324,10 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
policy::POLICY_SCOPE_MACHINE);
info = handler_.GetThreatProtectionInfo(profile_no_domain.get());
- ASSERT_TRUE(info.is_dict());
- threat_protection_info = info.GetIfDict();
- EXPECT_TRUE(threat_protection_info->FindList("info")->empty());
+ EXPECT_TRUE(info.FindList("info")->empty());
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION),
- base::UTF8ToUTF16(*threat_protection_info->FindString("description")));
+ base::UTF8ToUTF16(*info.FindString("description")));
// When policies are set to values that enable the feature with a usable DM
// token, report them.
@@ -1360,12 +1335,15 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
policy::DMToken::CreateValidTokenForTesting("fake-token"));
info = handler_.GetThreatProtectionInfo(profile_no_domain.get());
- ASSERT_TRUE(info.is_dict());
- threat_protection_info = info.GetIfDict();
- EXPECT_EQ(6u, threat_protection_info->FindList("info")->size());
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ const size_t expected_size = 7u;
+#else
+ const size_t expected_size = 6u;
+#endif
+ EXPECT_EQ(expected_size, info.FindList("info")->size());
EXPECT_EQ(
l10n_util::GetStringUTF16(IDS_MANAGEMENT_THREAT_PROTECTION_DESCRIPTION),
- base::UTF8ToUTF16(*threat_protection_info->FindString("description")));
+ base::UTF8ToUTF16(*info.FindString("description")));
base::Value::List expected_info;
{
@@ -1392,6 +1370,14 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
value.Set("permission", kManagementOnPrintVisibleData);
expected_info.Append(std::move(value));
}
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {
+ base::Value::Dict value;
+ value.Set("title", kManagementOnFileTransferEvent);
+ value.Set("permission", kManagementOnFileTransferVisibleData);
+ expected_info.Append(std::move(value));
+ }
+#endif
{
base::Value::Dict value;
value.Set("title", kManagementEnterpriseReportingEvent);
@@ -1405,5 +1391,5 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
expected_info.Append(std::move(value));
}
- EXPECT_EQ(expected_info, *threat_protection_info->FindList("info"));
+ EXPECT_EQ(expected_info, *info.FindList("info"));
}
diff --git a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
index 008ef35dd46..c15dcfdc3f1 100644
--- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -104,7 +104,7 @@ class WebRtcLogsDOMHandler final : public WebUIMessageHandler {
using WebRtcEventLogManager = webrtc_event_logging::WebRtcEventLogManager;
// Asynchronously fetches the list of upload WebRTC logs. Called from JS.
- void HandleRequestWebRtcLogs(const base::ListValue* args);
+ void HandleRequestWebRtcLogs(const base::Value::List& args);
// Asynchronously load WebRTC text logs.
void LoadWebRtcTextLogs(const std::string& callback_id);
@@ -124,8 +124,8 @@ class WebRtcLogsDOMHandler final : public WebUIMessageHandler {
void UpdateUI(const std::string& callback_id);
// Update the text/event logs part of the forementioned page.
- base::Value UpdateUIWithTextLogs() const;
- base::Value UpdateUIWithEventLogs() const;
+ base::Value::List UpdateUIWithTextLogs() const;
+ base::Value::List UpdateUIWithEventLogs() const;
// Convert a history entry about a captured WebRTC event log into a
// Value of the type expected by updateWebRtcLogsList().
@@ -185,15 +185,15 @@ WebRtcLogsDOMHandler::~WebRtcLogsDOMHandler() {
void WebRtcLogsDOMHandler::RegisterMessages() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestWebRtcLogsList",
base::BindRepeating(&WebRtcLogsDOMHandler::HandleRequestWebRtcLogs,
base::Unretained(this)));
}
void WebRtcLogsDOMHandler::HandleRequestWebRtcLogs(
- const base::ListValue* args) {
- std::string callback_id = args->GetListDeprecated()[0].GetString();
+ const base::Value::List& args) {
+ std::string callback_id = args[0].GetString();
AllowJavascript();
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
LoadWebRtcTextLogs(callback_id);
@@ -244,28 +244,28 @@ void WebRtcLogsDOMHandler::OnWebRtcEventLogsLoaded(
void WebRtcLogsDOMHandler::UpdateUI(const std::string& callback_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value result(base::Value::Type::DICTIONARY);
- result.SetKey("textLogs", UpdateUIWithTextLogs());
- result.SetKey("eventLogs", UpdateUIWithEventLogs());
- result.SetKey("version", base::Value(version_info::GetVersionNumber()));
+ base::Value::Dict result;
+ result.Set("textLogs", UpdateUIWithTextLogs());
+ result.Set("eventLogs", UpdateUIWithEventLogs());
+ result.Set("version", version_info::GetVersionNumber());
ResolveJavascriptCallback(base::Value(callback_id), result);
}
-base::Value WebRtcLogsDOMHandler::UpdateUIWithTextLogs() const {
+base::Value::List WebRtcLogsDOMHandler::UpdateUIWithTextLogs() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value result(base::Value::Type::LIST);
+ base::Value::List result;
std::vector<UploadList::UploadInfo> uploads;
text_log_upload_list_->GetUploads(50, &uploads);
for (const auto& upload : uploads) {
- base::Value upload_value(base::Value::Type::DICTIONARY);
- upload_value.SetStringKey("id", upload.upload_id);
+ base::Value::Dict upload_value;
+ upload_value.Set("id", upload.upload_id);
std::u16string value_w;
if (!upload.upload_time.is_null())
value_w = base::TimeFormatFriendlyDateAndTime(upload.upload_time);
- upload_value.SetStringKey("upload_time", value_w);
+ upload_value.Set("upload_time", value_w);
std::string value;
if (!upload.local_id.empty()) {
@@ -273,7 +273,7 @@ base::Value WebRtcLogsDOMHandler::UpdateUIWithTextLogs() const {
.AddExtension(FILE_PATH_LITERAL(".gz"))
.AsUTF8Unsafe();
}
- upload_value.SetStringKey("local_file", value);
+ upload_value.Set("local_file", value);
// In october 2015, capture time was added to the log list, previously the
// local ID was used as capture time. The local ID has however changed so
@@ -305,16 +305,16 @@ base::Value WebRtcLogsDOMHandler::UpdateUIWithTextLogs() const {
// inform that the time is unknown.
if (value_w.empty())
value_w = std::u16string(u"(unknown time)");
- upload_value.SetStringKey("capture_time", value_w);
+ upload_value.Set("capture_time", value_w);
result.Append(std::move(upload_value));
}
return result;
}
-base::Value WebRtcLogsDOMHandler::UpdateUIWithEventLogs() const {
+base::Value::List WebRtcLogsDOMHandler::UpdateUIWithEventLogs() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value result(base::Value::Type::LIST);
+ base::Value::List result;
for (const auto& log : event_logs_) {
result.Append(EventLogUploadInfoToValue(log));
}
@@ -351,13 +351,13 @@ base::Value WebRtcLogsDOMHandler::FromPendingLog(
return base::Value();
}
- base::Value log(base::Value::Type::DICTIONARY);
- log.SetStringKey("state", "pending");
- log.SetStringKey("capture_time",
- base::TimeFormatFriendlyDateAndTime(info.capture_time));
- log.SetStringKey("local_file",
- event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
- return log;
+ base::Value::Dict log;
+ log.Set("state", "pending");
+ log.Set("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log.Set("local_file",
+ event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
+ return base::Value(std::move(log));
}
base::Value WebRtcLogsDOMHandler::FromActivelyUploadedLog(
@@ -369,13 +369,13 @@ base::Value WebRtcLogsDOMHandler::FromActivelyUploadedLog(
return base::Value();
}
- base::Value log(base::Value::Type::DICTIONARY);
- log.SetStringKey("state", "actively_uploaded");
- log.SetStringKey("capture_time",
- base::TimeFormatFriendlyDateAndTime(info.capture_time));
- log.SetStringKey("local_file",
- event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
- return log;
+ base::Value::Dict log;
+ log.Set("state", "actively_uploaded");
+ log.Set("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log.Set("local_file",
+ event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
+ return base::Value(std::move(log));
}
base::Value WebRtcLogsDOMHandler::FromNotUploadedLog(
@@ -387,12 +387,12 @@ base::Value WebRtcLogsDOMHandler::FromNotUploadedLog(
return base::Value();
}
- base::Value log(base::Value::Type::DICTIONARY);
- log.SetStringKey("state", "not_uploaded");
- log.SetStringKey("capture_time",
- base::TimeFormatFriendlyDateAndTime(info.capture_time));
- log.SetStringKey("local_id", info.local_id);
- return log;
+ base::Value::Dict log;
+ log.Set("state", "not_uploaded");
+ log.Set("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log.Set("local_id", info.local_id);
+ return base::Value(std::move(log));
}
base::Value WebRtcLogsDOMHandler::FromUploadUnsuccessfulLog(
@@ -409,14 +409,13 @@ base::Value WebRtcLogsDOMHandler::FromUploadUnsuccessfulLog(
return base::Value();
}
- base::Value log(base::Value::Type::DICTIONARY);
- log.SetStringKey("state", "upload_unsuccessful");
- log.SetStringKey("capture_time",
- base::TimeFormatFriendlyDateAndTime(info.capture_time));
- log.SetStringKey("local_id", info.local_id);
- log.SetStringKey("upload_time",
- base::TimeFormatFriendlyDateAndTime(info.upload_time));
- return log;
+ base::Value::Dict log;
+ log.Set("state", "upload_unsuccessful");
+ log.Set("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log.Set("local_id", info.local_id);
+ log.Set("upload_time", base::TimeFormatFriendlyDateAndTime(info.upload_time));
+ return base::Value(std::move(log));
}
base::Value WebRtcLogsDOMHandler::FromUploadSuccessfulLog(
@@ -433,15 +432,14 @@ base::Value WebRtcLogsDOMHandler::FromUploadSuccessfulLog(
return base::Value();
}
- base::Value log(base::Value::Type::DICTIONARY);
- log.SetStringKey("state", "upload_successful");
- log.SetStringKey("capture_time",
- base::TimeFormatFriendlyDateAndTime(info.capture_time));
- log.SetStringKey("local_id", info.local_id);
- log.SetStringKey("upload_id", info.upload_id);
- log.SetStringKey("upload_time",
- base::TimeFormatFriendlyDateAndTime(info.upload_time));
- return log;
+ base::Value::Dict log;
+ log.Set("state", "upload_successful");
+ log.Set("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log.Set("local_id", info.local_id);
+ log.Set("upload_id", info.upload_id);
+ log.Set("upload_time", base::TimeFormatFriendlyDateAndTime(info.upload_time));
+ return base::Value(std::move(log));
}
bool WebRtcLogsDOMHandler::SanityCheckOnUploadInfo(
diff --git a/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.cc b/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.cc
index 2fd1b7eb689..52fabfdc0b5 100644
--- a/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.cc
@@ -175,7 +175,7 @@ CastFeedbackUI::CastFeedbackUI(content::WebUI* web_ui)
content::WebUIDataSource::Add(profile_, source);
- web_ui->RegisterDeprecatedMessageCallback(
+ web_ui->RegisterMessageCallback(
"close", base::BindRepeating(&CastFeedbackUI::OnCloseMessage,
base::Unretained(this)));
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
@@ -185,7 +185,7 @@ WEB_UI_CONTROLLER_TYPE_IMPL(CastFeedbackUI)
CastFeedbackUI::~CastFeedbackUI() = default;
-void CastFeedbackUI::OnCloseMessage(const base::ListValue*) {
+void CastFeedbackUI::OnCloseMessage(const base::Value::List&) {
web_contents_->GetDelegate()->CloseContents(web_contents_);
}
diff --git a/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.h b/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.h
index 0139c225272..16b6a7a1742 100644
--- a/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.h
+++ b/chromium/chrome/browser/ui/webui/media_router/cast_feedback_ui.h
@@ -6,14 +6,11 @@
#define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_CAST_FEEDBACK_UI_H_
#include "base/memory/raw_ptr.h"
+#include "base/values.h"
#include "content/public/browser/web_ui_controller.h"
class Profile;
-namespace base {
-class ListValue;
-}
-
namespace content {
class WebContents;
class WebUI;
@@ -29,7 +26,7 @@ class CastFeedbackUI : public content::WebUIController {
~CastFeedbackUI() override;
private:
- void OnCloseMessage(const base::ListValue*);
+ void OnCloseMessage(const base::Value::List&);
const raw_ptr<Profile> profile_;
const raw_ptr<content::WebContents> web_contents_;
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
index ad791553250..84e5b3b9a32 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
@@ -11,14 +11,15 @@ namespace media_router {
namespace {
-base::Value CastProviderStateToValue(const mojom::CastProviderState& state) {
- base::Value result(base::Value::Type::LIST);
+base::Value::List CastProviderStateToValue(
+ const mojom::CastProviderState& state) {
+ base::Value::List result;
for (const mojom::CastSessionStatePtr& session : state.session_state) {
- base::Value session_value(base::Value::Type::DICTIONARY);
- session_value.SetStringKey("sink_id", session->sink_id);
- session_value.SetStringKey("app_id", session->app_id);
- session_value.SetStringKey("session_id", session->session_id);
- session_value.SetStringKey("route_description", session->route_description);
+ base::Value::Dict session_value;
+ session_value.Set("sink_id", session->sink_id);
+ session_value.Set("app_id", session->app_id);
+ session_value.Set("session_id", session->session_id);
+ session_value.Set("route_description", session->route_description);
result.Append(std::move(session_value));
}
return result;
@@ -90,12 +91,14 @@ void MediaRouterInternalsWebUIMessageHandler::HandleGetLogs(
void MediaRouterInternalsWebUIMessageHandler::OnProviderState(
base::Value callback_id,
mojom::ProviderStatePtr state) {
- base::Value result;
if (state && state->is_cast_provider_state() &&
state->get_cast_provider_state()) {
- result = CastProviderStateToValue(*(state->get_cast_provider_state()));
+ ResolveJavascriptCallback(
+ callback_id,
+ CastProviderStateToValue(*(state->get_cast_provider_state())));
+ } else {
+ ResolveJavascriptCallback(callback_id, base::Value());
}
- ResolveJavascriptCallback(callback_id, result);
}
} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
index 98ec33f0b2d..6ee58049ea5 100644
--- a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
@@ -101,10 +101,10 @@ std::string GetMessageString() {
}
// Generates one row of the returned process info.
-base::Value MakeProcessInfo(int pid, std::string description) {
- base::Value result(base::Value::Type::LIST);
- result.Append(base::Value(pid));
- result.Append(base::Value(std::move(description)));
+base::Value::List MakeProcessInfo(int pid, std::string description) {
+ base::Value::List result;
+ result.Append(pid);
+ result.Append(std::move(description));
return result;
}
@@ -139,20 +139,20 @@ class MemoryInternalsDOMHandler : public content::WebUIMessageHandler,
void RegisterMessages() override;
// Callback for the "requestProcessList" message.
- void HandleRequestProcessList(const base::ListValue* args);
+ void HandleRequestProcessList(const base::Value::List& args);
// Callback for the "saveDump" message.
- void HandleSaveDump(const base::ListValue* args);
+ void HandleSaveDump(const base::Value::List& args);
// Callback for the "reportProcess" message.
- void HandleReportProcess(const base::ListValue* args);
+ void HandleReportProcess(const base::Value::List& args);
// Callback for the "startProfiling" message.
- void HandleStartProfiling(const base::ListValue* args);
+ void HandleStartProfiling(const base::Value::List& args);
private:
void ReturnProcessListOnUIThread(const std::string& callback_id,
- std::vector<base::Value> children,
+ std::vector<base::Value::List> children,
std::vector<base::ProcessId> profiled_pids);
// SelectFileDialog::Listener implementation:
@@ -186,30 +186,30 @@ MemoryInternalsDOMHandler::~MemoryInternalsDOMHandler() {
void MemoryInternalsDOMHandler::RegisterMessages() {
// Unretained should be OK here since this class is bound to the lifetime of
// the WebUI.
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestProcessList",
base::BindRepeating(&MemoryInternalsDOMHandler::HandleRequestProcessList,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"saveDump",
base::BindRepeating(&MemoryInternalsDOMHandler::HandleSaveDump,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"reportProcess",
base::BindRepeating(&MemoryInternalsDOMHandler::HandleReportProcess,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"startProfiling",
base::BindRepeating(&MemoryInternalsDOMHandler::HandleStartProfiling,
base::Unretained(this)));
}
void MemoryInternalsDOMHandler::HandleRequestProcessList(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- std::string callback_id = args->GetListDeprecated()[0].GetString();
+ std::string callback_id = args[0].GetString();
- std::vector<base::Value> result;
+ std::vector<base::Value::List> result;
// The only non-renderer child processes that currently support out-of-process
// heap profiling are GPU and UTILITY.
@@ -239,7 +239,7 @@ void MemoryInternalsDOMHandler::HandleRequestProcessList(
weak_factory_.GetWeakPtr(), callback_id, std::move(result)));
}
-void MemoryInternalsDOMHandler::HandleSaveDump(const base::ListValue* args) {
+void MemoryInternalsDOMHandler::HandleSaveDump(const base::Value::List& args) {
base::FilePath default_file = base::FilePath().AppendASCII(
base::StringPrintf("trace_with_heap_dump.json.gz"));
@@ -275,17 +275,17 @@ void MemoryInternalsDOMHandler::HandleSaveDump(const base::ListValue* args) {
}
void MemoryInternalsDOMHandler::HandleReportProcess(
- const base::ListValue* args) {
+ const base::Value::List& args) {
// TODO(etienneb): Delete the use of this method.
}
void MemoryInternalsDOMHandler::HandleStartProfiling(
- const base::ListValue* args) {
+ const base::Value::List& args) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (!args->is_list() || args->GetListDeprecated().size() != 1)
+ if (args.size() != 1)
return;
- base::ProcessId pid = args->GetListDeprecated()[0].GetInt();
+ base::ProcessId pid = args[0].GetInt();
heap_profiling::Supervisor* supervisor =
heap_profiling::Supervisor::GetInstance();
if (supervisor->HasStarted()) {
@@ -299,15 +299,15 @@ void MemoryInternalsDOMHandler::HandleStartProfiling(
void MemoryInternalsDOMHandler::ReturnProcessListOnUIThread(
const std::string& callback_id,
- std::vector<base::Value> children,
+ std::vector<base::Value::List> children,
std::vector<base::ProcessId> profiled_pids) {
// This function will be called with the child processes that are not
// renderers. It will fill in the browser and renderer processes on the UI
// thread (RenderProcessHost is UI-thread only) and return the full list.
- std::vector<base::Value> process_list;
+ base::Value::List process_list;
// Add browser process.
- process_list.push_back(MakeProcessInfo(base::GetCurrentProcId(), "Browser"));
+ process_list.Append(MakeProcessInfo(base::GetCurrentProcId(), "Browser"));
// Append renderer processes.
auto iter = content::RenderProcessHost::AllHostsIterator();
@@ -317,35 +317,34 @@ void MemoryInternalsDOMHandler::ReturnProcessListOnUIThread(
if (renderer_pid != 0) {
// TODO(brettw) make a better description of the process, maybe see
// what TaskManager does to get the page title.
- process_list.push_back(MakeProcessInfo(renderer_pid, "Renderer"));
+ process_list.Append(MakeProcessInfo(renderer_pid, "Renderer"));
}
}
iter.Advance();
}
// Append all child processes collected on the IO thread.
- process_list.insert(process_list.end(),
- std::make_move_iterator(std::begin(children)),
- std::make_move_iterator(std::end(children)));
+ for (auto& child : children)
+ process_list.Append(std::move(child));
// Sort profiled_pids to allow binary_search in the loop.
std::sort(profiled_pids.begin(), profiled_pids.end());
// Append whether each process is being profiled.
for (base::Value& value : process_list) {
- DCHECK_EQ(value.GetListDeprecated().size(), 2u);
+ DCHECK_EQ(value.GetList().size(), 2u);
base::ProcessId pid =
- static_cast<base::ProcessId>(value.GetListDeprecated()[0].GetInt());
+ static_cast<base::ProcessId>(value.GetList()[0].GetInt());
bool is_profiled =
std::binary_search(profiled_pids.begin(), profiled_pids.end(), pid);
value.Append(is_profiled);
}
// Pass the results in a dictionary.
- base::Value result(base::Value::Type::DICTIONARY);
- result.SetKey("message", base::Value(GetMessageString()));
- result.SetKey("processes", base::Value(std::move(process_list)));
+ base::Value::Dict result;
+ result.Set("message", GetMessageString());
+ result.Set("processes", std::move(process_list));
ResolveJavascriptCallback(base::Value(callback_id), result);
}
diff --git a/chromium/chrome/browser/ui/webui/nacl_ui.cc b/chromium/chrome/browser/ui/webui/nacl_ui.cc
index 92291be5b3e..a6415c182e8 100644
--- a/chromium/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nacl_ui.cc
@@ -90,7 +90,7 @@ class NaClDomHandler : public WebUIMessageHandler {
private:
// Callback for the "requestNaClInfo" message.
- void HandleRequestNaClInfo(const base::ListValue* args);
+ void HandleRequestNaClInfo(const base::Value::List& args);
// Callback for the NaCl plugin information.
void OnGotPlugins(const std::vector<content::WebPluginInfo>& plugins);
@@ -105,7 +105,7 @@ class NaClDomHandler : public WebUIMessageHandler {
// Helper for MaybeRespondToPage -- called after enough information
// is gathered.
- void PopulatePageInformation(base::DictionaryValue* naclInfo);
+ base::Value::Dict GetPageInformation();
// Returns whether the specified plugin is enabled.
bool isPluginEnabled(size_t plugin_index);
@@ -147,7 +147,7 @@ NaClDomHandler::NaClDomHandler()
NaClDomHandler::~NaClDomHandler() = default;
void NaClDomHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestNaClInfo",
base::BindRepeating(&NaClDomHandler::HandleRequestNaClInfo,
base::Unretained(this)));
@@ -290,10 +290,10 @@ void NaClDomHandler::AddNaClInfo(base::ListValue* list) {
AddLineBreak(list);
}
-void NaClDomHandler::HandleRequestNaClInfo(const base::ListValue* args) {
+void NaClDomHandler::HandleRequestNaClInfo(const base::Value::List& args) {
CHECK(callback_id_.empty());
- CHECK_EQ(1U, args->GetListDeprecated().size());
- callback_id_ = args->GetListDeprecated()[0].GetString();
+ CHECK_EQ(1U, args.size());
+ callback_id_ = args[0].GetString();
if (!has_plugin_info_) {
PluginService::GetInstance()->GetPlugins(base::BindOnce(
@@ -314,8 +314,7 @@ void NaClDomHandler::OnGotPlugins(
MaybeRespondToPage();
}
-void NaClDomHandler::PopulatePageInformation(base::DictionaryValue* naclInfo) {
- DCHECK(pnacl_path_validated_);
+base::Value::Dict NaClDomHandler::GetPageInformation() {
// Store Key-Value pairs of about-information.
base::ListValue list;
// Display the operating system and chrome version information.
@@ -327,7 +326,9 @@ void NaClDomHandler::PopulatePageInformation(base::DictionaryValue* naclInfo) {
// Display information relevant to NaCl (non-portable.
AddNaClInfo(&list);
// naclInfo will take ownership of list, and clean it up on destruction.
- naclInfo->SetKey("naclInfo", std::move(list));
+ base::Value::Dict dict;
+ dict.Set("naclInfo", std::move(list));
+ return dict;
}
void NaClDomHandler::DidCheckPathAndVersion(const std::string* version,
@@ -383,9 +384,7 @@ void NaClDomHandler::MaybeRespondToPage() {
return;
}
- base::DictionaryValue naclInfo;
- PopulatePageInformation(&naclInfo);
- ResolveJavascriptCallback(base::Value(callback_id_), naclInfo);
+ ResolveJavascriptCallback(base::Value(callback_id_), GetPageInformation());
callback_id_.clear();
}
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
index 50ca67b7f82..c0daf10c7cd 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc
@@ -17,10 +17,10 @@
namespace {
-std::string FormatAsJSON(const base::Value& value) {
+std::string FormatListAsJSON(const base::Value::List& list) {
std::string json;
base::JSONWriter::WriteWithOptions(
- value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+ list, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return json;
}
@@ -41,7 +41,7 @@ const char kContactMessageNumUnreachableContactsKey[] =
// TODO(nohle): We should probably break up this dictionary into smaller
// dictionaries corresponding to each contact-manager observer functions. This
// will require changes at the javascript layer as well.
-base::Value ContactMessageToDictionary(
+base::Value::Dict ContactMessageToDictionary(
absl::optional<bool> did_contacts_change_since_last_upload,
const absl::optional<std::set<std::string>>& allowed_contact_ids,
const absl::optional<std::vector<nearbyshare::proto::ContactRecord>>&
@@ -55,29 +55,28 @@ base::Value ContactMessageToDictionary(
*did_contacts_change_since_last_upload);
}
if (allowed_contact_ids) {
- base::Value::ListStorage allowed_ids_list;
+ base::Value::List allowed_ids_list;
allowed_ids_list.reserve(allowed_contact_ids->size());
for (const auto& contact_id : *allowed_contact_ids) {
- allowed_ids_list.push_back(base::Value(contact_id));
+ allowed_ids_list.Append(contact_id);
}
dictionary.Set(kContactMessageAllowedIdsKey,
- FormatAsJSON(base::Value(std::move(allowed_ids_list))));
+ FormatListAsJSON(allowed_ids_list));
}
if (contacts) {
- base::Value::ListStorage contact_list;
+ base::Value::List contact_list;
contact_list.reserve(contacts->size());
for (const auto& contact : *contacts)
- contact_list.push_back(
- base::Value(ContactRecordToReadableDictionary(contact)));
+ contact_list.Append(ContactRecordToReadableDictionary(contact));
dictionary.Set(kContactMessageContactRecordKey,
- FormatAsJSON(base::Value(std::move(contact_list))));
+ FormatListAsJSON(contact_list));
}
if (num_unreachable_contacts_filtered_out.has_value()) {
dictionary.Set(kContactMessageNumUnreachableContactsKey,
int(*num_unreachable_contacts_filtered_out));
}
- return base::Value(std::move(dictionary));
+ return dictionary;
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
index baf334907a9..5a01640a227 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc
@@ -56,15 +56,15 @@ const char kHttpMessageDirectionKey[] = "direction";
// Converts a RPC request/response to a raw dictionary value used as a
// JSON argument to JavaScript functions.
-base::Value HttpMessageToDictionary(const base::Value& message,
- Direction dir,
- Rpc rpc) {
+base::Value::Dict HttpMessageToDictionary(const base::Value& message,
+ Direction dir,
+ Rpc rpc) {
base::Value::Dict dictionary;
dictionary.Set(kHttpMessageBodyKey, FormatAsJSON(message));
dictionary.Set(kHttpMessageTimeKey, GetJavascriptTimestamp());
dictionary.Set(kHttpMessageRpcKey, static_cast<int>(rpc));
dictionary.Set(kHttpMessageDirectionKey, static_cast<int>(dir));
- return base::Value(std::move(dictionary));
+ return dictionary;
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
index 41b7f6dfd4c..ec7352eee52 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc
@@ -20,7 +20,8 @@ const char kLogMessageSeverityKey[] = "severity";
// Converts |log_message| to a raw dictionary value used as a JSON argument to
// JavaScript functions.
-base::Value LogMessageToDictionary(const LogBuffer::LogMessage& log_message) {
+base::Value::Dict LogMessageToDictionary(
+ const LogBuffer::LogMessage& log_message) {
base::Value::Dict dictionary;
dictionary.Set(kLogMessageTextKey, log_message.text);
dictionary.Set(kLogMessageTimeKey,
@@ -28,7 +29,7 @@ base::Value LogMessageToDictionary(const LogBuffer::LogMessage& log_message) {
dictionary.Set(kLogMessageFileKey, log_message.file);
dictionary.Set(kLogMessageLineKey, log_message.line);
dictionary.Set(kLogMessageSeverityKey, log_message.severity);
- return base::Value(std::move(dictionary));
+ return dictionary;
}
} // namespace
@@ -37,7 +38,7 @@ NearbyInternalsLogsHandler::NearbyInternalsLogsHandler() {}
NearbyInternalsLogsHandler::~NearbyInternalsLogsHandler() = default;
void NearbyInternalsLogsHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getLogMessages",
base::BindRepeating(&NearbyInternalsLogsHandler::HandleGetLogMessages,
base::Unretained(this)));
@@ -52,10 +53,10 @@ void NearbyInternalsLogsHandler::OnJavascriptDisallowed() {
}
void NearbyInternalsLogsHandler::HandleGetLogMessages(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- const base::Value& callback_id = args->GetListDeprecated()[0];
- base::Value list(base::Value::Type::LIST);
+ const base::Value& callback_id = args[0];
+ base::Value::List list;
for (const auto& log : *LogBuffer::GetInstance()->logs()) {
list.Append(LogMessageToDictionary(log));
}
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
index 48b69272700..19209ae47c5 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h
@@ -11,10 +11,6 @@
#include "chrome/browser/nearby_sharing/logging/logging.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class Value;
-}
-
// WebUIMessageHandler for the NS_LOG Macro to pass logging messages to the
// chrome://nearby-internals logging tab.
class NearbyInternalsLogsHandler : public content::WebUIMessageHandler,
@@ -37,10 +33,10 @@ class NearbyInternalsLogsHandler : public content::WebUIMessageHandler,
void OnLogBufferCleared() override;
// Message handler callback that returns the Log Buffer in dictionary form.
- void HandleGetLogMessages(const base::ListValue* args);
+ void HandleGetLogMessages(const base::Value::List& args);
// Message handler callback that clears the Log Buffer.
- void ClearLogBuffer(const base::ListValue* args);
+ void ClearLogBuffer(const base::Value::List& args);
base::ScopedObservation<LogBuffer, LogBuffer::Observer> observation_{this};
base::WeakPtrFactory<NearbyInternalsLogsHandler> weak_ptr_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc
index 424c3ae4735..4e13204c00a 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc
@@ -167,44 +167,44 @@ std::string TransferUpdateMetaDataToString(
// Converts |status_code| to a raw dictionary value used as a JSON argument
// to JavaScript functions.
-base::Value StatusCodeToDictionary(
+base::Value::Dict StatusCodeToDictionary(
const NearbySharingService::StatusCodes status_code,
TriggerEvent trigger_event) {
base::Value::Dict dictionary;
dictionary.Set(kStatusCodeKey, StatusCodeToString(status_code));
dictionary.Set(kTriggerEventKey, TriggerEventToString(trigger_event));
dictionary.Set(kTimeStampKey, GetJavascriptTimestamp());
- return base::Value(std::move(dictionary));
+ return dictionary;
}
// Converts |share_target| to a raw dictionary value used as a JSON argument
// to JavaScript functions.
-base::Value ShareTargetToDictionary(const ShareTarget share_target) {
+base::Value::Dict ShareTargetToDictionary(const ShareTarget share_target) {
base::Value::Dict share_target_dictionary;
share_target_dictionary.Set(kShareTargetDeviceNamesKey,
share_target.device_name);
share_target_dictionary.Set(kShareTargetIdKey, share_target.id.ToString());
share_target_dictionary.Set(kTimeStampKey, GetJavascriptTimestamp());
- return base::Value(std::move(share_target_dictionary));
+ return share_target_dictionary;
}
// Converts |id_to_share_target_map| to a raw dictionary value used as a JSON
// argument to JavaScript functions.
-base::Value ShareTargetMapToList(
+base::Value::List ShareTargetMapToList(
const base::flat_map<std::string, ShareTarget>& id_to_share_target_map) {
- base::Value::ListStorage share_target_list;
+ base::Value::List share_target_list;
share_target_list.reserve(id_to_share_target_map.size());
for (const auto& it : id_to_share_target_map) {
- share_target_list.push_back(ShareTargetToDictionary(it.second));
+ share_target_list.Append(ShareTargetToDictionary(it.second));
}
- return base::Value(share_target_list);
+ return share_target_list;
}
// Converts |transfer_metadata| to a raw dictionary value used as a JSON
// argument to JavaScript functions.
-base::Value TransferUpdateToDictionary(
+base::Value::Dict TransferUpdateToDictionary(
const ShareTarget& share_target,
const TransferMetadata& transfer_metadata) {
base::Value::Dict dictionary;
@@ -213,15 +213,15 @@ base::Value TransferUpdateToDictionary(
dictionary.Set(kTimeStampKey, GetJavascriptTimestamp());
dictionary.Set(kShareTargetDeviceNamesKey, share_target.device_name);
dictionary.Set(kShareTargetIdKey, share_target.id.ToString());
- return base::Value(std::move(dictionary));
+ return dictionary;
}
-base::Value StatusBooleansToDictionary(const bool is_scanning,
- const bool is_transferring,
- const bool is_receiving_files,
- const bool is_sending_files,
- const bool is_conecting,
- const bool is_in_high_visibility) {
+base::Value::Dict StatusBooleansToDictionary(const bool is_scanning,
+ const bool is_transferring,
+ const bool is_receiving_files,
+ const bool is_sending_files,
+ const bool is_conecting,
+ const bool is_in_high_visibility) {
base::Value::Dict dictionary;
dictionary.Set(kIsScanning, is_scanning);
dictionary.Set(kIsTransferring, is_transferring);
@@ -230,7 +230,7 @@ base::Value StatusBooleansToDictionary(const bool is_scanning,
dictionary.Set(kIsConnecting, is_conecting);
dictionary.Set(kIsInHighVisibility, is_in_high_visibility);
dictionary.Set(kTimeStampKey, GetJavascriptTimestamp());
- return base::Value(std::move(dictionary));
+ return dictionary;
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/quick_pair/quick_pair_handler.cc b/chromium/chrome/browser/ui/webui/nearby_internals/quick_pair/quick_pair_handler.cc
index dd7392bc00f..8af9441b929 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/quick_pair/quick_pair_handler.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/quick_pair/quick_pair_handler.cc
@@ -35,7 +35,7 @@ const char kImageUrl[] =
// Converts |log_message| to a raw dictionary value used as a JSON argument to
// JavaScript functions.
-base::Value LogMessageToDictionary(
+base::Value::Dict LogMessageToDictionary(
const ash::quick_pair::LogBuffer::LogMessage& log_message) {
base::Value::Dict dictionary;
dictionary.Set(kLogMessageTextKey, log_message.text);
@@ -44,7 +44,7 @@ base::Value LogMessageToDictionary(
dictionary.Set(kLogMessageFileKey, log_message.file);
dictionary.Set(kLogMessageLineKey, log_message.line);
dictionary.Set(kLogMessageSeverityKey, log_message.severity);
- return base::Value(std::move(dictionary));
+ return dictionary;
}
} // namespace
@@ -99,7 +99,7 @@ void QuickPairHandler::OnJavascriptDisallowed() {
void QuickPairHandler::HandleGetLogMessages(const base::Value::List& args) {
AllowJavascript();
const base::Value& callback_id = args[0];
- base::Value list(base::Value::Type::LIST);
+ base::Value::List list;
for (const auto& log : *ash::quick_pair::LogBuffer::GetInstance()->logs()) {
list.Append(LogMessageToDictionary(log));
}
diff --git a/chromium/chrome/browser/ui/webui/net_export_ui.cc b/chromium/chrome/browser/ui/webui/net_export_ui.cc
index c296f400d80..24e847c5ff1 100644
--- a/chromium/chrome/browser/ui/webui/net_export_ui.cc
+++ b/chromium/chrome/browser/ui/webui/net_export_ui.cc
@@ -98,11 +98,11 @@ class NetExportMessageHandler
void RegisterMessages() override;
// Messages
- void OnEnableNotifyUIWithState(const base::ListValue* list);
- void OnStartNetLog(const base::ListValue* list);
- void OnStopNetLog(const base::ListValue* list);
- void OnSendNetLog(const base::ListValue* list);
- void OnShowFile(const base::ListValue* list);
+ void OnEnableNotifyUIWithState(const base::Value::List& list);
+ void OnStartNetLog(const base::Value::List& list);
+ void OnStopNetLog(const base::Value::List& list);
+ void OnSendNetLog(const base::Value::List& list);
+ void OnShowFile(const base::Value::List& list);
// ui::SelectFileDialog::Listener implementation.
void FileSelected(const base::FilePath& path,
@@ -111,7 +111,7 @@ class NetExportMessageHandler
void FileSelectionCanceled(void* params) override;
// net_log::NetExportFileWriter::StateObserver implementation.
- void OnNewState(const base::DictionaryValue& state) override;
+ void OnNewState(const base::Value::Dict& state) override;
private:
// Send NetLog data via email.
@@ -136,7 +136,7 @@ class NetExportMessageHandler
// Fires net-log-info-changed event to update the JavaScript UI in the
// renderer.
- void NotifyUIWithState(std::unique_ptr<base::DictionaryValue> state);
+ void NotifyUIWithState(const base::Value::Dict& state);
// Opens the SelectFileDialog UI with the default path to save a
// NetLog file.
@@ -179,23 +179,23 @@ NetExportMessageHandler::~NetExportMessageHandler() {
void NetExportMessageHandler::RegisterMessages() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
net_log::kEnableNotifyUIWithStateHandler,
base::BindRepeating(&NetExportMessageHandler::OnEnableNotifyUIWithState,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
net_log::kStartNetLogHandler,
base::BindRepeating(&NetExportMessageHandler::OnStartNetLog,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
net_log::kStopNetLogHandler,
base::BindRepeating(&NetExportMessageHandler::OnStopNetLog,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
net_log::kSendNetLogHandler,
base::BindRepeating(&NetExportMessageHandler::OnSendNetLog,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
net_log::kShowFile,
base::BindRepeating(&NetExportMessageHandler::OnShowFile,
base::Unretained(this)));
@@ -205,7 +205,7 @@ void NetExportMessageHandler::RegisterMessages() {
// After this function, NotifyUIWithState() will be called on all |file_writer_|
// state changes.
void NetExportMessageHandler::OnEnableNotifyUIWithState(
- const base::ListValue* list) {
+ const base::Value::List& list) {
AllowJavascript();
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!state_observation_manager_.IsObserving()) {
@@ -214,11 +214,9 @@ void NetExportMessageHandler::OnEnableNotifyUIWithState(
NotifyUIWithState(file_writer_->GetState());
}
-void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
+void NetExportMessageHandler::OnStartNetLog(const base::Value::List& params) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::Value::ConstListView params = list->GetListDeprecated();
-
// Determine the capture mode.
capture_mode_ = net::NetLogCaptureMode::kDefault;
if (!params.empty() && params[0].is_string()) {
@@ -245,7 +243,7 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
}
}
-void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
+void NetExportMessageHandler::OnStopNetLog(const base::Value::List& list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::Value::Dict ui_thread_polled_data;
@@ -263,13 +261,13 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
file_writer_->StopNetLog(std::move(ui_thread_polled_data));
}
-void NetExportMessageHandler::OnSendNetLog(const base::ListValue* list) {
+void NetExportMessageHandler::OnSendNetLog(const base::Value::List& list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
file_writer_->GetFilePathToCompletedLog(
base::BindOnce(&NetExportMessageHandler::SendEmail));
}
-void NetExportMessageHandler::OnShowFile(const base::ListValue* list) {
+void NetExportMessageHandler::OnShowFile(const base::Value::List& list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
file_writer_->GetFilePathToCompletedLog(
base::BindOnce(&NetExportMessageHandler::ShowFileInShell, AsWeakPtr()));
@@ -294,8 +292,8 @@ void NetExportMessageHandler::FileSelectionCanceled(void* params) {
select_file_dialog_ = nullptr;
}
-void NetExportMessageHandler::OnNewState(const base::DictionaryValue& state) {
- NotifyUIWithState(state.CreateDeepCopy());
+void NetExportMessageHandler::OnNewState(const base::Value::Dict& state) {
+ NotifyUIWithState(state);
}
// static
@@ -349,10 +347,10 @@ bool NetExportMessageHandler::UsingMobileUI() {
}
void NetExportMessageHandler::NotifyUIWithState(
- std::unique_ptr<base::DictionaryValue> state) {
+ const base::Value::Dict& state) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(web_ui());
- FireWebUIListener(net_log::kNetLogInfoChangedEvent, *state);
+ FireWebUIListener(net_log::kNetLogInfoChangedEvent, state);
}
void NetExportMessageHandler::ShowSelectFileDialog(
diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index 30cb87891fe..1c147c98ebd 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -10,8 +10,10 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
+#include "base/containers/unique_ptr_adapters.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/types/expected.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
@@ -24,9 +26,18 @@
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "net/base/address_list.h"
+#include "net/base/host_port_pair.h"
+#include "net/base/ip_endpoint.h"
+#include "net/base/net_errors.h"
+#include "net/base/network_isolation_key.h"
+#include "net/dns/public/resolve_error_info.h"
#include "services/network/expect_ct_reporter.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
+#include "services/network/public/mojom/host_resolver.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/resources/grit/webui_generated_resources.h"
using content::BrowserThread;
@@ -41,7 +52,8 @@ content::WebUIDataSource* CreateNetInternalsHTMLSource() {
source->SetDefaultResource(IDR_NET_INTERNALS_INDEX_HTML);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
+ "script-src chrome://resources chrome://test chrome://webui-test "
+ "'self';");
source->AddResourcePath("test_loader_util.js",
IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
source->DisableTrustedTypesCSP();
@@ -50,6 +62,73 @@ content::WebUIDataSource* CreateNetInternalsHTMLSource() {
void IgnoreBoolCallback(bool result) {}
+// This function converts net::AddressList to base::Value.
+base::Value AddressListToBaseValue(
+ const std::vector<net::IPEndPoint>& resolved_addresses) {
+ base::Value::List resolved_addresses_base_val_list;
+ for (const net::IPEndPoint& resolved_address : resolved_addresses) {
+ resolved_addresses_base_val_list.Append(
+ resolved_address.ToStringWithoutPort());
+ }
+ return base::Value(std::move(resolved_addresses_base_val_list));
+}
+
+using ResolveHostResult = base::expected<base::Value, std::string>;
+
+// This class implements network::mojom::ResolveHostClient.
+class NetInternalsResolveHostClient : public network::mojom::ResolveHostClient {
+ public:
+ using Callback =
+ base::OnceCallback<void(const net::ResolveErrorInfo&,
+ const absl::optional<net::AddressList>&,
+ NetInternalsResolveHostClient*)>;
+
+ NetInternalsResolveHostClient(
+ mojo::PendingReceiver<network::mojom::ResolveHostClient> receiver,
+ Callback callback)
+ : receiver_(this, std::move(receiver)), callback_(std::move(callback)) {
+ receiver_.set_disconnect_handler(
+ base::BindOnce(&NetInternalsResolveHostClient::OnComplete,
+ base::Unretained(this), net::ERR_FAILED,
+ net::ResolveErrorInfo(net::ERR_FAILED), absl::nullopt));
+ }
+ ~NetInternalsResolveHostClient() override = default;
+
+ NetInternalsResolveHostClient(const NetInternalsResolveHostClient&) = delete;
+ NetInternalsResolveHostClient& operator=(
+ const NetInternalsResolveHostClient&) = delete;
+
+ private:
+ // network::mojom::ResolveHostClient:
+ void OnComplete(
+ int32_t error,
+ const net::ResolveErrorInfo& resolve_error_info,
+ const absl::optional<net::AddressList>& resolved_addresses) override {
+ std::move(callback_).Run(resolve_error_info, resolved_addresses, this);
+ }
+ void OnTextResults(const std::vector<std::string>& text_results) override {
+ NOTREACHED();
+ }
+ void OnHostnameResults(const std::vector<net::HostPortPair>& hosts) override {
+ NOTREACHED();
+ }
+
+ // This function converts net::AddressList to base::Value.
+ static base::Value AddressListToBaseValue(
+ const std::vector<net::IPEndPoint>& resolved_addresses) {
+ base::Value::List resolved_addresses_base_val_list;
+ for (const net::IPEndPoint& resolved_address : resolved_addresses) {
+ resolved_addresses_base_val_list.Append(
+ resolved_address.ToStringWithoutPort());
+ }
+ return base::Value(std::move(resolved_addresses_base_val_list));
+ }
+
+ private:
+ mojo::Receiver<network::mojom::ResolveHostClient> receiver_;
+ Callback callback_;
+};
+
// This class receives javascript messages from the renderer.
// Note that the WebUI infrastructure runs on the UI thread, therefore all of
// this class's methods are expected to run on the UI thread.
@@ -74,7 +153,7 @@ class NetInternalsMessageHandler : public content::WebUIMessageHandler {
// Resolve JS |callback_id| with |result|.
// If the renderer is displaying a log file, the message will be ignored.
void ResolveCallbackWithResult(const std::string& callback_id,
- base::Value result);
+ base::Value::Dict result);
void OnExpectCTTestReportCallback(const std::string& callback_id,
bool success);
@@ -85,6 +164,7 @@ class NetInternalsMessageHandler : public content::WebUIMessageHandler {
void OnReloadProxySettings(const base::Value::List& list);
void OnClearBadProxies(const base::Value::List& list);
+ void OnResolveHost(const base::Value::List& list);
void OnClearHostResolverCache(const base::Value::List& list);
void OnDomainSecurityPolicyDelete(const base::Value::List& list);
void OnHSTSQuery(const base::Value::List& list);
@@ -94,8 +174,15 @@ class NetInternalsMessageHandler : public content::WebUIMessageHandler {
void OnExpectCTTestReport(const base::Value::List& list);
void OnCloseIdleSockets(const base::Value::List& list);
void OnFlushSocketPools(const base::Value::List& list);
+ void OnResolveHostDone(const std::string& callback_id,
+ const net::ResolveErrorInfo&,
+ const absl::optional<net::AddressList>&,
+ NetInternalsResolveHostClient* dns_lookup_client);
raw_ptr<content::WebUI> web_ui_;
+ std::set<std::unique_ptr<NetInternalsResolveHostClient>,
+ base::UniquePtrComparator>
+ dns_lookup_clients_;
base::WeakPtrFactory<NetInternalsMessageHandler> weak_factory_{this};
};
@@ -114,6 +201,10 @@ void NetInternalsMessageHandler::RegisterMessages() {
base::BindRepeating(&NetInternalsMessageHandler::OnClearBadProxies,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "resolveHost",
+ base::BindRepeating(&NetInternalsMessageHandler::OnResolveHost,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"clearHostResolverCache",
base::BindRepeating(&NetInternalsMessageHandler::OnClearHostResolverCache,
base::Unretained(this)));
@@ -164,6 +255,30 @@ void NetInternalsMessageHandler::OnClearBadProxies(
GetNetworkContext()->ClearBadProxiesCache(base::NullCallback());
}
+void NetInternalsMessageHandler::OnResolveHost(const base::Value::List& list) {
+ const std::string* callback_id = list[0].GetIfString();
+ const std::string* hostname = list[1].GetIfString();
+ DCHECK(callback_id);
+ DCHECK(hostname);
+
+ const net::HostPortPair host_port_pair(*hostname, 0);
+ const url::Origin origin = url::Origin::Create(GURL("https://" + *hostname));
+ AllowJavascript();
+
+ // When ResolveHost() in network process completes, OnResolveHostDone() method
+ // is called.
+ mojo::PendingReceiver<network::mojom::ResolveHostClient> receiver;
+ GetNetworkContext()->ResolveHost(host_port_pair, net::NetworkIsolationKey(),
+ /*optional_parameters=*/nullptr,
+ receiver.InitWithNewPipeAndPassRemote());
+
+ auto callback = base::BindOnce(&NetInternalsMessageHandler::OnResolveHostDone,
+ weak_factory_.GetWeakPtr(), *callback_id);
+ auto dns_lookup_client = std::make_unique<NetInternalsResolveHostClient>(
+ std::move(receiver), std::move(callback));
+ dns_lookup_clients_.insert(std::move(dns_lookup_client));
+}
+
void NetInternalsMessageHandler::OnClearHostResolverCache(
const base::Value::List& list) {
GetNetworkContext()->ClearHostCache(/*filter=*/nullptr, base::NullCallback());
@@ -196,7 +311,7 @@ void NetInternalsMessageHandler::OnHSTSQuery(const base::Value::List& list) {
void NetInternalsMessageHandler::ResolveCallbackWithResult(
const std::string& callback_id,
- base::Value result) {
+ base::Value::Dict result) {
ResolveJavascriptCallback(base::Value(callback_id), result);
}
@@ -267,7 +382,8 @@ void NetInternalsMessageHandler::OnExpectCTTestReport(
GURL report_uri(*report_uri_str);
AllowJavascript();
if (!report_uri.is_valid()) {
- ResolveCallbackWithResult(*callback_id, base::Value("invalid"));
+ ResolveJavascriptCallback(base::Value(*callback_id),
+ base::Value("invalid"));
return;
}
@@ -280,8 +396,9 @@ void NetInternalsMessageHandler::OnExpectCTTestReport(
void NetInternalsMessageHandler::OnExpectCTTestReportCallback(
const std::string& callback_id,
bool success) {
- ResolveCallbackWithResult(
- callback_id, success ? base::Value("success") : base::Value("failure"));
+ ResolveJavascriptCallback(
+ base::Value(callback_id),
+ success ? base::Value("success") : base::Value("failure"));
}
void NetInternalsMessageHandler::OnFlushSocketPools(
@@ -294,6 +411,27 @@ void NetInternalsMessageHandler::OnCloseIdleSockets(
GetNetworkContext()->CloseIdleConnections(base::NullCallback());
}
+void NetInternalsMessageHandler::OnResolveHostDone(
+ const std::string& callback_id,
+ const net::ResolveErrorInfo& resolve_error_info,
+ const absl::optional<net::AddressList>& resolved_addresses,
+ NetInternalsResolveHostClient* dns_lookup_client) {
+ DCHECK_EQ(dns_lookup_clients_.count(dns_lookup_client), 1u);
+
+ if (resolved_addresses) {
+ const base::Value result =
+ AddressListToBaseValue(resolved_addresses->endpoints());
+ ResolveJavascriptCallback(base::Value(callback_id), result);
+ } else {
+ const base::Value result =
+ base::Value(net::ErrorToString(resolve_error_info.error));
+ RejectJavascriptCallback(base::Value(callback_id), result);
+ }
+
+ auto it = dns_lookup_clients_.find(dns_lookup_client);
+ dns_lookup_clients_.erase(it);
+}
+
network::mojom::NetworkContext*
NetInternalsMessageHandler::GetNetworkContext() {
return web_ui_->GetWebContents()
diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc
index 4a5281fe68c..c555d836c40 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc
@@ -254,7 +254,10 @@ NetInternalsTest::~NetInternalsTest() {
void NetInternalsTest::SetUpOnMainThread() {
WebUIBrowserTest::SetUpOnMainThread();
- host_resolver()->AddRule("*", "127.0.0.1");
+ host_resolver()->AddRule("*.com", "127.0.0.1");
+ // TODO(crbug.com/1351249): Enable this test after making
+ // RuleBasedHostResolverProc support multiple addresses.
+ // host_resolver()->AddRule("multihost.org", "127.0.0.2,127.0.0.3,127.0.0.4");
}
content::WebUIMessageHandler* NetInternalsTest::GetMockMessageHandler() {
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn b/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn
index d55e81bc3d8..e15ab8609de 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(!is_android)
+
mojom("mojo_bindings") {
sources = [ "new_tab_page.mojom" ]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS b/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
index cb3e1277358..9154f32f1b2 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
@@ -1,7 +1,8 @@
mahmadi@chromium.org
+pauladedeji@google.com
+romanarora@chromium.org
tiborg@chromium.org
tluk@chromium.org
-romanarora@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
index 6ea9c4a25be..20ea40a8a78 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
@@ -54,8 +54,6 @@ struct BackgroundImage {
struct Theme {
skia.mojom.SkColor text_color;
skia.mojom.SkColor background_color;
- // True if the theme is default.
- bool is_default;
// True if the background is custom.
bool is_custom_background;
// True if the theme is dark (e.g. NTP background color is dark).
@@ -251,6 +249,10 @@ interface PageHandler {
ChooseLocalCustomBackground() => (bool success);
// Get the middle slot promo if it exists.
GetPromo() => (Promo? promo);
+ // Marks a promo as blocked.
+ BlocklistPromo(string promo_id);
+ // Unmarks a promo as blocked.
+ UndoBlocklistPromo(string promo_id);
// Called when a module the given id is dismissed.
OnDismissModule(string module_id);
// Called when a module the given id is restored.
@@ -276,6 +278,8 @@ interface PageHandler {
UpdateModulesFreVisibility();
// Log user's FRE |optInStatus|.
LogModulesFreOptInStatus(OptInStatus opt_in_status);
+ // Shows customize chrome in unified side panel.
+ ShowCustomizeChromeSidePanel();
// ======= METRICS =======
// Logs that the One Google Bar was added to the DOM / loaded in an iframe at
@@ -312,6 +316,8 @@ interface PageHandler {
// WebUI-side handler for requests from the browser.
interface Page {
+ // Called when the customize chrome side panel is shown/hidden.
+ CustomizeChromeSidePanelVisibilityChanged(bool visible);
// Sets the current theme.
SetTheme(Theme theme);
// Disables the modules in |ids|. If |all|, disables all modules and passes an
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
index bf98e848f78..03d7f0511f0 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
@@ -28,7 +28,6 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/browser_features.h"
#include "chrome/browser/new_tab_page/promos/promo_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/background/ntp_background_service.h"
@@ -41,7 +40,7 @@
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/hats/hats_service.h"
#include "chrome/browser/ui/hats/hats_service_factory.h"
-#include "chrome/browser/ui/omnibox/omnibox_theme.h"
+#include "chrome/browser/ui/side_panel/customize_chrome/customize_chrome_tab_helper.h"
#include "chrome/browser/ui/webui/new_tab_page/ntp_pref_names.h"
#include "chrome/browser/ui/webui/realbox/realbox.mojom.h"
#include "chrome/browser/ui/webui/webui_util.h"
@@ -149,7 +148,6 @@ new_tab_page::mojom::ThemePtr MakeTheme(
ntp_custom_background_service
? ntp_custom_background_service->GetCustomBackground()
: absl::nullopt;
- theme->is_default = theme_service->UsingDefaultTheme();
theme->background_color = color_provider.GetColor(kColorNewTabPageBackground);
SkColor text_color;
if (custom_background.has_value()) {
@@ -261,47 +259,36 @@ new_tab_page::mojom::ThemePtr MakeTheme(
theme->most_visited = std::move(most_visited);
auto search_box = realbox::mojom::SearchBoxTheme::New();
- search_box->bg =
- GetOmniboxColor(theme_provider, OmniboxPart::LOCATION_BAR_BACKGROUND);
+ search_box->bg = color_provider.GetColor(kColorNewTabPageSearchBoxBackground);
search_box->bg_hovered =
- GetOmniboxColor(theme_provider, OmniboxPart::LOCATION_BAR_BACKGROUND,
- OmniboxPartState::HOVERED);
+ color_provider.GetColor(kColorNewTabPageSearchBoxBackgroundHovered);
search_box->border_color =
webui::GetNativeTheme(web_contents)->UserHasContrastPreference()
- ? theme_provider->GetColor(ThemeProperties::COLOR_LOCATION_BAR_BORDER)
+ ? color_provider.GetColor(kColorLocationBarBorder)
: SkColorSetRGB(218, 220, 224); // google-grey-300
- search_box->icon = GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_ICON);
- search_box->icon_selected = GetOmniboxColor(
- theme_provider, OmniboxPart::RESULTS_ICON, OmniboxPartState::SELECTED);
+ search_box->icon = color_provider.GetColor(kColorOmniboxResultsIcon);
+ search_box->icon_selected =
+ color_provider.GetColor(kColorOmniboxResultsIconSelected);
search_box->is_dark = !color_utils::IsDark(text_color);
search_box->ntp_bg = color_provider.GetColor(kColorNewTabPageBackground);
- search_box->placeholder =
- GetOmniboxColor(theme_provider, OmniboxPart::LOCATION_BAR_TEXT_DIMMED);
+ search_box->placeholder = color_provider.GetColor(kColorOmniboxTextDimmed);
search_box->results_bg =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_BACKGROUND);
+ color_provider.GetColor(kColorOmniboxResultsBackground);
search_box->results_bg_hovered =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_BACKGROUND,
- OmniboxPartState::HOVERED);
+ color_provider.GetColor(kColorOmniboxResultsBackgroundHovered);
search_box->results_bg_selected =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_BACKGROUND,
- OmniboxPartState::SELECTED);
+ color_provider.GetColor(kColorOmniboxResultsBackgroundSelected);
search_box->results_dim =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_DIMMED);
+ color_provider.GetColor(kColorOmniboxResultsTextDimmed);
search_box->results_dim_selected =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_DIMMED,
- OmniboxPartState::SELECTED);
- search_box->results_text =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_DEFAULT);
+ color_provider.GetColor(kColorOmniboxResultsTextDimmedSelected);
+ search_box->results_text = color_provider.GetColor(kColorOmniboxText);
search_box->results_text_selected =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_DEFAULT,
- OmniboxPartState::SELECTED);
- search_box->results_url =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_URL);
+ color_provider.GetColor(kColorOmniboxResultsTextSelected);
+ search_box->results_url = color_provider.GetColor(kColorOmniboxResultsUrl);
search_box->results_url_selected =
- GetOmniboxColor(theme_provider, OmniboxPart::RESULTS_TEXT_URL,
- OmniboxPartState::SELECTED);
- search_box->text =
- GetOmniboxColor(theme_provider, OmniboxPart::LOCATION_BAR_TEXT_DEFAULT);
+ color_provider.GetColor(kColorOmniboxResultsUrlSelected);
+ search_box->text = color_provider.GetColor(kColorOmniboxText);
theme->search_box = std::move(search_box);
return theme;
@@ -367,66 +354,67 @@ new_tab_page::mojom::PromoPtr MakePromo(const PromoData& data) {
// PromoService to base::Value. The middle-slot promo part is then reencoded
// from base::Value to a JSON string stored in |data.middle_slot_json|.
auto middle_slot = base::JSONReader::Read(data.middle_slot_json);
- if (!middle_slot.has_value() ||
- middle_slot.value().FindBoolPath("hidden").value_or(false)) {
+ if (!middle_slot.has_value())
return nullptr;
- }
+
+ base::Value::Dict& middle_slot_dict = middle_slot->GetDict();
+ if (middle_slot_dict.FindBoolByDottedPath("hidden").value_or(false))
+ return nullptr;
+
auto promo = new_tab_page::mojom::Promo::New();
promo->id = data.promo_id;
- if (middle_slot.has_value()) {
- auto* parts = middle_slot.value().FindListPath("part");
- if (parts) {
- std::vector<new_tab_page::mojom::PromoPartPtr> mojom_parts;
- for (const base::Value& part : parts->GetListDeprecated()) {
- const base::Value::Dict& part_dict = part.GetDict();
- if (part_dict.Find("image")) {
- auto mojom_image = new_tab_page::mojom::PromoImagePart::New();
- auto* image_url = part_dict.FindStringByDottedPath("image.image_url");
- if (!image_url || image_url->empty()) {
- continue;
- }
- mojom_image->image_url = GURL(*image_url);
- auto* target = part_dict.FindStringByDottedPath("image.target");
- if (target && !target->empty()) {
- mojom_image->target = GURL(*target);
- }
- mojom_parts.push_back(
- new_tab_page::mojom::PromoPart::NewImage(std::move(mojom_image)));
- } else if (part_dict.Find("link")) {
- auto mojom_link = new_tab_page::mojom::PromoLinkPart::New();
- auto* url = part_dict.FindStringByDottedPath("link.url");
- if (!url || url->empty()) {
- continue;
- }
- mojom_link->url = GURL(*url);
- auto* text = part_dict.FindStringByDottedPath("link.text");
- if (!text || text->empty()) {
- continue;
- }
- mojom_link->text = *text;
- auto* color = part_dict.FindStringByDottedPath("link.color");
- if (color && !color->empty()) {
- mojom_link->color = *color;
- }
- mojom_parts.push_back(
- new_tab_page::mojom::PromoPart::NewLink(std::move(mojom_link)));
- } else if (part_dict.Find("text")) {
- auto mojom_text = new_tab_page::mojom::PromoTextPart::New();
- auto* text = part_dict.FindStringByDottedPath("text.text");
- if (!text || text->empty()) {
- continue;
- }
- mojom_text->text = *text;
- auto* color = part_dict.FindStringByDottedPath("text.color");
- if (color && !color->empty()) {
- mojom_text->color = *color;
- }
- mojom_parts.push_back(
- new_tab_page::mojom::PromoPart::NewText(std::move(mojom_text)));
+ auto* parts = middle_slot_dict.FindList("part");
+ if (parts) {
+ std::vector<new_tab_page::mojom::PromoPartPtr> mojom_parts;
+ for (const base::Value& part : *parts) {
+ const base::Value::Dict& part_dict = part.GetDict();
+ if (part_dict.Find("image")) {
+ auto mojom_image = new_tab_page::mojom::PromoImagePart::New();
+ auto* image_url = part_dict.FindStringByDottedPath("image.image_url");
+ if (!image_url || image_url->empty()) {
+ continue;
+ }
+ mojom_image->image_url = GURL(*image_url);
+ auto* target = part_dict.FindStringByDottedPath("image.target");
+ if (target && !target->empty()) {
+ mojom_image->target = GURL(*target);
+ }
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewImage(std::move(mojom_image)));
+ } else if (part_dict.Find("link")) {
+ auto mojom_link = new_tab_page::mojom::PromoLinkPart::New();
+ auto* url = part_dict.FindStringByDottedPath("link.url");
+ if (!url || url->empty()) {
+ continue;
+ }
+ mojom_link->url = GURL(*url);
+ auto* text = part_dict.FindStringByDottedPath("link.text");
+ if (!text || text->empty()) {
+ continue;
+ }
+ mojom_link->text = *text;
+ auto* color = part_dict.FindStringByDottedPath("link.color");
+ if (color && !color->empty()) {
+ mojom_link->color = *color;
}
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewLink(std::move(mojom_link)));
+ } else if (part_dict.Find("text")) {
+ auto mojom_text = new_tab_page::mojom::PromoTextPart::New();
+ auto* text = part_dict.FindStringByDottedPath("text.text");
+ if (!text || text->empty()) {
+ continue;
+ }
+ mojom_text->text = *text;
+ auto* color = part_dict.FindStringByDottedPath("text.color");
+ if (color && !color->empty()) {
+ mojom_text->color = *color;
+ }
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewText(std::move(mojom_text)));
}
- promo->middle_slot_parts = std::move(mojom_parts);
}
+ promo->middle_slot_parts = std::move(mojom_parts);
}
promo->log_url = data.promo_log_url;
return promo;
@@ -478,6 +466,17 @@ NewTabPageHandler::NewTabPageHandler(
ntp_custom_background_service_.get());
promo_service_observation_.Observe(promo_service_.get());
OnThemeChanged();
+ if (base::FeatureList::IsEnabled(ntp_features::kCustomizeChromeSidePanel)) {
+ auto* customize_chrome_tab_helper =
+ CustomizeChromeTabHelper::FromWebContents(web_contents_);
+ // Lifetime is tied to NewTabPageUI which owns the NewTabPageHandler.
+ DCHECK(customize_chrome_tab_helper);
+ page_->CustomizeChromeSidePanelVisibilityChanged(
+ customize_chrome_tab_helper->IsCustomizeChromeEntryShowing());
+ customize_chrome_tab_helper->SetCallback(base::BindRepeating(
+ &NewTabPageHandler::NotifyCustomizeChromeSidePanelVisibilityChanged,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
}
NewTabPageHandler::~NewTabPageHandler() {
@@ -627,32 +626,6 @@ void NewTabPageHandler::ChooseLocalCustomBackground(
}
void NewTabPageHandler::GetPromo(GetPromoCallback callback) {
- // Replace the promo URL with "command:<id>" if such a command ID is set
- // via the feature params.
- const std::string command_id = base::GetFieldTrialParamValueByFeature(
- features::kPromoBrowserCommands, features::kBrowserCommandIdParam);
- if (!command_id.empty()) {
- auto promo = new_tab_page::mojom::Promo::New();
- std::vector<new_tab_page::mojom::PromoPartPtr> parts;
- auto image = new_tab_page::mojom::PromoImagePart::New();
- // Warning symbol used as the test image.
- image->image_url = GURL(
- "data:image/"
- "svg+xml;base64,"
- "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii01IC"
- "01IDU4IDU4IiBmaWxsPSIjZmRkNjMzIj48cGF0aCBkPSJNMiA0Mmg0NEwyNCA0IDIgNDJ6"
- "bTI0LTZoLTR2LTRoNHY0em0wLThoLTR2LThoNHY4eiIvPjwvc3ZnPg==");
- image->target = GURL("command:" + command_id);
- parts.push_back(new_tab_page::mojom::PromoPart::NewImage(std::move(image)));
- auto link = new_tab_page::mojom::PromoLinkPart::New();
- link->url = GURL("command:" + command_id);
- link->text = "Test command: " + command_id;
- parts.push_back(new_tab_page::mojom::PromoPart::NewLink(std::move(link)));
- promo->middle_slot_parts = std::move(parts);
- std::move(callback).Run(std::move(promo));
- return;
- }
-
promo_callbacks_.push_back(std::move(callback));
if (promo_service_->promo_data().has_value()) {
OnPromoDataUpdated();
@@ -661,6 +634,14 @@ void NewTabPageHandler::GetPromo(GetPromoCallback callback) {
promo_service_->Refresh();
}
+void NewTabPageHandler::BlocklistPromo(const std::string& promo_id) {
+ promo_service_->BlocklistPromo(promo_id);
+}
+
+void NewTabPageHandler::UndoBlocklistPromo(const std::string& promo_id) {
+ promo_service_->UndoBlocklistPromo(promo_id);
+}
+
void NewTabPageHandler::OnDismissModule(const std::string& module_id) {
const std::string histogram_prefix(kModuleDismissedHistogram);
base::UmaHistogramExactLinear(histogram_prefix, 1, 1);
@@ -681,12 +662,13 @@ void NewTabPageHandler::SetModulesVisible(bool visible) {
void NewTabPageHandler::SetModuleDisabled(const std::string& module_id,
bool disabled) {
ListPrefUpdate update(profile_->GetPrefs(), prefs::kNtpDisabledModules);
+ base::Value::List& list = update->GetList();
base::Value module_id_value(module_id);
if (disabled) {
- if (!base::Contains(update->GetListDeprecated(), module_id_value))
- update->Append(std::move(module_id_value));
+ if (!base::Contains(list, module_id_value))
+ list.Append(std::move(module_id_value));
} else {
- update->EraseListValue(module_id_value);
+ list.EraseValue(module_id_value);
}
UpdateDisabledModules();
}
@@ -696,9 +678,9 @@ void NewTabPageHandler::UpdateDisabledModules() {
// If the module visibility is managed by policy we either disable all modules
// (if invisible) or no modules (if visible).
if (!profile_->GetPrefs()->IsManagedPreference(prefs::kNtpModulesVisible)) {
- const auto* module_ids_value =
- profile_->GetPrefs()->GetList(prefs::kNtpDisabledModules);
- for (const auto& id : module_ids_value->GetListDeprecated()) {
+ const auto& module_ids_value =
+ profile_->GetPrefs()->GetValueList(prefs::kNtpDisabledModules);
+ for (const auto& id : module_ids_value) {
module_ids.push_back(id.GetString());
}
}
@@ -717,11 +699,12 @@ void NewTabPageHandler::OnModulesLoadedWithData() {
void NewTabPageHandler::SetModulesOrder(
const std::vector<std::string>& module_ids) {
- base::Value module_ids_value(base::Value::Type::LIST);
+ base::Value::List module_ids_value;
for (const auto& module_id : module_ids) {
module_ids_value.Append(module_id);
}
- profile_->GetPrefs()->Set(prefs::kNtpModulesOrder, module_ids_value);
+ profile_->GetPrefs()->SetList(prefs::kNtpModulesOrder,
+ std::move(module_ids_value));
}
void NewTabPageHandler::GetModulesOrder(GetModulesOrderCallback callback) {
@@ -729,9 +712,9 @@ void NewTabPageHandler::GetModulesOrder(GetModulesOrderCallback callback) {
// First, apply order as set by the last drag&drop interaction.
if (base::FeatureList::IsEnabled(ntp_features::kNtpModulesDragAndDrop)) {
- const auto* module_ids_value =
- profile_->GetPrefs()->GetList(prefs::kNtpModulesOrder);
- for (const auto& id : module_ids_value->GetListDeprecated()) {
+ const auto& module_ids_value =
+ profile_->GetPrefs()->GetValueList(prefs::kNtpModulesOrder);
+ for (const auto& id : module_ids_value) {
module_ids.push_back(id.GetString());
}
}
@@ -813,6 +796,12 @@ void NewTabPageHandler::LogModulesFreOptInStatus(
}
}
+void NewTabPageHandler::ShowCustomizeChromeSidePanel() {
+ auto* customize_chrome_tab_helper =
+ CustomizeChromeTabHelper::FromWebContents(web_contents_);
+ customize_chrome_tab_helper->ShowCustomizeChromeSidePanel();
+}
+
void NewTabPageHandler::OnPromoDataUpdated() {
if (promo_load_start_time_.has_value()) {
base::TimeDelta duration = base::TimeTicks::Now() - *promo_load_start_time_;
@@ -837,7 +826,7 @@ void NewTabPageHandler::OnPromoDataUpdated() {
const auto& data = promo_service_->promo_data();
for (auto& callback : promo_callbacks_) {
- if (data.has_value() && !data->promo_html.empty()) {
+ if (data.has_value()) {
std::move(callback).Run(MakePromo(data.value()));
} else {
std::move(callback).Run(nullptr);
@@ -1259,25 +1248,23 @@ void NewTabPageHandler::OnLogFetchResult(OnDoodleImageRenderedCallback callback,
return;
}
- auto* target_url_params_value = value->FindPath("ddllog.target_url_params");
+ base::Value::Dict& dict = value->GetDict();
+ auto* target_url_params_value =
+ dict.FindStringByDottedPath("ddllog.target_url_params");
auto target_url_params =
- target_url_params_value && target_url_params_value->is_string()
- ? target_url_params_value->GetString()
- : "";
+ target_url_params_value ? *target_url_params_value : "";
auto* interaction_log_url_value =
- value->FindPath("ddllog.interaction_log_url");
+ dict.FindStringByDottedPath("ddllog.interaction_log_url");
auto interaction_log_url =
- interaction_log_url_value && interaction_log_url_value->is_string()
+ interaction_log_url_value
? absl::optional<GURL>(
GURL(TemplateURLServiceFactory::GetForProfile(profile_)
->search_terms_data()
.GoogleBaseURLValue())
- .Resolve(interaction_log_url_value->GetString()))
+ .Resolve(*interaction_log_url_value))
: absl::nullopt;
- auto* encoded_ei_value = value->FindPath("ddllog.encoded_ei");
- auto encoded_ei = encoded_ei_value && encoded_ei_value->is_string()
- ? encoded_ei_value->GetString()
- : "";
+ auto* encoded_ei_value = dict.FindStringByDottedPath("ddllog.encoded_ei");
+ auto encoded_ei = encoded_ei_value ? *encoded_ei_value : "";
std::move(callback).Run(target_url_params, interaction_log_url, encoded_ei);
}
@@ -1288,3 +1275,8 @@ bool NewTabPageHandler::IsCustomLinksEnabled() const {
bool NewTabPageHandler::IsShortcutsVisible() const {
return profile_->GetPrefs()->GetBoolean(ntp_prefs::kNtpShortcutsVisible);
}
+
+void NewTabPageHandler::NotifyCustomizeChromeSidePanelVisibilityChanged(
+ bool is_open) {
+ page_->CustomizeChromeSidePanelVisibilityChanged(is_open);
+}
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
index 762d47f9961..d9c7082a107 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
@@ -98,6 +98,8 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void ChooseLocalCustomBackground(
ChooseLocalCustomBackgroundCallback callback) override;
void GetPromo(GetPromoCallback callback) override;
+ void BlocklistPromo(const std::string& promo_id) override;
+ void UndoBlocklistPromo(const std::string& promo_id) override;
void OnDismissModule(const std::string& module_id) override;
void OnRestoreModule(const std::string& module_id) override;
void SetModulesVisible(bool visible) override;
@@ -111,6 +113,7 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void UpdateModulesFreVisibility() override;
void LogModulesFreOptInStatus(
new_tab_page::mojom::OptInStatus opt_in_status) override;
+ void ShowCustomizeChromeSidePanel() override;
void OnAppRendered(double time) override;
void OnOneGoogleBarRendered(double time) override;
void OnPromoRendered(double time,
@@ -175,6 +178,7 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
bool IsCustomLinksEnabled() const;
bool IsShortcutsVisible() const;
+ void NotifyCustomizeChromeSidePanelVisibilityChanged(bool is_open);
ChooseLocalCustomBackgroundCallback choose_local_custom_background_callback_;
raw_ptr<NtpBackgroundService> ntp_background_service_;
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
index e143b65a38d..63a6b90dc18 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
@@ -76,6 +76,7 @@ class MockPage : public new_tab_page::mojom::Page {
MOCK_METHOD1(SetTheme, void(new_tab_page::mojom::ThemePtr));
MOCK_METHOD2(SetDisabledModules, void(bool, const std::vector<std::string>&));
MOCK_METHOD1(SetModulesFreVisibility, void(bool));
+ MOCK_METHOD1(CustomizeChromeSidePanelVisibilityChanged, void(bool));
mojo::Receiver<new_tab_page::mojom::Page> receiver_{this};
};
@@ -299,44 +300,32 @@ TEST_F(NewTabPageHandlerTest, SetTheme) {
.WillByDefault(testing::Return(true));
mock_color_provider_source_.SetColor(
kColorNewTabPageMostVisitedTileBackground, SkColorSetRGB(0, 0, 4));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_BACKGROUND))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 5)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_ICON))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 6)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_ICON_SELECTED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 7)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_TEXT_DIMMED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 8)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_BG))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 9)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_BG_HOVERED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 10)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_BG_SELECTED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 11)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_DIMMED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 12)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_DIMMED_SELECTED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 13)));
- ON_CALL(mock_theme_provider_, GetColor(ThemeProperties::COLOR_OMNIBOX_TEXT))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 14)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_SELECTED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 15)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_URL))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 16)));
- ON_CALL(mock_theme_provider_,
- GetColor(ThemeProperties::COLOR_OMNIBOX_RESULTS_URL_SELECTED))
- .WillByDefault(testing::Return(SkColorSetRGB(0, 0, 17)));
+ mock_color_provider_source_.SetColor(kColorNewTabPageSearchBoxBackground,
+ SkColorSetRGB(0, 0, 5));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsIcon,
+ SkColorSetRGB(0, 0, 6));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsIconSelected,
+ SkColorSetRGB(0, 0, 7));
+ mock_color_provider_source_.SetColor(kColorOmniboxTextDimmed,
+ SkColorSetRGB(0, 0, 8));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsBackground,
+ SkColorSetRGB(0, 0, 9));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsBackgroundHovered,
+ SkColorSetRGB(0, 0, 10));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsBackgroundSelected,
+ SkColorSetRGB(0, 0, 11));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsTextDimmed,
+ SkColorSetRGB(0, 0, 12));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsTextDimmedSelected,
+ SkColorSetRGB(0, 0, 13));
+ mock_color_provider_source_.SetColor(kColorOmniboxText,
+ SkColorSetRGB(0, 0, 14));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsTextSelected,
+ SkColorSetRGB(0, 0, 15));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsUrl,
+ SkColorSetRGB(0, 0, 16));
+ mock_color_provider_source_.SetColor(kColorOmniboxResultsUrlSelected,
+ SkColorSetRGB(0, 0, 17));
theme_service_observer_->OnThemeChanged();
mock_page_.FlushForTesting();
@@ -344,7 +333,6 @@ TEST_F(NewTabPageHandlerTest, SetTheme) {
ASSERT_TRUE(theme);
EXPECT_EQ(SkColorSetRGB(0, 0, 1), theme->background_color);
EXPECT_EQ(SkColorSetRGB(0, 0, 2), theme->text_color);
- EXPECT_FALSE(theme->is_default);
EXPECT_FALSE(theme->is_custom_background);
EXPECT_FALSE(theme->is_dark);
EXPECT_EQ(SkColorSetRGB(0, 0, 3), theme->logo_color);
@@ -563,7 +551,6 @@ TEST_F(NewTabPageHandlerTest, GetInteractiveDoodle) {
TEST_F(NewTabPageHandlerTest, GetPromo) {
PromoData promo_data;
- promo_data.promo_html = "<html/>";
promo_data.middle_slot_json = R"({
"part": [{
"image": {
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
index 30a073188c2..f61f5c95b4e 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
@@ -19,17 +19,20 @@
#include "chrome/browser/buildflags.h"
#include "chrome/browser/cart/cart_handler.h"
#include "chrome/browser/new_tab_page/modules/drive/drive_handler.h"
+#include "chrome/browser/new_tab_page/modules/feed/feed_handler.h"
#include "chrome/browser/new_tab_page/modules/photos/photos_handler.h"
-#include "chrome/browser/new_tab_page/modules/task_module/task_module_handler.h"
+#include "chrome/browser/new_tab_page/modules/recipes/recipes_handler.h"
+#include "chrome/browser/new_tab_page/new_tab_page_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/background/ntp_custom_background_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_provider_logos/logo_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
-#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/color/chrome_color_id.h"
+#include "chrome/browser/ui/side_panel/customize_chrome/customize_chrome_tab_helper.h"
#include "chrome/browser/ui/webui/browser_command/browser_command_handler.h"
#include "chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
@@ -52,6 +55,7 @@
#include "chrome/grit/theme_resources.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/favicon_base/favicon_url_parser.h"
+#include "components/feed/feed_feature_list.h"
#include "components/google/core/common/google_util.h"
#include "components/grit/components_scaled_resources.h"
#include "components/prefs/pref_registry_simple.h"
@@ -73,6 +77,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/color/color_provider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "url/url_util.h"
@@ -93,9 +98,8 @@ const std::pair<const char*, const base::Feature&> kModuleFeatures[] = {
#if !defined(OFFICIAL_BUILD)
{"dummyModulesEnabled", ntp_features::kNtpDummyModules},
#endif
- {"recipeTasksModuleEnabled", ntp_features::kNtpRecipeTasksModule},
- {"chromeCartModuleEnabled", ntp_features::kNtpChromeCartModule},
{"photosModuleEnabled", ntp_features::kNtpPhotosModule},
+ {"feedModuleEnabled", ntp_features::kNtpFeedModule},
};
void AddRawStringOrDefault(content::WebUIDataSource* source,
@@ -197,11 +201,12 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
base::FeatureList::IsEnabled(ntp_features::kNtpMiddleSlotPromo) &&
profile->GetPrefs()->GetBoolean(prefs::kNtpPromoVisible));
source->AddBoolean(
+ "middleSlotPromoDismissalEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpMiddleSlotPromoDismissal));
+ source->AddBoolean(
"modulesDragAndDropEnabled",
base::FeatureList::IsEnabled(ntp_features::kNtpModulesDragAndDrop));
- source->AddBoolean("modulesFirstRunExperienceEnabled",
- base::FeatureList::IsEnabled(
- ntp_features::kNtpModulesFirstRunExperience));
+ source->AddBoolean("modulesFirstRunExperienceEnabled", IsModuleFreEnabled());
source->AddBoolean("modulesLoadEnabled", base::FeatureList::IsEnabled(
ntp_features::kNtpModulesLoad));
source->AddInteger("modulesLoadTimeout",
@@ -255,6 +260,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"modulesMenuItem", IDS_NTP_CUSTOMIZE_MENU_MODULES_LABEL},
{"shortcutsOption", IDS_NTP_CUSTOMIZE_MENU_SHORTCUTS_LABEL},
{"shortcutsSuggested", IDS_NTP_CUSTOMIZE_MOST_VISITED_DESC},
+ {"themesContainerLabel", IDS_NTP_THEMES_CONTAINER_LABEL},
{"themesMenuItem", IDS_NTP_CUSTOMIZE_MENU_COLOR_LABEL},
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
@@ -299,6 +305,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"modulesDisableButtonText", IDS_NTP_MODULES_DISABLE_BUTTON_TEXT},
{"modulesCustomizeButtonText", IDS_NTP_MODULES_CUSTOMIZE_BUTTON_TEXT},
{"modulesRecipeInfo", IDS_NTP_MODULES_RECIPE_INFO},
+ {"modulesRecipeExtendedInfo", IDS_NTP_MODULES_RECIPE_EXTENDED_INFO},
{"modulesRecipeTasksSentence", IDS_NTP_MODULES_RECIPE_TASKS_SENTENCE},
{"modulesRecipeTasksLower", IDS_NTP_MODULES_RECIPE_TASKS_LOWER},
{"modulesRecipeTasksLowerThese",
@@ -335,6 +342,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"modulesDummy10Title", IDS_NTP_MODULES_DUMMY2_TITLE},
{"modulesDummy11Title", IDS_NTP_MODULES_DUMMY2_TITLE},
{"modulesDummy12Title", IDS_NTP_MODULES_DUMMY2_TITLE},
+ {"modulesFeedTitle", IDS_NTP_MODULES_FEED_TITLE},
{"modulesKaleidoscopeTitle", IDS_NTP_MODULES_KALEIDOSCOPE_TITLE},
{"modulesPhotosInfo", IDS_NTP_MODULES_PHOTOS_INFO},
{"modulesPhotosSentence", IDS_NTP_MODULES_PHOTOS_MEMORIES_TITLE},
@@ -411,6 +419,9 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT},
{"modulesFirstRunExperienceOptOutToast",
IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST},
+
+ // Middle slot promo.
+ {"undoDismissPromoButtonToast", IDS_NTP_UNDO_DISMISS_PROMO_BUTTON_TOAST},
};
source->AddLocalizedStrings(kStrings);
@@ -429,7 +440,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
source->AddBoolean(nameFeature.first,
base::FeatureList::IsEnabled(nameFeature.second));
}
-
+ source->AddBoolean("recipeTasksModuleEnabled", IsRecipeTasksModuleEnabled());
+ source->AddBoolean("chromeCartModuleEnabled", IsCartModuleEnabled());
source->AddString("photosModuleCustomArtWork",
base::GetFieldTrialParamValueByFeature(
ntp_features::kNtpPhotosModuleCustomizedOptInArtWork,
@@ -458,6 +470,9 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
source->AddBoolean(
"modulesRecipeHistoricalExperimentEnabled",
!splitExperimentGroup.empty() && splitExperimentGroup[0] == "historical");
+ source->AddBoolean(
+ "moduleRecipeExtendedExperimentEnabled",
+ !splitExperimentGroup.empty() && (splitExperimentGroup[0] == "historical" || splitExperimentGroup[0] == "mix"));
RealboxHandler::SetupWebUIDataSource(source);
@@ -512,6 +527,10 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
profile_->GetPrefs()->IsManagedPreference(prefs::kNtpModulesVisible));
content::WebUIDataSource::Add(profile_, source);
+ source->AddBoolean(
+ "customizeChromeEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kCustomizeChromeSidePanel));
+
content::URLDataSource::Add(profile_,
std::make_unique<SanitizedImageSource>(profile_));
content::URLDataSource::Add(
@@ -546,6 +565,13 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
ntp_custom_background_service_observation_.Observe(
ntp_custom_background_service_.get());
+ // Create and register customize chrome entry on unified side panel
+ if (base::FeatureList::IsEnabled(ntp_features::kCustomizeChromeSidePanel)) {
+ auto* customize_chrome_tab_helper =
+ CustomizeChromeTabHelper::FromWebContents(web_contents_);
+ customize_chrome_tab_helper->CreateAndRegisterEntry();
+ }
+
// Populates the load time data with basic info.
OnThemeChanged();
OnCustomBackgroundImageUpdated();
@@ -554,7 +580,14 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
WEB_UI_CONTROLLER_TYPE_IMPL(NewTabPageUI)
-NewTabPageUI::~NewTabPageUI() = default;
+NewTabPageUI::~NewTabPageUI() {
+ // Deregister customize chrome entry on unified side panel
+ if (base::FeatureList::IsEnabled(ntp_features::kCustomizeChromeSidePanel)) {
+ auto* customize_chrome_tab_helper =
+ CustomizeChromeTabHelper::FromWebContents(web_contents_);
+ customize_chrome_tab_helper->DeregisterEntry();
+ }
+}
// static
bool NewTabPageUI::IsNewTabPageOrigin(const GURL& url) {
@@ -644,10 +677,9 @@ void NewTabPageUI::BindInterface(
}
void NewTabPageUI::BindInterface(
- mojo::PendingReceiver<task_module::mojom::TaskModuleHandler>
- pending_receiver) {
- task_module_handler_ = std::make_unique<TaskModuleHandler>(
- std::move(pending_receiver), profile_);
+ mojo::PendingReceiver<recipes::mojom::RecipesHandler> pending_receiver) {
+ recipes_handler_ =
+ std::make_unique<RecipesHandler>(std::move(pending_receiver), profile_);
}
void NewTabPageUI::BindInterface(
@@ -662,6 +694,12 @@ void NewTabPageUI::BindInterface(
profile_, web_contents_);
}
+void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<ntp::feed::mojom::FeedHandler> pending_receiver) {
+ feed_handler_ =
+ ntp::FeedHandler::Create(std::move(pending_receiver), profile_);
+}
+
#if !defined(OFFICIAL_BUILD)
void NewTabPageUI::BindInterface(
mojo::PendingReceiver<foo::mojom::FooHandler> pending_page_handler) {
@@ -705,6 +743,7 @@ void NewTabPageUI::CreateBrowserCommandHandler(
std::vector<Command> supported_commands = {
Command::kOpenSafetyCheck,
Command::kOpenSafeBrowsingEnhancedProtectionSettings,
+ Command::kNoOpCommand,
};
promo_browser_command_handler_ = std::make_unique<BrowserCommandHandler>(
std::move(pending_handler), profile_, supported_commands);
@@ -729,18 +768,9 @@ void NewTabPageUI::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
void NewTabPageUI::OnThemeChanged() {
base::Value::Dict update;
-
- const ui::ThemeProvider* theme_provider =
- webui::GetThemeProvider(web_contents_);
- // TODO(crbug.com/1299925): Always mock theme provider in tests so that
- // `theme_provider` is never nullptr.
- if (theme_provider) {
- auto background_color =
- theme_provider->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
- update.Set("backgroundColor", skia::SkColorToHexString(background_color));
- } else {
- update.Set("backgroundColor", "");
- }
+ const ui::ColorProvider& color_provider = web_contents_->GetColorProvider();
+ auto background_color = color_provider.GetColor(kColorNewTabPageBackground);
+ update.Set("backgroundColor", skia::SkColorToHexString(background_color));
content::WebUIDataSource::Update(profile_, chrome::kChromeUINewTabPageHost,
std::move(update));
}
@@ -821,6 +851,8 @@ void NewTabPageUI::OnLoad() {
for (const auto& nameFeature : kModuleFeatures) {
anyModuleEnabled |= base::FeatureList::IsEnabled(nameFeature.second);
}
+ anyModuleEnabled |= IsRecipeTasksModuleEnabled();
+ anyModuleEnabled |= IsCartModuleEnabled();
// Only enable modules if account credentials are available as most modules
// won't have data to render otherwise. We can override this behavior with the
// "--signed-out-ntp-modules" command line switch, e.g. to allow modules in
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
index 081137babe8..92101ab3914 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
@@ -9,8 +9,9 @@
#include "base/time/time.h"
#include "chrome/browser/cart/chrome_cart.mojom.h"
#include "chrome/browser/new_tab_page/modules/drive/drive.mojom.h"
+#include "chrome/browser/new_tab_page/modules/feed/feed.mojom.h"
#include "chrome/browser/new_tab_page/modules/photos/photos.mojom.h"
-#include "chrome/browser/new_tab_page/modules/task_module/task_module.mojom.h"
+#include "chrome/browser/new_tab_page/modules/recipes/recipes.mojom.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
#if !defined(OFFICIAL_BUILD)
#include "chrome/browser/ui/webui/new_tab_page/foo/foo.mojom.h" // nogncheck crbug.com/1125897
@@ -57,11 +58,13 @@ class PrefService;
class Profile;
class BrowserCommandHandler;
class RealboxHandler;
-class TaskModuleHandler;
+class RecipesHandler;
class CartHandler;
class DriveHandler;
class PhotosHandler;
-
+namespace ntp {
+class FeedHandler;
+}
class NewTabPageUI
: public ui::MojoWebUIController,
public new_tab_page::mojom::PageHandlerFactory,
@@ -121,8 +124,7 @@ class NewTabPageUI
// recipe_tasks::mojom::RecipeTasksHandler mojo interface passing the
// pending receiver that will be internally bound.
void BindInterface(
- mojo::PendingReceiver<task_module::mojom::TaskModuleHandler>
- pending_receiver);
+ mojo::PendingReceiver<recipes::mojom::RecipesHandler> pending_receiver);
// Instantiates the implementor of drive::mojom::DriveHandler mojo interface
// passing the pending receiver that will be internally bound.
@@ -134,6 +136,11 @@ class NewTabPageUI
void BindInterface(
mojo::PendingReceiver<photos::mojom::PhotosHandler> pending_receiver);
+ // Instantiates the implementor of ntp::feed::mojom::FeedHandler mojo
+ // interface passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<ntp::feed::mojom::FeedHandler> pending_receiver);
+
#if !defined(OFFICIAL_BUILD)
// Instantiates the implementor of the foo::mojom::FooHandler mojo interface
// passing the pending receiver that will be internally bound.
@@ -232,9 +239,10 @@ class NewTabPageUI
base::Time navigation_start_time_;
// Mojo implementations for modules:
- std::unique_ptr<TaskModuleHandler> task_module_handler_;
+ std::unique_ptr<RecipesHandler> recipes_handler_;
std::unique_ptr<DriveHandler> drive_handler_;
std::unique_ptr<PhotosHandler> photos_handler_;
+ std::unique_ptr<ntp::FeedHandler> feed_handler_;
PrefChangeRegistrar pref_change_registrar_;
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc b/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
index 58b604f1d27..38973f2dbe6 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc
@@ -94,6 +94,8 @@ std::string UntrustedSource::GetContentSecurityPolicy(
return std::string();
case network::mojom::CSPDirectiveName::TrustedTypes:
return std::string();
+ case network::mojom::CSPDirectiveName::FormAction:
+ return "form-action https://ogs.google.com https://*.corp.google.com;";
default:
return content::URLDataSource::GetContentSecurityPolicy(directive);
}
@@ -192,8 +194,8 @@ void UntrustedSource::StartDataRequest(
std::move(callback).Run(base::MakeRefCounted<base::RefCountedString>());
}
-std::string UntrustedSource::GetMimeType(const std::string& path) {
- const std::string stripped_path = path.substr(0, path.find("?"));
+std::string UntrustedSource::GetMimeType(const GURL& url) {
+ const base::StringPiece stripped_path = url.path_piece();
if (base::EndsWith(stripped_path, ".js",
base::CompareCase::INSENSITIVE_ASCII)) {
return "application/javascript";
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h b/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
index e0d444f02cb..43854bf3118 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h
@@ -56,7 +56,7 @@ class UntrustedSource : public content::URLDataSource,
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool AllowCaching() override;
bool ShouldReplaceExistingSource() override;
bool ShouldServeMimeTypeAsContentTypeHeader() override;
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc b/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc
index 77c62014416..718ddd9741f 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_handler.cc
@@ -8,12 +8,14 @@
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/theme_resources.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
+#include "ui/color/color_provider.h"
#include "ui/gfx/color_utils.h"
NewTabPageThirdPartyHandler::NewTabPageThirdPartyHandler(
@@ -53,16 +55,17 @@ void NewTabPageThirdPartyHandler::NotifyAboutTheme() {
const ui::ThemeProvider* theme_provider =
webui::GetThemeProvider(web_contents_);
DCHECK(theme_provider);
+ const ui::ColorProvider& color_provider = web_contents_->GetColorProvider();
most_visited->background_color =
- theme_provider->GetColor(ThemeProperties::COLOR_NTP_SHORTCUT);
+ color_provider.GetColor(kColorNewTabPageMostVisitedTileBackground);
most_visited->use_white_tile_icon =
color_utils::IsDark(most_visited->background_color);
most_visited->use_title_pill = false;
- theme->text_color = theme_provider->GetColor(ThemeProperties::COLOR_NTP_TEXT);
+ theme->text_color = color_provider.GetColor(kColorNewTabPageText);
most_visited->is_dark = !color_utils::IsDark(theme->text_color);
- theme->color_background = color_utils::SkColorToRgbaString(
- GetThemeColor(webui::GetNativeTheme(web_contents_), *theme_provider,
- ThemeProperties::COLOR_NTP_BACKGROUND));
+ theme->color_background = color_utils::SkColorToRgbaString(GetThemeColor(
+ webui::GetNativeTheme(web_contents_), web_contents_->GetColorProvider(),
+ kColorNewTabPageBackground));
if (theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
theme->background_tiling = GetNewTabBackgroundTilingCSS(*theme_provider);
theme->background_position =
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc b/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc
index a69f085bb7a..dd334a01367 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page_third_party/new_tab_page_third_party_ui.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
@@ -33,6 +34,7 @@
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/color/color_provider.h"
#include "ui/gfx/color_utils.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "url/url_util.h"
@@ -66,14 +68,15 @@ content::WebUIDataSource* CreateNewTabPageThirdPartyUiHtmlSource(
// TODO(crbug.com/1299925): Always mock theme provider in tests so that
// `theme_provider` is never nullptr.
if (theme_provider) {
+ const ui::ColorProvider& color_provider = web_contents->GetColorProvider();
source->AddString("backgroundPosition",
GetNewTabBackgroundPositionCSS(*theme_provider));
source->AddString("backgroundTiling",
GetNewTabBackgroundTilingCSS(*theme_provider));
source->AddString("colorBackground",
color_utils::SkColorToRgbaString(GetThemeColor(
- webui::GetNativeTheme(web_contents), *theme_provider,
- ThemeProperties::COLOR_NTP_BACKGROUND)));
+ webui::GetNativeTheme(web_contents), color_provider,
+ kColorNewTabPageBackground)));
// TODO(crbug.com/1056758): don't get theme id from profile.
source->AddString("themeId",
profile->GetPrefs()->GetString(prefs::kCurrentThemeID));
@@ -81,10 +84,11 @@ content::WebUIDataSource* CreateNewTabPageThirdPartyUiHtmlSource(
theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)
? "has-custom-background"
: "");
- source->AddString("isdark", !color_utils::IsDark(theme_provider->GetColor(
- ThemeProperties::COLOR_NTP_TEXT))
- ? "dark"
- : "");
+ source->AddString(
+ "isdark",
+ !color_utils::IsDark(color_provider.GetColor(kColorNewTabPageText))
+ ? "dark"
+ : "");
} else {
source->AddString("backgroundPosition", "");
source->AddString("backgroundTiling", "");
diff --git a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index cb95515fa28..90909c5e207 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -81,6 +81,7 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
+#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/webapps/browser/install_result_code.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/uninstall_result_code.h"
@@ -302,8 +303,7 @@ base::Value::Dict AppLauncherHandler::CreateWebAppInfo(
: kRunOnOsLoginModeWindowed);
// Show settings instead of App info for locally installed web apps.
- if (base::FeatureList::IsEnabled(features::kDesktopPWAsWebAppSettingsPage) &&
- is_locally_installed) {
+ if (is_locally_installed) {
dict.Set("settingsMenuItemOverrideText",
l10n_util::GetStringUTF16(IDS_WEB_APP_SETTINGS_LINK));
}
@@ -367,7 +367,9 @@ base::Value::Dict AppLauncherHandler::CreateExtensionInfo(
!extension->is_platform_app() && is_locally_installed);
// Any locally installed app can have shortcuts created.
- dict.Set("mayCreateShortcuts", is_locally_installed);
+ dict.Set(
+ "mayCreateShortcuts",
+ is_locally_installed && extension->id() != extensions::kWebStoreAppId);
dict.Set("isLocallyInstalled", is_locally_installed);
auto icon_size = extension_misc::EXTENSION_ICON_LARGE;
@@ -449,55 +451,55 @@ void AppLauncherHandler::RegisterProfilePrefs(
}
void AppLauncherHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getApps", base::BindRepeating(&AppLauncherHandler::HandleGetApps,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"launchApp", base::BindRepeating(&AppLauncherHandler::HandleLaunchApp,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setLaunchType",
base::BindRepeating(&AppLauncherHandler::HandleSetLaunchType,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"uninstallApp",
base::BindRepeating(&AppLauncherHandler::HandleUninstallApp,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"createAppShortcut",
base::BindRepeating(&AppLauncherHandler::HandleCreateAppShortcut,
base::Unretained(this), base::DoNothing()));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"installAppLocally",
base::BindRepeating(&AppLauncherHandler::HandleInstallAppLocally,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"showAppInfo", base::BindRepeating(&AppLauncherHandler::HandleShowAppInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"reorderApps", base::BindRepeating(&AppLauncherHandler::HandleReorderApps,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setPageIndex",
base::BindRepeating(&AppLauncherHandler::HandleSetPageIndex,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"saveAppPageName",
base::BindRepeating(&AppLauncherHandler::HandleSaveAppPageName,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"generateAppForLink",
base::BindRepeating(&AppLauncherHandler::HandleGenerateAppForLink,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"pageSelected",
base::BindRepeating(&AppLauncherHandler::HandlePageSelected,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"runOnOsLogin",
base::BindRepeating(&AppLauncherHandler::HandleRunOnOsLogin,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"deprecatedDialogLinkClicked",
base::BindRepeating(&AppLauncherHandler::HandleLaunchDeprecatedAppDialog,
base::Unretained(this)));
@@ -523,10 +525,9 @@ void AppLauncherHandler::OnAppsReordered(
app_info = CreateExtensionInfo(extension);
}
- web_ui()->CallJavascriptFunctionUnsafe("ntp.appMoved",
- base::Value(std::move(app_info)));
+ web_ui()->CallJavascriptFunctionUnsafe("ntp.appMoved", std::move(app_info));
} else {
- HandleGetApps(nullptr);
+ HandleGetApps(base::Value::List());
}
}
@@ -537,9 +538,9 @@ void AppLauncherHandler::OnExtensionLoaded(
return;
visible_apps_.insert(extension->id());
- web_ui()->CallJavascriptFunctionUnsafe(
- "ntp.appAdded", base::Value(GetExtensionInfo(extension)),
- /*highlight=*/base::Value(false));
+ web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded",
+ GetExtensionInfo(extension),
+ /*highlight=*/base::Value(false));
}
void AppLauncherHandler::OnExtensionUnloaded(
@@ -567,8 +568,8 @@ void AppLauncherHandler::OnWebAppInstalled(const web_app::AppId& app_id) {
visible_apps_.insert(app_id);
base::Value highlight(attempting_web_app_install_page_ordinal_.has_value());
attempting_web_app_install_page_ordinal_ = absl::nullopt;
- web_ui()->CallJavascriptFunctionUnsafe(
- "ntp.appAdded", base::Value(CreateWebAppInfo(app_id)), highlight);
+ web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded",
+ CreateWebAppInfo(app_id), highlight);
}
void AppLauncherHandler::OnWebAppInstallTimeChanged(
@@ -577,7 +578,7 @@ void AppLauncherHandler::OnWebAppInstallTimeChanged(
// Use the appAdded to update the app icon's color to no longer be
// greyscale.
web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded",
- base::Value(CreateWebAppInfo(app_id)));
+ CreateWebAppInfo(app_id));
}
void AppLauncherHandler::OnWebAppWillBeUninstalled(
@@ -587,7 +588,7 @@ void AppLauncherHandler::OnWebAppWillBeUninstalled(
// dictionary is the id.
app_info.Set(kInfoIdKey, app_id);
web_ui()->CallJavascriptFunctionUnsafe(
- "ntp.appRemoved", base::Value(std::move(app_info)),
+ "ntp.appRemoved", std::move(app_info),
/*isUninstall=*/base::Value(true),
base::Value(!extension_id_prompting_.empty()));
}
@@ -603,7 +604,7 @@ void AppLauncherHandler::OnWebAppUninstalled(const web_app::AppId& app_id) {
// dictionary is the id.
app_info.Set(kInfoIdKey, app_id);
web_ui()->CallJavascriptFunctionUnsafe(
- "ntp.appRemoved", base::Value(std::move(app_info)),
+ "ntp.appRemoved", std::move(app_info),
/*isUninstall=*/base::Value(true),
base::Value(!extension_id_prompting_.empty()));
}
@@ -615,7 +616,7 @@ void AppLauncherHandler::OnWebAppRunOnOsLoginModeChanged(
}
void AppLauncherHandler::OnWebAppSettingsPolicyChanged() {
- HandleGetApps(nullptr);
+ HandleGetApps(base::Value::List());
}
void AppLauncherHandler::OnWebAppInstallManagerDestroyed() {
@@ -667,14 +668,15 @@ void AppLauncherHandler::FillAppDictionary(base::Value::Dict* dictionary) {
l10n_util::GetPluralStringFUTF16(IDS_DEPRECATED_APPS_DELETION_LINK,
deprecated_app_ids_.size()));
- const base::Value* app_page_names = prefs->GetList(prefs::kNtpAppPageNames);
- if (!app_page_names || !app_page_names->GetListDeprecated().size()) {
+ const base::Value::List& app_page_names =
+ prefs->GetValueList(prefs::kNtpAppPageNames);
+ if (!app_page_names.size()) {
ListPrefUpdate update(prefs, prefs::kNtpAppPageNames);
base::Value* list = update.Get();
list->Append(l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME));
dictionary->Set("appPageNames", list->Clone());
} else {
- dictionary->Set("appPageNames", app_page_names->Clone());
+ dictionary->Set("appPageNames", app_page_names.Clone());
}
}
@@ -685,7 +687,7 @@ base::Value::Dict AppLauncherHandler::GetExtensionInfo(
return CreateExtensionInfo(extension);
}
-void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
+void AppLauncherHandler::HandleGetApps(const base::Value::List& args) {
AllowJavascript();
base::Value::Dict dictionary;
@@ -724,7 +726,7 @@ void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
FillAppDictionary(&dictionary);
web_ui()->CallJavascriptFunctionUnsafe("ntp.getAppsCallback",
- base::Value(std::move(dictionary)));
+ std::move(dictionary));
// First time we get here we set up the observer so that we can tell update
// the apps as they change.
@@ -778,9 +780,9 @@ void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
has_loaded_apps_ = true;
}
-void AppLauncherHandler::HandleLaunchApp(const base::ListValue* args) {
- const std::string& extension_id = args->GetListDeprecated()[0].GetString();
- double source = args->GetListDeprecated()[1].GetDouble();
+void AppLauncherHandler::HandleLaunchApp(const base::Value::List& args) {
+ const std::string& extension_id = args[0].GetString();
+ double source = args[1].GetDouble();
extension_misc::AppLaunchBucket launch_bucket =
static_cast<extension_misc::AppLaunchBucket>(static_cast<int>(source));
@@ -788,12 +790,11 @@ void AppLauncherHandler::HandleLaunchApp(const base::ListValue* args) {
launch_bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
WindowOpenDisposition disposition =
- args->GetListDeprecated().size() > 3
- ? webui::GetDispositionFromClick(args, 3)
- : WindowOpenDisposition::CURRENT_TAB;
+ args.size() > 3 ? webui::GetDispositionFromClick(args, 3)
+ : WindowOpenDisposition::CURRENT_TAB;
std::string source_value;
- if (args->GetListDeprecated().size() > 2) {
- source_value = args->GetListDeprecated()[2].GetString();
+ if (args.size() > 2) {
+ source_value = args[2].GetString();
}
LaunchApp(extension_id, launch_bucket, source_value, disposition, false);
}
@@ -831,7 +832,7 @@ void AppLauncherHandler::LaunchApp(
extensions::Manifest::Type type;
GURL full_launch_url;
- apps::mojom::LaunchContainer launch_container;
+ apps::LaunchContainer launch_container;
web_app::WebAppRegistrar& registrar = web_app_provider_->registrar();
if (registrar.IsInstalled(extension_id) &&
@@ -875,9 +876,9 @@ void AppLauncherHandler::LaunchApp(
apps::AppLaunchParams params(
extension_id,
disposition == WindowOpenDisposition::NEW_WINDOW
- ? apps::mojom::LaunchContainer::kLaunchContainerWindow
- : apps::mojom::LaunchContainer::kLaunchContainerTab,
- disposition, apps::mojom::LaunchSource::kFromNewTabPage);
+ ? apps::LaunchContainer::kLaunchContainerWindow
+ : apps::LaunchContainer::kLaunchContainerTab,
+ disposition, apps::LaunchSource::kFromNewTabPage);
params.override_url = override_url;
apps::AppServiceProxyFactory::GetForProfile(profile)
->BrowserAppLauncher()
@@ -895,7 +896,7 @@ void AppLauncherHandler::LaunchApp(
extension_id, launch_container,
old_contents ? WindowOpenDisposition::CURRENT_TAB
: WindowOpenDisposition::NEW_FOREGROUND_TAB,
- apps::mojom::LaunchSource::kFromNewTabPage);
+ apps::LaunchSource::kFromNewTabPage);
params.override_url = override_url;
WebContents* new_contents =
apps::AppServiceProxyFactory::GetForProfile(profile)
@@ -910,9 +911,9 @@ void AppLauncherHandler::LaunchApp(
}
}
-void AppLauncherHandler::HandleSetLaunchType(const base::ListValue* args) {
- const std::string& app_id = args->GetListDeprecated()[0].GetString();
- double launch_type_double = args->GetListDeprecated()[1].GetDouble();
+void AppLauncherHandler::HandleSetLaunchType(const base::Value::List& args) {
+ const std::string& app_id = args[0].GetString();
+ double launch_type_double = args[1].GetDouble();
extensions::LaunchType launch_type =
static_cast<extensions::LaunchType>(static_cast<int>(launch_type_double));
@@ -955,8 +956,8 @@ void AppLauncherHandler::HandleSetLaunchType(const base::ListValue* args) {
extensions::SetLaunchType(Profile::FromWebUI(web_ui()), app_id, launch_type);
}
-void AppLauncherHandler::HandleUninstallApp(const base::ListValue* args) {
- const std::string& extension_id = args->GetListDeprecated()[0].GetString();
+void AppLauncherHandler::HandleUninstallApp(const base::Value::List& args) {
+ const std::string& extension_id = args[0].GetString();
if (web_app_provider_->registrar().IsInstalled(extension_id) &&
!IsYoutubeExtension(extension_id)) {
@@ -970,9 +971,8 @@ void AppLauncherHandler::HandleUninstallApp(const base::ListValue* args) {
}
extension_id_prompting_ = extension_id;
- const auto& list = args->GetListDeprecated();
const bool dont_confirm =
- list.size() >= 2 && list[1].is_bool() && list[1].GetBool();
+ args.size() >= 2 && args[1].is_bool() && args[1].GetBool();
if (dont_confirm) {
auto uninstall_success_callback = base::BindOnce(
@@ -1027,9 +1027,8 @@ void AppLauncherHandler::HandleUninstallApp(const base::ListValue* args) {
extension_id_prompting_ = extension_id;
- const auto& list = args->GetListDeprecated();
const bool dont_confirm =
- list.size() >= 2 && list[1].is_bool() && list[1].GetBool();
+ args.size() >= 2 && args[1].is_bool() && args[1].GetBool();
if (dont_confirm) {
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
// Do the uninstall work here.
@@ -1044,9 +1043,10 @@ void AppLauncherHandler::HandleUninstallApp(const base::ListValue* args) {
}
}
-void AppLauncherHandler::HandleCreateAppShortcut(base::OnceClosure done,
- const base::ListValue* args) {
- const std::string& app_id = args->GetListDeprecated()[0].GetString();
+void AppLauncherHandler::HandleCreateAppShortcut(
+ base::OnceClosure done,
+ const base::Value::List& args) {
+ const std::string& app_id = args[0].GetString();
if (web_app_provider_->registrar().IsInstalled(app_id) &&
!IsYoutubeExtension(app_id)) {
Browser* browser =
@@ -1084,8 +1084,9 @@ void AppLauncherHandler::HandleCreateAppShortcut(base::OnceClosure done,
std::move(done)));
}
-void AppLauncherHandler::HandleInstallAppLocally(const base::ListValue* args) {
- const std::string& app_id = args->GetListDeprecated()[0].GetString();
+void AppLauncherHandler::HandleInstallAppLocally(
+ const base::Value::List& args) {
+ const std::string& app_id = args[0].GetString();
if (!web_app_provider_->registrar().IsInstalled(app_id))
return;
@@ -1096,23 +1097,16 @@ void AppLauncherHandler::HandleInstallAppLocally(const base::ListValue* args) {
web_app_provider_->sync_bridge().SetAppInstallTime(app_id, base::Time::Now());
}
-void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
- const std::string& extension_id = args->GetListDeprecated()[0].GetString();
+void AppLauncherHandler::HandleShowAppInfo(const base::Value::List& args) {
+ const std::string& extension_id = args[0].GetString();
if (web_app_provider_->registrar().IsInstalled(extension_id) &&
!IsYoutubeExtension(extension_id)) {
- if (base::FeatureList::IsEnabled(
- features::kDesktopPWAsWebAppSettingsPage)) {
- // This assumes the AppLauncherHandler is only used by chrome://apps page.
- // It needs to be updated if it's also used by other surfaces.
- chrome::ShowWebAppSettings(
- chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()),
- extension_id, web_app::AppSettingsPageEntryPoint::kChromeAppsPage);
- return;
- }
- chrome::ShowSiteSettings(
+ // This assumes the AppLauncherHandler is only used by chrome://apps page.
+ // It needs to be updated if it's also used by other surfaces.
+ chrome::ShowWebAppSettings(
chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()),
- web_app_provider_->registrar().GetAppStartUrl(extension_id));
+ extension_id, web_app::AppSettingsPageEntryPoint::kChromeAppsPage);
return;
}
@@ -1130,12 +1124,11 @@ void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
base::DoNothing());
}
-void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) {
- base::Value::ConstListView args_list = args->GetListDeprecated();
+void AppLauncherHandler::HandleReorderApps(const base::Value::List& args_list) {
CHECK_EQ(args_list.size(), 2u);
const std::string& dragged_app_id = args_list[0].GetString();
- base::Value::ConstListView app_order = args_list[1].GetListDeprecated();
+ const base::Value::List& app_order = args_list[1].GetList();
std::string predecessor_to_moved_ext;
std::string successor_to_moved_ext;
@@ -1158,11 +1151,11 @@ void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) {
successor_to_moved_ext);
}
-void AppLauncherHandler::HandleSetPageIndex(const base::ListValue* args) {
+void AppLauncherHandler::HandleSetPageIndex(const base::Value::List& args) {
AppSorting* app_sorting =
ExtensionSystem::Get(extension_service_->profile())->app_sorting();
- const std::string& extension_id = args->GetListDeprecated()[0].GetString();
- double page_index = args->GetListDeprecated()[1].GetDouble();
+ const std::string& extension_id = args[0].GetString();
+ double page_index = args[1].GetDouble();
const syncer::StringOrdinal& page_ordinal =
app_sorting->PageIntegerAsStringOrdinal(static_cast<size_t>(page_index));
@@ -1171,10 +1164,9 @@ void AppLauncherHandler::HandleSetPageIndex(const base::ListValue* args) {
app_sorting->SetPageOrdinal(extension_id, page_ordinal);
}
-void AppLauncherHandler::HandleSaveAppPageName(const base::ListValue* args) {
- const std::string& name = args->GetListDeprecated()[0].GetString();
- size_t page_index =
- static_cast<size_t>(args->GetListDeprecated()[1].GetDouble());
+void AppLauncherHandler::HandleSaveAppPageName(const base::Value::List& args) {
+ const std::string& name = args[0].GetString();
+ size_t page_index = static_cast<size_t>(args[1].GetDouble());
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
@@ -1187,8 +1179,8 @@ void AppLauncherHandler::HandleSaveAppPageName(const base::ListValue* args) {
}
}
-void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
- base::Value::ConstListView list = args->GetListDeprecated();
+void AppLauncherHandler::HandleGenerateAppForLink(
+ const base::Value::List& list) {
GURL launch_url(list[0].GetString());
// Do not install app for invalid url.
if (!launch_url.SchemeIsHTTPOrHTTPS())
@@ -1227,20 +1219,20 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
&cancelable_task_tracker_);
}
-void AppLauncherHandler::HandlePageSelected(const base::ListValue* args) {
- double index_double = args->GetListDeprecated()[0].GetDouble();
+void AppLauncherHandler::HandlePageSelected(const base::Value::List& args) {
+ double index_double = args[0].GetDouble();
int index = static_cast<int>(index_double);
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetInteger(prefs::kNtpShownPage, APPS_PAGE_ID | index);
}
-void AppLauncherHandler::HandleRunOnOsLogin(const base::ListValue* args) {
+void AppLauncherHandler::HandleRunOnOsLogin(const base::Value::List& args) {
if (!base::FeatureList::IsEnabled(features::kDesktopPWAsRunOnOsLogin))
return;
- const std::string& app_id = args->GetListDeprecated()[0].GetString();
- const std::string& mode_string = args->GetListDeprecated()[1].GetString();
+ const std::string& app_id = args[0].GetString();
+ const std::string& mode_string = args[1].GetString();
web_app::RunOnOsLoginMode mode;
if (mode_string == kRunOnOsLoginModeNotRun) {
@@ -1252,14 +1244,15 @@ void AppLauncherHandler::HandleRunOnOsLogin(const base::ListValue* args) {
return;
}
- web_app::PersistRunOnOsLoginUserChoice(
- &web_app_provider_->registrar(),
- &web_app_provider_->os_integration_manager(),
- &web_app_provider_->sync_bridge(), app_id, mode);
+ web_app_provider_->command_manager().ScheduleCommand(
+ web_app::RunOnOsLoginCommand::CreateForSetLoginMode(
+ &web_app_provider_->registrar(),
+ &web_app_provider_->os_integration_manager(),
+ &web_app_provider_->sync_bridge(), app_id, mode, base::DoNothing()));
}
void AppLauncherHandler::HandleLaunchDeprecatedAppDialog(
- const base::ListValue* args) {
+ const base::Value::List& args) {
TabDialogs::FromWebContents(web_ui()->GetWebContents())
->ShowDeprecatedAppsDialog(extensions::ExtensionId(), deprecated_app_ids_,
web_ui()->GetWebContents(), base::DoNothing());
@@ -1313,7 +1306,7 @@ void AppLauncherHandler::OnExtensionPreferenceChanged() {
base::Value::Dict dictionary;
FillAppDictionary(&dictionary);
web_ui()->CallJavascriptFunctionUnsafe("ntp.appsPrefChangeCallback",
- base::Value(std::move(dictionary)));
+ std::move(dictionary));
}
void AppLauncherHandler::CleanupAfterUninstall() {
@@ -1402,8 +1395,8 @@ void AppLauncherHandler::ExtensionRemoved(const Extension* extension,
base::Value::Dict app_info(GetExtensionInfo(extension));
web_ui()->CallJavascriptFunctionUnsafe(
- "ntp.appRemoved", base::Value(std::move(app_info)),
- base::Value(is_uninstall), base::Value(!extension_id_prompting_.empty()));
+ "ntp.appRemoved", std::move(app_info), base::Value(is_uninstall),
+ base::Value(!extension_id_prompting_.empty()));
}
bool AppLauncherHandler::ShouldShow(const Extension* extension) {
diff --git a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
index df3a49691f9..07155869a33 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -130,12 +130,12 @@ class AppLauncherHandler
void FillPromoDictionary(base::DictionaryValue* value);
// Handles the "launchApp" message with unused |args|.
- void HandleGetApps(const base::ListValue* args);
+ void HandleGetApps(const base::Value::List& args);
// Handles the "launchApp" message with |args| containing [extension_id,
// source] with optional [url, disposition], |disposition| defaulting to
// CURRENT_TAB.
- void HandleLaunchApp(const base::ListValue* args);
+ void HandleLaunchApp(const base::Value::List& args);
void LaunchApp(std::string extension_id,
extension_misc::AppLaunchBucket launch_bucket,
@@ -145,49 +145,49 @@ class AppLauncherHandler
// Handles the "setLaunchType" message with args containing [extension_id,
// launch_type].
- void HandleSetLaunchType(const base::ListValue* args);
+ void HandleSetLaunchType(const base::Value::List& args);
// Handles the "uninstallApp" message with |args| containing [extension_id]
// and an optional bool to not confirm the uninstall when true, defaults to
// false.
- void HandleUninstallApp(const base::ListValue* args);
+ void HandleUninstallApp(const base::Value::List& args);
// Handles the "createAppShortcut" message with |args| containing
// [extension_id].
void HandleCreateAppShortcut(base::OnceClosure done,
- const base::ListValue* args);
+ const base::Value::List& args);
// Handles the "installAppLocally" message with |args| containing
// [extension_id].
- void HandleInstallAppLocally(const base::ListValue* args);
+ void HandleInstallAppLocally(const base::Value::List& args);
// Handles the "showAppInfo" message with |args| containing [extension_id].
- void HandleShowAppInfo(const base::ListValue* args);
+ void HandleShowAppInfo(const base::Value::List& args);
// Handles the "reorderApps" message with |args| containing [dragged_app_id,
// app_order].
- void HandleReorderApps(const base::ListValue* args);
+ void HandleReorderApps(const base::Value::List& args);
// Handles the "setPageIndex" message with |args| containing [extension_id,
// page_index].
- void HandleSetPageIndex(const base::ListValue* args);
+ void HandleSetPageIndex(const base::Value::List& args);
// Handles "saveAppPageName" message with |args| containing [name,
// page_index].
- void HandleSaveAppPageName(const base::ListValue* args);
+ void HandleSaveAppPageName(const base::Value::List& args);
// Handles "generateAppForLink" message with |args| containing [url, title,
// page_index].
- void HandleGenerateAppForLink(const base::ListValue* args);
+ void HandleGenerateAppForLink(const base::Value::List& args);
// Handles "pageSelected" message with |args| containing [page_index].
- void HandlePageSelected(const base::ListValue* args);
+ void HandlePageSelected(const base::Value::List& args);
// Handles "runOnOsLogin" message with |args| containing [app_id, mode]
- void HandleRunOnOsLogin(const base::ListValue* args);
+ void HandleRunOnOsLogin(const base::Value::List& args);
// Handles "deprecatedDialogLinkClicked" message with no |args|
- void HandleLaunchDeprecatedAppDialog(const base::ListValue* args);
+ void HandleLaunchDeprecatedAppDialog(const base::Value::List& args);
private:
FRIEND_TEST_ALL_PREFIXES(AppLauncherHandlerTest,
diff --git a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler_unittest.cc b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler_unittest.cc
index a04ac21d9b1..c1870693160 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler_unittest.cc
@@ -181,14 +181,14 @@ TEST_F(AppLauncherHandlerTest, HandleInstallAppLocally) {
std::unique_ptr<TestAppLauncherHandler> app_launcher_handler =
GetAppLauncherHandler(test_web_ui.get());
- auto args = std::make_unique<base::ListValue>();
- args->Append(base::Value(installed_app_id));
- app_launcher_handler->HandleGetApps(/*args=*/nullptr);
+ base::Value::List args;
+ args.Append(base::Value(installed_app_id));
+ app_launcher_handler->HandleGetApps(/*args=*/base::Value::List());
app_launcher_handler->test_web_ui()->ClearTrackedCalls();
// Call AppLauncherHandler::HandleInstallAppLocally for the web_ui and expect
// that the JS is made correctly.
- app_launcher_handler->HandleInstallAppLocally(args.get());
+ app_launcher_handler->HandleInstallAppLocally(args);
ValidateLocallyInstalledCallData(app_launcher_handler.get(),
installed_app_id);
@@ -207,9 +207,9 @@ TEST_F(AppLauncherHandlerTest, HandleInstallAppLocally_MultipleWebUI) {
std::unique_ptr<TestAppLauncherHandler> app_launcher_handler_1 =
GetAppLauncherHandler(test_web_ui_1.get());
- auto args = std::make_unique<base::ListValue>();
- args->Append(base::Value(installed_app_id));
- app_launcher_handler_1->HandleGetApps(/*args=*/nullptr);
+ base::Value::List args;
+ args.Append(base::Value(installed_app_id));
+ app_launcher_handler_1->HandleGetApps(/*args=*/base::Value::List());
app_launcher_handler_1->test_web_ui()->ClearTrackedCalls();
// Initialize the second web_ui instance.
@@ -219,13 +219,13 @@ TEST_F(AppLauncherHandlerTest, HandleInstallAppLocally_MultipleWebUI) {
CreateTestWebUI(test_web_contents_2.get());
std::unique_ptr<TestAppLauncherHandler> app_launcher_handler_2 =
GetAppLauncherHandler(test_web_ui_2.get());
- app_launcher_handler_2->HandleGetApps(/*args=*/nullptr);
+ app_launcher_handler_2->HandleGetApps(/*args=*/base::Value::List());
app_launcher_handler_2->test_web_ui()->ClearTrackedCalls();
// Call AppLauncherHandler::HandleInstallAppLocally for the first web_ui
// handler and expect the correct JS call is made to both the web_ui
// instances.
- app_launcher_handler_1->HandleInstallAppLocally(args.get());
+ app_launcher_handler_1->HandleInstallAppLocally(args);
ValidateLocallyInstalledCallData(app_launcher_handler_1.get(),
installed_app_id);
diff --git a/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc b/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc
index 8a7e21ef23e..e7d8557a9ef 100644
--- a/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc
@@ -86,11 +86,11 @@ void CookieControlsHandler::OnThirdPartyCookieBlockingPolicyChanged() {
}
void CookieControlsHandler::SendCookieControlsUIChanges() {
- base::DictionaryValue dict;
- dict.SetBoolKey("enforced", service_->ShouldEnforceCookieControls());
- dict.SetBoolKey("checked", service_->GetToggleCheckedValue());
- dict.SetStringKey(
- "icon", GetEnforcementIcon(service_->GetCookieControlsEnforcement()));
- dict.SetStringKey("cookieSettingsUrl", chrome::kChromeUICookieSettingsURL);
+ base::Value::Dict dict;
+ dict.Set("enforced", service_->ShouldEnforceCookieControls());
+ dict.Set("checked", service_->GetToggleCheckedValue());
+ dict.Set("icon",
+ GetEnforcementIcon(service_->GetCookieControlsEnforcement()));
+ dict.Set("cookieSettingsUrl", chrome::kChromeUICookieSettingsURL);
FireWebUIListener("cookie-controls-changed", dict);
}
diff --git a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index ca7b06558c1..d34cb55fae7 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -189,8 +189,7 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(
std::move(callback).Run(html_bytes.get());
}
-std::string NewTabUI::NewTabHTMLSource::GetMimeType(
- const std::string& resource) {
+std::string NewTabUI::NewTabHTMLSource::GetMimeType(const GURL&) {
return "text/html";
}
diff --git a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
index b812ddb072f..bd223e1bf24 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -64,7 +64,7 @@ class NewTabUI : public content::WebUIController {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string&) override;
+ std::string GetMimeType(const GURL&) override;
bool ShouldReplaceExistingSource() override;
std::string GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) override;
diff --git a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 8048353c495..8e19576e08d 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service_factory.h"
#include "chrome/browser/ui/layout_constants.h"
@@ -51,6 +52,7 @@
#include "ui/base/theme_provider.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/color/color_provider.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
@@ -96,9 +98,9 @@ std::string ReplaceTemplateExpressions(
} // namespace
SkColor GetThemeColor(const ui::NativeTheme* native_theme,
- const ui::ThemeProvider& tp,
+ const ui::ColorProvider& cp,
int id) {
- SkColor color = tp.GetColor(id);
+ SkColor color = cp.GetColor(id);
// If web contents are being inverted because the system is in high-contrast
// mode, any system theme colors we use must be inverted too to cancel out.
return native_theme->GetPlatformHighContrastColorScheme() ==
@@ -322,14 +324,11 @@ void NTPResourceCache::CreateNewTabIncognitoHTML(
replacements["cookieControlsTooltipText"] = l10n_util::GetStringUTF8(
IDS_NEW_TAB_OTR_COOKIE_CONTROLS_CONTROLLED_TOOLTIP_TEXT);
- // Requesting the incognito HTML is only done from within incognito browser
- // windows. The ThemeProvider associated with the requesting WebContents will
- // wrap the relevant incognito bits.
- const ui::ThemeProvider* tp = webui::GetThemeProvider(wc_getter.Run());
- DCHECK(tp);
+ const ui::ThemeProvider& tp =
+ ThemeService::GetThemeProviderForProfile(incognito_profile);
replacements["hasCustomBackground"] =
- tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND) ? "true" : "false";
+ tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND) ? "true" : "false";
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &replacements);
@@ -422,11 +421,8 @@ void NTPResourceCache::CreateNewTabIncognitoCSS(
const ui::NativeTheme* native_theme = webui::GetNativeTheme(web_contents);
DCHECK(native_theme);
- // Requesting the incognito CSS is only done from within incognito browser
- // windows. The ThemeProvider associated with the requesting WebContents will
- // wrap the relevant incognito bits.
- const ui::ThemeProvider* tp = webui::GetThemeProvider(web_contents);
- DCHECK(tp);
+ const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile(
+ profile_->GetPrimaryOTRProfile(/*create_if_needed=*/true));
// Generate the replacements.
ui::TemplateReplacements substitutions;
@@ -436,10 +432,11 @@ void NTPResourceCache::CreateNewTabIncognitoCSS(
profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
// Colors.
+ const ui::ColorProvider& cp = web_contents->GetColorProvider();
substitutions["colorBackground"] = color_utils::SkColorToRgbaString(
- GetThemeColor(native_theme, *tp, ThemeProperties::COLOR_NTP_BACKGROUND));
- substitutions["backgroundPosition"] = GetNewTabBackgroundPositionCSS(*tp);
- substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(*tp);
+ GetThemeColor(native_theme, cp, kColorNewTabPageBackground));
+ substitutions["backgroundPosition"] = GetNewTabBackgroundPositionCSS(tp);
+ substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
// Get our template.
static const base::NoDestructor<scoped_refptr<base::RefCountedMemory>>
@@ -461,19 +458,19 @@ void NTPResourceCache::CreateNewTabCSS(
const ui::NativeTheme* native_theme = webui::GetNativeTheme(web_contents);
DCHECK(native_theme);
- const ui::ThemeProvider* tp = webui::GetThemeProvider(web_contents);
- DCHECK(tp);
+ const ui::ThemeProvider& tp =
+ ThemeService::GetThemeProviderForProfile(profile_);
+ const ui::ColorProvider& cp = web_contents->GetColorProvider();
// Get our theme colors.
SkColor color_background =
- GetThemeColor(native_theme, *tp, ThemeProperties::COLOR_NTP_BACKGROUND);
- SkColor color_text =
- GetThemeColor(native_theme, *tp, ThemeProperties::COLOR_NTP_TEXT);
+ GetThemeColor(native_theme, cp, kColorNewTabPageBackground);
+ SkColor color_text = GetThemeColor(native_theme, cp, kColorNewTabPageText);
SkColor color_text_light =
- GetThemeColor(native_theme, *tp, ThemeProperties::COLOR_NTP_TEXT_LIGHT);
+ GetThemeColor(native_theme, cp, kColorNewTabPageTextLight);
- SkColor color_section_border = GetThemeColor(
- native_theme, *tp, ThemeProperties::COLOR_NTP_SECTION_BORDER);
+ SkColor color_section_border =
+ GetThemeColor(native_theme, cp, kColorNewTabPageSectionBorder);
// Generate the replacements.
ui::TemplateReplacements substitutions;
@@ -486,9 +483,9 @@ void NTPResourceCache::CreateNewTabCSS(
substitutions["colorBackground"] =
color_utils::SkColorToRgbaString(color_background);
substitutions["colorLink"] = color_utils::SkColorToRgbString(
- GetThemeColor(native_theme, *tp, ThemeProperties::COLOR_NTP_LINK));
- substitutions["backgroundPosition"] = GetNewTabBackgroundPositionCSS(*tp);
- substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(*tp);
+ GetThemeColor(native_theme, cp, kColorNewTabPageLink));
+ substitutions["backgroundPosition"] = GetNewTabBackgroundPositionCSS(tp);
+ substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
substitutions["colorTextRgba"] = color_utils::SkColorToRgbaString(color_text);
substitutions["colorTextLight"] =
color_utils::SkColorToRgbaString(color_text_light);
@@ -499,7 +496,7 @@ void NTPResourceCache::CreateNewTabCSS(
// For themes that right-align the background, we flip the attribution to the
// left to avoid conflicts.
int alignment =
- tp->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
+ tp.GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
if (alignment & ThemeProperties::ALIGN_RIGHT) {
substitutions["leftAlignAttribution"] = "0";
substitutions["rightAlignAttribution"] = "auto";
@@ -511,7 +508,7 @@ void NTPResourceCache::CreateNewTabCSS(
}
substitutions["displayAttribution"] =
- tp->HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "inline" : "none";
+ tp.HasCustomImage(IDR_THEME_NTP_ATTRIBUTION) ? "inline" : "none";
// Get our template.
static const base::NoDestructor<scoped_refptr<base::RefCountedMemory>>
diff --git a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
index 19fab17dfd3..b7a57809ded 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
@@ -31,11 +31,12 @@ class PolicyChangeRegistrar;
}
namespace ui {
+class ColorProvider;
class ThemeProvider;
}
SkColor GetThemeColor(const ui::NativeTheme* native_theme,
- const ui::ThemeProvider& tp,
+ const ui::ColorProvider& cp,
int id);
std::string GetNewTabBackgroundPositionCSS(
const ui::ThemeProvider& theme_provider);
diff --git a/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc b/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
index a63a42c231a..f1cafb15d00 100644
--- a/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
@@ -57,16 +57,12 @@ class ChromeNTPTilesInternalsMessageHandlerClient
std::unique_ptr<ntp_tiles::MostVisitedSites> MakeMostVisitedSites() override;
PrefService* GetPrefs() override;
void RegisterMessageCallback(
- const std::string& message,
+ base::StringPiece message,
base::RepeatingCallback<void(const base::Value::List&)> callback)
override;
- void RegisterDeprecatedMessageCallback(
- const std::string& message,
- const base::RepeatingCallback<void(const base::ListValue*)>& callback)
- override;
- void CallJavascriptFunctionVector(
- const std::string& name,
- const std::vector<const base::Value*>& values) override;
+ void CallJavascriptFunctionSpan(
+ base::StringPiece name,
+ base::span<const base::ValueView> values) override;
ntp_tiles::NTPTilesInternalsMessageHandler handler_;
};
@@ -117,21 +113,14 @@ PrefService* ChromeNTPTilesInternalsMessageHandlerClient::GetPrefs() {
}
void ChromeNTPTilesInternalsMessageHandlerClient::RegisterMessageCallback(
- const std::string& message,
+ base::StringPiece message,
base::RepeatingCallback<void(const base::Value::List&)> callback) {
web_ui()->RegisterMessageCallback(message, std::move(callback));
}
-void ChromeNTPTilesInternalsMessageHandlerClient::
- RegisterDeprecatedMessageCallback(
- const std::string& message,
- const base::RepeatingCallback<void(const base::ListValue*)>& callback) {
- web_ui()->RegisterDeprecatedMessageCallback(message, callback);
-}
-
-void ChromeNTPTilesInternalsMessageHandlerClient::CallJavascriptFunctionVector(
- const std::string& name,
- const std::vector<const base::Value*>& values) {
+void ChromeNTPTilesInternalsMessageHandlerClient::CallJavascriptFunctionSpan(
+ base::StringPiece name,
+ base::span<const base::ValueView> values) {
web_ui()->CallJavascriptFunctionUnsafe(name, values);
}
diff --git a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
index f7e394db878..c7cf7aaa7a0 100644
--- a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
@@ -92,9 +92,9 @@ void OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages(
std::string callback_id = args[0].GetString();
std::vector<int64_t> offline_ids;
- base::Value::ConstListView offline_ids_from_arg = args[1].GetListDeprecated();
- for (size_t i = 0; i < offline_ids_from_arg.size(); i++) {
- std::string value = offline_ids_from_arg[i].GetString();
+ const base::Value::List& offline_ids_from_arg = args[1].GetList();
+ for (const auto& arg : offline_ids_from_arg) {
+ std::string value = arg.GetString();
int64_t int_value;
base::StringToInt64(value, &int_value);
offline_ids.push_back(int_value);
@@ -115,9 +115,9 @@ void OfflineInternalsUIMessageHandler::HandleDeleteSelectedRequests(
std::string callback_id = args[0].GetString();
std::vector<int64_t> offline_ids;
- base::Value::ConstListView offline_ids_from_arg = args[1].GetListDeprecated();
- for (size_t i = 0; i < offline_ids_from_arg.size(); i++) {
- std::string value = offline_ids_from_arg[i].GetString();
+ const base::Value::List& offline_ids_from_arg = args[1].GetList();
+ for (const auto& arg : offline_ids_from_arg) {
+ std::string value = arg.GetString();
int64_t int_value;
base::StringToInt64(value, &int_value);
offline_ids.push_back(int_value);
@@ -151,22 +151,20 @@ void OfflineInternalsUIMessageHandler::HandleDeletedRequestsCallback(
void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback(
std::string callback_id,
const offline_pages::MultipleOfflinePageItemResult& pages) {
- std::vector<base::Value> results;
+ base::Value::List results;
for (const auto& page : pages) {
- base::Value offline_page(base::Value::Type::DICTIONARY);
- offline_page.SetStringKey("onlineUrl", page.url.spec());
- offline_page.SetStringKey("namespace", page.client_id.name_space);
- offline_page.SetDoubleKey("size", page.file_size);
- offline_page.SetStringKey("id", std::to_string(page.offline_id));
- offline_page.SetStringKey("filePath", page.file_path.MaybeAsASCII());
- offline_page.SetDoubleKey("creationTime", page.creation_time.ToJsTime());
- offline_page.SetDoubleKey("lastAccessTime",
- page.last_access_time.ToJsTime());
- offline_page.SetIntKey("accessCount", page.access_count);
- offline_page.SetStringKey("originalUrl",
- page.original_url_if_different.spec());
- offline_page.SetStringKey("requestOrigin", page.request_origin);
- results.push_back(std::move(offline_page));
+ base::Value::Dict offline_page;
+ offline_page.Set("onlineUrl", page.url.spec());
+ offline_page.Set("namespace", page.client_id.name_space);
+ offline_page.Set("size", static_cast<int>(page.file_size));
+ offline_page.Set("id", std::to_string(page.offline_id));
+ offline_page.Set("filePath", page.file_path.MaybeAsASCII());
+ offline_page.Set("creationTime", page.creation_time.ToJsTime());
+ offline_page.Set("lastAccessTime", page.last_access_time.ToJsTime());
+ offline_page.Set("accessCount", page.access_count);
+ offline_page.Set("originalUrl", page.original_url_if_different.spec());
+ offline_page.Set("requestOrigin", page.request_origin);
+ results.Append(std::move(offline_page));
}
// Sort by creation order.
std::sort(results.begin(), results.end(), [](const auto& a, const auto& b) {
@@ -174,8 +172,7 @@ void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback(
b.FindKey({"creationTime"})->GetDouble();
});
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(results)));
+ ResolveJavascriptCallback(base::Value(callback_id), results);
}
void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback(
@@ -195,8 +192,7 @@ void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback(
save_page_request.Set("requestOrigin", request->request_origin());
save_page_requests.Append(std::move(save_page_request));
}
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(save_page_requests)));
+ ResolveJavascriptCallback(base::Value(callback_id), save_page_requests);
}
void OfflineInternalsUIMessageHandler::HandleGetRequestQueue(
@@ -209,7 +205,7 @@ void OfflineInternalsUIMessageHandler::HandleGetRequestQueue(
&OfflineInternalsUIMessageHandler::HandleRequestQueueCallback,
weak_ptr_factory_.GetWeakPtr(), callback_id));
} else {
- base::ListValue results;
+ base::Value::List results;
ResolveJavascriptCallback(base::Value(callback_id), results);
}
}
@@ -224,7 +220,7 @@ void OfflineInternalsUIMessageHandler::HandleGetStoredPages(
&OfflineInternalsUIMessageHandler::HandleStoredPagesCallback,
weak_ptr_factory_.GetWeakPtr(), callback_id));
} else {
- base::ListValue results;
+ base::Value::List results;
ResolveJavascriptCallback(base::Value(callback_id), results);
}
}
@@ -452,20 +448,20 @@ void OfflineInternalsUIMessageHandler::HandleGetLoggingState(
AllowJavascript();
const base::Value& callback_id = args[0];
- base::DictionaryValue result;
- result.SetBoolKey("modelIsLogging",
- offline_page_model_
- ? offline_page_model_->GetLogger()->GetIsLogging()
- : false);
- result.SetBoolKey("queueIsLogging",
- request_coordinator_
- ? request_coordinator_->GetLogger()->GetIsLogging()
- : false);
+ base::Value::Dict result;
+ result.Set("modelIsLogging",
+ offline_page_model_
+ ? offline_page_model_->GetLogger()->GetIsLogging()
+ : false);
+ result.Set("queueIsLogging",
+ request_coordinator_
+ ? request_coordinator_->GetLogger()->GetIsLogging()
+ : false);
bool prefetch_logging = false;
if (prefetch_service_) {
prefetch_logging = prefetch_service_->GetLogger()->GetIsLogging();
}
- result.SetBoolKey("prefetchIsLogging", prefetch_logging);
+ result.Set("prefetchIsLogging", prefetch_logging);
ResolveJavascriptCallback(callback_id, result);
}
@@ -483,7 +479,7 @@ void OfflineInternalsUIMessageHandler::HandleGetEventLogs(
prefetch_service_->GetLogger()->GetLogs(&logs);
std::sort(logs.begin(), logs.end());
- base::ListValue result;
+ base::Value::List result;
for (const std::string& log : logs) {
result.Append(log);
}
diff --git a/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.cc b/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.cc
new file mode 100644
index 00000000000..ffa12bab5b9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/password_manager/password_manager_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/managed_ui_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/password_manager_resources.h"
+#include "chrome/grit/password_manager_resources_map.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace {
+
+content::WebUIDataSource* CreatePasswordsUIHTMLSource(Profile* profile) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIPasswordManagerHost);
+
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kPasswordManagerResources, kPasswordManagerResourcesSize),
+ IDR_PASSWORD_MANAGER_PASSWORD_MANAGER_HTML);
+
+ static constexpr webui::LocalizedString kStrings[] = {
+ {"title", IDS_PASSWORD_MANAGER_UI_TITLE},
+ };
+ source->AddLocalizedStrings(kStrings);
+
+ return source;
+}
+
+} // namespace
+
+PasswordManagerUI::PasswordManagerUI(content::WebUI* web_ui)
+ : WebUIController(web_ui) {
+ // Set up the chrome://password-manager/ source.
+ Profile* profile = Profile::FromWebUI(web_ui);
+ auto* source = CreatePasswordsUIHTMLSource(profile);
+ ManagedUIHandler::Initialize(web_ui, source);
+ content::WebUIDataSource::Add(profile, source);
+}
diff --git a/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.h b/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.h
new file mode 100644
index 00000000000..8b67716357e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/password_manager/password_manager_ui.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_PASSWORD_MANAGER_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_PASSWORD_MANAGER_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+#include "ui/base/resource/resource_scale_factor.h"
+
+class PasswordManagerUI : public content::WebUIController {
+ public:
+ explicit PasswordManagerUI(content::WebUI* web_ui);
+
+ PasswordManagerUI(const PasswordManagerUI&) = delete;
+ PasswordManagerUI& operator=(const PasswordManagerUI&) = delete;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_PASSWORD_MANAGER_PASSWORD_MANAGER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/policy_ui.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui.cc
index 6b26cb6162e..aa5796e47e2 100644
--- a/chromium/chrome/browser/ui/webui/policy/policy_ui.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui.cc
@@ -84,11 +84,19 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
source->AddResourcePath("policy.css", IDR_POLICY_CSS);
source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS);
source->AddResourcePath("policy.js", IDR_POLICY_JS);
+ source->AddResourcePath("policy_conflict.html.js",
+ IDR_POLICY_POLICY_CONFLICT_HTML_JS);
source->AddResourcePath("policy_conflict.js", IDR_POLICY_POLICY_CONFLICT_JS);
+ source->AddResourcePath("policy_row.html.js", IDR_POLICY_POLICY_ROW_HTML_JS);
source->AddResourcePath("policy_row.js", IDR_POLICY_POLICY_ROW_JS);
+ source->AddResourcePath("policy_precedence_row.html.js",
+ IDR_POLICY_POLICY_PRECEDENCE_ROW_HTML_JS);
source->AddResourcePath("policy_precedence_row.js",
IDR_POLICY_POLICY_PRECEDENCE_ROW_JS);
+ source->AddResourcePath("policy_table.html.js",
+ IDR_POLICY_POLICY_TABLE_HTML_JS);
source->AddResourcePath("policy_table.js", IDR_POLICY_POLICY_TABLE_JS);
+ source->AddResourcePath("status_box.html.js", IDR_POLICY_STATUS_BOX_HTML_JS);
source->AddResourcePath("status_box.js", IDR_POLICY_STATUS_BOX_JS);
source->SetDefaultResource(IDR_POLICY_HTML);
diff --git a/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
index 6ee6dbd905b..88f8d575e82 100644
--- a/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
@@ -415,7 +415,13 @@ void PolicyUITest::VerifyExportingPolicies(
EXPECT_EQ(expected, *value_ptr);
}
-IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
+#if !defined(NDEBUG)
+// Slow and hangs often in debug builds. https://crbug.com/1338642
+#define MAYBE_WritePoliciesToJSONFile DISABLED_WritePoliciesToJSONFile
+#else
+#define MAYBE_WritePoliciesToJSONFile WritePoliciesToJSONFile
+#endif
+IN_PROC_BROWSER_TEST_F(PolicyUITest, MAYBE_WritePoliciesToJSONFile) {
// Set policy values and generate expected dictionary.
policy::PolicyMap values;
base::DictionaryValue expected_values;
@@ -491,12 +497,13 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
// contents).
VerifyExportingPolicies(expected_values);
-#if !BUILDFLAG(IS_CHROMEOS_ASH)
+#if !BUILDFLAG(IS_CHROMEOS)
// This also checks that we do not bypass the policy that blocks file
// selection dialogs. This is a desktop only policy.
values.Set(policy::key::kAllowFileSelectionDialogs,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE,
policy::POLICY_SOURCE_PLATFORM, base::Value(false), nullptr);
+
popups_blocked_for_urls.Append("eeeeee");
values.Set(policy::key::kPopupsBlockedForUrls, policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM,
diff --git a/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc
index 1a9121fc759..6589d095899 100644
--- a/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <utility>
@@ -35,12 +36,13 @@
#include "chrome/browser/policy/policy_ui_utils.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/schema_registry_service.h"
+#include "chrome/browser/policy/status_provider/cloud_policy_core_status_provider.h"
+#include "chrome/browser/policy/status_provider/status_provider_util.h"
+#include "chrome/browser/policy/status_provider/user_cloud_policy_status_provider.h"
+#include "chrome/browser/policy/value_provider/value_provider_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/managed_ui.h"
-#include "chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/chromium_strings.h"
#include "components/enterprise/browser/controller/browser_dm_token_storage.h"
@@ -94,66 +96,50 @@
#include "chrome/browser/ash/policy/off_hours/device_off_hours_controller.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h"
-#include "chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h"
-#include "chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h"
-#include "chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h"
-#include "chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h"
+#include "chrome/browser/policy/status_provider/device_active_directory_policy_status_provider.h"
+#include "chrome/browser/policy/status_provider/device_cloud_policy_status_provider_chromeos.h"
+#include "chrome/browser/policy/status_provider/device_local_account_policy_status_provider.h"
+#include "chrome/browser/policy/status_provider/user_active_directory_policy_status_provider.h"
+#include "chrome/browser/policy/status_provider/user_cloud_policy_status_provider_chromeos.h"
#include "components/user_manager/user_manager.h"
#else
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-#include "chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h"
-#include "chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h"
+#include "chrome/browser/policy/status_provider/device_policy_status_provider_lacros.h"
+#include "chrome/browser/policy/status_provider/user_policy_status_provider_lacros.h"
#include "chromeos/crosapi/mojom/policy_service.mojom.h"
#include "chromeos/lacros/lacros_service.h"
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
-#include "extensions/browser/extension_registry.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/manifest.h"
-#include "extensions/common/manifest_constants.h"
+#include "chrome/browser/policy/value_provider/extension_policies_value_provider.h"
#endif
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-#include <windows.h>
-
-#include <DSRole.h>
-
-#include "chrome/browser/google/google_update_policy_fetcher_win.h"
-#include "chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h"
-#include "chrome/install_static/install_util.h"
-#include "content/public/browser/browser_task_traits.h"
-#include "content/public/browser/browser_thread.h"
+#include "chrome/browser/policy/status_provider/updater_status_and_value_provider.h"
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
PolicyUIHandler::PolicyUIHandler() = default;
PolicyUIHandler::~PolicyUIHandler() {
- GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
- GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
+ GetPolicyService(Profile::FromWebUI(web_ui()))
+ ->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
policy::SchemaRegistry* registry = Profile::FromWebUI(web_ui())
->GetOriginalProfile()
->GetPolicySchemaRegistryService()
->registry();
registry->RemoveObserver(this);
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
- ->RemoveObserver(this);
-#endif
-
if (export_policies_select_file_dialog_) {
export_policies_select_file_dialog_->ListenerDestroyed();
}
}
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-void PolicyUIHandler::OnGotDevicePolicy(base::Value device_policy,
- base::Value legend_data) {
+void PolicyUIHandler::OnGotDevicePolicy(base::Value::Dict device_policy,
+ base::Value::Dict legend_data) {
if (device_policy != device_policy_) {
device_policy_ = std::move(device_policy);
static_cast<DevicePolicyStatusProviderLacros*>(
@@ -162,6 +148,19 @@ void PolicyUIHandler::OnGotDevicePolicy(base::Value device_policy,
SendPolicies();
}
}
+
+void PolicyUIHandler::OnGotDevicePolicyDeprecated(base::Value device_policy,
+ base::Value legend_data) {
+ base::Value::Dict device_policy_dict;
+ base::Value::Dict legend_data_dict;
+ if (device_policy.is_dict()) {
+ device_policy_dict = std::move(device_policy.GetDict());
+ }
+ if (legend_data.is_dict()) {
+ legend_data_dict = std::move(legend_data.GetDict());
+ }
+ OnGotDevicePolicy(std::move(device_policy_dict), std::move(legend_data_dict));
+}
#endif
void PolicyUIHandler::AddCommonLocalizedStringsToSource(
@@ -293,50 +292,64 @@ void PolicyUIHandler::RegisterMessages() {
std::make_unique<DevicePolicyStatusProviderLacros>();
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
-#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- ReloadUpdaterPoliciesAndState();
-#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
if (!user_status_provider_.get())
user_status_provider_ = std::make_unique<policy::PolicyStatusProvider>();
if (!device_status_provider_.get())
device_status_provider_ = std::make_unique<policy::PolicyStatusProvider>();
if (!machine_status_provider_.get())
machine_status_provider_ = std::make_unique<policy::PolicyStatusProvider>();
- if (!updater_status_provider_.get())
- updater_status_provider_ = std::make_unique<policy::PolicyStatusProvider>();
auto update_callback(base::BindRepeating(&PolicyUIHandler::SendStatus,
base::Unretained(this)));
user_status_provider_->SetStatusChangeCallback(update_callback);
device_status_provider_->SetStatusChangeCallback(update_callback);
machine_status_provider_->SetStatusChangeCallback(update_callback);
- updater_status_provider_->SetStatusChangeCallback(update_callback);
+
+#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ updater_status_and_value_provider_ =
+ std::make_unique<UpdaterStatusAndValueProvider>(
+ Profile::FromWebUI(web_ui()));
+ policy_value_provider_observations_.AddObservation(
+ updater_status_and_value_provider_.get());
+ updater_status_and_value_provider_->SetStatusChangeCallback(update_callback);
+#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(g_browser_process->local_state());
pref_change_registrar_->Add(
enterprise_reporting::kLastUploadSucceededTimestamp, update_callback);
- GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
- GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
+ GetPolicyService(Profile::FromWebUI(web_ui()))
+ ->AddObserver(policy::POLICY_DOMAIN_CHROME, this);
#if BUILDFLAG(ENABLE_EXTENSIONS)
- extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
- ->AddObserver(this);
-#endif
+ extension_policies_value_provider_ =
+ std::make_unique<ExtensionPoliciesValueProvider>(
+ Profile::FromWebUI(web_ui()));
+ policy_value_provider_observations_.AddObservation(
+ extension_policies_value_provider_.get());
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
chromeos::LacrosService* service = chromeos::LacrosService::Get();
// Get device policy.
- if (service->IsAvailable<crosapi::mojom::DeviceSettingsService>() &&
- service->GetInterfaceVersion(
- crosapi::mojom::DeviceSettingsService::Uuid_) >=
- static_cast<int>(crosapi::mojom::DeviceSettingsService::
- kGetDevicePolicyMinVersion)) {
- service->GetRemote<crosapi::mojom::DeviceSettingsService>()
- ->GetDevicePolicy(base::BindOnce(&PolicyUIHandler::OnGotDevicePolicy,
- weak_factory_.GetWeakPtr()));
+ if (service->IsAvailable<crosapi::mojom::DeviceSettingsService>()) {
+ if (service->GetInterfaceVersion(
+ crosapi::mojom::DeviceSettingsService::Uuid_) >=
+ static_cast<int>(crosapi::mojom::DeviceSettingsService::
+ kGetDevicePolicyMinVersion)) {
+ service->GetRemote<crosapi::mojom::DeviceSettingsService>()
+ ->GetDevicePolicy(base::BindOnce(&PolicyUIHandler::OnGotDevicePolicy,
+ weak_factory_.GetWeakPtr()));
+ } else if (service->GetInterfaceVersion(
+ crosapi::mojom::DeviceSettingsService::Uuid_) >=
+ static_cast<int>(crosapi::mojom::DeviceSettingsService::
+ kGetDevicePolicyDeprecatedMinVersion)) {
+ service->GetRemote<crosapi::mojom::DeviceSettingsService>()
+ ->GetDevicePolicyDeprecated(
+ base::BindOnce(&PolicyUIHandler::OnGotDevicePolicyDeprecated,
+ weak_factory_.GetWeakPtr()));
+ }
}
#endif
@@ -364,21 +377,6 @@ void PolicyUIHandler::RegisterMessages() {
base::Unretained(this)));
}
-#if BUILDFLAG(ENABLE_EXTENSIONS)
-void PolicyUIHandler::OnExtensionLoaded(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension) {
- SendPolicies();
-}
-
-void PolicyUIHandler::OnExtensionUnloaded(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- extensions::UnloadedExtensionReason reason) {
- SendPolicies();
-}
-#endif
-
void PolicyUIHandler::OnSchemaRegistryUpdated(bool has_new_schemas) {
// Update UI when new schema is added.
if (has_new_schemas) {
@@ -392,8 +390,12 @@ void PolicyUIHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
SendPolicies();
}
-base::Value PolicyUIHandler::GetPolicyNames() {
- base::Value names(base::Value::Type::DICTIONARY);
+void PolicyUIHandler::OnPolicyValueChanged() {
+ SendPolicies();
+}
+
+base::Value::Dict PolicyUIHandler::GetPolicyNames() {
+ base::Value::Dict names;
Profile* profile = Profile::FromWebUI(web_ui());
policy::SchemaRegistry* registry = profile->GetOriginalProfile()
->GetPolicySchemaRegistryService()
@@ -401,47 +403,37 @@ base::Value PolicyUIHandler::GetPolicyNames() {
scoped_refptr<policy::SchemaMap> schema_map = registry->schema_map();
// Add Chrome policy names.
- base::Value chrome_policy_names(base::Value::Type::LIST);
+ base::Value::List chrome_policy_names;
policy::PolicyNamespace chrome_ns(policy::POLICY_DOMAIN_CHROME, "");
const policy::Schema* chrome_schema = schema_map->GetSchema(chrome_ns);
for (auto it = chrome_schema->GetPropertiesIterator(); !it.IsAtEnd();
it.Advance()) {
- chrome_policy_names.Append(base::Value(it.key()));
+ chrome_policy_names.Append(it.key());
}
- base::Value chrome_values(base::Value::Type::DICTIONARY);
- chrome_values.SetStringKey("name", "Chrome Policies");
- chrome_values.SetKey("policyNames", std::move(chrome_policy_names));
- names.SetKey("chrome", std::move(chrome_values));
+ base::Value::Dict chrome_values;
+ chrome_values.Set("name", "Chrome Policies");
+ chrome_values.Set("policyNames", std::move(chrome_policy_names));
+ names.Set("chrome", std::move(chrome_values));
#if !BUILDFLAG(IS_CHROMEOS)
// Add precedence policy names.
- base::Value precedence_policy_names(base::Value::Type::LIST);
+ base::Value::List precedence_policy_names;
for (auto* policy : policy::metapolicy::kPrecedence) {
- precedence_policy_names.Append(base::Value(policy));
+ precedence_policy_names.Append(policy);
}
- base::Value precedence_values(base::Value::Type::DICTIONARY);
- precedence_values.SetStringKey("name", "Policy Precedence");
- precedence_values.SetKey("policyNames", std::move(precedence_policy_names));
- names.SetKey("precedence", std::move(precedence_values));
+ base::Value::Dict precedence_values;
+ precedence_values.Set("name", "Policy Precedence");
+ precedence_values.Set("policyNames", std::move(precedence_policy_names));
+ names.Set("precedence", std::move(precedence_values));
#endif // !BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- if (updater_policies_) {
- base::Value updater_policies(base::Value::Type::DICTIONARY);
- updater_policies.SetStringKey("name", "Google Update Policies");
- updater_policies.SetKey("policyNames", GetGoogleUpdatePolicyNames());
- names.SetKey("updater", std::move(updater_policies));
- }
+ names.Merge(updater_status_and_value_provider_->GetNames());
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
#if BUILDFLAG(ENABLE_EXTENSIONS)
// Add extension policy names.
- AddExtensionPolicyNames(&names, policy::POLICY_DOMAIN_EXTENSIONS);
-
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- AddExtensionPolicyNames(&names, policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS);
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-
+ names.Merge(extension_policies_value_provider_->GetNames());
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
return names;
@@ -450,78 +442,28 @@ base::Value PolicyUIHandler::GetPolicyNames() {
base::Value::List PolicyUIHandler::GetPolicyValues() {
auto client = std::make_unique<policy::ChromePolicyConversionsClient>(
web_ui()->GetWebContents()->GetBrowserContext());
-
-#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- if (updater_policies_) {
- return policy::ArrayPolicyConversions(std::move(client))
- .EnableConvertValues(true)
- .SetDropDefaultValues(true)
- .WithUpdaterPolicies(
- std::make_unique<policy::PolicyMap>(updater_policies_->Clone()))
- .WithUpdaterPolicySchemas(GetGoogleUpdatePolicySchemas())
- .ToValueList();
- }
-#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
auto policy_conversions = policy::ArrayPolicyConversions(std::move(client));
#if BUILDFLAG(IS_CHROMEOS_LACROS)
policy_conversions.WithAdditionalChromePolicies(device_policy_.Clone());
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
- return policy_conversions.EnableConvertValues(true).ToValueList();
-}
+ // Disable extension policies in `policy_conversions` as the extension
+ // policies will be retrieved by `extension_policies_value_provider_` if
+ // extension policies are enabled with build flags.
+ base::Value::List policy_values = policy_conversions.EnableConvertValues(true)
+ .EnableExtensionPolicies(false)
+ .ToValueList();
-void PolicyUIHandler::AddExtensionPolicyNames(
- base::Value* names,
- policy::PolicyDomain policy_domain) {
- DCHECK(names->is_dict());
#if BUILDFLAG(ENABLE_EXTENSIONS)
+ extension_policies_value_provider_->GetValues(policy_values);
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- Profile* extension_profile =
- policy_domain == policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS
- ? ash::ProfileHelper::GetSigninProfile()
- : Profile::FromWebUI(web_ui());
-#else // BUILDFLAG(IS_CHROMEOS_ASH)
- Profile* extension_profile = Profile::FromWebUI(web_ui());
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ updater_status_and_value_provider_->GetValues(policy_values);
+#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- scoped_refptr<policy::SchemaMap> schema_map =
- extension_profile->GetOriginalProfile()
- ->GetPolicySchemaRegistryService()
- ->registry()
- ->schema_map();
-
- const extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(extension_profile);
- std::unique_ptr<extensions::ExtensionSet> extension_set =
- registry->GenerateInstalledExtensionsSet();
-
- for (const scoped_refptr<const extensions::Extension>& extension :
- *extension_set) {
- // Skip this extension if it's not an enterprise extension.
- if (!extension->manifest()->FindPath(
- extensions::manifest_keys::kStorageManagedSchema)) {
- continue;
- }
- base::Value extension_value(base::Value::Type::DICTIONARY);
- extension_value.SetStringKey("name", extension->name());
- const policy::Schema* schema = schema_map->GetSchema(
- policy::PolicyNamespace(policy_domain, extension->id()));
- base::Value policy_names(base::Value::Type::LIST);
- if (schema && schema->valid()) {
- // Get policy names from the extension's policy schema.
- // Store in a map, not an array, for faster lookup on JS side.
- for (auto prop = schema->GetPropertiesIterator(); !prop.IsAtEnd();
- prop.Advance()) {
- policy_names.Append(base::Value(prop.key()));
- }
- }
- extension_value.SetKey("policyNames", std::move(policy_names));
- names->SetKey(extension->id(), std::move(extension_value));
- }
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+ return policy_values;
}
void PolicyUIHandler::SendStatus() {
@@ -531,49 +473,43 @@ void PolicyUIHandler::SendStatus() {
FireWebUIListener("status-updated", GetStatusValue(/*for_webui*/ true));
}
-base::DictionaryValue PolicyUIHandler::GetStatusValue(bool for_webui) const {
- std::unique_ptr<base::DictionaryValue> device_status(
- new base::DictionaryValue);
- device_status_provider_->GetStatus(device_status.get());
- std::unique_ptr<base::DictionaryValue> user_status(new base::DictionaryValue);
- user_status_provider_->GetStatus(user_status.get());
- const std::string* username = user_status->FindStringKey("username");
+base::Value::Dict PolicyUIHandler::GetStatusValue(bool for_webui) const {
+ base::Value::Dict device_status = device_status_provider_->GetStatus();
+ base::Value::Dict user_status = user_status_provider_->GetStatus();
+ const std::string* username = user_status.FindString("username");
if (username && !username->empty())
- user_status->SetStringKey("domain", gaia::ExtractDomainName(*username));
-
- std::unique_ptr<base::DictionaryValue> machine_status(
- new base::DictionaryValue);
- machine_status_provider_->GetStatus(machine_status.get());
+ user_status.Set("domain", gaia::ExtractDomainName(*username));
- std::unique_ptr<base::DictionaryValue> updater_status(
- new base::DictionaryValue);
- updater_status_provider_->GetStatus(updater_status.get());
+ base::Value::Dict machine_status = machine_status_provider_->GetStatus();
- base::DictionaryValue status;
- if (!device_status->DictEmpty()) {
+ base::Value::Dict status;
+ if (!device_status.empty()) {
if (for_webui)
- device_status->SetStringKey("boxLegendKey", "statusDevice");
+ device_status.Set("boxLegendKey", "statusDevice");
status.Set("device", std::move(device_status));
}
- if (!machine_status->DictEmpty()) {
+ if (!machine_status.empty()) {
if (for_webui)
- machine_status->SetStringKey("boxLegendKey", GetMachineStatusLegendKey());
-
+ machine_status.Set("boxLegendKey", GetMachineStatusLegendKey());
status.Set("machine", std::move(machine_status));
}
- if (!user_status->DictEmpty()) {
+ if (!user_status.empty()) {
if (for_webui)
- user_status->SetStringKey("boxLegendKey", "statusUser");
+ user_status.Set("boxLegendKey", "statusUser");
status.Set("user", std::move(user_status));
}
- if (!updater_status->DictEmpty()) {
+#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ base::Value::Dict updater_status =
+ updater_status_and_value_provider_->GetStatus();
+ if (!updater_status.empty()) {
if (for_webui)
- updater_status->SetStringKey("boxLegendKey", "statusUpdater");
+ updater_status.Set("boxLegendKey", "statusUpdater");
status.Set("updater", std::move(updater_status));
}
+#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
return status;
}
@@ -659,11 +595,12 @@ void PolicyUIHandler::HandleReloadPolicies(const base::Value::List& args) {
#endif
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- ReloadUpdaterPoliciesAndState();
+ updater_status_and_value_provider_->Refresh();
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- GetPolicyService()->RefreshPolicies(base::BindOnce(
- &PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr()));
+ GetPolicyService(Profile::FromWebUI(web_ui()))
+ ->RefreshPolicies(base::BindOnce(&PolicyUIHandler::OnRefreshPoliciesDone,
+ weak_factory_.GetWeakPtr()));
}
void PolicyUIHandler::HandleCopyPoliciesJson(const base::Value::List& args) {
@@ -714,42 +651,10 @@ void PolicyUIHandler::FileSelectionCanceled(void* params) {
void PolicyUIHandler::SendPolicies() {
if (IsJavascriptAllowed())
- FireWebUIListener("policies-updated", GetPolicyNames(),
- base::Value(GetPolicyValues()));
-}
-
-#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-void PolicyUIHandler::SetUpdaterPoliciesAndState(
- std::unique_ptr<GoogleUpdatePoliciesAndState> updater_policies_and_state) {
- updater_policies_ = std::move(updater_policies_and_state->policies);
- static_cast<UpdaterStatusProvider*>(updater_status_provider_.get())
- ->SetUpdaterStatus(std::move(updater_policies_and_state->state));
- if (updater_policies_)
- SendPolicies();
-}
-
-void PolicyUIHandler::ReloadUpdaterPoliciesAndState() {
- if (!updater_status_provider_)
- updater_status_provider_ = std::make_unique<UpdaterStatusProvider>();
- base::PostTaskAndReplyWithResult(
- base::ThreadPool::CreateCOMSTATaskRunner(
- {base::TaskPriority::USER_BLOCKING,
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN, base::MayBlock()})
- .get(),
- FROM_HERE, base::BindOnce(&GetGoogleUpdatePoliciesAndState),
- base::BindOnce(&PolicyUIHandler::SetUpdaterPoliciesAndState,
- weak_factory_.GetWeakPtr()));
+ FireWebUIListener("policies-updated", GetPolicyNames(), GetPolicyValues());
}
-#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
void PolicyUIHandler::OnRefreshPoliciesDone() {
SendPolicies();
SendStatus();
}
-
-policy::PolicyService* PolicyUIHandler::GetPolicyService() {
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
- return profile->GetProfilePolicyConnector()->policy_service();
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h
index 8b44c7c16c2..540019ffa03 100644
--- a/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h
@@ -12,10 +12,12 @@
#include <string>
#include "base/memory/weak_ptr.h"
+#include "base/scoped_multi_source_observation.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "chrome/browser/policy/value_provider/policy_value_provider.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_namespace.h"
@@ -28,11 +30,14 @@
#include "ui/shell_dialogs/select_file_dialog.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
-#include "extensions/browser/extension_registry_observer.h"
+#include "chrome/browser/policy/value_provider/extension_policies_value_provider.h"
#endif
+#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+#include "chrome/browser/policy/status_provider/updater_status_and_value_provider.h"
+#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+
class PrefChangeRegistrar;
-struct GoogleUpdatePoliciesAndState;
namespace policy {
class PolicyMap;
@@ -41,11 +46,9 @@ class PolicyStatusProvider;
// The JavaScript message handler for the chrome://policy page.
class PolicyUIHandler : public content::WebUIMessageHandler,
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- public extensions::ExtensionRegistryObserver,
-#endif
public policy::PolicyService::Observer,
public policy::SchemaRegistry::Observer,
+ public policy::PolicyValueProvider::Observer,
public ui::SelectFileDialog::Listener {
public:
PolicyUIHandler();
@@ -61,15 +64,6 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
// content::WebUIMessageHandler implementation.
void RegisterMessages() override;
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- // extensions::ExtensionRegistryObserver implementation.
- void OnExtensionLoaded(content::BrowserContext* browser_context,
- const extensions::Extension* extension) override;
- void OnExtensionUnloaded(content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- extensions::UnloadedExtensionReason reason) override;
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-
// policy::PolicyService::Observer implementation.
void OnPolicyUpdated(const policy::PolicyNamespace& ns,
const policy::PolicyMap& previous,
@@ -78,6 +72,9 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
// policy::SchemaRegistry::Observer implementation.
void OnSchemaRegistryUpdated(bool has_new_schemas) override;
+ // policy::PolicyValueProvider::Observer implementation.
+ void OnPolicyValueChanged() override;
+
protected:
// ui::SelectFileDialog::Listener implementation.
void FileSelected(const base::FilePath& path,
@@ -86,12 +83,9 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
void FileSelectionCanceled(void* params) override;
private:
- base::Value GetPolicyNames();
+ base::Value::Dict GetPolicyNames();
base::Value::List GetPolicyValues();
- void AddExtensionPolicyNames(base::Value* names,
- policy::PolicyDomain policy_domain);
-
void HandleExportPoliciesJson(const base::Value::List& args);
void HandleListenPoliciesUpdates(const base::Value::List& args);
void HandleReloadPolicies(const base::Value::List& args);
@@ -102,16 +96,6 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
// metadata is sent.
void SendPolicies();
-#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Sets |updater_policies_| in this instance, updates
- // |updater_status_provider_| with a new state and refreshes the UI via
- // SendPolicies.
- void SetUpdaterPoliciesAndState(
- std::unique_ptr<GoogleUpdatePoliciesAndState> updater_policies_and_state);
-
- void ReloadUpdaterPoliciesAndState();
-#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
// Send the status of cloud policy to the UI.
void SendStatus();
@@ -119,7 +103,7 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
// enabled (device and/or user), a dictionary containing status information.
// If |for_webui| is true, values needed for webui will be included
// additionally.
- base::DictionaryValue GetStatusValue(bool for_webui) const;
+ base::Value::Dict GetStatusValue(bool for_webui) const;
// Build a JSON string of all the policies.
std::string GetPoliciesAsJson();
@@ -128,10 +112,11 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
void OnRefreshPoliciesDone();
- policy::PolicyService* GetPolicyService();
-
#if BUILDFLAG(IS_CHROMEOS_LACROS)
- void OnGotDevicePolicy(base::Value device_policy, base::Value legend_data);
+ void OnGotDevicePolicy(base::Value::Dict device_policy,
+ base::Value::Dict legend_data);
+ void OnGotDevicePolicyDeprecated(base::Value device_policy,
+ base::Value legend_data);
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
scoped_refptr<ui::SelectFileDialog> export_policies_select_file_dialog_;
@@ -142,18 +127,27 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
std::unique_ptr<policy::PolicyStatusProvider> user_status_provider_;
std::unique_ptr<policy::PolicyStatusProvider> device_status_provider_;
std::unique_ptr<policy::PolicyStatusProvider> machine_status_provider_;
- std::unique_ptr<policy::PolicyStatusProvider> updater_status_provider_;
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ std::unique_ptr<ExtensionPoliciesValueProvider>
+ extension_policies_value_provider_;
+#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- std::unique_ptr<policy::PolicyMap> updater_policies_;
+ std::unique_ptr<UpdaterStatusAndValueProvider>
+ updater_status_and_value_provider_;
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
- base::Value device_policy_;
+ base::Value::Dict device_policy_;
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
+ base::ScopedMultiSourceObservation<policy::PolicyValueProvider,
+ policy::PolicyValueProvider::Observer>
+ policy_value_provider_observations_{this};
+
base::WeakPtrFactory<PolicyUIHandler> weak_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.cc
deleted file mode 100644
index 11cff2f855d..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h"
-
-#include "components/policy/core/common/cloud/cloud_policy_core.h"
-
-CloudPolicyCoreStatusProvider::CloudPolicyCoreStatusProvider(
- policy::CloudPolicyCore* core)
- : core_(core) {
- core_->store()->AddObserver(this);
- // TODO(bartfab): Add an observer that watches for client errors. Observing
- // core_->client() directly is not safe as the client may be destroyed and
- // (re-)created anytime if the user signs in or out on desktop platforms.
-}
-
-CloudPolicyCoreStatusProvider::~CloudPolicyCoreStatusProvider() {
- core_->store()->RemoveObserver(this);
-}
-
-void CloudPolicyCoreStatusProvider::OnStoreLoaded(
- policy::CloudPolicyStore* store) {
- NotifyStatusChange();
-}
-
-void CloudPolicyCoreStatusProvider::OnStoreError(
- policy::CloudPolicyStore* store) {
- NotifyStatusChange();
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h
deleted file mode 100644
index 9683be70604..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_CLOUD_POLICY_CORE_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_CLOUD_POLICY_CORE_STATUS_PROVIDER_H_
-
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-
-namespace policy {
-class CloudPolicyCore;
-} // namespace policy
-
-// Status provider implementation that pulls cloud policy status from a
-// CloudPolicyCore instance provided at construction time. Also listens for
-// changes on that CloudPolicyCore and reports them through the status change
-// callback.
-class CloudPolicyCoreStatusProvider
- : public policy::PolicyStatusProvider,
- public policy::CloudPolicyStore::Observer {
- public:
- explicit CloudPolicyCoreStatusProvider(policy::CloudPolicyCore* core);
-
- CloudPolicyCoreStatusProvider(const CloudPolicyCoreStatusProvider&) = delete;
- CloudPolicyCoreStatusProvider& operator=(
- const CloudPolicyCoreStatusProvider&) = delete;
-
- ~CloudPolicyCoreStatusProvider() override;
-
- // policy::CloudPolicyStore::Observer implementation.
- void OnStoreLoaded(policy::CloudPolicyStore* store) override;
- void OnStoreError(policy::CloudPolicyStore* store) override;
-
- protected:
- // Policy status is read from the CloudPolicyClient, CloudPolicyStore and
- // CloudPolicyRefreshScheduler hosted by this |core_|.
- raw_ptr<policy::CloudPolicyCore> core_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_CLOUD_POLICY_CORE_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.cc
deleted file mode 100644
index dfcb75d9ac1..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h"
-
-#include "base/values.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-
-DeviceActiveDirectoryPolicyStatusProvider::
- DeviceActiveDirectoryPolicyStatusProvider(
- policy::ActiveDirectoryPolicyManager* policy_manager,
- const std::string& enterprise_domain_manager)
- : UserActiveDirectoryPolicyStatusProvider(policy_manager, nullptr),
- enterprise_domain_manager_(enterprise_domain_manager) {}
-
-void DeviceActiveDirectoryPolicyStatusProvider::GetStatus(
- base::DictionaryValue* dict) {
- UserActiveDirectoryPolicyStatusProvider::GetStatus(dict);
- dict->SetStringKey("enterpriseDomainManager", enterprise_domain_manager_);
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h
deleted file mode 100644
index be6bfa43107..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_active_directory_policy_status_provider.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
-
-#include <string>
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h"
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class ActiveDirectoryPolicyManager;
-} // namespace policy
-
-// Provides status for Device Active Directory policy.
-class DeviceActiveDirectoryPolicyStatusProvider
- : public UserActiveDirectoryPolicyStatusProvider {
- public:
- DeviceActiveDirectoryPolicyStatusProvider(
- policy::ActiveDirectoryPolicyManager* policy_manager,
- const std::string& enterprise_domain_manager);
-
- DeviceActiveDirectoryPolicyStatusProvider(
- const DeviceActiveDirectoryPolicyStatusProvider&) = delete;
- DeviceActiveDirectoryPolicyStatusProvider& operator=(
- const DeviceActiveDirectoryPolicyStatusProvider&) = delete;
-
- ~DeviceActiveDirectoryPolicyStatusProvider() override = default;
-
- // PolicyStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- std::string enterprise_domain_manager_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.cc
deleted file mode 100644
index 6d1ea57a234..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h"
-
-#include <string>
-
-#include "base/values.h"
-#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-
-DeviceCloudPolicyStatusProviderChromeOS::
- DeviceCloudPolicyStatusProviderChromeOS(
- const policy::BrowserPolicyConnectorAsh* connector)
- : CloudPolicyCoreStatusProvider(
- connector->GetDeviceCloudPolicyManager()->core()) {
- enterprise_domain_manager_ = connector->GetEnterpriseDomainManager();
-}
-
-DeviceCloudPolicyStatusProviderChromeOS::
- ~DeviceCloudPolicyStatusProviderChromeOS() = default;
-
-void DeviceCloudPolicyStatusProviderChromeOS::GetStatus(
- base::DictionaryValue* dict) {
- policy::PolicyStatusProvider::GetStatusFromCore(core_, dict);
- dict->SetStringKey("enterpriseDomainManager", enterprise_domain_manager_);
- GetOffHoursStatus(dict);
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h b/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h
deleted file mode 100644
index dfbceafe823..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_cloud_policy_status_provider_chromeos.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
-
-#include "chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h"
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class BrowserPolicyConnectorAsh;
-} // namespace policy
-
-// A cloud policy status provider for device policy.
-class DeviceCloudPolicyStatusProviderChromeOS
- : public CloudPolicyCoreStatusProvider {
- public:
- explicit DeviceCloudPolicyStatusProviderChromeOS(
- const policy::BrowserPolicyConnectorAsh* connector);
-
- DeviceCloudPolicyStatusProviderChromeOS(
- const DeviceCloudPolicyStatusProviderChromeOS&) = delete;
- DeviceCloudPolicyStatusProviderChromeOS& operator=(
- const DeviceCloudPolicyStatusProviderChromeOS&) = delete;
-
- ~DeviceCloudPolicyStatusProviderChromeOS() override;
-
- // CloudPolicyCoreStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- std::string enterprise_domain_manager_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.cc
deleted file mode 100644
index f39e82ea8cd..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h"
-
-#include "base/values.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "components/policy/core/browser/cloud/message_util.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-
-DeviceLocalAccountPolicyStatusProvider::DeviceLocalAccountPolicyStatusProvider(
- const std::string& user_id,
- policy::DeviceLocalAccountPolicyService* service)
- : user_id_(user_id), service_(service) {
- service_->AddObserver(this);
-}
-
-DeviceLocalAccountPolicyStatusProvider::
- ~DeviceLocalAccountPolicyStatusProvider() {
- service_->RemoveObserver(this);
-}
-
-void DeviceLocalAccountPolicyStatusProvider::GetStatus(
- base::DictionaryValue* dict) {
- const policy::DeviceLocalAccountPolicyBroker* broker =
- service_->GetBrokerForUser(user_id_);
- if (broker) {
- policy::PolicyStatusProvider::GetStatusFromCore(broker->core(), dict);
- } else {
- dict->SetBoolKey("error", true);
- dict->SetStringKey("status",
- policy::FormatStoreStatus(
- policy::CloudPolicyStore::STATUS_BAD_STATE,
- policy::CloudPolicyValidatorBase::VALIDATION_OK));
- dict->SetStringKey("username", std::string());
- }
- ExtractDomainFromUsername(dict);
- dict->SetBoolKey("publicAccount", true);
-}
-
-void DeviceLocalAccountPolicyStatusProvider::OnPolicyUpdated(
- const std::string& user_id) {
- if (user_id == user_id_)
- NotifyStatusChange();
-}
-
-void DeviceLocalAccountPolicyStatusProvider::OnDeviceLocalAccountsChanged() {
- NotifyStatusChange();
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h
deleted file mode 100644
index a07f12add30..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_local_account_policy_status_provider.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_LOCAL_ACCOUNT_POLICY_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_LOCAL_ACCOUNT_POLICY_STATUS_PROVIDER_H_
-
-#include <string>
-
-#include "chrome/browser/ash/policy/core/device_local_account_policy_service.h"
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-// A cloud policy status provider that reads policy status from the policy core
-// associated with the device-local account specified by |user_id| at
-// construction time. The indirection via user ID and
-// DeviceLocalAccountPolicyService is necessary because the device-local account
-// may go away any time behind the scenes, at which point the status message
-// text will indicate CloudPolicyStore::STATUS_BAD_STATE.
-class DeviceLocalAccountPolicyStatusProvider
- : public policy::PolicyStatusProvider,
- public policy::DeviceLocalAccountPolicyService::Observer {
- public:
- DeviceLocalAccountPolicyStatusProvider(
- const std::string& user_id,
- policy::DeviceLocalAccountPolicyService* service);
-
- DeviceLocalAccountPolicyStatusProvider(
- const DeviceLocalAccountPolicyStatusProvider&) = delete;
- DeviceLocalAccountPolicyStatusProvider& operator=(
- const DeviceLocalAccountPolicyStatusProvider&) = delete;
-
- ~DeviceLocalAccountPolicyStatusProvider() override;
-
- // PolicyStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- // policy::DeviceLocalAccountPolicyService::Observer implementation.
- void OnPolicyUpdated(const std::string& user_id) override;
- void OnDeviceLocalAccountsChanged() override;
-
- private:
- const std::string user_id_;
- policy::DeviceLocalAccountPolicyService* service_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_LOCAL_ACCOUNT_POLICY_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.cc
deleted file mode 100644
index e5e7b0a25a8..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h"
-
-DevicePolicyStatusProviderLacros::DevicePolicyStatusProviderLacros()
- : PolicyStatusProvider() {}
-
-DevicePolicyStatusProviderLacros::~DevicePolicyStatusProviderLacros() {}
-
-void DevicePolicyStatusProviderLacros::SetDevicePolicyStatus(
- base::Value status) {
- device_policy_status_ = std::move(status);
-}
-
-void DevicePolicyStatusProviderLacros::GetStatus(base::DictionaryValue* dict) {
- if (!device_policy_status_.is_dict()) {
- return;
- }
- base::DictionaryValue* dict_value;
- device_policy_status_.GetAsDictionary(&dict_value);
- dict->Swap(dict_value);
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h b/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h
deleted file mode 100644
index b6f94e0c716..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/device_policy_status_provider_lacros.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_POLICY_STATUS_PROVIDER_LACROS_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_POLICY_STATUS_PROVIDER_LACROS_H_
-
-#include "base/values.h"
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-
-// A policy status provider for device policy for Lacros.
-class DevicePolicyStatusProviderLacros : public policy::PolicyStatusProvider {
- public:
- DevicePolicyStatusProviderLacros();
- ~DevicePolicyStatusProviderLacros() override;
-
- void SetDevicePolicyStatus(base::Value status);
-
- // PolicyStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- base::Value device_policy_status_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_DEVICE_POLICY_STATUS_PROVIDER_LACROS_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.cc
deleted file mode 100644
index 072d99fb1ec..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-
-#include "google_apis/gaia/gaia_auth_util.h"
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "chrome/browser/ash/policy/off_hours/device_off_hours_controller.h"
-#include "chrome/browser/ash/profiles/profile_helper.h"
-#include "chrome/browser/ash/settings/device_settings_service.h"
-#include "chrome/browser/ui/managed_ui.h"
-#include "components/user_manager/user_manager.h"
-#else
-#include "chrome/browser/enterprise/util/affiliation.h"
-#include "components/enterprise/browser/controller/browser_dm_token_storage.h"
-#endif
-
-void ExtractDomainFromUsername(base::DictionaryValue* dict) {
- const std::string* username = dict->FindStringKey("username");
- if (username && !username->empty())
- dict->SetStringKey("domain", gaia::ExtractDomainName(*username));
-}
-
-void GetUserAffiliationStatus(base::DictionaryValue* dict, Profile* profile) {
- CHECK(profile);
-
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- const user_manager::User* user =
- ash::ProfileHelper::Get()->GetUserByProfile(profile);
- if (!user)
- return;
- dict->SetBoolKey("isAffiliated", user->IsAffiliated());
-#else
- // Don't show affiliation status if the browser isn't enrolled in CBCM.
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- if (!profile->IsMainProfile())
-#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
- {
- if (!policy::BrowserDMTokenStorage::Get()->RetrieveDMToken().is_valid())
- return;
- }
- dict->SetBoolKey("isAffiliated",
- chrome::enterprise_util::IsProfileAffiliated(profile));
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-}
-
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-void GetOffHoursStatus(base::DictionaryValue* dict) {
- policy::off_hours::DeviceOffHoursController* off_hours_controller =
- ash::DeviceSettingsService::Get()->device_off_hours_controller();
- if (off_hours_controller) {
- dict->SetBoolKey("isOffHoursActive",
- off_hours_controller->is_off_hours_mode());
- }
-}
-
-void GetUserManager(base::DictionaryValue* dict, Profile* profile) {
- CHECK(profile);
-
- absl::optional<std::string> account_manager =
- chrome::GetAccountManagerIdentity(profile);
- if (account_manager) {
- dict->SetStringKey("enterpriseDomainManager", *account_manager);
- }
-}
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-
-std::string GetMachineStatusLegendKey() {
-#if BUILDFLAG(IS_ANDROID)
- return "statusDevice";
-#else
- return "statusMachine";
-#endif // BUILDFLAG(IS_ANDROID)
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.h b/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.h
deleted file mode 100644
index 4078f7e97fa..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/status_provider_util.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_STATUS_PROVIDER_UTIL_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_STATUS_PROVIDER_UTIL_H_
-
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-
-void ExtractDomainFromUsername(base::DictionaryValue* dict);
-
-// Adds a new entry to |dict| with the affiliation status of the user associated
-// with |profile|. This method shouldn't be called for device scope status.
-void GetUserAffiliationStatus(base::DictionaryValue* dict, Profile* profile);
-
-// MachineStatus box labels itself as `machine policies` on desktop. In the
-// domain of mobile devices such as iOS or Android we want to label this box as
-// `device policies`. This is a helper function that retrieves the expected
-// labelKey
-std::string GetMachineStatusLegendKey();
-
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-void GetOffHoursStatus(base::DictionaryValue* dict);
-
-// Adds a new entry to |dict| with the enterprise domain manager of the user
-// associated with |profile|. This method shouldn't be called for device scope
-// status.
-void GetUserManager(base::DictionaryValue* dict, Profile* profile);
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_STATUS_PROVIDER_UTIL_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.cc
deleted file mode 100644
index b75331638f0..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h"
-
-#include <windows.h>
-
-#include <DSRole.h>
-
-#include "base/strings/utf_string_conversions.h"
-#include "base/task/task_traits.h"
-#include "base/task/thread_pool.h"
-#include "base/values.h"
-#include "chrome/browser/google/google_update_policy_fetcher_win.h"
-#include "chrome/install_static/install_util.h"
-
-UpdaterStatusProvider::UpdaterStatusProvider() {
- base::ThreadPool::PostTaskAndReplyWithResult(
- FROM_HERE,
- {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
- base::BindOnce(&UpdaterStatusProvider::FetchActiveDirectoryDomain),
- base::BindOnce(&UpdaterStatusProvider::OnDomainReceived,
- weak_factory_.GetWeakPtr()));
-}
-
-UpdaterStatusProvider::~UpdaterStatusProvider() {}
-
-void UpdaterStatusProvider::SetUpdaterStatus(
- std::unique_ptr<GoogleUpdateState> status) {
- updater_status_ = std::move(status);
- NotifyStatusChange();
-}
-
-void UpdaterStatusProvider::GetStatus(base::DictionaryValue* dict) {
- if (!domain_.empty())
- dict->SetStringKey("domain", domain_);
- if (!updater_status_)
- return;
- if (!updater_status_->version.empty())
- dict->SetStringKey("version", base::WideToUTF8(updater_status_->version));
- if (!updater_status_->last_checked_time.is_null()) {
- dict->SetStringKey(
- "timeSinceLastRefresh",
- GetTimeSinceLastActionString(updater_status_->last_checked_time));
- }
-}
-
-// static
-std::string UpdaterStatusProvider::FetchActiveDirectoryDomain() {
- std::string domain;
- ::DSROLE_PRIMARY_DOMAIN_INFO_BASIC* info = nullptr;
- if (::DsRoleGetPrimaryDomainInformation(nullptr,
- ::DsRolePrimaryDomainInfoBasic,
- (PBYTE*)&info) != ERROR_SUCCESS) {
- return domain;
- }
- if (info->DomainNameDns)
- domain = base::WideToUTF8(info->DomainNameDns);
- ::DsRoleFreeMemory(info);
- return domain;
-}
-
-void UpdaterStatusProvider::OnDomainReceived(std::string domain) {
- domain_ = std::move(domain);
- NotifyStatusChange();
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h
deleted file mode 100644
index b632ae8414c..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/updater_status_provider.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_UPDATER_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_UPDATER_STATUS_PROVIDER_H_
-
-#include <string>
-
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-
-struct GoogleUpdateState;
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-class UpdaterStatusProvider : public policy::PolicyStatusProvider {
- public:
- UpdaterStatusProvider();
- ~UpdaterStatusProvider() override;
- void SetUpdaterStatus(std::unique_ptr<GoogleUpdateState> status);
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- static std::string FetchActiveDirectoryDomain();
- void OnDomainReceived(std::string domain);
-
- std::unique_ptr<GoogleUpdateState> updater_status_;
- std::string domain_;
- base::WeakPtrFactory<UpdaterStatusProvider> weak_factory_{this};
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_UPDATER_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.cc
deleted file mode 100644
index 2677d8a319a..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h"
-
-#include "base/time/time.h"
-#include "base/values.h"
-#include "chrome/browser/ash/policy/active_directory/active_directory_policy_manager.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "components/policy/core/browser/cloud/message_util.h"
-#include "components/policy/core/common/cloud/cloud_policy_core.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-#include "components/policy/proto/device_management_backend.pb.h"
-#include "ui/base/l10n/time_format.h"
-
-UserActiveDirectoryPolicyStatusProvider::
- UserActiveDirectoryPolicyStatusProvider(
- policy::ActiveDirectoryPolicyManager* policy_manager,
- Profile* profile)
- : policy_manager_(policy_manager) {
- policy_manager_->store()->AddObserver(this);
- profile_ = profile;
-}
-
-UserActiveDirectoryPolicyStatusProvider::
- ~UserActiveDirectoryPolicyStatusProvider() {
- policy_manager_->store()->RemoveObserver(this);
-}
-
-void UserActiveDirectoryPolicyStatusProvider::GetStatus(
- base::DictionaryValue* dict) {
- const enterprise_management::PolicyData* policy =
- policy_manager_->store()->policy();
- const std::string client_id = policy ? policy->device_id() : std::string();
- const std::string username = policy ? policy->username() : std::string();
- const std::u16string status =
- policy::FormatStoreStatus(policy_manager_->store()->status(),
- policy_manager_->store()->validation_status());
- dict->SetStringKey("status", status);
- dict->SetStringKey("username", username);
- dict->SetStringKey("clientId", client_id);
-
- const base::TimeDelta refresh_interval =
- policy_manager_->scheduler()->interval();
- dict->SetStringKey(
- "refreshInterval",
- ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
- ui::TimeFormat::LENGTH_SHORT, refresh_interval));
-
- const base::Time last_refresh_time =
- (policy && policy->has_timestamp())
- ? base::Time::FromJavaTime(policy->timestamp())
- : base::Time();
- dict->SetStringKey("timeSinceLastRefresh",
- GetTimeSinceLastActionString(last_refresh_time));
-
- const base::Time last_refresh_attempt_time =
- policy_manager_->scheduler()->last_refresh_attempt();
- dict->SetStringKey("timeSinceLastFetchAttempt",
- GetTimeSinceLastActionString(last_refresh_attempt_time));
-
- // Check if profile is present. Note that profile is not present if object is
- // an instance of DeviceActiveDirectoryPolicyStatusProvider that inherits from
- // UserActiveDirectoryPolicyStatusProvider.
- // TODO(b/182585903): Extend browser test to cover Active Directory case.
- if (profile_) {
- GetUserAffiliationStatus(dict, profile_);
- GetUserManager(dict, profile_);
- }
-}
-
-void UserActiveDirectoryPolicyStatusProvider::OnStoreLoaded(
- policy::CloudPolicyStore* store) {
- NotifyStatusChange();
-}
-
-void UserActiveDirectoryPolicyStatusProvider::OnStoreError(
- policy::CloudPolicyStore* store) {
- NotifyStatusChange();
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h
deleted file mode 100644
index 02cea505672..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_active_directory_policy_status_provider.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
-
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-
-class Profile;
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class ActiveDirectoryPolicyManager;
-} // namespace policy
-
-// Provides status for Active Directory user policy.
-class UserActiveDirectoryPolicyStatusProvider
- : public policy::PolicyStatusProvider,
- public policy::CloudPolicyStore::Observer {
- public:
- explicit UserActiveDirectoryPolicyStatusProvider(
- policy::ActiveDirectoryPolicyManager* policy_manager,
- Profile* profile);
-
- UserActiveDirectoryPolicyStatusProvider(
- const UserActiveDirectoryPolicyStatusProvider&) = delete;
- UserActiveDirectoryPolicyStatusProvider& operator=(
- const UserActiveDirectoryPolicyStatusProvider&) = delete;
-
- ~UserActiveDirectoryPolicyStatusProvider() override;
-
- // PolicyStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- // policy::CloudPolicyStore::Observer implementation.
- void OnStoreLoaded(policy::CloudPolicyStore* store) override;
- void OnStoreError(policy::CloudPolicyStore* store) override;
-
- private:
- policy::ActiveDirectoryPolicyManager* const policy_manager_; // not owned.
- Profile* profile_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_ACTIVE_DIRECTORY_POLICY_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.cc
deleted file mode 100644
index 7153e46a864..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h"
-
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "components/policy/core/common/cloud/cloud_policy_core.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-
-UserCloudPolicyStatusProvider::UserCloudPolicyStatusProvider(
- policy::CloudPolicyCore* core,
- Profile* profile)
- : CloudPolicyCoreStatusProvider(core), profile_(profile) {}
-
-UserCloudPolicyStatusProvider::~UserCloudPolicyStatusProvider() = default;
-
-void UserCloudPolicyStatusProvider::GetStatus(base::DictionaryValue* dict) {
- if (!core_->store()->is_managed())
- return;
- policy::PolicyStatusProvider::GetStatusFromCore(core_, dict);
- ExtractDomainFromUsername(dict);
- GetUserAffiliationStatus(dict, profile_);
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h b/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h
deleted file mode 100644
index 93098c3e886..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_H_
-
-#include "base/memory/raw_ptr.h"
-#include "chrome/browser/ui/webui/policy/status_provider/cloud_policy_core_status_provider.h"
-
-class Profile;
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class CloudPolicyCore;
-} // namespace policy
-
-// A cloud policy status provider for user policy.
-class UserCloudPolicyStatusProvider : public CloudPolicyCoreStatusProvider {
- public:
- explicit UserCloudPolicyStatusProvider(policy::CloudPolicyCore* core,
- Profile* profile);
-
- UserCloudPolicyStatusProvider(const UserCloudPolicyStatusProvider&) = delete;
- UserCloudPolicyStatusProvider& operator=(
- const UserCloudPolicyStatusProvider&) = delete;
-
- ~UserCloudPolicyStatusProvider() override;
-
- // CloudPolicyCoreStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- raw_ptr<Profile> profile_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.cc
deleted file mode 100644
index 2230391218d..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h"
-
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "components/policy/core/common/cloud/cloud_policy_core.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-
-UserCloudPolicyStatusProviderChromeOS::UserCloudPolicyStatusProviderChromeOS(
- policy::CloudPolicyCore* core,
- Profile* profile)
- : UserCloudPolicyStatusProvider(core, profile) {
- profile_ = profile;
-}
-
-UserCloudPolicyStatusProviderChromeOS::
- ~UserCloudPolicyStatusProviderChromeOS() = default;
-
-void UserCloudPolicyStatusProviderChromeOS::GetStatus(
- base::DictionaryValue* dict) {
- if (!core_->store()->is_managed())
- return;
- UserCloudPolicyStatusProvider::GetStatus(dict);
- GetUserAffiliationStatus(dict, profile_);
- GetUserManager(dict, profile_);
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h b/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h
deleted file mode 100644
index a5dd9839d52..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider_chromeos.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_cloud_policy_status_provider.h"
-
-class Profile;
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class CloudPolicyCore;
-} // namespace policy
-
-// A cloud policy status provider for user policy on Chrome OS.
-class UserCloudPolicyStatusProviderChromeOS
- : public UserCloudPolicyStatusProvider {
- public:
- explicit UserCloudPolicyStatusProviderChromeOS(policy::CloudPolicyCore* core,
- Profile* profile);
-
- UserCloudPolicyStatusProviderChromeOS(
- const UserCloudPolicyStatusProviderChromeOS&) = delete;
- UserCloudPolicyStatusProviderChromeOS& operator=(
- const UserCloudPolicyStatusProviderChromeOS&) = delete;
-
- ~UserCloudPolicyStatusProviderChromeOS() override;
-
- // CloudPolicyCoreStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- Profile* profile_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_CLOUD_POLICY_STATUS_PROVIDER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.cc b/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.cc
deleted file mode 100644
index 13fad57d1cb..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h"
-
-#include "base/time/time.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/policy/status_provider/status_provider_util.h"
-#include "components/policy/core/browser/cloud/message_util.h"
-#include "components/policy/core/common/cloud/cloud_policy_store.h"
-#include "components/policy/core/common/policy_loader_lacros.h"
-#include "components/policy/proto/device_management_backend.pb.h"
-
-UserPolicyStatusProviderLacros::UserPolicyStatusProviderLacros(
- policy::PolicyLoaderLacros* loader,
- Profile* profile)
- : profile_(profile), loader_(loader) {}
-
-UserPolicyStatusProviderLacros::~UserPolicyStatusProviderLacros() = default;
-
-void UserPolicyStatusProviderLacros::GetStatus(base::DictionaryValue* dict) {
- enterprise_management::PolicyData* policy = loader_->GetPolicyData();
- if (!policy)
- return;
- GetStatusFromPolicyData(policy, dict);
- ExtractDomainFromUsername(dict);
- GetUserAffiliationStatus(dict, profile_);
-
- // Get last fetched time from policy, since we have no refresh scheduler here.
- base::Time last_refresh_time =
- policy && policy->has_timestamp()
- ? base::Time::FromJavaTime(policy->timestamp())
- : base::Time();
- dict->SetStringKey("timeSinceLastRefresh",
- GetTimeSinceLastActionString(last_refresh_time));
-
- const base::Time last_refresh_attempt_time = loader_->last_fetch_timestamp();
- dict->SetStringKey("timeSinceLastFetchAttempt",
- GetTimeSinceLastActionString(last_refresh_attempt_time));
-
- // TODO(https://crbug.com/1243869): Pass this information from Ash through
- // Mojo. Assume no error for now.
- dict->SetBoolKey("error", false);
- dict->SetStringKey(
- "status", FormatStoreStatus(
- policy::CloudPolicyStore::STATUS_OK,
- policy::CloudPolicyValidatorBase::Status::VALIDATION_OK));
-}
diff --git a/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h b/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h
deleted file mode 100644
index 8a25c035908..00000000000
--- a/chromium/chrome/browser/ui/webui/policy/status_provider/user_policy_status_provider_lacros.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2022 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_POLICY_STATUS_PROVIDER_LACROS_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_POLICY_STATUS_PROVIDER_LACROS_H_
-
-#include "components/policy/core/browser/webui/policy_status_provider.h"
-
-class Profile;
-
-namespace base {
-class DictionaryValue;
-} // namespace base
-
-namespace policy {
-class PolicyLoaderLacros;
-} // namespace policy
-
-// A cloud policy status provider for device account.
-class UserPolicyStatusProviderLacros : public policy::PolicyStatusProvider {
- public:
- UserPolicyStatusProviderLacros(policy::PolicyLoaderLacros* loader,
- Profile* profile);
-
- UserPolicyStatusProviderLacros(const UserPolicyStatusProviderLacros&) =
- delete;
- UserPolicyStatusProviderLacros& operator=(
- const UserPolicyStatusProviderLacros&) = delete;
-
- ~UserPolicyStatusProviderLacros() override;
-
- // CloudPolicyCoreStatusProvider implementation.
- void GetStatus(base::DictionaryValue* dict) override;
-
- private:
- raw_ptr<Profile> profile_;
- raw_ptr<policy::PolicyLoaderLacros> loader_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_STATUS_PROVIDER_USER_POLICY_STATUS_PROVIDER_LACROS_H_
diff --git a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
index 524e3e2daa1..1f9f1e049d8 100644
--- a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
+++ b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
@@ -32,12 +32,12 @@ PredictorsHandler::PredictorsHandler(Profile* profile) {
PredictorsHandler::~PredictorsHandler() { }
void PredictorsHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestAutocompleteActionPredictorDb",
base::BindRepeating(
&PredictorsHandler::RequestAutocompleteActionPredictorDb,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestResourcePrefetchPredictorDb",
base::BindRepeating(
&PredictorsHandler::RequestResourcePrefetchPredictorDb,
@@ -45,40 +45,39 @@ void PredictorsHandler::RegisterMessages() {
}
void PredictorsHandler::RequestAutocompleteActionPredictorDb(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
const bool enabled = !!autocomplete_action_predictor_;
- base::DictionaryValue dict;
- dict.SetBoolKey("enabled", enabled);
+ base::Value::Dict dict;
+ dict.Set("enabled", enabled);
if (enabled) {
- auto db = std::make_unique<base::ListValue>();
+ base::Value::List db;
for (AutocompleteActionPredictor::DBCacheMap::const_iterator it =
autocomplete_action_predictor_->db_cache_.begin();
it != autocomplete_action_predictor_->db_cache_.end();
++it) {
- std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
- entry->SetStringKey("user_text", it->first.user_text);
- entry->SetStringKey("url", it->first.url.spec());
- entry->SetIntKey("hit_count", it->second.number_of_hits);
- entry->SetIntKey("miss_count", it->second.number_of_misses);
- entry->SetDoubleKey(
+ base::Value::Dict entry;
+ entry.Set("user_text", it->first.user_text);
+ entry.Set("url", it->first.url.spec());
+ entry.Set("hit_count", it->second.number_of_hits);
+ entry.Set("miss_count", it->second.number_of_misses);
+ entry.Set(
"confidence",
autocomplete_action_predictor_->CalculateConfidenceForDbEntry(it));
- db->Append(base::Value::FromUniquePtrValue(std::move(entry)));
+ db.Append(std::move(entry));
}
dict.Set("db", std::move(db));
}
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- dict);
+ ResolveJavascriptCallback(args[0] /* callback_id */, dict);
}
void PredictorsHandler::RequestResourcePrefetchPredictorDb(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
const bool enabled = (loading_predictor_ != nullptr);
- base::DictionaryValue dict;
- dict.SetBoolKey("enabled", enabled);
+ base::Value::Dict dict;
+ dict.Set("enabled", enabled);
if (enabled) {
auto* resource_prefetch_predictor =
@@ -91,38 +90,38 @@ void PredictorsHandler::RequestResourcePrefetchPredictorDb(
// TODO(alexilin): Add redirects table.
// Origin table cache.
- auto db = std::make_unique<base::ListValue>();
+ base::Value::List db;
AddOriginDataMapToListValue(
- resource_prefetch_predictor->origin_data_->GetAllCached(), db.get());
+ resource_prefetch_predictor->origin_data_->GetAllCached(), &db);
dict.Set("origin_db", std::move(db));
}
}
- ResolveJavascriptCallback(args->GetListDeprecated()[0] /* callback_id */,
- dict);
+ ResolveJavascriptCallback(args[0] /* callback_id */, dict);
}
void PredictorsHandler::AddOriginDataMapToListValue(
const std::map<std::string, predictors::OriginData>& data_map,
- base::ListValue* db) const {
+ base::Value::List* db) const {
for (const auto& p : data_map) {
- auto main = std::make_unique<base::DictionaryValue>();
- main->SetStringKey("main_frame_host", p.first);
- auto origins = std::make_unique<base::ListValue>();
+ base::Value::Dict main;
+ main.Set("main_frame_host", p.first);
+ base::Value::List origins;
for (const predictors::OriginStat& o : p.second.origins()) {
- auto origin = std::make_unique<base::DictionaryValue>();
- origin->SetStringKey("origin", o.origin());
- origin->SetIntKey("number_of_hits", o.number_of_hits());
- origin->SetIntKey("number_of_misses", o.number_of_misses());
- origin->SetIntKey("consecutive_misses", o.consecutive_misses());
- origin->SetDoubleKey("position", o.average_position());
- origin->SetBoolKey("always_access_network", o.always_access_network());
- origin->SetBoolKey("accessed_network", o.accessed_network());
- origin->SetDoubleKey(
- "score", ResourcePrefetchPredictorTables::ComputeOriginScore(o));
- origins->Append(base::Value::FromUniquePtrValue(std::move(origin)));
+ base::Value::Dict origin;
+ origin.Set("origin", o.origin());
+ origin.Set("number_of_hits", static_cast<int>(o.number_of_hits()));
+ origin.Set("number_of_misses", static_cast<int>(o.number_of_misses()));
+ origin.Set("consecutive_misses",
+ static_cast<int>(o.consecutive_misses()));
+ origin.Set("position", o.average_position());
+ origin.Set("always_access_network", o.always_access_network());
+ origin.Set("accessed_network", o.accessed_network());
+ origin.Set("score",
+ ResourcePrefetchPredictorTables::ComputeOriginScore(o));
+ origins.Append(std::move(origin));
}
- main->Set("origins", std::move(origins));
- db->Append(base::Value::FromUniquePtrValue(std::move(main)));
+ main.Set("origins", std::move(origins));
+ db->Append(std::move(main));
}
}
diff --git a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.h b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.h
index 0e8af098d76..3e97c13f09a 100644
--- a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.h
+++ b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.h
@@ -9,10 +9,6 @@
#include "chrome/browser/predictors/resource_prefetch_predictor.h"
#include "content/public/browser/web_ui_message_handler.h"
-namespace base {
-class ListValue;
-}
-
namespace predictors {
class AutocompleteActionPredictor;
class LoadingPredictor;
@@ -36,16 +32,16 @@ class PredictorsHandler : public content::WebUIMessageHandler {
private:
// Synchronously fetches the database from AutocompleteActionPredictor and
// calls into JS with the resulting DictionaryValue.
- void RequestAutocompleteActionPredictorDb(const base::ListValue* args);
+ void RequestAutocompleteActionPredictorDb(const base::Value::List& args);
// Fetches stats for the ResourcePrefetchPredictor and returns it as a
// DictionaryValue to the JS.
- void RequestResourcePrefetchPredictorDb(const base::ListValue* args);
+ void RequestResourcePrefetchPredictorDb(const base::Value::List& args);
// Helpers for RequestResourcePrefetchPredictorDb.
void AddOriginDataMapToListValue(
const std::map<std::string, predictors::OriginData>& data_map,
- base::ListValue* db) const;
+ base::Value::List* db) const;
raw_ptr<predictors::AutocompleteActionPredictor>
autocomplete_action_predictor_;
diff --git a/chromium/chrome/browser/ui/webui/prefs_internals_source.cc b/chromium/chrome/browser/ui/webui/prefs_internals_source.cc
index 2b3d41b3d5a..7ce302b271b 100644
--- a/chromium/chrome/browser/ui/webui/prefs_internals_source.cc
+++ b/chromium/chrome/browser/ui/webui/prefs_internals_source.cc
@@ -23,7 +23,7 @@ std::string PrefsInternalsSource::GetSource() {
return chrome::kChromeUIPrefsInternalsHost;
}
-std::string PrefsInternalsSource::GetMimeType(const std::string& path) {
+std::string PrefsInternalsSource::GetMimeType(const GURL& url) {
return "text/plain";
}
diff --git a/chromium/chrome/browser/ui/webui/prefs_internals_source.h b/chromium/chrome/browser/ui/webui/prefs_internals_source.h
index 5062b6c94e2..1a800933e44 100644
--- a/chromium/chrome/browser/ui/webui/prefs_internals_source.h
+++ b/chromium/chrome/browser/ui/webui/prefs_internals_source.h
@@ -22,7 +22,7 @@ class PrefsInternalsSource : public content::URLDataSource {
// content::URLDataSource:
std::string GetSource() override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
index c38eef36978..7aa7365b8aa 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
@@ -292,8 +292,10 @@ void ExtensionPrinterHandler::WrapGetCapabilityCallback(
base::Value::Dict capabilities;
base::Value::Dict cdd = ValidateCddForPrintPreview(std::move(capability));
// Leave |capabilities| empty if |cdd| is empty.
- if (!cdd.empty())
- capabilities.Set(kSettingCapabilities, std::move(cdd));
+ if (!cdd.empty()) {
+ capabilities.Set(kSettingCapabilities,
+ UpdateCddWithDpiIfMissing(std::move(cdd)));
+ }
std::move(callback).Run(std::move(capabilities));
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
index e9c4bd09d92..3c73d215d1d 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
@@ -285,7 +285,8 @@ void RecordPrinterInfo(size_t* call_count,
std::unique_ptr<base::DictionaryValue>* printer_info_out,
const base::DictionaryValue& printer_info) {
++(*call_count);
- printer_info_out->reset(printer_info.DeepCopy());
+ *printer_info_out = base::DictionaryValue::From(
+ base::Value::ToUniquePtrValue(printer_info.Clone()));
}
std::string RefCountedMemoryToString(
@@ -644,11 +645,26 @@ TEST_F(ExtensionPrinterHandlerTest, GetCapability) {
base::test::ParseJson(kPWGRasterOnlyPrinterSimpleDescription);
ASSERT_TRUE(original_capability.is_dict());
+ // TODO(thestig): Consolidate constants used in this section.
+ base::Value::Dict original_capability_with_dpi_dict =
+ original_capability.GetDict().Clone();
+ base::Value::Dict* printer =
+ original_capability_with_dpi_dict.FindDict("printer");
+ ASSERT_TRUE(printer);
+ base::Value::Dict default_dpi_option;
+ default_dpi_option.Set("horizontal_dpi", kDefaultPdfDpi);
+ default_dpi_option.Set("vertical_dpi", kDefaultPdfDpi);
+ base::Value::List dpi_list;
+ dpi_list.Append(std::move(default_dpi_option));
+ base::Value::Dict dpi_dict;
+ dpi_dict.Set("option", std::move(dpi_list));
+ printer->Set("dpi", std::move(dpi_dict));
+
fake_api->TriggerNextGetCapabilityCallback(
- original_capability.GetDict().Clone());
+ std::move(original_capability.GetDict()));
EXPECT_EQ(1u, call_count);
- EXPECT_EQ(capability, original_capability.GetDict());
+ EXPECT_EQ(capability, original_capability_with_dpi_dict);
}
TEST_F(ExtensionPrinterHandlerTest, GetCapability_Reset) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc b/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
index b2bd74f28f7..f3c3f85edb1 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
@@ -23,7 +23,8 @@ FakePrintRenderFrame::~FakePrintRenderFrame() = default;
void FakePrintRenderFrame::PrintRequestedPages() {}
-void FakePrintRenderFrame::PrintWithParams(mojom::PrintPagesParamsPtr params) {
+void FakePrintRenderFrame::PrintWithParams(mojom::PrintPagesParamsPtr params,
+ PrintWithParamsCallback callback) {
NOTREACHED();
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h b/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
index 42f9f296e6e..0e788384809 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
@@ -26,7 +26,8 @@ class FakePrintRenderFrame : public mojom::PrintRenderFrame {
private:
// printing::mojom::PrintRenderFrame:
void PrintRequestedPages() override;
- void PrintWithParams(mojom::PrintPagesParamsPtr params) override;
+ void PrintWithParams(mojom::PrintPagesParamsPtr params,
+ PrintWithParamsCallback callback) override;
void PrintForSystemDialog() override;
void SetPrintPreviewUI(
mojo::PendingAssociatedRemote<mojom::PrintPreviewUI> preview) override;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc
index a096d3bb35b..2ee9d56abd4 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc
@@ -121,20 +121,20 @@ base::Value::Dict LocalPrinterHandlerChromeos::CapabilityToValue(
}
// static
-base::Value LocalPrinterHandlerChromeos::StatusToValue(
+base::Value::Dict LocalPrinterHandlerChromeos::StatusToValue(
const crosapi::mojom::PrinterStatus& status) {
- base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetStringKey("printerId", status.printer_id);
- dict.SetDoubleKey("timestamp", status.timestamp.ToJsTimeIgnoringNull());
- base::Value status_reasons(base::Value::Type::LIST);
+ base::Value::Dict dict;
+ dict.Set("printerId", status.printer_id);
+ dict.Set("timestamp", status.timestamp.ToJsTimeIgnoringNull());
+ base::Value::List status_reasons;
for (const crosapi::mojom::StatusReasonPtr& reason_ptr :
status.status_reasons) {
- base::Value status_reason(base::Value::Type::DICTIONARY);
- status_reason.SetIntKey("reason", static_cast<int>(reason_ptr->reason));
- status_reason.SetIntKey("severity", static_cast<int>(reason_ptr->severity));
+ base::Value::Dict status_reason;
+ status_reason.Set("reason", static_cast<int>(reason_ptr->reason));
+ status_reason.Set("severity", static_cast<int>(reason_ptr->severity));
status_reasons.Append(std::move(status_reason));
}
- dict.SetKey("statusReasons", std::move(status_reasons));
+ dict.Set("statusReasons", std::move(status_reasons));
return dict;
}
@@ -241,7 +241,7 @@ void LocalPrinterHandlerChromeos::StartPrinterStatusRequest(
if (!local_printer_) {
PRINTER_LOG(ERROR)
<< "Local printer not available (StartPrinterStatusRequest)";
- std::move(callback).Run(base::Value());
+ std::move(callback).Run(absl::nullopt);
return;
}
local_printer_->GetStatus(
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
index 4a32e29223f..741c9605797 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
@@ -8,6 +8,7 @@
#include <memory>
#include <string>
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
@@ -58,7 +59,8 @@ class LocalPrinterHandlerChromeos : public PrinterHandler {
// Returns a PrinterStatus object (defined in
// chrome/browser/resources/print_preview/data/printer_status_cros.js).
- static base::Value StatusToValue(const crosapi::mojom::PrinterStatus& status);
+ static base::Value::Dict StatusToValue(
+ const crosapi::mojom::PrinterStatus& status);
// PrinterHandler implementation.
void Reset() override;
@@ -83,8 +85,8 @@ class LocalPrinterHandlerChromeos : public PrinterHandler {
PrinterHandler::PrintCallback callback,
const absl::optional<std::string>& username);
- content::WebContents* const preview_web_contents_;
- crosapi::mojom::LocalPrinter* local_printer_ = nullptr;
+ const raw_ptr<content::WebContents> preview_web_contents_;
+ raw_ptr<crosapi::mojom::LocalPrinter> local_printer_ = nullptr;
#if BUILDFLAG(IS_CHROMEOS_LACROS)
int local_printer_version_ = 0;
#endif
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc
index be741292e2e..e9619b6769c 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc
@@ -80,13 +80,13 @@ class LocalPrinterHandlerChromeosTest : public testing::Test {
TEST_F(LocalPrinterHandlerChromeosTest,
PrinterStatusRequestNoAsh_ProvidesDefaultValue) {
- base::Value printer_status("unset");
+ absl::optional<base::Value::Dict> printer_status = base::Value::Dict();
local_printer_handler()->StartPrinterStatusRequest(
- "printer1",
- base::BindOnce(base::BindLambdaForTesting([&](const base::Value& status) {
- printer_status = status.Clone();
- })));
- EXPECT_EQ(base::Value(), printer_status);
+ "printer1", base::BindOnce(base::BindLambdaForTesting(
+ [&](absl::optional<base::Value::Dict> status) {
+ printer_status = std::move(status);
+ })));
+ EXPECT_EQ(absl::nullopt, printer_status);
}
TEST_F(LocalPrinterHandlerChromeosTest, GetPrintersNoAsh_ProvidesDefaultValue) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc
index 7db11fbc140..18cab3a65c4 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc
@@ -156,7 +156,7 @@ PrinterList LocalPrinterHandlerDefault::EnumeratePrintersAsync(
PrintBackend::CreateInstance(locale));
PrinterList printer_list;
- mojom::ResultCode result = print_backend->EnumeratePrinters(&printer_list);
+ mojom::ResultCode result = print_backend->EnumeratePrinters(printer_list);
if (result != mojom::ResultCode::kSuccess) {
PRINTER_LOG(ERROR) << "Failure enumerating local printers, result: "
<< result;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 4afc519711e..94ee1b52886 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -231,166 +231,159 @@ UserActionBuckets DetermineUserAction(const base::Value::Dict& settings) {
}
#if BUILDFLAG(IS_CHROMEOS)
-base::Value PoliciesToValue(crosapi::mojom::PoliciesPtr ptr) {
- base::Value policies(base::Value::Type::DICTIONARY);
+base::Value::Dict PoliciesToValue(crosapi::mojom::PoliciesPtr ptr) {
+ base::Value::Dict policies;
- base::Value header_footer_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict header_footer_policy;
if (ptr->print_header_footer_allowed !=
crosapi::mojom::Policies::OptionalBool::kUnset) {
- header_footer_policy.SetBoolKey(
- kAllowedMode, ptr->print_header_footer_allowed ==
- crosapi::mojom::Policies::OptionalBool::kTrue);
+ header_footer_policy.Set(kAllowedMode,
+ ptr->print_header_footer_allowed ==
+ crosapi::mojom::Policies::OptionalBool::kTrue);
}
if (ptr->print_header_footer_default !=
crosapi::mojom::Policies::OptionalBool::kUnset) {
- header_footer_policy.SetBoolKey(
- kDefaultMode, ptr->print_header_footer_default ==
- crosapi::mojom::Policies::OptionalBool::kTrue);
+ header_footer_policy.Set(kDefaultMode,
+ ptr->print_header_footer_default ==
+ crosapi::mojom::Policies::OptionalBool::kTrue);
}
- if (!header_footer_policy.DictEmpty())
- policies.SetKey(kHeaderFooter, std::move(header_footer_policy));
+ if (!header_footer_policy.empty())
+ policies.Set(kHeaderFooter, std::move(header_footer_policy));
- base::Value background_graphics_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict background_graphics_policy;
int value = static_cast<int>(ptr->allowed_background_graphics_modes);
if (value)
- background_graphics_policy.SetIntKey(kAllowedMode, value);
+ background_graphics_policy.Set(kAllowedMode, value);
value = static_cast<int>(ptr->background_graphics_default);
if (value)
- background_graphics_policy.SetIntKey(kDefaultMode, value);
- if (!background_graphics_policy.DictEmpty())
- policies.SetKey(kCssBackground, std::move(background_graphics_policy));
+ background_graphics_policy.Set(kDefaultMode, value);
+ if (!background_graphics_policy.empty())
+ policies.Set(kCssBackground, std::move(background_graphics_policy));
- base::Value paper_size_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict paper_size_policy;
const absl::optional<gfx::Size>& default_paper_size = ptr->paper_size_default;
if (default_paper_size.has_value()) {
- base::Value default_paper_size_value(base::Value::Type::DICTIONARY);
- default_paper_size_value.SetIntKey(kPaperSizeWidth,
- default_paper_size.value().width());
- default_paper_size_value.SetIntKey(kPaperSizeHeight,
- default_paper_size.value().height());
- paper_size_policy.SetKey(kDefaultMode, std::move(default_paper_size_value));
+ base::Value::Dict default_paper_size_value;
+ default_paper_size_value.Set(kPaperSizeWidth,
+ default_paper_size.value().width());
+ default_paper_size_value.Set(kPaperSizeHeight,
+ default_paper_size.value().height());
+ paper_size_policy.Set(kDefaultMode, std::move(default_paper_size_value));
}
- if (!paper_size_policy.DictEmpty())
- policies.SetKey(kMediaSize, std::move(paper_size_policy));
+ if (!paper_size_policy.empty())
+ policies.Set(kMediaSize, std::move(paper_size_policy));
if (ptr->max_sheets_allowed_has_value) {
- base::Value sheets_policy(base::Value::Type::DICTIONARY);
- sheets_policy.SetIntKey(kValue, ptr->max_sheets_allowed);
- policies.SetKey(kSheets, std::move(sheets_policy));
+ base::Value::Dict sheets_policy;
+ sheets_policy.Set(kValue, static_cast<int>(ptr->max_sheets_allowed));
+ policies.Set(kSheets, std::move(sheets_policy));
}
- base::Value color_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict color_policy;
if (ptr->allowed_color_modes)
- color_policy.SetIntKey(kAllowedMode,
- static_cast<int>(ptr->allowed_color_modes));
+ color_policy.Set(kAllowedMode, static_cast<int>(ptr->allowed_color_modes));
if (ptr->default_color_mode != printing::mojom::ColorModeRestriction::kUnset)
- color_policy.SetIntKey(kDefaultMode,
- static_cast<int>(ptr->default_color_mode));
- if (!color_policy.DictEmpty())
- policies.SetKey(kColor, std::move(color_policy));
+ color_policy.Set(kDefaultMode, static_cast<int>(ptr->default_color_mode));
+ if (!color_policy.empty())
+ policies.Set(kColor, std::move(color_policy));
- base::Value duplex_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict duplex_policy;
if (ptr->allowed_duplex_modes)
- duplex_policy.SetIntKey(kAllowedMode,
- static_cast<int>(ptr->allowed_duplex_modes));
+ duplex_policy.Set(kAllowedMode,
+ static_cast<int>(ptr->allowed_duplex_modes));
if (ptr->default_duplex_mode !=
printing::mojom::DuplexModeRestriction::kUnset)
- duplex_policy.SetIntKey(kDefaultMode,
- static_cast<int>(ptr->default_duplex_mode));
- if (!duplex_policy.DictEmpty())
- policies.SetKey(kDuplex, std::move(duplex_policy));
+ duplex_policy.Set(kDefaultMode, static_cast<int>(ptr->default_duplex_mode));
+ if (!duplex_policy.empty())
+ policies.Set(kDuplex, std::move(duplex_policy));
- base::Value pin_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict pin_policy;
if (ptr->allowed_pin_modes != printing::mojom::PinModeRestriction::kUnset)
- pin_policy.SetIntKey(kAllowedMode,
- static_cast<int>(ptr->allowed_pin_modes));
+ pin_policy.Set(kAllowedMode, static_cast<int>(ptr->allowed_pin_modes));
if (ptr->default_pin_mode != printing::mojom::PinModeRestriction::kUnset)
- pin_policy.SetIntKey(kDefaultMode, static_cast<int>(ptr->default_pin_mode));
- if (!pin_policy.DictEmpty())
- policies.SetKey(kPin, std::move(pin_policy));
+ pin_policy.Set(kDefaultMode, static_cast<int>(ptr->default_pin_mode));
+ if (!pin_policy.empty())
+ policies.Set(kPin, std::move(pin_policy));
- base::Value print_as_image_for_pdf_default_policy(
- base::Value::Type::DICTIONARY);
+ base::Value::Dict print_as_image_for_pdf_default_policy;
if (ptr->default_print_pdf_as_image !=
crosapi::mojom::Policies::OptionalBool::kUnset) {
- print_as_image_for_pdf_default_policy.SetBoolKey(
+ print_as_image_for_pdf_default_policy.Set(
kDefaultMode, ptr->default_print_pdf_as_image ==
crosapi::mojom::Policies::OptionalBool::kTrue);
}
- if (!print_as_image_for_pdf_default_policy.DictEmpty()) {
- policies.SetKey(kPrintPdfAsImage,
- std::move(print_as_image_for_pdf_default_policy));
+ if (!print_as_image_for_pdf_default_policy.empty()) {
+ policies.Set(kPrintPdfAsImage,
+ std::move(print_as_image_for_pdf_default_policy));
}
return policies;
}
#else
-base::Value GetPolicies(const PrefService& prefs) {
- base::Value policies(base::Value::Type::DICTIONARY);
+base::Value::Dict GetPolicies(const PrefService& prefs) {
+ base::Value::Dict policies;
- base::Value header_footer_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict header_footer_policy;
if (prefs.HasPrefPath(prefs::kPrintHeaderFooter)) {
if (prefs.IsManagedPreference(prefs::kPrintHeaderFooter)) {
- header_footer_policy.SetBoolKey(
- kAllowedMode, prefs.GetBoolean(prefs::kPrintHeaderFooter));
+ header_footer_policy.Set(kAllowedMode,
+ prefs.GetBoolean(prefs::kPrintHeaderFooter));
} else {
- header_footer_policy.SetBoolKey(
- kDefaultMode, prefs.GetBoolean(prefs::kPrintHeaderFooter));
+ header_footer_policy.Set(kDefaultMode,
+ prefs.GetBoolean(prefs::kPrintHeaderFooter));
}
}
- if (!header_footer_policy.DictEmpty())
- policies.SetKey(kHeaderFooter, std::move(header_footer_policy));
+ if (!header_footer_policy.empty())
+ policies.Set(kHeaderFooter, std::move(header_footer_policy));
- base::Value background_graphics_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict background_graphics_policy;
if (prefs.HasPrefPath(prefs::kPrintingAllowedBackgroundGraphicsModes)) {
- background_graphics_policy.SetIntKey(
+ background_graphics_policy.Set(
kAllowedMode,
prefs.GetInteger(prefs::kPrintingAllowedBackgroundGraphicsModes));
}
if (prefs.HasPrefPath(prefs::kPrintingBackgroundGraphicsDefault)) {
- background_graphics_policy.SetIntKey(
+ background_graphics_policy.Set(
kDefaultMode,
prefs.GetInteger(prefs::kPrintingBackgroundGraphicsDefault));
}
- if (!background_graphics_policy.DictEmpty())
- policies.SetKey(kCssBackground, std::move(background_graphics_policy));
+ if (!background_graphics_policy.empty())
+ policies.Set(kCssBackground, std::move(background_graphics_policy));
- base::Value paper_size_policy(base::Value::Type::DICTIONARY);
+ base::Value::Dict paper_size_policy;
absl::optional<gfx::Size> default_paper_size = ParsePaperSizeDefault(prefs);
if (default_paper_size.has_value()) {
- base::Value default_paper_size_value(base::Value::Type::DICTIONARY);
- default_paper_size_value.SetIntKey(kPaperSizeWidth,
- default_paper_size.value().width());
- default_paper_size_value.SetIntKey(kPaperSizeHeight,
- default_paper_size.value().height());
- paper_size_policy.SetKey(kDefaultMode, std::move(default_paper_size_value));
+ base::Value::Dict default_paper_size_value;
+ default_paper_size_value.Set(kPaperSizeWidth,
+ default_paper_size.value().width());
+ default_paper_size_value.Set(kPaperSizeHeight,
+ default_paper_size.value().height());
+ paper_size_policy.Set(kDefaultMode, std::move(default_paper_size_value));
}
- if (!paper_size_policy.DictEmpty())
- policies.SetKey(kMediaSize, std::move(paper_size_policy));
+ if (!paper_size_policy.empty())
+ policies.Set(kMediaSize, std::move(paper_size_policy));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- base::Value print_as_image_available_for_pdf_policy(
- base::Value::Type::DICTIONARY);
+ base::Value::Dict print_as_image_available_for_pdf_policy;
if (prefs.HasPrefPath(prefs::kPrintPdfAsImageAvailability)) {
- print_as_image_available_for_pdf_policy.SetBoolKey(
+ print_as_image_available_for_pdf_policy.Set(
kAllowedMode, prefs.GetBoolean(prefs::kPrintPdfAsImageAvailability));
}
- if (!print_as_image_available_for_pdf_policy.DictEmpty()) {
- policies.SetKey(kPrintPdfAsImageAvailability,
- std::move(print_as_image_available_for_pdf_policy));
+ if (!print_as_image_available_for_pdf_policy.empty()) {
+ policies.Set(kPrintPdfAsImageAvailability,
+ std::move(print_as_image_available_for_pdf_policy));
}
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- base::Value print_as_image_for_pdf_default_policy(
- base::Value::Type::DICTIONARY);
+ base::Value::Dict print_as_image_for_pdf_default_policy;
if (prefs.HasPrefPath(prefs::kPrintPdfAsImageDefault)) {
- print_as_image_for_pdf_default_policy.SetBoolKey(
+ print_as_image_for_pdf_default_policy.Set(
kDefaultMode, prefs.GetBoolean(prefs::kPrintPdfAsImageDefault));
}
- if (!print_as_image_for_pdf_default_policy.DictEmpty()) {
- policies.SetKey(kPrintPdfAsImage,
- std::move(print_as_image_for_pdf_default_policy));
+ if (!print_as_image_for_pdf_default_policy.empty()) {
+ policies.Set(kPrintPdfAsImage,
+ std::move(print_as_image_for_pdf_default_policy));
}
return policies;
@@ -519,14 +512,12 @@ void PrintPreviewHandler::ReadPrinterTypeDenyListFromPrefs() {
if (!prefs->HasPrefPath(prefs::kPrinterTypeDenyList))
return;
- const base::Value* deny_list_from_prefs =
- prefs->Get(prefs::kPrinterTypeDenyList);
- if (!deny_list_from_prefs)
- return;
+ const base::Value::List& deny_list_from_prefs =
+ prefs->GetValueList(prefs::kPrinterTypeDenyList);
std::vector<mojom::PrinterType> deny_list;
- deny_list.reserve(deny_list_from_prefs->GetList().size());
- for (const base::Value& deny_list_value : deny_list_from_prefs->GetList()) {
+ deny_list.reserve(deny_list_from_prefs.size());
+ for (const base::Value& deny_list_value : deny_list_from_prefs) {
const std::string& deny_list_str = deny_list_value.GetString();
mojom::PrinterType printer_type;
if (deny_list_str == "extension")
@@ -822,11 +813,11 @@ void PrintPreviewHandler::HandleClosePreviewDialog(
regenerate_preview_request_count_);
}
-void PrintPreviewHandler::GetLocaleInformation(base::Value* settings) {
+void PrintPreviewHandler::GetLocaleInformation(base::Value::Dict* settings) {
// Getting the measurement system based on the locale.
UErrorCode errorCode = U_ZERO_ERROR;
const char* locale = g_browser_process->GetApplicationLocale().c_str();
- settings->SetStringKey(kUiLocale, std::string(locale));
+ settings->Set(kUiLocale, std::string(locale));
UMeasurementSystem system = ulocdata_getMeasurementSystem(locale, &errorCode);
// On error, assume the units are SI.
// Since the only measurement units print preview's WebUI cares about are
@@ -844,9 +835,9 @@ void PrintPreviewHandler::GetLocaleInformation(base::Value* settings) {
size_t decimal_pos = number_format.find('6') + 1;
DCHECK_NE(number_format[decimal_pos], '7');
std::u16string decimal_delimiter = number_format.substr(decimal_pos, 1);
- settings->SetStringKey(kDecimalDelimiter, decimal_delimiter);
- settings->SetStringKey(kThousandsDelimiter, thousands_delimiter);
- settings->SetIntKey(kUnitType, system);
+ settings->Set(kDecimalDelimiter, decimal_delimiter);
+ settings->Set(kThousandsDelimiter, thousands_delimiter);
+ settings->Set(kUnitType, system);
}
void PrintPreviewHandler::HandleGetInitialSettings(
@@ -858,20 +849,22 @@ void PrintPreviewHandler::HandleGetInitialSettings(
AllowJavascript();
PrinterHandler* handler = GetPrinterHandler(mojom::PrinterType::kLocal);
- base::OnceCallback<void(base::Value, const std::string&)> cb =
+ base::OnceCallback<void(base::Value::Dict, const std::string&)> cb =
base::BindOnce(&PrintPreviewHandler::SendInitialSettings,
weak_factory_.GetWeakPtr(), callback_id);
#if BUILDFLAG(IS_CHROMEOS)
if (!local_printer_) {
LOG(ERROR) << "Local printer not available";
- handler->GetDefaultPrinter(base::BindOnce(std::move(cb), base::Value()));
+ handler->GetDefaultPrinter(
+ base::BindOnce(std::move(cb), base::Value::Dict()));
return;
}
local_printer_->GetPolicies(
base::BindOnce(PoliciesToValue)
.Then(base::BindOnce(
- [](base::OnceCallback<void(base::Value, const std::string&)> cb,
- PrinterHandler* handler, base::Value policies) {
+ [](base::OnceCallback<void(base::Value::Dict, const std::string&)>
+ cb,
+ PrinterHandler* handler, base::Value::Dict policies) {
handler->GetDefaultPrinter(
base::BindOnce(std::move(cb), std::move(policies)));
},
@@ -884,58 +877,55 @@ void PrintPreviewHandler::HandleGetInitialSettings(
void PrintPreviewHandler::SendInitialSettings(
const std::string& callback_id,
- base::Value policies,
+ base::Value::Dict policies,
const std::string& default_printer) {
- base::Value initial_settings(base::Value::Type::DICTIONARY);
- initial_settings.SetStringKey(kDocumentTitle,
- print_preview_ui()->initiator_title());
- initial_settings.SetBoolKey(kSettingPreviewModifiable,
- print_preview_ui()->source_is_modifiable());
+ base::Value::Dict initial_settings;
+ initial_settings.Set(kDocumentTitle, print_preview_ui()->initiator_title());
+ initial_settings.Set(kSettingPreviewModifiable,
+ print_preview_ui()->source_is_modifiable());
#if BUILDFLAG(IS_CHROMEOS_ASH)
bool source_is_arc = print_preview_ui()->source_is_arc();
#else
bool source_is_arc = false;
#endif
- initial_settings.SetBoolKey(kSettingPreviewIsFromArc, source_is_arc);
- initial_settings.SetStringKey(kSettingPrinterName, default_printer);
- initial_settings.SetBoolKey(kDocumentHasSelection,
- print_preview_ui()->source_has_selection());
- initial_settings.SetBoolKey(kSettingShouldPrintSelectionOnly,
- print_preview_ui()->print_selection_only());
+ initial_settings.Set(kSettingPreviewIsFromArc, source_is_arc);
+ initial_settings.Set(kSettingPrinterName, default_printer);
+ initial_settings.Set(kDocumentHasSelection,
+ print_preview_ui()->source_has_selection());
+ initial_settings.Set(kSettingShouldPrintSelectionOnly,
+ print_preview_ui()->print_selection_only());
PrefService* prefs = GetPrefs();
PrintPreviewStickySettings* sticky_settings =
PrintPreviewStickySettings::GetInstance();
sticky_settings->RestoreFromPrefs(prefs);
if (sticky_settings->printer_app_state()) {
- initial_settings.SetStringKey(kAppState,
- *sticky_settings->printer_app_state());
+ initial_settings.Set(kAppState, *sticky_settings->printer_app_state());
} else {
- initial_settings.SetKey(kAppState, base::Value());
+ initial_settings.Set(kAppState, base::Value());
}
- if (policies.is_dict() && !policies.DictEmpty())
- initial_settings.SetKey(kPolicies, std::move(policies));
+ if (!policies.empty())
+ initial_settings.Set(kPolicies, std::move(policies));
- initial_settings.SetBoolKey(
+ initial_settings.Set(
kPdfPrinterDisabled,
base::Contains(printer_type_deny_list_, mojom::PrinterType::kPdf));
const bool destinations_managed =
!printer_type_deny_list_.empty() &&
prefs->IsManagedPreference(prefs::kPrinterTypeDenyList);
- initial_settings.SetBoolKey(kDestinationsManaged, destinations_managed);
+ initial_settings.Set(kDestinationsManaged, destinations_managed);
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- initial_settings.SetBoolKey(kIsInKioskAutoPrintMode,
- cmdline->HasSwitch(switches::kKioskModePrinting));
- initial_settings.SetBoolKey(kIsInAppKioskMode,
- chrome::IsRunningInForcedAppMode());
+ initial_settings.Set(kIsInKioskAutoPrintMode,
+ cmdline->HasSwitch(switches::kKioskModePrinting));
+ initial_settings.Set(kIsInAppKioskMode, chrome::IsRunningInForcedAppMode());
const std::string rules_str =
prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules);
if (rules_str.empty()) {
- initial_settings.SetKey(kDefaultDestinationSelectionRules, base::Value());
+ initial_settings.Set(kDefaultDestinationSelectionRules, base::Value());
} else {
- initial_settings.SetStringKey(kDefaultDestinationSelectionRules, rules_str);
+ initial_settings.Set(kDefaultDestinationSelectionRules, rules_str);
}
GetLocaleInformation(&initial_settings);
@@ -944,8 +934,8 @@ void PrintPreviewHandler::SendInitialSettings(
drive::DriveIntegrationService* drive_service =
drive::DriveIntegrationServiceFactory::GetForProfile(
Profile::FromWebUI(web_ui()));
- initial_settings.SetBoolKey(kIsDriveMounted,
- drive_service && drive_service->IsMounted());
+ initial_settings.Set(kIsDriveMounted,
+ drive_service && drive_service->IsMounted());
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
if (drive_integration_service_) {
drive_integration_service_->GetMountPointPath(base::BindOnce(
@@ -959,10 +949,10 @@ void PrintPreviewHandler::SendInitialSettings(
}
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-void PrintPreviewHandler::OnDrivePathReady(base::Value initial_settings,
+void PrintPreviewHandler::OnDrivePathReady(base::Value::Dict initial_settings,
const std::string& callback_id,
const base::FilePath& drive_path) {
- initial_settings.SetBoolKey(kIsDriveMounted, !drive_path.empty());
+ initial_settings.Set(kIsDriveMounted, !drive_path.empty());
ResolveJavascriptCallback(base::Value(callback_id), initial_settings);
}
#endif
@@ -977,8 +967,7 @@ void PrintPreviewHandler::SendPrinterCapabilities(
// Check that |settings_info| is valid.
if (settings_info.FindDict(kSettingCapabilities)) {
VLOG(1) << "Get printer capabilities finished";
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(settings_info)));
+ ResolveJavascriptCallback(base::Value(callback_id), settings_info);
return;
}
@@ -1149,8 +1138,7 @@ void PrintPreviewHandler::OnAddedPrinters(mojom::PrinterType printer_type,
const size_t printer_count = printers.size();
DCHECK(printer_count);
FireWebUIListener("printers-added",
- base::Value(static_cast<int>(printer_type)),
- base::Value(std::move(printers)));
+ base::Value(static_cast<int>(printer_type)), printers);
if (printer_type == mojom::PrinterType::kLocal &&
!has_logged_printers_count_) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h
index 57573392abc..7e54b4e16b6 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h
@@ -13,6 +13,7 @@
#include "base/containers/flat_set.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
@@ -212,12 +213,12 @@ class PrintPreviewHandler : public content::WebUIMessageHandler {
void HandleManagePrinters(const base::Value::List& args);
void SendInitialSettings(const std::string& callback_id,
- base::Value policies,
+ base::Value::Dict policies,
const std::string& default_printer);
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Sets |kIsDriveMounted| for Lacros chrome then returns the initial settings.
- void OnDrivePathReady(base::Value initial_settings,
+ void OnDrivePathReady(base::Value::Dict initial_settings,
const std::string& callback_id,
const base::FilePath& drive_path);
#endif
@@ -235,10 +236,10 @@ class PrintPreviewHandler : public content::WebUIMessageHandler {
void ClearInitiatorDetails();
// Populates |settings| according to the current locale.
- void GetLocaleInformation(base::Value* settings);
+ void GetLocaleInformation(base::Value::Dict* settings);
// Populates |settings| with the list of logged in accounts.
- void GetUserAccountList(base::Value* settings);
+ void GetUserAccountList(base::Value::Dict* settings);
PdfPrinterHandler* GetPdfPrinterHandler();
@@ -303,7 +304,7 @@ class PrintPreviewHandler : public content::WebUIMessageHandler {
// Note that this is not propagated to LocalPrinterHandlerLacros.
// The pointer is constant - if ash crashes and the mojo connection is lost,
// lacros will automatically be restarted.
- crosapi::mojom::LocalPrinter* local_printer_ = nullptr;
+ raw_ptr<crosapi::mojom::LocalPrinter> local_printer_ = nullptr;
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -314,7 +315,8 @@ class PrintPreviewHandler : public content::WebUIMessageHandler {
// Null if the interface is unavailable.
// The pointer is constant - if ash crashes and the mojo connection is lost,
// lacros will automatically be restarted.
- crosapi::mojom::DriveIntegrationService* drive_integration_service_ = nullptr;
+ raw_ptr<crosapi::mojom::DriveIntegrationService> drive_integration_service_ =
+ nullptr;
#endif
base::WeakPtrFactory<PrintPreviewHandler> weak_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc
index 47f9e3f2988..227ec75b1e0 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc
@@ -44,18 +44,18 @@ namespace printing {
namespace {
-base::Value PrintServersConfigMojomToValue(
+base::Value::Dict PrintServersConfigMojomToValue(
crosapi::mojom::PrintServersConfigPtr config) {
- base::Value ui_print_servers(base::Value::Type::LIST);
+ base::Value::List ui_print_servers;
for (const auto& print_server : config->print_servers) {
- base::Value ui_print_server(base::Value::Type::DICTIONARY);
- ui_print_server.SetStringKey("id", print_server->id);
- ui_print_server.SetStringKey("name", print_server->name);
+ base::Value::Dict ui_print_server;
+ ui_print_server.Set("id", print_server->id);
+ ui_print_server.Set("name", print_server->name);
ui_print_servers.Append(std::move(ui_print_server));
}
- base::Value ui_print_servers_config(base::Value::Type::DICTIONARY);
- ui_print_servers_config.SetKey("printServers", std::move(ui_print_servers));
- ui_print_servers_config.SetBoolKey(
+ base::Value::Dict ui_print_servers_config;
+ ui_print_servers_config.Set("printServers", std::move(ui_print_servers));
+ ui_print_servers_config.Set(
"isSingleServerFetchingMode",
config->fetching_mode ==
ash::ServerPrintersFetchingMode::kSingleServerOnly);
@@ -216,8 +216,7 @@ void PrintPreviewHandlerChromeOS::SendPrinterSetup(
if (policies_value)
response.Set("policies", std::move(*policies_value));
}
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(callback_id), response);
}
PrintPreviewHandler* PrintPreviewHandlerChromeOS::GetPrintPreviewHandler() {
@@ -259,10 +258,20 @@ void PrintPreviewHandlerChromeOS::HandleRequestPrinterStatusUpdate(
PrinterHandler* handler = GetPrinterHandler(mojom::PrinterType::kLocal);
handler->StartPrinterStatusRequest(
printer_id,
- base::BindOnce(&PrintPreviewHandlerChromeOS::ResolveJavascriptCallback,
+ base::BindOnce(&PrintPreviewHandlerChromeOS::
+ HandleRequestPrinterStatusUpdateCompletion,
weak_factory_.GetWeakPtr(), base::Value(callback_id)));
}
+void PrintPreviewHandlerChromeOS::HandleRequestPrinterStatusUpdateCompletion(
+ base::Value callback_id,
+ absl::optional<base::Value::Dict> result) {
+ if (result)
+ ResolveJavascriptCallback(callback_id, *result);
+ else
+ ResolveJavascriptCallback(callback_id, base::Value());
+}
+
void PrintPreviewHandlerChromeOS::HandleChoosePrintServers(
const base::Value::List& args) {
CHECK_EQ(1U, args.size());
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h
index 4225ac565c8..9e1d3c3e007 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/gtest_prod_util.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "build/chromeos_buildflags.h"
@@ -92,6 +93,9 @@ class PrintPreviewHandlerChromeOS : public content::WebUIMessageHandler,
// Called to initiate a status request for a printer.
void HandleRequestPrinterStatusUpdate(const base::Value::List& args);
+ void HandleRequestPrinterStatusUpdateCompletion(
+ base::Value callback_id,
+ absl::optional<base::Value::Dict> result);
// crosapi::mojom::PrintServerObserver Implementation
void OnPrintServersChanged(
@@ -112,7 +116,7 @@ class PrintPreviewHandlerChromeOS : public content::WebUIMessageHandler,
// Note that this is not propagated to LocalPrinterHandlerLacros.
// The pointer is constant - if ash crashes and the mojo connection is lost,
// lacros will automatically be restarted.
- crosapi::mojom::LocalPrinter* local_printer_ = nullptr;
+ raw_ptr<crosapi::mojom::LocalPrinter> local_printer_ = nullptr;
base::WeakPtrFactory<PrintPreviewHandlerChromeOS> weak_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc
index 1cffba93181..b57be1f449b 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/logging.h"
+#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
@@ -166,7 +167,7 @@ class PrintPreviewHandlerChromeOSTest : public testing::Test {
std::unique_ptr<TestLocalPrinter> local_printer_;
std::unique_ptr<content::WebContents> preview_web_contents_;
std::unique_ptr<content::TestWebUI> web_ui_;
- PrintPreviewHandlerChromeOS* handler_;
+ raw_ptr<PrintPreviewHandlerChromeOS> handler_;
};
TEST_F(PrintPreviewHandlerChromeOSTest, ChoosePrintServersNoAsh) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
index 550e6de3645..45a34224ed2 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -1086,9 +1086,9 @@ TEST_F(PrintPreviewHandlerTest, GetNoDenyListPrinters) {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
AddToDenyList(mojom::PrinterType::kExtension);
#else
- base::Value::ListStorage deny_list;
- deny_list.push_back(base::Value("extension"));
- prefs()->Set(prefs::kPrinterTypeDenyList, base::Value(std::move(deny_list)));
+ base::Value::List deny_list;
+ deny_list.Append("extension");
+ prefs()->SetList(prefs::kPrinterTypeDenyList, std::move(deny_list));
#endif
Initialize();
@@ -1174,10 +1174,10 @@ TEST_F(PrintPreviewHandlerTest, GetNoDenyListPrinterCapabilities) {
AddToDenyList(mojom::PrinterType::kLocal);
AddToDenyList(mojom::PrinterType::kPdf);
#else
- base::Value::ListStorage deny_list;
- deny_list.push_back(base::Value("local"));
- deny_list.push_back(base::Value("pdf"));
- prefs()->Set(prefs::kPrinterTypeDenyList, base::Value(std::move(deny_list)));
+ base::Value::List deny_list;
+ deny_list.Append("local");
+ deny_list.Append("pdf");
+ prefs()->SetList(prefs::kPrinterTypeDenyList, std::move(deny_list));
#endif
Initialize();
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
index 2ff28727197..a18c6f39409 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
@@ -140,13 +140,15 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewBrowserTest,
ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP);
browser()->tab_strip_model()->ActivateTabAt(
- 0, {TabStripModel::GestureType::kOther});
+ 0, TabStripUserGestureDetails(
+ TabStripUserGestureDetails::GestureType::kOther));
// Navigate main tab to hide print preview.
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL("about:blank")));
browser()->tab_strip_model()->ActivateTabAt(
- 1, {TabStripModel::GestureType::kOther});
+ 1, TabStripUserGestureDetails(
+ TabStripUserGestureDetails::GestureType::kOther));
}
#endif // BUILDFLAG(IS_WIN)
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc
index 5dcfca34c92..1dab6c77d76 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc
@@ -28,6 +28,7 @@
#include "printing/backend/print_backend_consts.h"
#include "printing/page_range.h"
#include "printing/print_job_constants.h"
+#include "printing/units.h"
namespace printing {
@@ -199,6 +200,24 @@ base::Value::Dict ValidateCddForPrintPreview(base::Value::Dict cdd) {
return cdd;
}
+base::Value::Dict UpdateCddWithDpiIfMissing(base::Value::Dict cdd) {
+ base::Value::Dict* printer = cdd.FindDict(kPrinter);
+ if (!printer)
+ return cdd;
+
+ if (!printer->FindDict(kDpiCapabilityKey)) {
+ base::Value::Dict default_dpi;
+ default_dpi.Set(kHorizontalDpi, kDefaultPdfDpi);
+ default_dpi.Set(kVerticalDpi, kDefaultPdfDpi);
+ base::Value::List dpi_options;
+ dpi_options.Append(std::move(default_dpi));
+ base::Value::Dict dpi_capability;
+ dpi_capability.Set(kOptionKey, std::move(dpi_options));
+ printer->Set(kDpiCapabilityKey, std::move(dpi_capability));
+ }
+ return cdd;
+}
+
void ConvertPrinterListForCallback(
PrinterHandler::AddedPrintersCallback callback,
PrinterHandler::GetPrintersDoneCallback done_callback,
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.h b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.h
index 3c0f08a5f11..6200664d8f6 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.h
@@ -26,14 +26,14 @@ extern const char kSelectString[];
extern const char kTypeKey[];
extern const char kVendorCapabilityKey[];
-// Converts |printer_list| to a base::Value::List form, runs |callback| with the
-// converted list as the argument if it is not empty, and runs |done_callback|.
+// Converts `printer_list` to a base::Value::List form, runs `callback` with the
+// converted list as the argument if it is not empty, and runs `done_callback`.
void ConvertPrinterListForCallback(
PrinterHandler::AddedPrintersCallback callback,
PrinterHandler::GetPrintersDoneCallback done_callback,
const PrinterList& printer_list);
-// Returns a sanitized version of |cdd| to prevent possible JS
+// Returns a sanitized version of `cdd` to prevent possible JS
// errors in Print Preview. Will remove null items from lists or options lists
// and remove any lists/options that are empty or only contain null values.
// Will also check some CDD entries to make sure the input conforms to the
@@ -41,14 +41,22 @@ void ConvertPrinterListForCallback(
// On failure, returns an empty dict.
base::Value::Dict ValidateCddForPrintPreview(base::Value::Dict cdd);
-// Starts a local print of |print_data| with print settings dictionary
-// |job_settings|. Runs |callback| on failure or success.
+// Returns an updated version of `cdd` and ensures it has a valid value for the
+// DPI capability. Uses the existing validated value if it exists, or fills in a
+// reasonable default if the capability is missing. Having a DPI is not required
+// in the CDD, but it is crucial for performing page setup.
+//
+// Assumes `cdd` is the output from ValidateCddForPrintPreview().
+base::Value::Dict UpdateCddWithDpiIfMissing(base::Value::Dict cdd);
+
+// Starts a local print of `print_data` with print settings dictionary
+// `job_settings`. Runs `callback` on failure or success.
void StartLocalPrint(base::Value::Dict job_settings,
scoped_refptr<base::RefCountedMemory> print_data,
content::WebContents* preview_web_contents,
PrinterHandler::PrintCallback callback);
-// Parses print job settings. Returns |true| on success.
+// Parses print job settings. Returns `true` on success.
// This is used by extension printers.
bool ParseSettings(const base::Value::Dict& settings,
std::string* out_destination_id,
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils_unittest.cc
index 56b7a6f6166..2b26fa0e4ee 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_utils_unittest.cc
@@ -439,4 +439,60 @@ TEST_F(PrintPreviewUtilsTest, CddResetToDefault) {
EXPECT_FALSE(GetDpiResetToDefault(std::move(cdd_out)));
}
+TEST_F(PrintPreviewUtilsTest, AddMissingDpi) {
+ // Set up the test expectation to have only the 300 DPI setting, which is the
+ // default DPI setting.
+ base::Value::Dict printer = GetCapabilitiesFull();
+ base::Value::Dict* dpi_dict = printer.FindDict(kDpi);
+ ASSERT_TRUE(dpi_dict);
+ base::Value::List* dpi_list = dpi_dict->FindList(kOptionKey);
+ ASSERT_TRUE(dpi_list);
+ ASSERT_EQ(2u, dpi_list->size());
+ dpi_list->erase(dpi_list->begin() + 1);
+ ASSERT_EQ(1u, dpi_list->size());
+ ASSERT_EQ(
+ base::test::ParseJson("{\"horizontal_dpi\": 300, \"vertical_dpi\": 300}"),
+ (*dpi_list)[0]);
+
+ // Initialize `cdd` but clear the DPI list.
+ base::Value::Dict cdd;
+ base::Value::Dict& cdd_printer =
+ cdd.Set(kPrinter, printer.Clone())->GetDict();
+ base::Value::Dict* cdd_printer_dpi_dict = cdd_printer.FindDict(kDpi);
+ ASSERT_TRUE(cdd_printer_dpi_dict);
+ base::Value::List* cdd_printer_dpi_list =
+ cdd_printer_dpi_dict->FindList(kOptionKey);
+ ASSERT_TRUE(cdd_printer_dpi_list);
+ cdd_printer_dpi_list->clear();
+
+ // ValidateCddForPrintPreview() should delete the `kDpi` key altogether, since
+ // the associated value was an empty list.
+ auto cdd_out = ValidateCddForPrintPreview(std::move(cdd));
+ const base::Value::Dict* cdd_out_printer = cdd_out.FindDict(kPrinter);
+ ASSERT_TRUE(cdd_out_printer);
+ EXPECT_FALSE(cdd_out_printer->FindDict(kDpi));
+
+ // Update `cdd_out` with the default value for this required capability. Then
+ // `cdd_out` will pass validation.
+ ValidatePrinter(UpdateCddWithDpiIfMissing(std::move(cdd_out)), printer);
+}
+
+TEST_F(PrintPreviewUtilsTest, ExistingValidDpiCapabilityDoesNotChange) {
+ // Ensure the test expectation has multiple DPIs.
+ const base::Value::Dict printer = GetCapabilitiesFull();
+ const base::Value::Dict* dpi_dict = printer.FindDict(kDpi);
+ ASSERT_TRUE(dpi_dict);
+ const base::Value::List* dpi_list = dpi_dict->FindList(kOptionKey);
+ ASSERT_TRUE(dpi_list);
+ ASSERT_EQ(2u, dpi_list->size());
+
+ // Initialize `cdd`, which is perfectly valid. It should pass through
+ // ValidateCddForPrintPreview() and UpdateCddWithDpiIfMissing() without any
+ // changes.
+ base::Value::Dict cdd;
+ cdd.Set(kPrinter, printer.Clone());
+ auto cdd_out = ValidateCddForPrintPreview(std::move(cdd));
+ ValidatePrinter(UpdateCddWithDpiIfMissing(std::move(cdd_out)), printer);
+}
+
} // namespace printing
diff --git a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
index 17b57dbecc0..2738254c4b7 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
@@ -52,8 +52,8 @@ class PrinterHandler {
#if BUILDFLAG(IS_CHROMEOS)
using GetEulaUrlCallback =
base::OnceCallback<void(const std::string& license)>;
- using PrinterStatusRequestCallback =
- base::OnceCallback<void(const base::Value& cups_printer_status)>;
+ using PrinterStatusRequestCallback = base::OnceCallback<void(
+ absl::optional<base::Value::Dict> cups_printer_status)>;
#endif
// Creates an instance of a PrinterHandler for extension printers.
diff --git a/chromium/chrome/browser/ui/webui/privacy_sandbox/OWNERS b/chromium/chrome/browser/ui/webui/privacy_sandbox/OWNERS
index 0bab1928974..e46b4fee924 100644
--- a/chromium/chrome/browser/ui/webui/privacy_sandbox/OWNERS
+++ b/chromium/chrome/browser/ui/webui/privacy_sandbox/OWNERS
@@ -1,3 +1,4 @@
# Chrome Privacy Team
rainhard@chromium.org
sauski@google.com
+olesiamarukhno@google.com
diff --git a/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.cc b/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.cc
index fd3915ad6a7..b482c16b206 100644
--- a/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.cc
@@ -15,18 +15,20 @@
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "content/public/browser/web_ui.h"
+#include "skia/ext/skia_utils_base.h"
namespace {
-base::Value CreateProfileEntry(
+base::Value::Dict CreateProfileEntry(
const ProfileAttributesEntry* entry,
const base::flat_set<base::FilePath>& loaded_profile_paths,
const base::flat_set<base::FilePath>& has_off_the_record_profile) {
- base::Value profile_entry(base::Value::Type::DICTIONARY);
- profile_entry.SetKey("profilePath", base::FilePathToValue(entry->GetPath()));
- profile_entry.SetStringKey("localProfileName", entry->GetLocalProfileName());
+ base::Value::Dict profile_entry;
+ profile_entry.Set("profilePath", base::FilePathToValue(entry->GetPath()));
+ profile_entry.Set("localProfileName", entry->GetLocalProfileName());
std::string signin_state;
switch (entry->GetSigninState()) {
case SigninState::kNotSignedIn:
@@ -39,21 +41,29 @@ base::Value CreateProfileEntry(
signin_state = "Signed in with consented primary account";
break;
}
- profile_entry.SetStringKey("signinState", signin_state);
- profile_entry.SetBoolKey("signinRequired", entry->IsSigninRequired());
+ profile_entry.Set("signinState", signin_state);
+ profile_entry.Set("signinRequired", entry->IsSigninRequired());
// GAIA full name/user name can be empty, if the profile is not signed in to
// chrome.
- profile_entry.SetStringKey("gaiaName", entry->GetGAIAName());
- profile_entry.SetStringKey("gaiaId", entry->GetGAIAId());
- profile_entry.SetStringKey("userName", entry->GetUserName());
- profile_entry.SetStringKey("hostedDomain", entry->GetHostedDomain());
- profile_entry.SetBoolKey("isSupervised", entry->IsSupervised());
- profile_entry.SetBoolKey("isOmitted", entry->IsOmitted());
- profile_entry.SetBoolKey("isEphemeral", entry->IsEphemeral());
- profile_entry.SetBoolKey("userAcceptedAccountManagement",
- entry->UserAcceptedAccountManagement());
+ profile_entry.Set("gaiaName", entry->GetGAIAName());
+ profile_entry.Set("gaiaId", entry->GetGAIAId());
+ profile_entry.Set("userName", entry->GetUserName());
+ profile_entry.Set("hostedDomain", entry->GetHostedDomain());
+ profile_entry.Set("isSupervised", entry->IsSupervised());
+ profile_entry.Set("isOmitted", entry->IsOmitted());
+ profile_entry.Set("isEphemeral", entry->IsEphemeral());
+ profile_entry.Set("userAcceptedAccountManagement",
+ entry->UserAcceptedAccountManagement());
- base::Value keep_alives(base::Value::Type::LIST);
+ SkColor highlight_color =
+ entry->GetProfileThemeColors().profile_highlight_color;
+ profile_entry.Set("backgroundColor",
+ skia::SkColorToHexString(highlight_color));
+ profile_entry.Set(
+ "foregroundColor",
+ skia::SkColorToHexString(GetProfileForegroundTextColor(highlight_color)));
+
+ base::Value::List keep_alives;
std::map<ProfileKeepAliveOrigin, int> keep_alives_map =
g_browser_process->profile_manager()->GetKeepAlivesByPath(
entry->GetPath());
@@ -61,23 +71,23 @@ base::Value CreateProfileEntry(
if (pair.second != 0) {
std::stringstream ss;
ss << pair.first;
- base::Value keep_alive_pair(base::Value::Type::DICTIONARY);
- keep_alive_pair.SetStringKey("origin", ss.str());
- keep_alive_pair.SetIntKey("count", pair.second);
+ base::Value::Dict keep_alive_pair;
+ keep_alive_pair.Set("origin", ss.str());
+ keep_alive_pair.Set("count", pair.second);
keep_alives.Append(std::move(keep_alive_pair));
}
}
- profile_entry.SetKey("keepAlives", std::move(keep_alives));
+ profile_entry.Set("keepAlives", std::move(keep_alives));
- base::Value signedAccounts(base::Value::Type::LIST);
+ base::Value::List signedAccounts;
for (const std::string& gaiaId : entry->GetGaiaIds()) {
signedAccounts.Append(gaiaId);
}
- profile_entry.SetKey("signedAccounts", std::move(signedAccounts));
- profile_entry.SetBoolKey("isLoaded",
- loaded_profile_paths.contains(entry->GetPath()));
- profile_entry.SetBoolKey(
- "hasOffTheRecord", has_off_the_record_profile.contains(entry->GetPath()));
+ profile_entry.Set("signedAccounts", std::move(signedAccounts));
+ profile_entry.Set("isLoaded",
+ loaded_profile_paths.contains(entry->GetPath()));
+ profile_entry.Set("hasOffTheRecord",
+ has_off_the_record_profile.contains(entry->GetPath()));
return profile_entry;
}
@@ -106,8 +116,8 @@ void ProfileInternalsHandler::PushProfilesList() {
FireWebUIListener("profiles-list-changed", GetProfilesList());
}
-base::Value ProfileInternalsHandler::GetProfilesList() {
- base::Value profiles_list(base::Value::Type::LIST);
+base::Value::List ProfileInternalsHandler::GetProfilesList() {
+ base::Value::List profiles_list;
std::vector<ProfileAttributesEntry*> entries =
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
diff --git a/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.h b/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.h
index 97d937cfe5b..8f22836ad56 100644
--- a/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.h
+++ b/chromium/chrome/browser/ui/webui/profile_internals/profile_internals_handler.h
@@ -28,7 +28,7 @@ class ProfileInternalsHandler : public content::WebUIMessageHandler {
void PushProfilesList();
// Returns the list of profiles ordered by the local profile name.
- base::Value GetProfilesList();
+ base::Value::List GetProfilesList();
};
#endif // CHROME_BROWSER_UI_WEBUI_PROFILE_INTERNALS_PROFILE_INTERNALS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/realbox/BUILD.gn b/chromium/chrome/browser/ui/webui/realbox/BUILD.gn
index bfbcdf09bfa..6b66b6b558a 100644
--- a/chromium/chrome/browser/ui/webui/realbox/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/realbox/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(!is_android)
+
mojom("mojo_bindings") {
sources = [ "realbox.mojom" ]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/realbox/OWNERS b/chromium/chrome/browser/ui/webui/realbox/OWNERS
index 222931b07a6..fcdf4f331ba 100644
--- a/chromium/chrome/browser/ui/webui/realbox/OWNERS
+++ b/chromium/chrome/browser/ui/webui/realbox/OWNERS
@@ -1,5 +1,5 @@
mahmadi@chromium.org
-tommycli@chromium.org
+mfacey@chromium.org
file://components/omnibox/OWNERS
per-file *.mojom=set noparent
diff --git a/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc
index 86edef42f4c..afdebc6f0f6 100644
--- a/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc
+++ b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc
@@ -21,8 +21,8 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/predictors/autocomplete_action_predictor.h"
#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
-#include "chrome/browser/prefetch/search_prefetch/search_prefetch_service.h"
-#include "chrome/browser/prefetch/search_prefetch/search_prefetch_service_factory.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
@@ -122,25 +122,23 @@ constexpr char kShareIconResourceName[] = "realbox/icons/share.svg";
#endif
base::flat_map<int32_t, realbox::mojom::SuggestionGroupPtr>
-CreateSuggestionGroupsMap(
- const AutocompleteResult& result,
- PrefService* prefs,
- const SearchSuggestionParser::HeadersMap& headers_map) {
+CreateSuggestionGroupsMap(const AutocompleteResult& result,
+ PrefService* prefs,
+ const SuggestionGroupsMap& suggestion_groups_map) {
base::flat_map<int32_t, realbox::mojom::SuggestionGroupPtr> result_map;
- for (const auto& pair : headers_map) {
+ for (const auto& pair : suggestion_groups_map) {
realbox::mojom::SuggestionGroupPtr suggestion_group =
realbox::mojom::SuggestionGroup::New();
- suggestion_group->header = pair.second;
+ suggestion_group->header = pair.second.header;
suggestion_group->hidden =
- result.IsSuggestionGroupIdHidden(prefs, pair.first);
- suggestion_group->show_group_a11y_label =
- l10n_util::GetStringFUTF16(IDS_ACC_HEADER_SHOW_SUGGESTIONS_BUTTON,
- result.GetHeaderForGroupId(pair.first));
- suggestion_group->hide_group_a11y_label =
- l10n_util::GetStringFUTF16(IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON,
- result.GetHeaderForGroupId(pair.first));
+ result.IsSuggestionGroupHidden(prefs, pair.first);
+ suggestion_group->show_group_a11y_label = l10n_util::GetStringFUTF16(
+ IDS_ACC_HEADER_SHOW_SUGGESTIONS_BUTTON, suggestion_group->header);
+ suggestion_group->hide_group_a11y_label = l10n_util::GetStringFUTF16(
+ IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON, suggestion_group->header);
- result_map.emplace(pair.first, std::move(suggestion_group));
+ result_map.emplace(static_cast<int>(pair.first),
+ std::move(suggestion_group));
}
return result_map;
}
@@ -215,8 +213,8 @@ std::vector<realbox::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
description_class.style));
}
mojom_match->destination_url = match.destination_url;
- mojom_match->suggestion_group_id = match.suggestion_group_id.value_or(
- SearchSuggestionParser::kNoSuggestionGroupId);
+ mojom_match->suggestion_group_id = static_cast<int>(
+ match.suggestion_group_id.value_or(SuggestionGroupId::kInvalid));
const bool is_bookmarked =
bookmark_model->IsBookmarked(match.destination_url);
mojom_match->icon_url =
@@ -283,7 +281,8 @@ realbox::mojom::AutocompleteResultPtr CreateAutocompleteResult(
bookmarks::BookmarkModel* bookmark_model,
PrefService* prefs) {
return realbox::mojom::AutocompleteResult::New(
- input, CreateSuggestionGroupsMap(result, prefs, result.headers_map()),
+ input,
+ CreateSuggestionGroupsMap(result, prefs, result.suggestion_groups_map()),
CreateAutocompleteMatches(result, bookmark_model));
}
@@ -382,6 +381,8 @@ std::string RealboxHandler::AutocompleteMatchVectorIconToResourceName(
return kDriveVideoIconResourceName;
} else if (icon.name == omnibox::kExtensionAppIcon.name) {
return kExtensionAppIconResourceName;
+ } else if (icon.name == omnibox::kJourneysIcon.name) {
+ return kJourneysIconResourceName;
} else if (icon.name == omnibox::kPageIcon.name) {
return kPageIconResourceName;
} else if (icon.name == omnibox::kPedalIcon.name) {
@@ -604,7 +605,7 @@ void RealboxHandler::OpenAutocompleteMatch(
auto* bookmark_model = BookmarkModelFactory::GetForBrowserContext(profile_);
if (bookmark_model->IsBookmarked(match.destination_url)) {
- RecordBookmarkLaunch(BOOKMARK_LAUNCH_LOCATION_OMNIBOX,
+ RecordBookmarkLaunch(BookmarkLaunchLocation::kOmnibox,
profile_metrics::GetBrowserProfileType(profile_));
}
@@ -689,13 +690,16 @@ void RealboxHandler::ToggleSuggestionGroupIdVisibility(
if (!autocomplete_controller_)
return;
- omnibox::SuggestionGroupVisibility new_value =
- autocomplete_controller_->result().IsSuggestionGroupIdHidden(
- profile_->GetPrefs(), suggestion_group_id)
- ? omnibox::SuggestionGroupVisibility::SHOWN
- : omnibox::SuggestionGroupVisibility::HIDDEN;
- omnibox::SetSuggestionGroupVisibility(profile_->GetPrefs(),
- suggestion_group_id, new_value);
+ // It should be safe to cast |suggestion_group_id| to SuggestionGroupId type,
+ // since the group ID was originally passed to the page by the browser.
+ // TODO(crbug.com/1343512): Investigate migrating this enum to a proto enum
+ // to take advantage of its built-in check for conversion from int32 type.
+ const auto& group_id = static_cast<SuggestionGroupId>(suggestion_group_id);
+ const bool current_visibility =
+ autocomplete_controller_->result().IsSuggestionGroupHidden(
+ profile_->GetPrefs(), group_id);
+ autocomplete_controller_->result().SetSuggestionGroupHidden(
+ profile_->GetPrefs(), group_id, !current_visibility);
}
void RealboxHandler::LogCharTypedToRepaintLatency(base::TimeDelta latency) {
@@ -778,7 +782,8 @@ void RealboxHandler::OnResultChanged(AutocompleteController* controller,
// Request favicons for navigational matches.
// TODO(crbug.com/1075848): Investigate using chrome://favicon2.
if (!AutocompleteMatch::IsSearchType(match.type) &&
- match.type != AutocompleteMatchType::DOCUMENT_SUGGESTION) {
+ match.type != AutocompleteMatchType::DOCUMENT_SUGGESTION &&
+ match.type != AutocompleteMatchType::HISTORY_CLUSTER) {
gfx::Image favicon = favicon_cache_.GetLargestFaviconForPageUrl(
match.destination_url,
base::BindOnce(&RealboxHandler::OnRealboxFaviconFetched,
diff --git a/chromium/chrome/browser/ui/webui/realbox/realbox_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/realbox/realbox_handler_browsertest.cc
index 15da1bb75f9..e092ee3a9aa 100644
--- a/chromium/chrome/browser/ui/webui/realbox/realbox_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/realbox/realbox_handler_browsertest.cc
@@ -11,10 +11,10 @@
#include "base/check.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/scoped_feature_list.h"
-#include "chrome/browser/prefetch/search_prefetch/field_trial_settings.h"
-#include "chrome/browser/prefetch/search_prefetch/search_prefetch_browser_test_base.h"
-#include "chrome/browser/prefetch/search_prefetch/search_prefetch_service.h"
-#include "chrome/browser/prefetch/search_prefetch/search_prefetch_service_factory.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/field_trial_settings.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_browser_test_base.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service.h"
+#include "chrome/browser/preloading/prefetch/search_prefetch/search_prefetch_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/omnibox/omnibox_pedal_implementations.h"
#include "chrome/common/chrome_features.h"
diff --git a/chromium/chrome/browser/ui/webui/reset_password/OWNERS b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
index 6a739ea7892..929be254208 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/OWNERS
+++ b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
@@ -1,6 +1,4 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-drubery@chromium.org
-nparker@chromium.org
-vakh@chromium.org
+file://components/safe_browsing/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
index ca61b25b731..aa62b6e941b 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
@@ -88,7 +88,7 @@ class ResetPasswordHandlerImpl : public mojom::ResetPasswordHandler {
PasswordType GetPasswordType(content::WebContents* web_contents) {
content::NavigationEntry* nav_entry =
web_contents->GetController().GetPendingEntry();
- if (!nav_entry || !nav_entry->GetHasPostData())
+ if (!nav_entry || !nav_entry->GetHasPostData() || !nav_entry->GetPostData())
return PasswordType::PASSWORD_TYPE_UNKNOWN;
auto& post_data = nav_entry->GetPostData()->elements()->at(0);
if (post_data.type() == network::DataElement::Tag::kBytes) {
@@ -142,8 +142,11 @@ void ResetPasswordUI::BindInterface(
base::Value::Dict ResetPasswordUI::PopulateStrings() const {
auto* service = safe_browsing::ChromePasswordProtectionService::
GetPasswordProtectionService(Profile::FromWebUI(web_ui()));
- std::string org_name = service->GetOrganizationName(
- service->reused_password_account_type_for_last_shown_warning());
+ std::string org_name =
+ service
+ ? service->GetOrganizationName(
+ service->reused_password_account_type_for_last_shown_warning())
+ : std::string();
bool known_password_type =
password_type_ != PasswordType::PASSWORD_TYPE_UNKNOWN;
diff --git a/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.cc b/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.cc
index bf7e2ae1300..58f48da9a96 100644
--- a/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.cc
@@ -26,36 +26,34 @@ using content::RenderProcessHost;
namespace sandbox_handler {
namespace {
-base::Value FetchBrowserChildProcesses() {
+base::Value::List FetchBrowserChildProcesses() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value browser_processes(base::Value::Type::LIST);
+ base::Value::List browser_processes;
for (BrowserChildProcessHostIterator itr; !itr.Done(); ++itr) {
const ChildProcessData& process_data = itr.GetData();
// Only add processes that have already started, i.e. with valid handles.
if (!process_data.GetProcess().IsValid())
continue;
- base::Value proc(base::Value::Type::DICTIONARY);
- proc.SetPath("processId", base::Value(base::strict_cast<double>(
- process_data.GetProcess().Pid())));
- proc.SetPath("processType",
- base::Value(content::GetProcessTypeNameInEnglish(
- process_data.process_type)));
- proc.SetPath("name", base::Value(process_data.name));
- proc.SetPath("metricsName", base::Value(process_data.metrics_name));
- proc.SetPath(
- "sandboxType",
- base::Value(sandbox::policy::SandboxWin::GetSandboxTypeInEnglish(
- process_data.sandbox_type)));
+ base::Value::Dict proc;
+ proc.Set("processId",
+ base::strict_cast<double>(process_data.GetProcess().Pid()));
+ proc.Set("processType",
+ content::GetProcessTypeNameInEnglish(process_data.process_type));
+ proc.Set("name", process_data.name);
+ proc.Set("metricsName", process_data.metrics_name);
+ proc.Set("sandboxType",
+ sandbox::policy::SandboxWin::GetSandboxTypeInEnglish(
+ process_data.sandbox_type));
browser_processes.Append(std::move(proc));
}
return browser_processes;
}
-base::Value FetchRenderHostProcesses() {
+base::Value::List FetchRenderHostProcesses() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value renderer_processes(base::Value::Type::LIST);
+ base::Value::List renderer_processes;
for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) {
@@ -64,32 +62,31 @@ base::Value FetchRenderHostProcesses() {
if (!host->GetProcess().IsValid())
continue;
- base::Value proc(base::Value::Type::DICTIONARY);
- proc.SetPath(
- "processId",
- base::Value(base::strict_cast<double>(host->GetProcess().Pid())));
+ base::Value::Dict proc;
+ proc.Set("processId", base::strict_cast<double>(host->GetProcess().Pid()));
renderer_processes.Append(std::move(proc));
}
return renderer_processes;
}
-base::Value FeatureToValue(const base::Feature& feature) {
- base::Value feature_info(base::Value::Type::DICTIONARY);
- feature_info.SetPath("name", base::Value(feature.name));
- feature_info.SetPath("enabled",
- base::Value(base::FeatureList::IsEnabled(feature)));
+base::Value::Dict FeatureToValue(const base::Feature& feature) {
+ base::Value::Dict feature_info;
+ feature_info.Set("name", feature.name);
+ feature_info.Set("enabled", base::FeatureList::IsEnabled(feature));
return feature_info;
}
-base::Value FetchSandboxFeatures() {
- base::Value features(base::Value::Type::LIST);
+base::Value::List FetchSandboxFeatures() {
+ base::Value::List features;
features.Append(FeatureToValue(sandbox::policy::features::kGpuAppContainer));
features.Append(FeatureToValue(sandbox::policy::features::kGpuLPAC));
features.Append(
FeatureToValue(sandbox::policy::features::kNetworkServiceSandbox));
features.Append(
FeatureToValue(sandbox::policy::features::kRendererAppContainer));
+ features.Append(
+ FeatureToValue(sandbox::policy::features::kSharedSandboxPolicies));
features.Append(FeatureToValue(
sandbox::policy::features::kWinSboxDisableExtensionPoints));
features.Append(
@@ -141,11 +138,11 @@ void SandboxHandler::GetRendererProcessesAndFinish() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto renderer_processes = FetchRenderHostProcesses();
- base::Value results(base::Value::Type::DICTIONARY);
- results.SetPath("browser", std::move(browser_processes_));
- results.SetPath("policies", std::move(sandbox_policies_));
- results.SetPath("renderer", std::move(renderer_processes));
- results.SetPath("features", FetchSandboxFeatures());
+ base::Value::Dict results;
+ results.Set("browser", std::move(browser_processes_));
+ results.Set("policies", std::move(sandbox_policies_));
+ results.Set("renderer", std::move(renderer_processes));
+ results.Set("features", FetchSandboxFeatures());
ResolveJavascriptCallback(sandbox_diagnostics_callback_id_,
std::move(results));
}
diff --git a/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.h b/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.h
index 2f9bb43f522..abd4c456384 100644
--- a/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.h
+++ b/chromium/chrome/browser/ui/webui/sandbox/sandbox_handler.h
@@ -38,7 +38,7 @@ class SandboxHandler : public content::WebUIMessageHandler {
// The ID of the callback that will get invoked with the sandbox list.
base::Value sandbox_diagnostics_callback_id_;
- base::Value browser_processes_;
+ base::Value::List browser_processes_;
base::Value sandbox_policies_;
// Always keep this the last member of this class to make sure it's the
diff --git a/chromium/chrome/browser/ui/webui/sanitized_image_source.cc b/chromium/chrome/browser/ui/webui/sanitized_image_source.cc
index 7cdb4be7ef4..90bcea8ee83 100644
--- a/chromium/chrome/browser/ui/webui/sanitized_image_source.cc
+++ b/chromium/chrome/browser/ui/webui/sanitized_image_source.cc
@@ -212,7 +212,7 @@ void SanitizedImageSource::StartImageDownload(
network::SimpleURLLoader::kMaxBoundedStringDownloadSize);
}
-std::string SanitizedImageSource::GetMimeType(const std::string& path) {
+std::string SanitizedImageSource::GetMimeType(const GURL& url) {
return "image/png";
}
diff --git a/chromium/chrome/browser/ui/webui/sanitized_image_source.h b/chromium/chrome/browser/ui/webui/sanitized_image_source.h
index ad5a4838e57..a3c3724b5cd 100644
--- a/chromium/chrome/browser/ui/webui/sanitized_image_source.h
+++ b/chromium/chrome/browser/ui/webui/sanitized_image_source.h
@@ -64,7 +64,7 @@ class SanitizedImageSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool ShouldReplaceExistingSource() override;
void set_identity_manager_for_test(
diff --git a/chromium/chrome/browser/ui/webui/sanitized_image_source_unittest.cc b/chromium/chrome/browser/ui/webui/sanitized_image_source_unittest.cc
index 90814d65454..48f8dffd053 100644
--- a/chromium/chrome/browser/ui/webui/sanitized_image_source_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/sanitized_image_source_unittest.cc
@@ -195,7 +195,7 @@ TEST_F(SanitizedImageSourceTest, GooglePhotosImage) {
// Encode a URL so that it can be used as a param value.
url::RawCanonOutputT<char> encoded_url;
url::EncodeURIComponent(kImageUrl, std::size(kImageUrl), &encoded_url);
- EXPECT_GT(encoded_url.length(), 0);
+ EXPECT_GT(encoded_url.length(), 0u);
base::StringPiece encoded_url_str(encoded_url.data(), encoded_url.length());
// Verify that param-formatted requests can be sent with auth tokens.
@@ -251,7 +251,7 @@ TEST_F(SanitizedImageSourceTest, GooglePhotosImage) {
url::RawCanonOutputT<char> encoded_bad_url;
url::EncodeURIComponent(kBadImageUrl, std::size(kBadImageUrl),
&encoded_bad_url);
- EXPECT_GT(encoded_bad_url.length(), 0);
+ EXPECT_GT(encoded_bad_url.length(), 0u);
base::StringPiece encoded_bad_url_str(encoded_bad_url.data(),
encoded_bad_url.length());
diff --git a/chromium/chrome/browser/ui/webui/settings/OWNERS b/chromium/chrome/browser/ui/webui/settings/OWNERS
index b033c557ff9..f6990533f9d 100644
--- a/chromium/chrome/browser/ui/webui/settings/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/OWNERS
@@ -9,7 +9,7 @@ per-file *site_settings*=msramek@chromium.org
per-file *site_settings*=sauski@google.com
per-file safe_browsing_handler*=msramek@chromium.org
per-file safe_browsing_handler*=sauski@google.com
-per-file safety_check_handler*=andzaytsev@google.com
+per-file safety_check_handler*=andzaytsev@google.com,rainhard@chromium.org
per-file settings_clear_browsing_data_handler*=sauski@google.com
per-file settings_cookies_view_handler*=sauski@google.com
per-file settings_localized_strings_provider*=sauski@google.com
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index e5a142ceedb..98350e4663b 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <limits>
#include <string>
#include "base/bind.h"
@@ -21,7 +22,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/thread_pool.h"
#include "base/time/default_clock.h"
-#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
@@ -40,6 +40,7 @@
#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/policy_constants.h"
+#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
@@ -49,6 +50,8 @@
#include "v8/include/v8-version-string.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/components/fwupd/firmware_update_manager.h"
+#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "base/i18n/time_formatting.h"
#include "chrome/browser/ash/arc/arc_util.h"
@@ -63,12 +66,12 @@
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
#include "chrome/browser/ui/webui/webui_util.h"
+#include "chromeos/ash/components/dbus/update_engine/update_engine_client.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "chromeos/dbus/power/power_manager_client.h"
-#include "chromeos/dbus/update_engine/update_engine_client.h"
-#include "chromeos/dbus/util/version_loader.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
#include "chromeos/system/statistics_provider.h"
+#include "chromeos/version/version_loader.h"
#include "components/user_manager/user_manager.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -102,7 +105,7 @@ struct RegulatoryLabel {
std::u16string GetAllowedConnectionTypesMessage() {
if (help_utils_chromeos::IsUpdateOverCellularAllowed(
/*interactive=*/true)) {
- const bool metered = chromeos::NetworkHandler::Get()
+ const bool metered = ash::NetworkHandler::Get()
->network_state_handler()
->default_network_is_metered();
return metered
@@ -197,16 +200,12 @@ std::string ReadRegulatoryLabelText(const base::FilePath& label_dir_path) {
return std::string();
}
-std::unique_ptr<base::DictionaryValue> GetVersionInfo() {
- std::unique_ptr<base::DictionaryValue> version_info(
- new base::DictionaryValue);
- version_info->SetStringKey("osVersion",
- chromeos::version_loader::GetVersion(
- chromeos::version_loader::VERSION_FULL));
- version_info->SetStringKey("arcVersion",
- chromeos::version_loader::GetARCVersion());
- version_info->SetStringKey("osFirmware",
- chromeos::version_loader::GetFirmware());
+base::Value::Dict GetVersionInfo() {
+ base::Value::Dict version_info;
+ version_info.Set("osVersion", chromeos::version_loader::GetVersion(
+ chromeos::version_loader::VERSION_FULL));
+ version_info.Set("arcVersion", chromeos::version_loader::GetArcVersion());
+ version_info.Set("osFirmware", chromeos::version_loader::GetFirmware());
return version_info;
}
@@ -247,6 +246,9 @@ std::string UpdateStatusToString(VersionUpdater::Status status) {
case VersionUpdater::NEED_PERMISSION_TO_UPDATE:
status_str = "need_permission_to_update";
break;
+ case VersionUpdater::DEFERRED:
+ status_str = "deferred";
+ break;
}
return status_str;
@@ -294,12 +296,21 @@ void AboutHandler::RegisterMessages() {
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "getFirmwareUpdateCount",
+ base::BindRepeating(&AboutHandler::HandleGetFirmwareUpdateCount,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
"openOsHelpPage", base::BindRepeating(&AboutHandler::HandleOpenOsHelpPage,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setChannel", base::BindRepeating(&AboutHandler::HandleSetChannel,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "applyDeferredUpdate",
+ base::BindRepeating(&AboutHandler::HandleApplyDeferredUpdate,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"requestUpdate", base::BindRepeating(&AboutHandler::HandleRequestUpdate,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
@@ -370,10 +381,12 @@ void AboutHandler::OnJavascriptAllowed() {
policy_registrar_ = std::make_unique<policy::PolicyChangeRegistrar>(
g_browser_process->policy_service(),
policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
+#if BUILDFLAG(IS_CHROMEOS)
policy_registrar_->Observe(
policy::key::kDeviceAutoUpdateDisabled,
base::BindRepeating(&AboutHandler::OnDeviceAutoUpdatePolicyChanged,
base::Unretained(this)));
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void AboutHandler::OnJavascriptDisallowed() {
@@ -467,10 +480,9 @@ void AboutHandler::HandleCheckInternetConnection(
CHECK_EQ(1U, args.size());
const std::string& callback_id = args[0].GetString();
- chromeos::NetworkStateHandler* network_state_handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- const chromeos::NetworkState* network =
- network_state_handler->DefaultNetwork();
+ ash::NetworkStateHandler* network_state_handler =
+ ash::NetworkHandler::Get()->network_state_handler();
+ const ash::NetworkState* network = network_state_handler->DefaultNetwork();
ResolveJavascriptCallback(base::Value(callback_id),
base::Value(network && network->IsOnline()));
}
@@ -480,8 +492,7 @@ void AboutHandler::HandleLaunchReleaseNotes(const base::Value::List& args) {
// We can always show the release notes since the Help app caches it, or can
// show an appropriate error state (e.g. No internet connection).
base::RecordAction(base::UserMetricsAction("ReleaseNotes.LaunchedAboutPage"));
- chrome::LaunchReleaseNotes(profile_,
- apps::mojom::LaunchSource::kFromOtherApp);
+ chrome::LaunchReleaseNotes(profile_, apps::LaunchSource::kFromOtherApp);
}
void AboutHandler::HandleOpenOsHelpPage(const base::Value::List& args) {
@@ -492,7 +503,7 @@ void AboutHandler::HandleOpenOsHelpPage(const base::Value::List& args) {
}
void AboutHandler::HandleSetChannel(const base::Value::List& args) {
- DCHECK(args.size() == 2);
+ DCHECK_EQ(2U, args.size());
if (!CanChangeChannel(profile_)) {
LOG(WARNING) << "Non-owner tried to change release track.";
@@ -526,10 +537,20 @@ void AboutHandler::HandleGetVersionInfo(const base::Value::List& args) {
weak_factory_.GetWeakPtr(), callback_id));
}
-void AboutHandler::OnGetVersionInfoReady(
- std::string callback_id,
- std::unique_ptr<base::DictionaryValue> version_info) {
- ResolveJavascriptCallback(base::Value(callback_id), *version_info);
+void AboutHandler::OnGetVersionInfoReady(std::string callback_id,
+ base::Value::Dict version_info) {
+ ResolveJavascriptCallback(base::Value(callback_id), version_info);
+}
+
+void AboutHandler::HandleGetFirmwareUpdateCount(const base::Value::List& args) {
+ DCHECK(base::FeatureList::IsEnabled(chromeos::features::kFirmwareUpdaterApp));
+ CHECK_EQ(1U, args.size());
+ const std::string& callback_id = args[0].GetString();
+ auto* firmware_update_manager = ash::FirmwareUpdateManager::Get();
+ size_t update_count = firmware_update_manager->GetUpdateCount();
+ DCHECK_LT(update_count, std::numeric_limits<int>::max());
+ ResolveJavascriptCallback(base::Value(callback_id),
+ base::Value(static_cast<int>(update_count)));
}
void AboutHandler::HandleGetRegulatoryInfo(const base::Value::List& args) {
@@ -570,19 +591,22 @@ void AboutHandler::OnGetCurrentChannel(std::string callback_id,
void AboutHandler::OnGetTargetChannel(std::string callback_id,
const std::string& current_channel,
const std::string& target_channel) {
- std::unique_ptr<base::DictionaryValue> channel_info(
- new base::DictionaryValue);
- channel_info->SetStringKey("currentChannel", current_channel);
- channel_info->SetStringKey("targetChannel", target_channel);
+ base::Value::Dict channel_info;
+ channel_info.Set("currentChannel", current_channel);
+ channel_info.Set("targetChannel", target_channel);
// For the LTS pilot simply check whether the device policy is set and ignore
// its value.
std::string value;
bool is_lts =
ash::CrosSettings::Get()->GetString(ash::kReleaseLtsTag, &value);
- channel_info->SetBoolKey("isLts", is_lts);
+ channel_info.Set("isLts", is_lts);
+
+ ResolveJavascriptCallback(base::Value(callback_id), channel_info);
+}
- ResolveJavascriptCallback(base::Value(callback_id), *channel_info);
+void AboutHandler::HandleApplyDeferredUpdate(const base::Value::List& args) {
+ version_updater_->ApplyDeferredUpdate();
}
void AboutHandler::HandleRequestUpdate(const base::Value::List& args) {
@@ -619,9 +643,9 @@ void AboutHandler::HandleRefreshTPMFirmwareUpdateStatus(
void AboutHandler::RefreshTPMFirmwareUpdateStatus(
const std::set<ash::tpm_firmware_update::Mode>& modes) {
- std::unique_ptr<base::DictionaryValue> event(new base::DictionaryValue);
- event->SetBoolKey("updateAvailable", !modes.empty());
- FireWebUIListener("tpm-firmware-update-status-changed", *event);
+ base::Value::Dict event;
+ event.Set("updateAvailable", !modes.empty());
+ FireWebUIListener("tpm-firmware-update-status-changed", event);
}
void AboutHandler::HandleGetEndOfLifeInfo(const base::Value::List& args) {
@@ -634,15 +658,15 @@ void AboutHandler::HandleGetEndOfLifeInfo(const base::Value::List& args) {
void AboutHandler::OnGetEndOfLifeInfo(
std::string callback_id,
- chromeos::UpdateEngineClient::EolInfo eol_info) {
- base::Value response(base::Value::Type::DICTIONARY);
+ ash::UpdateEngineClient::EolInfo eol_info) {
+ base::Value::Dict response;
if (!eol_info.eol_date.is_null()) {
bool has_eol_passed = eol_info.eol_date <= clock_->Now();
- response.SetBoolKey("hasEndOfLife", has_eol_passed);
+ response.Set("hasEndOfLife", has_eol_passed);
int eol_string_id =
has_eol_passed ? IDS_SETTINGS_ABOUT_PAGE_END_OF_LIFE_MESSAGE_PAST
: IDS_SETTINGS_ABOUT_PAGE_END_OF_LIFE_MESSAGE_FUTURE;
- response.SetStringKey(
+ response.Set(
"aboutPageEndOfLifeMessage",
l10n_util::GetStringFUTF16(
eol_string_id,
@@ -651,8 +675,8 @@ void AboutHandler::OnGetEndOfLifeInfo(
base::ASCIIToUTF16(has_eol_passed ? chrome::kEolNotificationURL
: chrome::kAutoUpdatePolicyURL)));
} else {
- response.SetBoolKey("hasEndOfLife", false);
- response.SetStringKey("aboutPageEndOfLifeMessage", "");
+ response.Set("hasEndOfLife", false);
+ response.Set("aboutPageEndOfLifeMessage", "");
}
ResolveJavascriptCallback(base::Value(callback_id), response);
}
@@ -724,29 +748,29 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status,
// Only UPDATING state should have progress set.
DCHECK(status == VersionUpdater::UPDATING || progress == 0);
- std::unique_ptr<base::DictionaryValue> event(new base::DictionaryValue);
- event->SetStringKey("status", UpdateStatusToString(status));
- event->SetStringKey("message", message);
- event->SetIntKey("progress", progress);
- event->SetBoolKey("rollback", rollback);
- event->SetBoolKey("powerwash", powerwash);
- event->SetStringKey("version", version);
+ base::Value::Dict event;
+ event.Set("status", UpdateStatusToString(status));
+ event.Set("message", message);
+ event.Set("progress", progress);
+ event.Set("rollback", rollback);
+ event.Set("powerwash", powerwash);
+ event.Set("version", version);
// DictionaryValue does not support int64_t, so convert to string.
- event->SetStringKey("size", base::NumberToString(size));
+ event.Set("size", base::NumberToString(size));
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (status == VersionUpdater::FAILED_OFFLINE ||
status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) {
std::u16string types_msg = GetAllowedConnectionTypesMessage();
if (!types_msg.empty())
- event->SetStringKey("connectionTypes", types_msg);
+ event.Set("connectionTypes", types_msg);
else
- event->Set("connectionTypes", std::make_unique<base::Value>());
+ event.Set("connectionTypes", base::Value());
} else {
- event->Set("connectionTypes", std::make_unique<base::Value>());
+ event.Set("connectionTypes", base::Value());
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- FireWebUIListener("update-status-changed", *event);
+ FireWebUIListener("update-status-changed", event);
}
#if BUILDFLAG(IS_MAC)
@@ -766,12 +790,12 @@ void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) {
else if (state == VersionUpdater::PROMOTED)
text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL_IS_ON);
- base::DictionaryValue promo_state;
- promo_state.SetBoolKey("hidden", hidden);
- promo_state.SetBoolKey("disabled", disabled);
- promo_state.SetBoolKey("actionable", actionable);
+ base::Value::Dict promo_state;
+ promo_state.Set("hidden", hidden);
+ promo_state.Set("disabled", disabled);
+ promo_state.Set("actionable", actionable);
if (!text.empty())
- promo_state.SetStringKey("text", text);
+ promo_state.Set("text", text);
FireWebUIListener("promotion-state-changed", promo_state);
}
@@ -797,19 +821,17 @@ void AboutHandler::OnRegulatoryLabelTextRead(
std::string callback_id,
const base::FilePath& label_dir_path,
const std::string& text) {
- std::unique_ptr<base::DictionaryValue> regulatory_info(
- new base::DictionaryValue);
+ base::Value::Dict regulatory_info;
// Remove unnecessary whitespace.
- regulatory_info->SetStringKey("text",
- base::CollapseWhitespaceASCII(text, true));
+ regulatory_info.Set("text", base::CollapseWhitespaceASCII(text, true));
std::string image_path =
label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII();
std::string url =
std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
- regulatory_info->SetStringKey("url", url);
+ regulatory_info.Set("url", url);
- ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info);
+ ResolveJavascriptCallback(base::Value(callback_id), regulatory_info);
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h
index 1990ef08692..d8d826688ef 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h
@@ -10,6 +10,7 @@
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
@@ -24,7 +25,6 @@
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace base {
-class DictionaryValue;
class FilePath;
class Clock;
} // namespace base
@@ -52,9 +52,6 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// UpgradeObserver implementation.
void OnUpgradeRecommended() override;
- // Returns the browser version as a string.
- static std::u16string BuildBrowserVersionString();
-
protected:
// Used to test the EOL string displayed in the About details page.
void set_clock(base::Clock* clock) { clock_ = clock; }
@@ -102,9 +99,11 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Retrieves OS, ARC and firmware versions.
void HandleGetVersionInfo(const base::Value::List& args);
- void OnGetVersionInfoReady(
- std::string callback_id,
- std::unique_ptr<base::DictionaryValue> version_info);
+ void OnGetVersionInfoReady(std::string callback_id,
+ base::Value::Dict version_info);
+
+ // Retrieves the number of firmware updates available.
+ void HandleGetFirmwareUpdateCount(const base::Value::List& args);
// Retrieves channel info.
void HandleGetChannelInfo(const base::Value::List& args);
@@ -119,6 +118,9 @@ class AboutHandler : public settings::SettingsPageUIHandler,
const std::string& current_channel,
const std::string& target_channel);
+ // Applies deferred update, triggered by JS.
+ void HandleApplyDeferredUpdate(const base::Value::List& args);
+
// Checks for and applies update, triggered by JS.
void HandleRequestUpdate(const base::Value::List& args);
@@ -179,7 +181,7 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Callbacks for version_updater_->GetEolInfo calls.
void OnGetEndOfLifeInfo(std::string callback_id,
- chromeos::UpdateEngineClient::EolInfo eol_info);
+ ash::UpdateEngineClient::EolInfo eol_info);
// Get the managed auto update cros setting.
void HandleIsManagedAutoUpdateEnabled(const base::Value::List& args);
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
index 603ebd5fa40..33a51e9ce5c 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
@@ -8,8 +8,8 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ash/components/dbus/concierge/concierge_client.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/update_engine/fake_update_engine_client.h"
+#include "chromeos/ash/components/dbus/update_engine/fake_update_engine_client.h"
+#include "chromeos/ash/components/dbus/update_engine/update_engine_client.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,10 +39,8 @@ class AboutHandlerTest : public testing::Test {
AboutHandlerTest& operator=(const AboutHandlerTest&) = delete;
void SetUp() override {
- fake_update_engine_client_ = new FakeUpdateEngineClient();
- DBusThreadManager::Initialize();
- DBusThreadManager::GetSetterForTesting()->SetUpdateEngineClient(
- base::WrapUnique<UpdateEngineClient>(fake_update_engine_client_));
+ fake_update_engine_client_ =
+ ash::UpdateEngineClient::InitializeFakeForTest();
ConciergeClient::InitializeFake(/*fake_cicerone_client=*/nullptr);
handler_ = std::make_unique<TestAboutHandler>(&profile_);
@@ -58,7 +56,7 @@ class AboutHandlerTest : public testing::Test {
handler_.reset();
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
ConciergeClient::Shutdown();
- DBusThreadManager::Shutdown();
+ ash::UpdateEngineClient::Shutdown();
}
const content::TestWebUI::CallData& CallDataAtIndex(size_t index) {
@@ -68,10 +66,9 @@ class AboutHandlerTest : public testing::Test {
std::string CallGetEndOfLifeInfoAndReturnString(bool has_eol_passed) {
size_t call_data_count_before_call = web_ui_.call_data().size();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("handlerFunctionName");
- web_ui_.HandleReceivedMessage("getEndOfLifeInfo",
- &base::Value::AsListValue(args));
+ web_ui_.HandleReceivedMessage("getEndOfLifeInfo", args);
task_environment_.RunUntilIdle();
EXPECT_EQ(call_data_count_before_call + 1u, web_ui_.call_data().size());
@@ -102,7 +99,7 @@ class AboutHandlerTest : public testing::Test {
TestingProfile profile_;
content::TestWebUI web_ui_;
std::unique_ptr<TestAboutHandler> handler_;
- FakeUpdateEngineClient* fake_update_engine_client_;
+ ash::FakeUpdateEngineClient* fake_update_engine_client_;
std::unique_ptr<base::SimpleTestClock> clock_;
};
@@ -128,6 +125,17 @@ TEST_F(AboutHandlerTest, EndOfLifeMessageInAboutDetailsSubpage) {
EXPECT_EQ("", CallGetEndOfLifeInfoAndReturnString(false /*=has_eol_passed*/));
}
+TEST_F(AboutHandlerTest, DeferredUpdateMessageInAboutPage) {
+ update_engine::StatusResult status;
+ status.set_current_operation(update_engine::Operation::UPDATED_BUT_DEFERRED);
+ fake_update_engine_client_->set_default_status(status);
+ fake_update_engine_client_->NotifyObserversThatStatusChanged(status);
+
+ EXPECT_EQ(0, fake_update_engine_client_->apply_deferred_update_count());
+ web_ui_.HandleReceivedMessage("applyDeferredUpdate", base::Value::List());
+ EXPECT_EQ(1, fake_update_engine_client_->apply_deferred_update_count());
+}
+
} // namespace
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.cc b/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.cc
index ad7f2c8f9d7..56057b0c0f6 100644
--- a/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.cc
@@ -9,8 +9,6 @@
#include "ash/components/arc/session/arc_bridge_service.h"
#include "ash/components/arc/session/arc_service_manager.h"
#include "ash/components/arc/storage_manager/arc_storage_manager.h"
-#include "ash/components/cryptohome/cryptohome_util.h"
-#include "ash/components/cryptohome/userdataauth_util.h"
#include "base/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/system/sys_info.h"
@@ -20,8 +18,10 @@
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/browsing_data/browsing_data_file_system_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chromeos/ash/components/cryptohome/cryptohome_util.h"
+#include "chromeos/ash/components/cryptohome/userdataauth_util.h"
#include "chromeos/ash/components/dbus/spaced/spaced_client.h"
-#include "chromeos/dbus/userdataauth/userdataauth_client.h"
+#include "chromeos/ash/components/dbus/userdataauth/userdataauth_client.h"
#include "components/browsing_data/content/cache_storage_helper.h"
#include "components/browsing_data/content/conditional_cache_counting_helper.h"
#include "components/browsing_data/content/cookie_helper.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.h b/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.h
index 7c148217ae3..f7afa7f6d85 100644
--- a/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.h
+++ b/chromium/chrome/browser/ui/webui/settings/ash/calculator/size_calculator.h
@@ -18,8 +18,8 @@
#include "base/observer_list_types.h"
#include "chrome/browser/ash/crostini/crostini_manager.h"
#include "chrome/browser/browsing_data/site_data_size_collector.h"
-#include "chromeos/dbus/cryptohome/UserDataAuth.pb.h"
-#include "chromeos/dbus/cryptohome/rpc.pb.h"
+#include "chromeos/ash/components/dbus/cryptohome/UserDataAuth.pb.h"
+#include "chromeos/ash/components/dbus/cryptohome/rpc.pb.h"
#include "components/user_manager/user.h"
class Profile;
diff --git a/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.cc b/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.cc
index debd20b5c2c..56a48854296 100644
--- a/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/ash/os_apps_page/mojom/app_type_mojom_traits.h"
#include "components/services/app_service/public/cpp/app_types.h"
+#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/cpp/permission.h"
#include "components/services/app_service/public/cpp/types_util.h"
@@ -102,8 +103,12 @@ void AppNotificationHandler::SetQuietMode(bool in_quiet_mode) {
void AppNotificationHandler::SetNotificationPermission(
const std::string& app_id,
apps::PermissionPtr permission) {
- app_service_proxy_->SetPermission(
- app_id, apps::ConvertPermissionToMojomPermission(permission));
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ app_service_proxy_->SetPermission(app_id, std::move(permission));
+ } else {
+ app_service_proxy_->SetPermission(
+ app_id, apps::ConvertPermissionToMojomPermission(permission));
+ }
}
void AppNotificationHandler::GetApps(GetAppsCallback callback) {
diff --git a/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler_unittest.cc
index 08d155b2872..821378cb163 100644
--- a/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler_unittest.cc
@@ -16,10 +16,10 @@
#include "chrome/test/base/testing_profile.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
#include "components/services/app_service/public/cpp/app_types.h"
-#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/cpp/permission.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/abseil-cpp/absl/types/variant.h"
namespace chromeos {
namespace settings {
@@ -146,17 +146,8 @@ class AppNotificationHandlerTest : public testing::Test {
void UpdateAppRegistryCache(std::vector<apps::AppPtr>& fake_apps,
apps::AppType app_type) {
- if (base::FeatureList::IsEnabled(
- apps::kAppServiceOnAppUpdateWithoutMojom)) {
- app_service_proxy_->AppRegistryCache().OnApps(std::move(fake_apps),
- app_type, false);
- } else {
- std::vector<apps::mojom::AppPtr> mojom_apps;
- mojom_apps.push_back(apps::ConvertAppToMojomApp(fake_apps[0]));
- app_service_proxy_->AppRegistryCache().OnApps(
- std::move(mojom_apps), apps::mojom::AppType::kUnknown,
- /*should_notify_initialized=*/false);
- }
+ app_service_proxy_->AppRegistryCache().OnApps(std::move(fake_apps),
+ app_type, false);
}
bool CheckIfFakeAppInList(std::string fake_id) {
@@ -214,9 +205,9 @@ TEST_F(AppNotificationHandlerTest, TestAppListUpdated) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(observer()->app_list_changed(), 1);
EXPECT_EQ("arcAppWithNotifications", observer()->recently_updated_app()->id);
- EXPECT_TRUE(observer()
- ->recently_updated_app()
- ->notification_permission->value->bool_value.value());
+ EXPECT_TRUE(absl::get<bool>(observer()
+ ->recently_updated_app()
+ ->notification_permission->value->value));
CreateAndStoreFakeApp("webAppWithNotifications", apps::AppType::kWeb,
apps::PermissionType::kNotifications,
@@ -225,9 +216,10 @@ TEST_F(AppNotificationHandlerTest, TestAppListUpdated) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(observer()->app_list_changed(), 2);
EXPECT_EQ("webAppWithNotifications", observer()->recently_updated_app()->id);
- EXPECT_TRUE(observer()
- ->recently_updated_app()
- ->notification_permission->value->bool_value.value());
+ EXPECT_TRUE(absl::holds_alternative<bool>(
+ observer()
+ ->recently_updated_app()
+ ->notification_permission->value->value));
CreateAndStoreFakeApp("arcAppWithCamera", apps::AppType::kArc,
apps::PermissionType::kCamera);
@@ -254,9 +246,9 @@ TEST_F(AppNotificationHandlerTest, TestAppListUpdated) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(observer()->app_list_changed(), 3);
EXPECT_EQ("arcAppWithNotifications", observer()->recently_updated_app()->id);
- EXPECT_FALSE(observer()
- ->recently_updated_app()
- ->notification_permission->value->bool_value.value());
+ EXPECT_FALSE(absl::get<bool>(observer()
+ ->recently_updated_app()
+ ->notification_permission->value->value));
CreateAndStoreFakeApp("webAppWithNotifications", apps::AppType::kWeb,
apps::PermissionType::kNotifications,
@@ -265,9 +257,9 @@ TEST_F(AppNotificationHandlerTest, TestAppListUpdated) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(observer()->app_list_changed(), 4);
EXPECT_EQ("webAppWithNotifications", observer()->recently_updated_app()->id);
- EXPECT_FALSE(observer()
- ->recently_updated_app()
- ->notification_permission->value->bool_value.value());
+ EXPECT_FALSE(absl::get<bool>(observer()
+ ->recently_updated_app()
+ ->notification_permission->value->value));
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn b/chromium/chrome/browser/ui/webui/settings/ash/search/BUILD.gn
index 00650950dfd..47af717da78 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/BUILD.gn
@@ -15,7 +15,9 @@ mojom("mojo_bindings") {
]
public_deps = [
- "../constants:mojom",
+ "//chrome/browser/ui/webui/settings/chromeos/constants:mojom",
"//mojo/public/mojom/base",
]
+
+ webui_module_path = "/search"
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS b/chromium/chrome/browser/ui/webui/settings/ash/search/OWNERS
index 2acde077ff6..2acde077ff6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.cc
index 7f568b21376..6d0272a3a4c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h"
#include "base/metrics/histogram_functions.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h
index da5c370691a..932a617c988 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
#include "base/time/time.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@@ -64,4 +64,4 @@ class PerSessionSettingsUserActionTracker {
} // namespace settings
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker_unittest.cc
index 74f716ec095..96640f1bf52 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search.mojom b/chromium/chrome/browser/ui/webui/settings/ash/search/search.mojom
index 7de9a4cd08c..754d27bc774 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search.mojom
@@ -6,7 +6,7 @@ module chromeos.settings.mojom;
import "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom";
import "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom";
-import "chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom";
+import "chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom";
import "mojo/public/mojom/base/string16.mojom";
// Describes the type of settings result.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_concept.h b/chromium/chrome/browser/ui/webui/settings/ash/search/search_concept.h
index 7fbeb7ddb34..a97fa571d25 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_concept.h
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_concept.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_CONCEPT_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_CONCEPT_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_CONCEPT_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_CONCEPT_H_
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom.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"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom.h"
namespace chromeos {
namespace settings {
@@ -68,4 +68,4 @@ struct SearchConcept {
} // namespace settings
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_CONCEPT_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_CONCEPT_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.cc
index efea097a553..889a4163182 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.cc
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_handler.h"
#include <algorithm>
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_concept.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/hierarchy.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_concept.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.h
index 4bfda7987a4..fd7722d7c7f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler.h
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_HANDLER_H_
#include <vector>
#include "base/gtest_prod_util.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
-#include "chromeos/components/local_search_service/public/mojom/index.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/mojom/index.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
@@ -119,4 +119,4 @@ class SearchHandler : public mojom::SearchHandler,
} // namespace settings
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler_unittest.cc
index 3ece90c4553..39215dd772d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_handler_unittest.cc
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_handler.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom-test-utils.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_hierarchy.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_os_settings_sections.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search.mojom-test-utils.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom b/chromium/chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom
index 0afbaeb6305..c0d0c5b131a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom
@@ -10,18 +10,25 @@ enum SearchResultIcon {
kAndroid,
kAppsGrid,
kAssistant,
+ kAudio,
kAuthKey,
+ kAutoclick,
kAvatar,
kBluetooth,
kCellular,
kChrome,
+ kChromeVox,
kClock,
+ kContrast,
kDeveloperTags,
+ kDictation,
kDisplay,
+ kDockedMagnifier,
kDrive,
kEthernet,
kFingerprint,
kFolder,
+ kFullscreenMagnifier,
kGlobe,
kGooglePlay,
kHardDrive,
@@ -33,6 +40,7 @@ enum SearchResultIcon {
kMessages,
kMouse,
kNearbyShare,
+ kOnScreenKeyboard,
kPaintbrush,
kPenguin,
kPhone,
@@ -40,9 +48,11 @@ enum SearchResultIcon {
kPower,
kPrinter,
kReset,
+ kSelectToSpeak,
kShield,
kStartup,
kStylus,
+ kSwitchAccess,
kSync,
kWallpaper,
kWifi
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.cc
index cd6463871da..44c862dda15 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include <algorithm>
#include <sstream>
@@ -10,8 +10,8 @@
#include "base/feature_list.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_concept.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_concept.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h
index 7e968520624..4c8568e8cfd 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_TAG_REGISTRY_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_TAG_REGISTRY_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_TAG_REGISTRY_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_TAG_REGISTRY_H_
#include <unordered_map>
#include <utility>
@@ -13,8 +13,8 @@
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
-#include "chromeos/components/local_search_service/public/mojom/index.mojom.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/mojom/index.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
@@ -108,4 +108,4 @@ class SearchTagRegistry {
} // namespace settings
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SEARCH_TAG_REGISTRY_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_ASH_SEARCH_SEARCH_TAG_REGISTRY_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry_unittest.cc
index 5611dab7336..bb47722bedb 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/search_tag_registry_unittest.cc
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "base/no_destructor.h"
#include "base/test/task_environment.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_concept.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_concept.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/local_search_service/public/mojom/index.mojom.h"
+#include "chromeos/ash/components/local_search_service/public/mojom/index.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom b/chromium/chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom
index 1deccb1c9ec..1deccb1c9ec 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom
diff --git a/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.cc b/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.cc
new file mode 100644
index 00000000000..cea2906f395
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.cc
@@ -0,0 +1,81 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/autofill_assistant_handler.h"
+
+#include <string>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/containers/flat_map.h"
+#include "base/memory/weak_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/autofill_assistant/password_change/apc_client.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace settings {
+
+AutofillAssistantHandler::AutofillAssistantHandler(
+ const std::vector<int>& accepted_revoke_grd_ids) {
+ for (int id : accepted_revoke_grd_ids) {
+ string_to_revoke_grd_id_map_[l10n_util::GetStringUTF8(id)] = id;
+ }
+}
+
+AutofillAssistantHandler::~AutofillAssistantHandler() = default;
+
+void AutofillAssistantHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "PromptForAutofillAssistantConsent",
+ base::BindRepeating(&AutofillAssistantHandler::HandlePromptForConsent,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "RevokeAutofillAssistantConsent",
+ base::BindRepeating(&AutofillAssistantHandler::HandleRevokeConsent,
+ base::Unretained(this)));
+}
+
+void AutofillAssistantHandler::OnJavascriptAllowed() {}
+
+void AutofillAssistantHandler::OnJavascriptDisallowed() {
+ // Ensures that there are no attempts to resolve a callback after Javascript
+ // has been disabled.
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
+void AutofillAssistantHandler::HandlePromptForConsent(
+ const base::Value::List& args) {
+ CHECK(!args.empty());
+ AllowJavascript();
+ base::Value callback_id = args.front().Clone();
+ GetApcClient()->PromptForConsent(
+ base::BindOnce(&AutofillAssistantHandler::OnPromptResultReceived,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
+}
+
+void AutofillAssistantHandler::OnPromptResultReceived(
+ const base::Value& callback_id,
+ bool success) {
+ ResolveJavascriptCallback(callback_id, base::Value(success));
+}
+
+void AutofillAssistantHandler::HandleRevokeConsent(
+ const base::Value::List& args) {
+ std::vector<int> description_grd_ids;
+
+ for (const base::Value& element : args) {
+ CHECK(element.is_string());
+
+ auto grd_id = string_to_revoke_grd_id_map_.find(element.GetString());
+ CHECK(grd_id != string_to_revoke_grd_id_map_.end());
+ description_grd_ids.push_back(grd_id->second);
+ }
+ GetApcClient()->RevokeConsent(description_grd_ids);
+}
+
+ApcClient* AutofillAssistantHandler::GetApcClient() {
+ return ApcClient::GetOrCreateForWebContents(web_ui()->GetWebContents());
+}
+
+} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.h b/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.h
new file mode 100644
index 00000000000..58e9b01ac28
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/autofill_assistant_handler.h
@@ -0,0 +1,65 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_AUTOFILL_ASSISTANT_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_AUTOFILL_ASSISTANT_HANDLER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/containers/flat_map.h"
+#include "base/memory/weak_ptr.h"
+#include "base/values.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+
+class ApcClient;
+
+namespace settings {
+
+// A custom WebUI handler for the personalization section in settings. It
+// currently handles consent requests for Autofill Assistant.
+class AutofillAssistantHandler : public SettingsPageUIHandler {
+ public:
+ // Constructs a personalization handler. `accepted_revoke_grd_ids` are
+ // resource ids that are permitted to describe revoking consent.
+ explicit AutofillAssistantHandler(
+ const std::vector<int>& accepted_revoke_grd_ids);
+
+ AutofillAssistantHandler(const AutofillAssistantHandler&) = delete;
+ AutofillAssistantHandler& operator=(const AutofillAssistantHandler&) = delete;
+
+ ~AutofillAssistantHandler() override;
+
+ // SettingsPageUIHandler:
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // Shows the onboarding prompt for Autofill Assistant.
+ void HandlePromptForConsent(const base::Value::List& args);
+
+ // Resolves a Javascript callback (corresponding to the promise returned by
+ // `PromptForConsent()`) with a boolean parameter that indicates whether the
+ // prompt was accepted.
+ void OnPromptResultReceived(const base::Value& callback_id, bool success);
+
+ // Handles the request to revoke consent for Autofill Assistant. `args`
+ // is expected to be the set of strings contained in the UI element shown
+ // to the user.
+ void HandleRevokeConsent(const base::Value::List& args);
+
+ // Returns the `ApcClient` associated with this `WebContents`.
+ ApcClient* GetApcClient();
+
+ // A map of permitted strings from the consent revokation dialog to their
+ // resource ids.
+ base::flat_map<std::string, int> string_to_revoke_grd_id_map_;
+
+ base::WeakPtrFactory<AutofillAssistantHandler> weak_ptr_factory_{this};
+};
+
+} // namespace settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_AUTOFILL_ASSISTANT_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
index ed49c212332..ba3c326ea1f 100644
--- a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
@@ -93,7 +93,9 @@ void CaptionsHandler::OnSodaInstalled(speech::LanguageCode language_code) {
base::Value(speech::GetLanguageName(language_code)));
}
-void CaptionsHandler::OnSodaError(speech::LanguageCode language_code) {
+void CaptionsHandler::OnSodaInstallError(
+ speech::LanguageCode language_code,
+ speech::SodaInstaller::ErrorCode error_code) {
// If multi-language is disabled and the language code received is not for
// Live Caption (perhaps it is downloading because another feature, such as
// dictation on ChromeOS, has a different language selected), then return
diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.h b/chromium/chrome/browser/ui/webui/settings/captions_handler.h
index 421951dfe76..104de16f454 100644
--- a/chromium/chrome/browser/ui/webui/settings/captions_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.h
@@ -34,7 +34,8 @@ class CaptionsHandler : public SettingsPageUIHandler,
// SodaInstaller::Observer overrides:
void OnSodaInstalled(speech::LanguageCode language_code) override;
- void OnSodaError(speech::LanguageCode language_code) override;
+ void OnSodaInstallError(speech::LanguageCode language_code,
+ speech::SodaInstaller::ErrorCode error_code) override;
void OnSodaProgress(speech::LanguageCode language_code,
int progress) override;
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 3581c03fe67..ec9aa613fc1 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
@@ -61,14 +61,13 @@ base::Value::List GetStringSetAsListStorage(
return value;
}
-base::DictionaryValue GetScannerResultsAsDictionary(
+base::Value::Dict GetScannerResultsAsDictionary(
const safe_browsing::ChromeCleanerScannerResults& scanner_results,
Profile* profile) {
- base::DictionaryValue value;
- value.GetDict().Set("files",
- GetFilesAsListStorage(scanner_results.files_to_delete()));
- value.GetDict().Set("registryKeys", GetStringSetAsListStorage(
- scanner_results.registry_keys()));
+ base::Value::Dict value;
+ value.Set("files", GetFilesAsListStorage(scanner_results.files_to_delete()));
+ value.Set("registryKeys",
+ GetStringSetAsListStorage(scanner_results.registry_keys()));
return value;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/BUILD.gn b/chromium/chrome/browser/ui/webui/settings/chromeos/BUILD.gn
index c86ea049cc4..ac5590ae582 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/BUILD.gn
@@ -5,8 +5,9 @@
group("mojom_js") {
public_deps = [
"constants:mojom_js",
- "search:mojo_bindings_js",
"//chrome/browser/ui/webui/nearby_share/public/mojom:mojom_js",
+ "//chrome/browser/ui/webui/settings/ash/search:mojo_bindings_js",
+ "//chromeos/ash/components/audio/public/mojom/:mojom_js",
"//ui/webui/resources/cr_components/app_management:mojo_bindings_js",
]
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS b/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
index 14daad84991..409e07a06c5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+ash/components/peripheral_notification",
+ "+ash/quick_pair",
"+components/account_manager_core",
"+chrome/services/local_search_service",
"+device/udev_linux/fake_udev_loader.h", # For keyboard unit test.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
index 37ddeebcb7e..aac0619ae84 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
@@ -2,5 +2,5 @@ file://chrome/browser/resources/settings/chromeos/OWNERS
per-file languages_section*=file://chrome/browser/resources/settings/chromeos/os_languages_page/OWNERS
per-file multidevice_handler*=file://ash/components/multidevice/OWNERS
-per-file account_manager_*=file://ash/components/account_manager/OWNERS
+per-file account_manager_*=file://chromeos/ash/components/account_manager/OWNERS
per-file apps_section*=file://chrome/browser/ui/webui/app_management/OWNERS
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 63190340019..4ac25109131 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
@@ -21,8 +21,8 @@
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/webui/management/management_ui.h"
#include "chrome/browser/ui/webui/settings/about_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_name_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h"
@@ -37,7 +37,6 @@
#include "components/strings/grit/components_chromium_strings.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
-#include "components/version_info/version_info.h"
#include "components/version_ui/version_ui_constants.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
@@ -245,11 +244,13 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"aboutProductLogoAlt", IDS_SHORT_PRODUCT_LOGO_ALT_TEXT},
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
{"aboutReportAnIssue", IDS_SETTINGS_ABOUT_PAGE_REPORT_AN_ISSUE},
+ {"aboutSendFeedback", IDS_SETTINGS_ABOUT_PAGE_SEND_FEEDBACK},
#endif
{"aboutDiagnostics", IDS_SETTINGS_ABOUT_PAGE_DIAGNOSTICS},
{"aboutFirmwareUpdates", IDS_SETTINGS_ABOUT_PAGE_FIRMWARE_UPDATES},
{"aboutRelaunch", IDS_SETTINGS_ABOUT_PAGE_RELAUNCH},
{"aboutUpgradeCheckStarted", IDS_SETTINGS_ABOUT_UPGRADE_CHECK_STARTED},
+ {"aboutUpgradeNotUpToDate", IDS_SETTINGS_UPGRADE_NOT_UP_TO_DATE},
{"aboutUpgradeRelaunch", IDS_SETTINGS_UPGRADE_SUCCESSFUL_RELAUNCH},
{"aboutUpgradeUpdating", IDS_SETTINGS_UPGRADE_UPDATING},
{"aboutUpgradeUpdatingPercent", IDS_SETTINGS_UPGRADE_UPDATING_PERCENT},
@@ -259,6 +260,8 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"aboutEndOfLifeTitle", IDS_SETTINGS_ABOUT_PAGE_END_OF_LIFE_TITLE},
{"aboutDeviceName", IDS_SETTINGS_ABOUT_PAGE_DEVICE_NAME},
+ {"aboutRelaunchAndAutoUpdate",
+ IDS_SETTINGS_ABOUT_PAGE_RELAUNCH_AND_AUTO_UPDATE},
{"aboutRelaunchAndPowerwash",
IDS_SETTINGS_ABOUT_PAGE_RELAUNCH_AND_POWERWASH},
{"aboutRollbackInProgress", IDS_SETTINGS_UPGRADE_ROLLBACK_IN_PROGRESS},
@@ -271,6 +274,8 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_ABOUT_TPM_FIRMWARE_UPDATE_TITLE},
{"aboutTPMFirmwareUpdateDescription",
IDS_SETTINGS_ABOUT_TPM_FIRMWARE_UPDATE_DESCRIPTION},
+ {"aboutDeferredUpdate",
+ IDS_SETTINGS_ABOUT_PAGE_DEFERRED_UPDATE_DESCRIPTION},
// About page, channel switcher dialog.
{"aboutChangeChannel", IDS_SETTINGS_ABOUT_PAGE_CHANGE_CHANNEL},
@@ -407,18 +412,8 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddBoolean("showConsumerAutoUpdateToggle", show_cau_toggle);
}
- html_source->AddString(
- "aboutBrowserVersion",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_ABOUT_PAGE_BROWSER_VERSION,
- base::UTF8ToUTF16(version_info::GetVersionNumber()),
- l10n_util::GetStringUTF16(version_info::IsOfficialBuild()
- ? IDS_VERSION_UI_OFFICIAL
- : IDS_VERSION_UI_UNOFFICIAL),
- // 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("aboutBrowserVersion",
+ VersionUI::GetAnnotatedVersionStringForUi());
html_source->AddString(
"aboutProductCopyright",
base::i18n::MessageFormatter::FormatWithNumberedArgs(
@@ -463,6 +458,10 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
"isFirmwareUpdaterAppEnabled",
base::FeatureList::IsEnabled(chromeos::features::kFirmwareUpdaterApp));
+ html_source->AddBoolean(
+ "isOsFeedbackEnabled",
+ base::FeatureList::IsEnabled(chromeos::features::kOsFeedback));
+
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
html_source->AddString("aboutTermsURL", chrome::kChromeUITermsURL);
html_source->AddLocalizedString("aboutProductTos",
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
index c2baa56cec6..659783d0777 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
@@ -192,7 +192,9 @@ void AccessibilityHandler::OnSodaProgress(speech::LanguageCode language_code,
progress)));
}
-void AccessibilityHandler::OnSodaError(speech::LanguageCode language_code) {
+void AccessibilityHandler::OnSodaInstallError(
+ speech::LanguageCode language_code,
+ speech::SodaInstaller::ErrorCode error_code) {
if (language_code != speech::LanguageCode::kNone &&
language_code != GetDictationLocale()) {
return;
@@ -242,15 +244,15 @@ void AccessibilityHandler::MaybeAddDictationLocales() {
ui_languages.insert(language::SplitIntoMainAndTail(enabled_language).first);
}
- base::Value locales_list(base::Value::Type::LIST);
+ base::Value::List locales_list;
for (auto& locale : locales) {
- base::Value option(base::Value::Type::DICTIONARY);
- option.SetKey("value", base::Value(locale.first));
- option.SetKey("name",
- base::Value(l10n_util::GetDisplayNameForLocale(
- locale.first, application_locale, /*is_for_ui=*/true)));
- option.SetKey("worksOffline", base::Value(locale.second.works_offline));
- option.SetKey("installed", base::Value(locale.second.installed));
+ base::Value::Dict option;
+ option.Set("value", locale.first);
+ option.Set("name",
+ l10n_util::GetDisplayNameForLocale(
+ locale.first, application_locale, /*is_for_ui=*/true));
+ option.Set("worksOffline", locale.second.works_offline);
+ option.Set("installed", locale.second.installed);
// We can recommend languages that match the current application
// locale, IME languages or enabled preferred languages.
@@ -258,7 +260,7 @@ void AccessibilityHandler::MaybeAddDictationLocales() {
language::SplitIntoMainAndTail(locale.first);
bool is_recommended = base::Contains(ui_languages, lang_and_locale.first);
- option.SetKey("recommended", base::Value(is_recommended));
+ option.Set("recommended", is_recommended);
locales_list.Append(std::move(option));
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
index b64f767b00c..c21494b2415 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
@@ -53,7 +53,8 @@ class AccessibilityHandler : public ::settings::SettingsPageUIHandler,
void OnSodaInstalled(speech::LanguageCode language_code) override;
void OnSodaProgress(speech::LanguageCode language_code,
int progress) override;
- void OnSodaError(speech::LanguageCode language_code) override;
+ void OnSodaInstallError(speech::LanguageCode language_code,
+ speech::SodaInstaller::ErrorCode error_code) override;
void MaybeAddDictationLocales();
speech::LanguageCode GetDictationLocale();
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 6867e09ecb6..b1f5bc7a607 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
@@ -21,9 +21,9 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/captions_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/tts_handler.h"
#include "chrome/browser/ui/webui/settings/font_handler.h"
@@ -58,39 +58,57 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
{IDS_OS_SETTINGS_TAG_A11Y_ALWAYS_SHOW_OPTIONS_ALT1,
SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_STICKY_KEYS,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kStickyKeys}},
{IDS_OS_SETTINGS_TAG_A11Y_LARGE_CURSOR,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kCursorAndTouchpadSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kLargeCursor}},
+ {.setting = mojom::Setting::kLargeCursor},
+ {IDS_OS_SETTINGS_TAG_A11Y_LARGE_CURSOR_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_LARGE_CURSOR_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_LARGE_CURSOR_ALT3,
+ IDS_OS_SETTINGS_TAG_A11Y_LARGE_CURSOR_ALT4, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y,
mojom::kAccessibilitySectionPath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kHigh,
mojom::SearchResultType::kSection,
{.section = mojom::Section::kAccessibility},
- {IDS_OS_SETTINGS_TAG_A11Y_ALT1, SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11Y_ALT1, IDS_OS_SETTINGS_TAG_A11Y_ALT2,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_DOCKED_MAGNIFIER,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kDisplayAndMagnificationSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kDockedMagnifier,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kDockedMagnifier}},
+ {.setting = mojom::Setting::kDockedMagnifier},
+ {IDS_OS_SETTINGS_TAG_A11Y_DOCKED_MAGNIFIER_ALT1,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11y_CHROMEVOX,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kTextToSpeechPagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kChromeVox,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kChromeVox},
- {IDS_OS_SETTINGS_TAG_A11y_CHROMEVOX_ALT1, SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11y_CHROMEVOX_ALT1,
+ IDS_OS_SETTINGS_TAG_A11y_CHROMEVOX_ALT2, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_MONO_AUDIO,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kAudioAndCaptionsSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kLow,
mojom::SearchResultType::kSetting,
@@ -103,7 +121,9 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kTextToSpeech},
{IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_ALT1,
- SearchConcept::kAltTagEnd}},
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_ALT3,
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_ALT4}},
{IDS_OS_SETTINGS_TAG_A11Y_CAPTIONS,
mojom::kCaptionsSubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -111,11 +131,17 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kCaptions}},
{IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_CURSOR,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kCursorAndTouchpadSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kHighlightCursorWhileMoving}},
+ {.setting = mojom::Setting::kHighlightCursorWhileMoving},
+ {IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_CURSOR_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_CURSOR_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_CURSOR_ALT3,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_MANAGE,
mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -124,53 +150,80 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
{.subpage = mojom::Subpage::kManageAccessibility},
{IDS_OS_SETTINGS_TAG_A11Y_MANAGE_ALT1, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_ON_SCREEN_KEYBOARD,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kOnScreenKeyboard,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kOnScreenKeyboard}},
{IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_TEXT_CARET,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kHighlightTextCaret}},
+ {.setting = mojom::Setting::kHighlightTextCaret},
+ {IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_TEXT_CARET_ALT1,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_DICTATION,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kDictation,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kDictation},
- {IDS_OS_SETTINGS_TAG_A11Y_DICTATION_ALT1, SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11Y_DICTATION_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_DICTATION_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_DICTATION_ALT3,
+ IDS_OS_SETTINGS_TAG_A11Y_DICTATION_ALT4, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_HIGH_CONTRAST,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kDisplayAndMagnificationSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kContrast,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kHighContrastMode},
{IDS_OS_SETTINGS_TAG_A11Y_HIGH_CONTRAST_ALT1,
SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_KEYBOARD_FOCUS,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kHighlightKeyboardFocus}},
+ {.setting = mojom::Setting::kHighlightKeyboardFocus},
+ {IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_KEYBOARD_FOCUS_ALT1,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_STARTUP_SOUND,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kAudioAndCaptionsSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kStartupSound}},
+ {.setting = mojom::Setting::kStartupSound},
+ {IDS_OS_SETTINGS_TAG_A11Y_STARTUP_SOUND_ALT1,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_AUTOMATICALLY_CLICK,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kCursorAndTouchpadSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kAutoclick,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAutoClickWhenCursorStops}},
+ {.setting = mojom::Setting::kAutoClickWhenCursorStops},
+ {IDS_OS_SETTINGS_TAG_A11Y_AUTOMATICALLY_CLICK_ALT1,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_SELECT_TO_SPEAK,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kTextToSpeechPagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kSelectToSpeak,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kSelectToSpeak}},
@@ -185,7 +238,8 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kTextToSpeechRate}},
+ {.setting = mojom::Setting::kTextToSpeechRate},
+ {IDS_OS_SETTINGS_TAG_A11Y_SPEECH_RATE_ALT1, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_SPEECH_VOLUME,
mojom::kTextToSpeechSubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -193,23 +247,34 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kTextToSpeechVolume}},
{IDS_OS_SETTINGS_TAG_A11Y_FULLSCREEN_MAGNIFIER,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kDisplayAndMagnificationSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kFullscreenMagnifier,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kFullscreenMagnifier}},
+ {.setting = mojom::Setting::kFullscreenMagnifier},
+ {IDS_OS_SETTINGS_TAG_A11Y_FULLSCREEN_MAGNIFIER_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_FULLSCREEN_MAGNIFIER_ALT2,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_A11Y_ENABLE_SWITCH_ACCESS,
- mojom::kManageAccessibilitySubpagePath,
- mojom::SearchResultIcon::kA11y,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kKeyboardAndTextInputSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kSwitchAccess,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kEnableSwitchAccess}},
{IDS_OS_SETTINGS_TAG_A11Y_CURSOR_COLOR,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kCursorAndTouchpadSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kEnableCursorColor}},
+ {.setting = mojom::Setting::kEnableCursorColor},
+ {IDS_OS_SETTINGS_TAG_A11Y_CURSOR_COLOR_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_CURSOR_COLOR_ALT2, SearchConcept::kAltTagEnd}},
});
return *tags;
}
@@ -242,7 +307,9 @@ const std::vector<SearchConcept>&
GetA11yTabletNavigationButtonSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_A11Y_TABLET_NAVIGATION_BUTTONS,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kCursorAndTouchpadSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
@@ -306,7 +373,8 @@ const std::vector<SearchConcept>& GetA11yLiveCaptionSearchConcepts() {
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kLiveCaption}},
+ {.setting = mojom::Setting::kLiveCaption},
+ {IDS_OS_SETTINGS_TAG_A11Y_LIVE_CAPTION_ALT1, SearchConcept::kAltTagEnd}},
});
return *tags;
}
@@ -315,7 +383,9 @@ const std::vector<SearchConcept>&
GetA11yFullscreenMagnifierFocusFollowingSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_A11Y_FULLSCREEN_MAGNIFIER_FOCUS_FOLLOWING,
- mojom::kManageAccessibilitySubpagePath,
+ ::features::IsAccessibilityOSSettingsVisibilityEnabled()
+ ? mojom::kDisplayAndMagnificationSubpagePath
+ : mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
@@ -324,6 +394,56 @@ GetA11yFullscreenMagnifierFocusFollowingSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetA11yVisibilitySearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_PAGE,
+ mojom::kTextToSpeechPagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kTextToSpeechPage},
+ {IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_PAGE_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_PAGE_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_PAGE_ALT3,
+ IDS_OS_SETTINGS_TAG_A11Y_TEXT_TO_SPEECH_PAGE_ALT4,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11Y_DISPLAY_AND_MAGNIFICATION_PAGE,
+ mojom::kDisplayAndMagnificationSubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kDisplayAndMagnification},
+ {IDS_OS_SETTINGS_TAG_A11Y_DISPLAY_AND_MAGNIFICATION_PAGE_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11Y_KEYBOARD_AND_TEXT_INPUT_PAGE,
+ mojom::kKeyboardAndTextInputSubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kKeyboardAndTextInput}},
+ {IDS_OS_SETTINGS_TAG_A11Y_CURSOR_AND_TOUCHPAD_PAGE,
+ mojom::kCursorAndTouchpadSubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kCursorAndTouchpad},
+ {IDS_OS_SETTINGS_TAG_A11Y_CURSOR_AND_TOUCHPAD_PAGE_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_CURSOR_AND_TOUCHPAD_PAGE_ALT2,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_A11Y_AUDIO_AND_CAPTIONS_PAGE,
+ mojom::kAudioAndCaptionsSubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kAudioAndCaptions},
+ {IDS_OS_SETTINGS_TAG_A11Y_AUDIO_AND_CAPTIONS_PAGE_ALT1,
+ IDS_OS_SETTINGS_TAG_A11Y_AUDIO_AND_CAPTIONS_PAGE_ALT2,
+ IDS_OS_SETTINGS_TAG_A11Y_AUDIO_AND_CAPTIONS_PAGE_ALT3,
+ SearchConcept::kAltTagEnd}},
+ });
+ return *tags;
+}
+
bool IsLiveCaptionEnabled() {
return captions::IsLiveCaptionFeatureSupported();
}
@@ -332,6 +452,10 @@ bool IsMagnifierContinuousMouseFollowingModeSettingEnabled() {
return ::features::IsMagnifierContinuousMouseFollowingModeSettingEnabled();
}
+bool IsAccessibilityOSSettingsVisibilityEnabled() {
+ return ::features::IsAccessibilityOSSettingsVisibilityEnabled();
+}
+
bool IsSwitchAccessTextAllowed() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kEnableExperimentalAccessibilitySwitchAccessText);
@@ -406,7 +530,28 @@ void AccessibilitySection::AddLoadTimeData(
IDS_SETTINGS_SLIDER_MIN_MAX_ARIA_ROLE_DESCRIPTION},
{"manageAccessibilityFeatures",
IDS_SETTINGS_ACCESSIBILITY_MANAGE_ACCESSIBILITY_FEATURES},
+ {"textToSpeechLinkTitle",
+ IDS_SETTINGS_ACCESSIBILITY_TEXT_TO_SPEECH_LINK_TITLE},
+ {"textToSpeechLinkDescription",
+ IDS_SETTINGS_ACCESSIBILITY_TEXT_TO_SPEECH_LINK_DESCRIPTION},
+ {"displayAndMagnificationLinkTitle",
+ IDS_SETTINGS_ACCESSIBILITY_DISPLAY_AND_MAGNIFICATION_LINK_TITLE},
+ {"displayAndMagnificationLinkDescription",
+ IDS_SETTINGS_ACCESSIBILITY_DISPLAY_AND_MAGNIFICATION_LINK_DESCRIPTION},
+ {"keyboardAndTextInputLinkTitle",
+ IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_AND_TEXT_INPUT_LINK_TITLE},
+ {"keyboardAndTextInputLinkDescription",
+ IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_AND_TEXT_INPUT_LINK_DESCRIPTION},
+ {"cursorAndTouchpadLinkTitle",
+ IDS_SETTINGS_ACCESSIBILITY_CURSOR_AND_TOUCHPAD_LINK_TITLE},
+ {"cursorAndTouchpadLinkDescription",
+ IDS_SETTINGS_ACCESSIBILITY_CURSOR_AND_TOUCHPAD_LINK_DESCRIPTION},
+ {"audioAndCaptionsLinkTitle",
+ IDS_SETTINGS_ACCESSIBILITY_AUDIO_AND_CAPTIONS_LINK_TITLE},
+ {"audioAndCaptionsLinkDescription",
+ IDS_SETTINGS_ACCESSIBILITY_AUDIO_AND_CAPTIONS_LINK_DESCRIPTION},
{"optionsInMenuLabel", IDS_SETTINGS_OPTIONS_IN_MENU_LABEL},
+ {"optionsInMenuDescription", IDS_SETTINGS_OPTIONS_IN_MENU_DESCRIPTION},
{"largeMouseCursorLabel", IDS_SETTINGS_LARGE_MOUSE_CURSOR_LABEL},
{"largeMouseCursorSizeLabel", IDS_SETTINGS_LARGE_MOUSE_CURSOR_SIZE_LABEL},
{"largeMouseCursorSizeDefaultLabel",
@@ -423,12 +568,19 @@ void AccessibilitySection::AddLoadTimeData(
{"cursorColorMagenta", IDS_SETTINGS_CURSOR_COLOR_MAGENTA},
{"cursorColorPink", IDS_SETTINGS_CURSOR_COLOR_PINK},
{"highContrastLabel", IDS_SETTINGS_HIGH_CONTRAST_LABEL},
+ {"highContrastDescription", IDS_SETTINGS_HIGH_CONTRAST_DESCRIPTION},
{"stickyKeysLabel", IDS_SETTINGS_STICKY_KEYS_LABEL},
+ {"stickyKeysDescription", IDS_SETTINGS_STICKY_KEYS_DESCRIPTION},
{"chromeVoxLabel", IDS_SETTINGS_CHROMEVOX_LABEL},
+ {"chromeVoxDescriptionOff", IDS_SETTINGS_CHROMEVOX_DESCRIPTION_OFF},
+ {"chromeVoxDescriptionOn", IDS_SETTINGS_CHROMEVOX_DESCRIPTION_ON},
{"chromeVoxOptionsLabel", IDS_SETTINGS_CHROMEVOX_OPTIONS_LABEL},
{"chromeVoxTutorialLabel", IDS_SETTINGS_CHROMEVOX_TUTORIAL_LABEL},
{"screenMagnifierLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_LABEL},
- {"screenMagnifierHintLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_HINT_LABEL},
+ {"screenMagnifierDescriptionOff",
+ IDS_SETTINGS_SCREEN_MAGNIFIER_DESCRIPTION_OFF},
+ {"screenMagnifierDescriptionOn",
+ IDS_SETTINGS_SCREEN_MAGNIFIER_DESCRIPTION_ON},
{"screenMagnifierMouseFollowingModeContinuous",
IDS_SETTINGS_SCREEN_MANIFIER_MOUSE_FOLLOWING_MODE_CONTINUOUS},
{"screenMagnifierMouseFollowingModeCentered",
@@ -441,6 +593,7 @@ void AccessibilitySection::AddLoadTimeData(
{"screenMagnifierZoomHintLabel",
IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_HINT_LABEL},
{"dockedMagnifierLabel", IDS_SETTINGS_DOCKED_MAGNIFIER_LABEL},
+ {"dockedMagnifierDescription", IDS_SETTINGS_DOCKED_MAGNIFIER_DESCRIPTION},
{"dockedMagnifierZoomLabel", IDS_SETTINGS_DOCKED_MAGNIFIER_ZOOM_LABEL},
{"screenMagnifierZoom2x", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_2_X},
{"screenMagnifierZoom4x", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_4_X},
@@ -454,6 +607,7 @@ void AccessibilitySection::AddLoadTimeData(
{"screenMagnifierZoom20x", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_20_X},
{"tapDraggingLabel", IDS_SETTINGS_TAP_DRAGGING_LABEL},
{"clickOnStopLabel", IDS_SETTINGS_CLICK_ON_STOP_LABEL},
+ {"clickOnStopDescription", IDS_SETTINGS_CLICK_ON_STOP_DESCRIPTION},
{"delayBeforeClickLabel", IDS_SETTINGS_DELAY_BEFORE_CLICK_LABEL},
{"delayBeforeClickExtremelyShort",
IDS_SETTINGS_DELAY_BEFORE_CLICK_EXTREMELY_SHORT},
@@ -478,6 +632,8 @@ void AccessibilitySection::AddLoadTimeData(
{"autoclickMovementThresholdExtraLarge",
IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_EXTRA_LARGE},
{"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL},
+ {"dictationDescription",
+ IDS_SETTINGS_ACCESSIBILITY_DICTATION_NEW_DESCRIPTION},
{"dictationLocaleMenuLabel",
IDS_SETTINGS_ACCESSIBILITY_DICTATION_LOCALE_MENU_LABEL},
{"dictationLocaleSubLabelOffline",
@@ -515,15 +671,26 @@ void AccessibilitySection::AddLoadTimeData(
{"dictationChangeLanguageDialogNotSelectedDescription",
IDS_SETTINGS_ACCESSIBILITY_DICTATION_LANGUAGE_DIALOG_NOT_SELECTED_DESCRIPTION},
{"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL},
+ {"onScreenKeyboardDescription",
+ IDS_SETTINGS_ON_SCREEN_KEYBOARD_DESCRIPTION},
{"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL},
+ {"monoAudioDescription", IDS_SETTINGS_MONO_AUDIO_DESCRIPTION},
{"startupSoundLabel", IDS_SETTINGS_STARTUP_SOUND_LABEL},
{"a11yExplanation", IDS_SETTINGS_ACCESSIBILITY_EXPLANATION},
{"caretHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_CARET_HIGHLIGHT_DESCRIPTION},
+ {"caretHighlightLabelSubtext",
+ IDS_SETTINGS_ACCESSIBILITY_CARET_HIGHLIGHT_DESCRIPTION_SUBTEXT},
+ {"caretBrowsingLabel",
+ IDS_SETTINGS_ACCESSIBILITY_CARET_BROWSING_DESCRIPTION},
+ {"caretBrowsingLabelSubtext",
+ IDS_SETTINGS_ACCESSIBILITY_CARET_BROWSING_DESCRIPTION_SUBTEXT},
{"cursorHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_CURSOR_HIGHLIGHT_DESCRIPTION},
{"focusHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_FOCUS_HIGHLIGHT_DESCRIPTION},
+ {"focusHighlightLabelSubtext",
+ IDS_SETTINGS_ACCESSIBILITY_FOCUS_HIGHLIGHT_DESCRIPTION_SUBTEXT},
{"selectToSpeakTitle", IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_TITLE},
{"selectToSpeakDisabledDescription",
IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_DISABLED_DESCRIPTION},
@@ -535,6 +702,8 @@ void AccessibilitySection::AddLoadTimeData(
IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_OPTIONS_LABEL},
{"switchAccessLabel",
IDS_SETTINGS_ACCESSIBILITY_SWITCH_ACCESS_DESCRIPTION},
+ {"switchAccessLabelSubtext",
+ IDS_SETTINGS_ACCESSIBILITY_SWITCH_ACCESS_DESCRIPTION_SUBTEXT},
{"switchAccessOptionsLabel",
IDS_SETTINGS_ACCESSIBILITY_SWITCH_ACCESS_OPTIONS_LABEL},
{"manageSwitchAccessSettings",
@@ -689,8 +858,6 @@ void AccessibilitySection::AddLoadTimeData(
{"mouseAndTouchpadHeading",
IDS_SETTINGS_ACCESSIBILITY_MOUSE_AND_TOUCHPAD_HEADING},
{"mouseSettingsTitle", IDS_SETTINGS_ACCESSIBILITY_MOUSE_SETTINGS_TITLE},
- {"mouseSettingsDescription",
- IDS_SETTINGS_ACCESSIBILITY_MOUSE_SETTINGS_DESCRIPTION},
{"audioAndCaptionsHeading",
IDS_SETTINGS_ACCESSIBILITY_AUDIO_AND_CAPTIONS_HEADING},
{"additionalFeaturesTitle",
@@ -737,15 +904,6 @@ 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->AddLocalizedString(
- "dictationDescription",
- IDS_SETTINGS_ACCESSIBILITY_DICTATION_NEW_DESCRIPTION);
-
html_source->AddString("a11yLearnMoreUrl",
chrome::kChromeAccessibilityHelpURL);
@@ -763,6 +921,9 @@ void AccessibilitySection::AddLoadTimeData(
"isMagnifierContinuousMouseFollowingModeSettingEnabled",
IsMagnifierContinuousMouseFollowingModeSettingEnabled());
+ html_source->AddBoolean("isAccessibilityOSSettingsVisibilityEnabled",
+ IsAccessibilityOSSettingsVisibilityEnabled());
+
::settings::AddCaptionSubpageStrings(html_source);
}
@@ -828,6 +989,39 @@ void AccessibilitySection::RegisterHierarchy(
mojom::Subpage::kManageAccessibility, mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::kManageAccessibilitySubpagePath);
+
+ if (IsAccessibilityOSSettingsVisibilityEnabled()) {
+ // Text-to-Speech page.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_ACCESSIBILITY_TEXT_TO_SPEECH_LINK_TITLE,
+ mojom::Subpage::kTextToSpeechPage, mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium, mojom::kTextToSpeechPagePath);
+ // Display and magnification page.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_ACCESSIBILITY_DISPLAY_AND_MAGNIFICATION_LINK_TITLE,
+ mojom::Subpage::kDisplayAndMagnification,
+ mojom::SearchResultIcon::kA11y, mojom::SearchResultDefaultRank::kMedium,
+ mojom::kDisplayAndMagnificationSubpagePath);
+ // Keyboard and text input page.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_AND_TEXT_INPUT_LINK_TITLE,
+ mojom::Subpage::kKeyboardAndTextInput, mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kKeyboardAndTextInputSubpagePath);
+ // Cursor and touchpad page.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_ACCESSIBILITY_CURSOR_AND_TOUCHPAD_LINK_TITLE,
+ mojom::Subpage::kCursorAndTouchpad, mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kCursorAndTouchpadSubpagePath);
+ // Audio and captions page.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_ACCESSIBILITY_AUDIO_AND_CAPTIONS_LINK_TITLE,
+ mojom::Subpage::kAudioAndCaptions, mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kAudioAndCaptionsSubpagePath);
+ }
+
static constexpr mojom::Setting kManageAccessibilitySettings[] = {
mojom::Setting::kChromeVox,
mojom::Setting::kSelectToSpeak,
@@ -963,6 +1157,10 @@ void AccessibilitySection::UpdateSearchTags() {
GetA11yFullscreenMagnifierFocusFollowingSearchConcepts());
}
+ if (IsAccessibilityOSSettingsVisibilityEnabled()) {
+ updater.AddSearchTags(GetA11yVisibilitySearchConcepts());
+ }
+
if (!pref_service_->GetBoolean(
ash::prefs::kAccessibilitySwitchAccessEnabled)) {
return;
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 403b1f65804..c5265f66c5e 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
@@ -6,8 +6,7 @@
#include <utility>
-#include "ash/components/account_manager/account_manager_factory.h"
-#include "ash/public/cpp/system/toast_catalog.h"
+#include "ash/constants/notifier_catalogs.h"
#include "ash/public/cpp/system/toast_data.h"
#include "ash/public/cpp/system/toast_manager.h"
#include "base/bind.h"
@@ -24,6 +23,7 @@
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/account_manager_facade.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
#include "components/signin/public/base/consent_level.h"
@@ -48,15 +48,15 @@ constexpr char kAccountRemovedToastId[] =
"settings_account_manager_account_removed";
::account_manager::AccountKey GetAccountKeyFromJsCallback(
- const base::Value& dictionary) {
- const base::Value* id_value = dictionary.FindKey("id");
- DCHECK(id_value);
- const std::string id = id_value->GetString();
- DCHECK(!id.empty());
+ const base::Value::Dict& dictionary) {
+ const std::string* id = dictionary.FindString("id");
+ DCHECK(id);
+ DCHECK(!id->empty());
- const base::Value* account_type_value = dictionary.FindKey("accountType");
+ const absl::optional<int> account_type_value =
+ dictionary.FindInt("accountType");
DCHECK(account_type_value);
- const int account_type_int = account_type_value->GetInt();
+ const int account_type_int = *account_type_value;
DCHECK((account_type_int >=
static_cast<int>(account_manager::AccountType::kGaia)) &&
(account_type_int <=
@@ -64,13 +64,13 @@ constexpr char kAccountRemovedToastId[] =
const account_manager::AccountType account_type =
static_cast<account_manager::AccountType>(account_type_int);
- return ::account_manager::AccountKey{id, account_type};
+ return ::account_manager::AccountKey{*id, account_type};
}
::account_manager::Account GetAccountFromJsCallback(
- const base::Value& dictionary) {
+ const base::Value::Dict& dictionary) {
::account_manager::AccountKey key = GetAccountKeyFromJsCallback(dictionary);
- const std::string* email = dictionary.FindStringKey("email");
+ const std::string* email = dictionary.FindString("email");
DCHECK(email);
return ::account_manager::Account{key, *email};
}
@@ -102,80 +102,80 @@ class AccountBuilder {
~AccountBuilder() = default;
- void PopulateFrom(base::DictionaryValue account) {
+ void PopulateFrom(base::Value::Dict account) {
account_ = std::move(account);
}
- bool IsEmpty() const { return account_.DictEmpty(); }
+ bool IsEmpty() const { return account_.empty(); }
AccountBuilder& SetId(const std::string& value) {
- account_.SetStringKey("id", value);
+ account_.Set("id", value);
return *this;
}
AccountBuilder& SetEmail(const std::string& value) {
- account_.SetStringKey("email", value);
+ account_.Set("email", value);
return *this;
}
AccountBuilder& SetFullName(const std::string& value) {
- account_.SetStringKey("fullName", value);
+ account_.Set("fullName", value);
return *this;
}
AccountBuilder& SetAccountType(const int& value) {
- account_.SetIntKey("accountType", value);
+ account_.Set("accountType", value);
return *this;
}
AccountBuilder& SetIsDeviceAccount(const bool& value) {
- account_.SetBoolKey("isDeviceAccount", value);
+ account_.Set("isDeviceAccount", value);
return *this;
}
AccountBuilder& SetIsSignedIn(const bool& value) {
- account_.SetBoolKey("isSignedIn", value);
+ account_.Set("isSignedIn", value);
return *this;
}
AccountBuilder& SetUnmigrated(const bool& value) {
- account_.SetBoolKey("unmigrated", value);
+ account_.Set("unmigrated", value);
return *this;
}
AccountBuilder& SetIsManaged(const bool& value) {
- account_.SetBoolKey("isManaged", value);
+ account_.Set("isManaged", value);
return *this;
}
AccountBuilder& SetPic(const std::string& value) {
- account_.SetStringKey("pic", value);
+ account_.Set("pic", value);
return *this;
}
AccountBuilder& SetOrganization(const std::string& value) {
- account_.SetStringKey("organization", value);
+ account_.Set("organization", value);
return *this;
}
AccountBuilder& SetIsAvailableInArc(bool value) {
- account_.SetBoolKey("isAvailableInArc", value);
+ account_.Set("isAvailableInArc", value);
return *this;
}
// Should be called only once.
- base::DictionaryValue Build() {
+ base::Value::Dict Build() {
// Check that values were set.
- DCHECK(account_.FindStringKey("id"));
- DCHECK(account_.FindStringKey("email"));
- DCHECK(account_.FindStringKey("fullName"));
- DCHECK(account_.FindIntKey("accountType"));
- DCHECK(account_.FindBoolKey("isDeviceAccount"));
- DCHECK(account_.FindBoolKey("isSignedIn"));
- DCHECK(account_.FindBoolKey("unmigrated"));
- DCHECK(account_.FindStringKey("pic"));
+ DCHECK(account_.FindString("id"));
+ DCHECK(account_.FindString("email"));
+ DCHECK(account_.FindString("fullName"));
+ DCHECK(account_.FindInt("accountType"));
+ DCHECK(account_.FindBool("isDeviceAccount"));
+ DCHECK(account_.FindBool("isSignedIn"));
+ DCHECK(account_.FindBool("unmigrated"));
+ DCHECK(account_.FindString("pic"));
if (ash::AccountAppsAvailability::IsArcAccountRestrictionsEnabled()) {
- DCHECK(account_.FindBoolKey("isAvailableInArc"));
+ DCHECK(account_.FindBool("isAvailableInArc"));
}
// "organization" is an optional field.
@@ -183,7 +183,7 @@ class AccountBuilder {
}
private:
- base::DictionaryValue account_;
+ base::Value::Dict account_;
};
} // namespace
@@ -278,8 +278,8 @@ void AccountManagerUIHandler::FinishHandleGetAccounts(
user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile_);
DCHECK(user);
- base::DictionaryValue gaia_device_account;
- base::ListValue accounts = GetSecondaryGaiaAccounts(
+ base::Value::Dict gaia_device_account;
+ base::Value::List accounts = GetSecondaryGaiaAccounts(
account_dummy_token_list, arc_accounts, user->GetAccountId(),
profile_->IsChild(), &gaia_device_account);
@@ -328,21 +328,20 @@ void AccountManagerUIHandler::FinishHandleGetAccounts(
}
// Device account must show up at the top.
- accounts.Insert(accounts.GetListDeprecated().begin(),
- device_account.Build());
+ accounts.Insert(accounts.begin(), base::Value(device_account.Build()));
}
ResolveJavascriptCallback(callback_id, accounts);
}
-base::ListValue AccountManagerUIHandler::GetSecondaryGaiaAccounts(
+base::Value::List AccountManagerUIHandler::GetSecondaryGaiaAccounts(
const std::vector<std::pair<::account_manager::Account, bool>>&
account_dummy_token_list,
const base::flat_set<account_manager::Account>& arc_accounts,
const AccountId device_account_id,
const bool is_child_user,
- base::DictionaryValue* device_account) {
- base::ListValue accounts;
+ base::Value::Dict* device_account) {
+ base::Value::List accounts;
for (const auto& account_token_pair : account_dummy_token_list) {
const ::account_manager::Account& stored_account = account_token_pair.first;
const ::account_manager::AccountKey& account_key = stored_account.key;
@@ -432,13 +431,13 @@ void AccountManagerUIHandler::HandleRemoveAccount(
AllowJavascript();
CHECK(!args.empty());
- const base::Value& dictionary = args[0];
- CHECK(dictionary.is_dict());
+ const base::Value::Dict* dictionary = args[0].GetIfDict();
+ CHECK(dictionary);
const AccountId device_account_id =
ProfileHelper::Get()->GetUserByProfile(profile_)->GetAccountId();
const ::account_manager::AccountKey account_key =
- GetAccountKeyFromJsCallback(dictionary);
+ GetAccountKeyFromJsCallback(*dictionary);
if (IsSameAccount(account_key, device_account_id)) {
// It should not be possible to remove a device account.
return;
@@ -447,14 +446,14 @@ void AccountManagerUIHandler::HandleRemoveAccount(
account_manager_->RemoveAccount(account_key);
// Show toast with removal message.
- const base::Value* email_value = dictionary.FindKey("email");
- const std::string email = email_value->GetString();
- DCHECK(!email.empty());
+ const std::string* email = dictionary->FindString("email");
+ DCHECK(email);
+ DCHECK(!email->empty());
ShowToast(kAccountRemovedToastId, ash::ToastCatalogName::kAccountRemoved,
l10n_util::GetStringFUTF16(
IDS_SETTINGS_ACCOUNT_MANAGER_ACCOUNT_REMOVED_MESSAGE,
- base::UTF8ToUTF16(email)));
+ base::UTF8ToUTF16(*email)));
}
void AccountManagerUIHandler::HandleChangeArcAvailability(
@@ -463,13 +462,13 @@ void AccountManagerUIHandler::HandleChangeArcAvailability(
// 2 args: account, is_available.
CHECK_GT(args.size(), 1u);
- const base::Value& account_dict = args[0];
- CHECK(account_dict.is_dict());
+ const base::Value::Dict* account_dict = args[0].GetIfDict();
+ CHECK(account_dict);
const absl::optional<bool> is_available = args[1].GetIfBool();
CHECK(is_available.has_value());
const ::account_manager::Account account =
- GetAccountFromJsCallback(account_dict);
+ GetAccountFromJsCallback(*account_dict);
account_apps_availability_->SetIsAccountAvailableInArc(account,
is_available.value());
// Note: the observer call will update the UI.
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 2ca8d2c6b50..331f90de8d8 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
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
+#include "base/values.h"
#include "chrome/browser/ash/account_manager/account_apps_availability.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/account_id/account_id.h"
@@ -109,13 +110,13 @@ class AccountManagerUIHandler
// If user (device account) is child - |is_child_user| should be set to true,
// in this case "unmigrated" property will be always false for secondary
// accounts.
- base::ListValue GetSecondaryGaiaAccounts(
+ base::Value::List GetSecondaryGaiaAccounts(
const std::vector<std::pair<::account_manager::Account, bool>>&
account_dummy_token_list,
const base::flat_set<account_manager::Account>& arc_accounts,
const AccountId device_account_id,
const bool is_child_user,
- base::DictionaryValue* device_account);
+ base::Value::Dict* device_account);
// Refreshes the UI.
void RefreshUI();
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 24c737f03e1..493211b7c75 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
@@ -7,7 +7,6 @@
#include <memory>
#include <ostream>
-#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/constants/ash_features.h"
#include "base/test/bind.h"
#include "chrome/browser/ash/account_manager/account_apps_availability.h"
@@ -20,6 +19,7 @@
#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 "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/account_manager_facade.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
@@ -293,10 +293,9 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
ASSERT_EQ(1UL, account_manager_accounts.size());
// Call "getAccounts".
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kHandleFunctionName);
- web_ui()->HandleReceivedMessage(kGetAccountsMessage,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetAccountsMessage, args);
const content::TestWebUI::CallData& call_data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
@@ -343,10 +342,9 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
base::RunLoop().RunUntilIdle();
// Call "getAccounts".
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kHandleFunctionName);
- web_ui()->HandleReceivedMessage(kGetAccountsMessage,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetAccountsMessage, args);
const content::TestWebUI::CallData& call_data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
@@ -427,10 +425,7 @@ class AccountManagerUIHandlerTestWithArcAccountRestrictions
: public AccountManagerUIHandlerTest {
public:
AccountManagerUIHandlerTestWithArcAccountRestrictions() {
- feature_list_.InitWithFeatures(
- /*enabled_features=*/{chromeos::features::kArcAccountRestrictions,
- chromeos::features::kLacrosSupport},
- /*disabled_features=*/{});
+ feature_list_.InitAndEnableFeature(chromeos::features::kLacrosSupport);
}
void SetUpOnMainThread() override {
@@ -527,10 +522,9 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTestWithArcAccountRestrictions,
false);
// Call "getAccounts".
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kHandleFunctionName);
- web_ui()->HandleReceivedMessage(kGetAccountsMessage,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetAccountsMessage, args);
// Wait for the async calls to finish.
base::RunLoop().RunUntilIdle();
@@ -603,10 +597,9 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTestWithArcAccountRestrictions,
}
// Call "getAccounts".
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kHandleFunctionName);
- web_ui()->HandleReceivedMessage(kGetAccountsMessage,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetAccountsMessage, args);
// Wait for the async calls to finish.
base::RunLoop().RunUntilIdle();
@@ -620,11 +613,10 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTestWithArcAccountRestrictions,
ASSERT_TRUE(secondary_1_dict.has_value());
// Call "changeArcAvailability".
- base::Value args_1(base::Value::Type::LIST);
+ base::Value::List args_1;
args_1.Append(secondary_1_dict.value().Clone()); // account
args_1.Append(false); // is_available
- web_ui()->HandleReceivedMessage("changeArcAvailability",
- &base::Value::AsListValue(args_1));
+ web_ui()->HandleReceivedMessage("changeArcAvailability", args_1);
// Wait for the async calls to finish.
base::RunLoop().RunUntilIdle();
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
deleted file mode 100644
index f60135b3364..00000000000
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc
+++ /dev/null
@@ -1,695 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h"
-
-#include <algorithm>
-#include <string>
-#include <utility>
-
-#include "ash/constants/ash_features.h"
-#include "ash/public/cpp/ambient/ambient_backend_controller.h"
-#include "ash/public/cpp/ambient/ambient_client.h"
-#include "ash/public/cpp/ambient/ambient_metrics.h"
-#include "ash/public/cpp/ambient/ambient_prefs.h"
-#include "ash/public/cpp/ambient/common/ambient_settings.h"
-#include "ash/public/cpp/image_downloader.h"
-#include "base/barrier_closure.h"
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted_memory.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/threading/sequenced_task_runner_handle.h"
-#include "base/values.h"
-#include "chrome/browser/ash/web_applications/personalization_app/personalization_app_manager.h"
-#include "chrome/browser/ash/web_applications/personalization_app/personalization_app_manager_factory.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/prefs/pref_service.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/web_contents.h"
-#include "net/http/http_request_headers.h"
-#include "net/traffic_annotation/network_traffic_annotation.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/webui/web_ui_util.h"
-#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/image/image_skia.h"
-#include "url/gurl.h"
-
-namespace chromeos {
-namespace settings {
-
-namespace {
-
-// Width and height of the preview image for personal album.
-constexpr int kBannerWidthPx = 160;
-constexpr int kBannerHeightPx = 160;
-
-// Strings for converting to and from AmbientModeTemperatureUnit enum.
-constexpr char kCelsius[] = "celsius";
-constexpr char kFahrenheit[] = "fahrenheit";
-
-constexpr int kMaxRetries = 3;
-
-constexpr net::BackoffEntry::Policy kRetryBackoffPolicy = {
- 0, // Number of initial errors to ignore.
- 500, // Initial delay in ms.
- 2.0, // Factor by which the waiting time will be multiplied.
- 0.2, // Fuzzing percentage.
- 60 * 1000, // Maximum delay in ms.
- -1, // Never discard the entry.
- true, // Use initial delay.
-};
-
-ash::AmbientModeTemperatureUnit ExtractTemperatureUnit(
- const base::Value::List& args) {
- auto temperature_unit = args[0].GetString();
- if (temperature_unit == kCelsius)
- return ash::AmbientModeTemperatureUnit::kCelsius;
- if (temperature_unit == kFahrenheit)
- return ash::AmbientModeTemperatureUnit::kFahrenheit;
-
- NOTREACHED() << "Unknown temperature unit";
- return ash::AmbientModeTemperatureUnit::kFahrenheit;
-}
-
-std::string TemperatureUnitToString(
- ash::AmbientModeTemperatureUnit temperature_unit) {
- switch (temperature_unit) {
- case ash::AmbientModeTemperatureUnit::kFahrenheit:
- return kFahrenheit;
- case ash::AmbientModeTemperatureUnit::kCelsius:
- return kCelsius;
- }
-}
-
-ash::AmbientModeTopicSource ExtractTopicSource(const base::Value& value) {
- ash::AmbientModeTopicSource topic_source =
- static_cast<ash::AmbientModeTopicSource>(value.GetInt());
- // Check the |topic_source| has valid value.
- CHECK_GE(topic_source, ash::AmbientModeTopicSource::kMinValue);
- CHECK_LE(topic_source, ash::AmbientModeTopicSource::kMaxValue);
- return topic_source;
-}
-
-ash::AmbientModeTopicSource ExtractTopicSource(const base::Value::List& args) {
- CHECK_EQ(args.size(), 1U);
- return ExtractTopicSource(args[0]);
-}
-
-void EncodeImage(const gfx::ImageSkia& image,
- std::vector<unsigned char>* output) {
- if (!gfx::PNGCodec::EncodeBGRASkBitmap(*image.bitmap(),
- /*discard_transparency=*/false,
- output)) {
- VLOG(1) << "Failed to encode image to png";
- output->clear();
- }
-}
-
-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);
- }
-
- if (album.number_of_photos <= 1) {
- return l10n_util::GetStringFUTF16Int(
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_PHOTOS_NUM_SINGULAR,
- album.number_of_photos);
- }
-
- return l10n_util::GetStringFUTF16Int(
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_PHOTOS_NUM_PLURAL,
- album.number_of_photos);
-}
-
-} // namespace
-
-AmbientModeHandler::AmbientModeHandler(PrefService* pref_service)
- : fetch_settings_retry_backoff_(&kRetryBackoffPolicy),
- update_settings_retry_backoff_(&kRetryBackoffPolicy),
- pref_service_(pref_service) {}
-
-AmbientModeHandler::~AmbientModeHandler() {
- if (IsJavascriptAllowed()) {
- ::ash::personalization_app::PersonalizationAppManagerFactory::
- GetForBrowserContext(web_ui()->GetWebContents()->GetBrowserContext())
- ->MaybeStartHatsTimer(
- ::ash::personalization_app::HatsSurveyType::kScreensaver);
- }
-}
-
-void AmbientModeHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "requestSettings",
- base::BindRepeating(&AmbientModeHandler::HandleRequestSettings,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "requestAlbums",
- base::BindRepeating(&AmbientModeHandler::HandleRequestAlbums,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "setSelectedTemperatureUnit",
- base::BindRepeating(&AmbientModeHandler::HandleSetSelectedTemperatureUnit,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "setSelectedAlbums",
- base::BindRepeating(&AmbientModeHandler::HandleSetSelectedAlbums,
- base::Unretained(this)));
-}
-
-void AmbientModeHandler::OnJavascriptAllowed() {
- pref_change_registrar_.Init(pref_service_);
- pref_change_registrar_.Add(
- ash::ambient::prefs::kAmbientModeEnabled,
- base::BindRepeating(&AmbientModeHandler::OnEnabledPrefChanged,
- base::Unretained(this)));
-}
-
-void AmbientModeHandler::OnJavascriptDisallowed() {
- backend_weak_factory_.InvalidateWeakPtrs();
- ui_update_weak_factory_.InvalidateWeakPtrs();
- pref_change_registrar_.RemoveAll();
-}
-
-bool AmbientModeHandler::IsAmbientModeEnabled() {
- return pref_service_->GetBoolean(ash::ambient::prefs::kAmbientModeEnabled);
-}
-
-void AmbientModeHandler::OnEnabledPrefChanged() {
- // Call |UpdateSettings| when Ambient mode is enabled to make sure that
- // settings are properly synced to the server even if the user never touches
- // the other controls.
- if (settings_ && IsAmbientModeEnabled())
- UpdateSettings();
-}
-
-void AmbientModeHandler::HandleRequestSettings(const base::Value::List& args) {
- CHECK(args.empty());
-
- AllowJavascript();
-
- // Settings subpages may have changed from ambientMode/photos to ambientMode
- // since the last time requesting the data. Abort any request in progress to
- // avoid unnecessary updating invisible subpage.
- ui_update_weak_factory_.InvalidateWeakPtrs();
- RequestSettingsAndAlbums(/*topic_source=*/absl::nullopt);
-}
-
-void AmbientModeHandler::HandleRequestAlbums(const base::Value::List& args) {
- CHECK_EQ(args.size(), 1U);
-
- AllowJavascript();
-
- // ambientMode/photos subpages may have changed, e.g. from displaying Google
- // Photos to Art gallery, since the last time requesting the data.
- // Abort any request in progress to avoid updating incorrect contents.
- ui_update_weak_factory_.InvalidateWeakPtrs();
- RequestSettingsAndAlbums(ExtractTopicSource(args));
-}
-
-void AmbientModeHandler::HandleSetSelectedTemperatureUnit(
- const base::Value::List& args) {
- DCHECK(settings_);
- CHECK_EQ(1U, args.size());
-
- auto temperature_unit = ExtractTemperatureUnit(args);
- if (settings_->temperature_unit != temperature_unit) {
- settings_->temperature_unit = temperature_unit;
- UpdateSettings();
- }
-}
-
-void AmbientModeHandler::HandleSetSelectedAlbums(
- const base::Value::List& args) {
- CHECK_EQ(args.size(), 1U);
- const base::Value& dictionary = args[0];
- const base::Value* topic_source_value = dictionary.FindKey("topicSource");
- CHECK(topic_source_value);
- ash::AmbientModeTopicSource topic_source =
- ExtractTopicSource(*topic_source_value);
- const base::Value* albums = dictionary.FindKey("albums");
- CHECK(albums);
- switch (topic_source) {
- case ash::AmbientModeTopicSource::kGooglePhotos:
- // For Google Photos, we will populate the |selected_album_ids| with IDs
- // of selected albums.
- settings_->selected_album_ids.clear();
- for (const auto& album : albums->GetListDeprecated()) {
- const base::Value* album_id = album.FindKey("albumId");
- const std::string& id = album_id->GetString();
- ash::PersonalAlbum* personal_album = FindPersonalAlbumById(id);
- DCHECK(personal_album);
- settings_->selected_album_ids.emplace_back(personal_album->album_id);
- }
-
- // Update topic source based on selections.
- if (settings_->selected_album_ids.empty())
- settings_->topic_source = ash::AmbientModeTopicSource::kArtGallery;
- else
- settings_->topic_source = ash::AmbientModeTopicSource::kGooglePhotos;
-
- ash::ambient::RecordAmbientModeTotalNumberOfAlbums(
- personal_albums_.albums.size());
- ash::ambient::RecordAmbientModeSelectedNumberOfAlbums(
- settings_->selected_album_ids.size());
- break;
- case ash::AmbientModeTopicSource::kArtGallery:
- // For Art gallery, we set the corresponding setting to be enabled or not
- // based on the selections.
- for (auto& art_setting : settings_->art_settings) {
- const std::string& album_id = art_setting.album_id;
- auto it = std::find_if(
- albums->GetListDeprecated().begin(),
- albums->GetListDeprecated().end(), [&album_id](const auto& album) {
- return album.FindKey("albumId")->GetString() == album_id;
- });
- const bool checked = it != albums->GetListDeprecated().end();
- art_setting.enabled = checked;
- // A setting must be visible to be enabled.
- if (art_setting.enabled)
- CHECK(art_setting.visible);
- }
- break;
- }
-
- UpdateSettings();
- SendTopicSource();
-}
-
-void AmbientModeHandler::SendTemperatureUnit() {
- DCHECK(settings_);
- FireWebUIListener(
- "temperature-unit-changed",
- base::Value(TemperatureUnitToString(settings_->temperature_unit)));
-}
-
-void AmbientModeHandler::SendTopicSource() {
- DCHECK(settings_);
- base::Value topic_source(base::Value::Type::DICTIONARY);
- topic_source.SetKey("hasGooglePhotosAlbums",
- base::Value(!personal_albums_.albums.empty()));
- topic_source.SetKey("topicSource",
- base::Value(static_cast<int>(settings_->topic_source)));
- FireWebUIListener("topic-source-changed",
- base::Value(std::move(topic_source)));
-}
-
-void AmbientModeHandler::SendAlbums(ash::AmbientModeTopicSource topic_source) {
- DCHECK(settings_);
-
- base::Value dictionary(base::Value::Type::DICTIONARY);
- base::Value albums(base::Value::Type::LIST);
- switch (topic_source) {
- case ash::AmbientModeTopicSource::kGooglePhotos:
- for (const auto& album : personal_albums_.albums) {
- base::Value value(base::Value::Type::DICTIONARY);
- value.SetKey("albumId", base::Value(album.album_id));
- value.SetKey("checked", base::Value(album.selected));
- value.SetKey("description", base::Value(GetAlbumDescription(album)));
- value.SetKey("title", base::Value(album.album_name));
- albums.Append(std::move(value));
- }
- break;
- case ash::AmbientModeTopicSource::kArtGallery:
- for (const auto& setting : settings_->art_settings) {
- if (!setting.visible)
- continue;
- base::Value value(base::Value::Type::DICTIONARY);
- value.SetKey("albumId", base::Value(setting.album_id));
- value.SetKey("checked", base::Value(setting.enabled));
- value.SetKey("description", base::Value(setting.description));
- value.SetKey("title", base::Value(setting.title));
- albums.Append(std::move(value));
- }
- break;
- }
-
- dictionary.SetKey("topicSource", base::Value(static_cast<int>(topic_source)));
- dictionary.SetKey("selectedTopicSource",
- base::Value(static_cast<int>(settings_->topic_source)));
- dictionary.SetKey("albums", std::move(albums));
- FireWebUIListener("albums-changed", std::move(dictionary));
-}
-
-void AmbientModeHandler::SendAlbumPreview(
- ash::AmbientModeTopicSource topic_source,
- const std::string& album_id,
- std::string&& png_data_url) {
- base::Value album(base::Value::Type::DICTIONARY);
- album.SetKey("albumId", base::Value(album_id));
- album.SetKey("topicSource", base::Value(static_cast<int>(topic_source)));
- album.SetKey("url", base::Value(png_data_url));
- FireWebUIListener("album-preview-changed", std::move(album));
-}
-
-void AmbientModeHandler::SendRecentHighlightsPreviews() {
- if (!FindPersonalAlbumById(ash::kAmbientModeRecentHighlightsAlbumId))
- return;
-
- base::Value png_data_urls(base::Value::Type::LIST);
- for (const auto& image : recent_highlights_preview_images_) {
- if (image.isNull())
- continue;
-
- std::vector<unsigned char> encoded_image_bytes;
- EncodeImage(image, &encoded_image_bytes);
- if (!encoded_image_bytes.empty()) {
- png_data_urls.Append(base::Value(webui::GetPngDataUrl(
- &encoded_image_bytes.front(), encoded_image_bytes.size())));
- }
- }
-
- base::Value album(base::Value::Type::DICTIONARY);
- album.SetKey("albumId",
- base::Value(ash::kAmbientModeRecentHighlightsAlbumId));
- album.SetKey("topicSource", base::Value(static_cast<int>(
- ash::AmbientModeTopicSource::kGooglePhotos)));
- album.SetKey("recentHighlightsUrls", std::move(png_data_urls));
- FireWebUIListener("album-preview-changed", std::move(album));
-}
-
-void AmbientModeHandler::UpdateSettings() {
- DCHECK(IsAmbientModeEnabled())
- << "Ambient mode must be enabled to update settings";
- DCHECK(settings_);
-
- // Prevent fetch settings callback changing |settings_| and |personal_albums_|
- // while updating.
- ui_update_weak_factory_.InvalidateWeakPtrs();
-
- if (is_updating_backend_) {
- has_pending_updates_for_backend_ = true;
- return;
- }
-
- has_pending_updates_for_backend_ = false;
- is_updating_backend_ = true;
-
- // Explicitly set show_weather to true to force server to respond with
- // weather information. See: b/158630188.
- settings_->show_weather = true;
-
- settings_sent_for_update_ = settings_;
- ash::AmbientBackendController::Get()->UpdateSettings(
- *settings_, base::BindOnce(&AmbientModeHandler::OnUpdateSettings,
- backend_weak_factory_.GetWeakPtr()));
-}
-
-void AmbientModeHandler::OnUpdateSettings(bool success) {
- is_updating_backend_ = false;
-
- if (success) {
- update_settings_retry_backoff_.Reset();
- cached_settings_ = settings_sent_for_update_;
- } else {
- update_settings_retry_backoff_.InformOfRequest(/*succeeded=*/false);
- }
-
- if (MaybeScheduleNewUpdateSettings(success))
- return;
-
- UpdateUIWithCachedSettings(success);
-}
-
-bool AmbientModeHandler::MaybeScheduleNewUpdateSettings(bool success) {
- // If it was unsuccessful to update settings, but have not reached
- // |kMaxRetries|, then it will retry.
- const bool need_retry_update_settings_at_backend =
- !success && update_settings_retry_backoff_.failure_count() <= kMaxRetries;
-
- // If there has pending updates or need to retry, then updates settings again.
- const bool should_update_settings_at_backend =
- has_pending_updates_for_backend_ || need_retry_update_settings_at_backend;
-
- if (!should_update_settings_at_backend)
- return false;
-
- const base::TimeDelta kDelay =
- update_settings_retry_backoff_.GetTimeUntilRelease();
- base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::BindOnce(&AmbientModeHandler::UpdateSettings,
- backend_weak_factory_.GetWeakPtr()),
- kDelay);
- return true;
-}
-
-void AmbientModeHandler::UpdateUIWithCachedSettings(bool success) {
- // If it was unsuccessful to update settings with |kMaxRetries|, need to
- // restore to cached settings.
- const bool should_restore_previous_settings =
- !success && update_settings_retry_backoff_.failure_count() > kMaxRetries;
-
- // Otherwise, if there has pending fetching request or need to restore
- // cached settings, then updates the WebUi.
- const bool should_update_web_ui =
- has_pending_fetch_request_ || should_restore_previous_settings;
-
- if (!should_update_web_ui)
- return;
-
- OnSettingsAndAlbumsFetched(last_fetch_request_topic_source_, cached_settings_,
- std::move(personal_albums_));
- has_pending_fetch_request_ = false;
- last_fetch_request_topic_source_ = absl::nullopt;
-}
-
-void AmbientModeHandler::RequestSettingsAndAlbums(
- absl::optional<ash::AmbientModeTopicSource> topic_source) {
- last_fetch_request_topic_source_ = topic_source;
-
- // If there is an ongoing update, do not request. If update succeeds, it will
- // update the UI with the new settings. If update fails, it will restore
- // previous settings and update UI.
- if (is_updating_backend_) {
- has_pending_fetch_request_ = true;
- return;
- }
-
- // TODO(b/161044021): Add a helper function to get all the albums. Currently
- // only load 100 latest modified albums.
- ash::AmbientBackendController::Get()->FetchSettingsAndAlbums(
- kBannerWidthPx, kBannerHeightPx, /*num_albums=*/100,
- base::BindOnce(&AmbientModeHandler::OnSettingsAndAlbumsFetched,
- ui_update_weak_factory_.GetWeakPtr(), topic_source));
-}
-
-void AmbientModeHandler::OnSettingsAndAlbumsFetched(
- absl::optional<ash::AmbientModeTopicSource> topic_source,
- const absl::optional<ash::AmbientSettings>& settings,
- ash::PersonalAlbums personal_albums) {
- // |settings| value implies success.
- if (!settings) {
- fetch_settings_retry_backoff_.InformOfRequest(/*succeeded=*/false);
- if (fetch_settings_retry_backoff_.failure_count() > kMaxRetries)
- return;
-
- const base::TimeDelta kDelay =
- fetch_settings_retry_backoff_.GetTimeUntilRelease();
- base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::BindOnce(&AmbientModeHandler::RequestSettingsAndAlbums,
- ui_update_weak_factory_.GetWeakPtr(), topic_source),
- kDelay);
- return;
- }
-
- fetch_settings_retry_backoff_.Reset();
- settings_ = settings;
- cached_settings_ = settings;
- personal_albums_ = std::move(personal_albums);
- SyncSettingsAndAlbums();
-
- if (!topic_source) {
- SendTopicSource();
- SendTemperatureUnit();
-
- // If weather info is disabled, call |UpdateSettings| immediately to force
- // it to true.
- if (!settings_->show_weather && IsAmbientModeEnabled()) {
- UpdateSettings();
- }
- return;
- }
-
- if (chromeos::features::IsAmbientModePhotoPreviewEnabled())
- DownloadAlbumPreviewImage(*topic_source);
-
- UpdateTopicSource(*topic_source);
- SendAlbums(*topic_source);
-}
-
-void AmbientModeHandler::SyncSettingsAndAlbums() {
- auto it = settings_->selected_album_ids.begin();
- while (it != settings_->selected_album_ids.end()) {
- const std::string& album_id = *it;
- ash::PersonalAlbum* album = FindPersonalAlbumById(album_id);
- if (album) {
- album->selected = true;
- ++it;
- } else {
- // The selected album does not exist any more.
- it = settings_->selected_album_ids.erase(it);
- }
- }
-
- if (settings_->selected_album_ids.empty())
- MaybeUpdateTopicSource(ash::AmbientModeTopicSource::kArtGallery);
-}
-
-void AmbientModeHandler::UpdateTopicSource(
- ash::AmbientModeTopicSource topic_source) {
- // If this is an Art gallery album page, will select art gallery topic source.
- if (topic_source == ash::AmbientModeTopicSource::kArtGallery) {
- MaybeUpdateTopicSource(topic_source);
- return;
- }
-
- // If this is a Google Photos album page, will
- // 1. Select art gallery topic source if no albums or no album is selected.
- if (settings_->selected_album_ids.empty()) {
- MaybeUpdateTopicSource(ash::AmbientModeTopicSource::kArtGallery);
- return;
- }
-
- // 2. Select Google Photos topic source if at least one album is selected.
- MaybeUpdateTopicSource(ash::AmbientModeTopicSource::kGooglePhotos);
-}
-
-void AmbientModeHandler::MaybeUpdateTopicSource(
- ash::AmbientModeTopicSource topic_source) {
- // If the setting is the same, no need to update.
- if (settings_->topic_source == topic_source)
- return;
-
- settings_->topic_source = topic_source;
- UpdateSettings();
- SendTopicSource();
-}
-
-void AmbientModeHandler::DownloadAlbumPreviewImage(
- ash::AmbientModeTopicSource topic_source) {
- switch (topic_source) {
- case ash::AmbientModeTopicSource::kGooglePhotos:
- // TODO(b/163413738): Slow down the downloading when there are too many
- // albums.
- for (const auto& album : personal_albums_.albums) {
- if (album.album_id == ash::kAmbientModeRecentHighlightsAlbumId) {
- DownloadRecentHighlightsPreviewImages(album.preview_image_urls);
- continue;
- }
-
- ash::AmbientClient::Get()->DownloadImage(
- album.banner_image_url,
- base::BindOnce(&AmbientModeHandler::OnAlbumPreviewImageDownloaded,
- backend_weak_factory_.GetWeakPtr(), topic_source,
- album.album_id));
- }
- break;
- case ash::AmbientModeTopicSource::kArtGallery:
- for (const auto& album : settings_->art_settings) {
- ash::AmbientClient::Get()->DownloadImage(
- album.preview_image_url,
-
- base::BindOnce(&AmbientModeHandler::OnAlbumPreviewImageDownloaded,
- backend_weak_factory_.GetWeakPtr(), topic_source,
- album.album_id));
- }
- break;
- }
-}
-
-void AmbientModeHandler::OnAlbumPreviewImageDownloaded(
- ash::AmbientModeTopicSource topic_source,
- const std::string& album_id,
- const gfx::ImageSkia& image) {
- switch (topic_source) {
- case ash::AmbientModeTopicSource::kGooglePhotos:
- // Album does not exist any more.
- if (!FindPersonalAlbumById(album_id))
- return;
- break;
- case ash::AmbientModeTopicSource::kArtGallery:
- if (!FindArtAlbumById(album_id))
- return;
- break;
- }
-
- std::vector<unsigned char> encoded_image_bytes;
- EncodeImage(image, &encoded_image_bytes);
- if (encoded_image_bytes.empty())
- return;
-
- SendAlbumPreview(topic_source, album_id,
- webui::GetPngDataUrl(&encoded_image_bytes.front(),
- encoded_image_bytes.size()));
-}
-
-void AmbientModeHandler::DownloadRecentHighlightsPreviewImages(
- const std::vector<std::string>& urls) {
- recent_highlights_previews_weak_factory_.InvalidateWeakPtrs();
-
- // Only show up to 4 previews.
- constexpr int kMaxRecentHighlightsPreviews = 4;
- const int total_previews =
- std::min(kMaxRecentHighlightsPreviews, static_cast<int>(urls.size()));
- recent_highlights_preview_images_.resize(total_previews);
- auto on_done = base::BarrierClosure(
- total_previews,
- base::BindOnce(&AmbientModeHandler::SendRecentHighlightsPreviews,
- recent_highlights_previews_weak_factory_.GetWeakPtr()));
-
- for (int url_index = 0; url_index < total_previews; ++url_index) {
- const auto& url = urls[url_index];
- ash::AmbientClient::Get()->DownloadImage(
- url, base::BindOnce(
- [](std::vector<gfx::ImageSkia>* preview_images, int url_index,
- base::RepeatingClosure on_done,
- base::WeakPtr<AmbientModeHandler> weak_ptr,
- const gfx::ImageSkia& image) {
- if (!weak_ptr)
- return;
-
- (*preview_images)[url_index] = image;
- on_done.Run();
- },
- &recent_highlights_preview_images_, url_index, on_done,
- recent_highlights_previews_weak_factory_.GetWeakPtr()));
- }
-}
-
-ash::PersonalAlbum* AmbientModeHandler::FindPersonalAlbumById(
- const std::string& album_id) {
- auto it = std::find_if(
- personal_albums_.albums.begin(), personal_albums_.albums.end(),
- [&album_id](const auto& album) { return album.album_id == album_id; });
-
- if (it == personal_albums_.albums.end())
- return nullptr;
-
- return &(*it);
-}
-
-ash::ArtSetting* AmbientModeHandler::FindArtAlbumById(
- const std::string& album_id) {
- auto it = std::find_if(
- settings_->art_settings.begin(), settings_->art_settings.end(),
- [&album_id](const auto& album) { return album.album_id == album_id; });
- // Album does not exist any more.
- if (it == settings_->art_settings.end())
- return nullptr;
-
- return &(*it);
-}
-
-} // namespace settings
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h
deleted file mode 100644
index 81b9b5f0394..00000000000
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_AMBIENT_MODE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_AMBIENT_MODE_HANDLER_H_
-
-#include <vector>
-
-#include "ash/public/cpp/ambient/ambient_backend_controller.h"
-#include "ash/public/cpp/image_downloader.h"
-#include "base/memory/weak_ptr.h"
-#include "base/values.h"
-#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "components/prefs/pref_change_registrar.h"
-#include "net/base/backoff_entry.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
-
-namespace ash {
-struct AmbientSettings;
-} // namespace ash
-
-namespace gfx {
-class ImageSkia;
-} // namespace gfx
-
-class PrefService;
-
-namespace chromeos {
-namespace settings {
-
-// Chrome OS ambient mode settings page UI handler, to allow users to customize
-// photo frame and other related functionalities.
-class AmbientModeHandler : public ::settings::SettingsPageUIHandler {
- public:
- explicit AmbientModeHandler(PrefService* pref_service);
- AmbientModeHandler(const AmbientModeHandler&) = delete;
- AmbientModeHandler& operator=(const AmbientModeHandler&) = delete;
- ~AmbientModeHandler() override;
-
- // settings::SettingsPageUIHandler:
- void RegisterMessages() override;
- void OnJavascriptAllowed() override;
- void OnJavascriptDisallowed() override;
-
- private:
- friend class AmbientModeHandlerTest;
-
- bool IsAmbientModeEnabled();
-
- void OnEnabledPrefChanged();
-
- // WebUI call to request topic source and temperature unit related data.
- void HandleRequestSettings(const base::Value::List& args);
-
- // WebUI call to request albums related data.
- void HandleRequestAlbums(const base::Value::List& args);
-
- // WebUI call to sync temperature unit with server.
- void HandleSetSelectedTemperatureUnit(const base::Value::List& args);
-
- // WebUI call to sync albums with server.
- void HandleSetSelectedAlbums(const base::Value::List& args);
-
- // Send the "temperature-unit-changed" WebUIListener event to update the
- // WebUI.
- void SendTemperatureUnit();
-
- // Send the "topic-source-changed" WebUIListener event to update the WebUI.
- void SendTopicSource();
-
- // Send the "albums-changed" WebUIListener event with albums info
- // in the |topic_source|.
- void SendAlbums(ash::AmbientModeTopicSource topic_source);
-
- // Send the "album-preview-changed" WebUIListener event with album preview
- // in the |topic_source|.
- void SendAlbumPreview(ash::AmbientModeTopicSource topic_source,
- const std::string& album_id,
- std::string&& png_data_url);
-
- // Send the "album-preview-changed" WebUIListener event with Recent Highlights
- // previews in the |topic_source|.
- void SendRecentHighlightsPreviews();
-
- // Update the local |settings_| to server.
- void UpdateSettings();
-
- // Called when the settings is updated.
- // |success| is true when update successfully.
- void OnUpdateSettings(bool success);
-
- // Return true if a new update needed.
- // |success| is true when update successfully.
- bool MaybeScheduleNewUpdateSettings(bool success);
-
- // |success| is true when update successfully.
- void UpdateUIWithCachedSettings(bool success);
-
- // Will be called from ambientMode/photos subpage and ambientMode subpage.
- // |topic_source| is used to request the albums in that source and identify
- // the callers:
- // 1. |kGooglePhotos|: ambientMode/photos?topicSource=0
- // 2. |kArtGallery|: ambientMode/photos?topicSource=1
- // 3. absl::nullopt: ambientMode/
- void RequestSettingsAndAlbums(
- absl::optional<ash::AmbientModeTopicSource> topic_source);
- void OnSettingsAndAlbumsFetched(
- absl::optional<ash::AmbientModeTopicSource> topic_source,
- const absl::optional<ash::AmbientSettings>& settings,
- ash::PersonalAlbums personal_albums);
-
- // The |settings_| could be stale when the albums in Google Photos changes.
- // Prune the |selected_album_id| which does not exist any more.
- // Populate albums with selected info which will be shown on Settings UI.
- void SyncSettingsAndAlbums();
-
- // Update topic source if needed.
- void UpdateTopicSource(ash::AmbientModeTopicSource topic_source);
- void MaybeUpdateTopicSource(ash::AmbientModeTopicSource topic_source);
-
- void DownloadAlbumPreviewImage(ash::AmbientModeTopicSource topic_source);
- void DownloadRecentHighlightsPreviewImages(
- const std::vector<std::string>& urls);
-
- void OnAlbumPreviewImageDownloaded(ash::AmbientModeTopicSource topic_source,
- const std::string& album_id,
- const gfx::ImageSkia& image);
-
- ash::PersonalAlbum* FindPersonalAlbumById(const std::string& album_id);
-
- ash::ArtSetting* FindArtAlbumById(const std::string& album_id);
-
- // Local settings which may contain changes from WebUI but have not sent to
- // server.
- absl::optional<ash::AmbientSettings> settings_;
-
- // The cached settings from the server. Should be the same as the server side.
- // This value will be updated when RequestSettingsAndAlbums() and
- // UpdateSettings() return successfully.
- // If UpdateSettings() fails, will restore to this value.
- absl::optional<ash::AmbientSettings> cached_settings_;
-
- // A temporary settings sent to the server in UpdateSettings().
- absl::optional<ash::AmbientSettings> settings_sent_for_update_;
-
- ash::PersonalAlbums personal_albums_;
-
- // Backoff retries for RequestSettingsAndAlbums().
- net::BackoffEntry fetch_settings_retry_backoff_;
-
- // Whether to update UI when UpdateSettings() returns successfully.
- bool has_pending_fetch_request_ = false;
-
- // The topic source in the latest RequestSettingsAndAlbums().
- absl::optional<ash::AmbientModeTopicSource> last_fetch_request_topic_source_;
-
- // Whether the Settings updating is ongoing.
- bool is_updating_backend_ = false;
-
- // Whether there are pending updates.
- bool has_pending_updates_for_backend_ = false;
-
- // Backoff retries for UpdateSettings().
- net::BackoffEntry update_settings_retry_backoff_;
-
- std::vector<gfx::ImageSkia> recent_highlights_preview_images_;
-
- PrefService* pref_service_;
-
- PrefChangeRegistrar pref_change_registrar_;
-
- base::WeakPtrFactory<AmbientModeHandler> backend_weak_factory_{this};
- base::WeakPtrFactory<AmbientModeHandler> ui_update_weak_factory_{this};
- base::WeakPtrFactory<AmbientModeHandler>
- recent_highlights_previews_weak_factory_{this};
-};
-
-} // namespace settings
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_AMBIENT_MODE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc
deleted file mode 100644
index 144a30af375..00000000000
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc
+++ /dev/null
@@ -1,860 +0,0 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h"
-
-#include <memory>
-
-#include "ash/ambient/test/ambient_ash_test_helper.h"
-#include "ash/constants/ash_features.h"
-#include "ash/public/cpp/ambient/ambient_prefs.h"
-#include "ash/public/cpp/ambient/common/ambient_settings.h"
-#include "ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h"
-#include "base/test/metrics/histogram_tester.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "components/prefs/pref_registry_simple.h"
-#include "components/prefs/testing_pref_service.h"
-#include "content/public/test/test_web_ui.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-namespace settings {
-
-namespace {
-
-const char kWebCallbackFunctionName[] = "cr.webUIListenerCallback";
-
-class TestAmbientModeHandler : public AmbientModeHandler {
- public:
- explicit TestAmbientModeHandler(PrefService* pref_service)
- : AmbientModeHandler(pref_service) {}
- ~TestAmbientModeHandler() override = default;
-
- // Make public for testing.
- using AmbientModeHandler::AllowJavascript;
- using AmbientModeHandler::RegisterMessages;
- using AmbientModeHandler::set_web_ui;
-};
-
-} // namespace
-
-class AmbientModeHandlerTest : public testing::Test {
- public:
- AmbientModeHandlerTest() = default;
- ~AmbientModeHandlerTest() override = default;
-
- void SetUp() override {
- web_ui_ = std::make_unique<content::TestWebUI>();
- test_pref_service_ = std::make_unique<TestingPrefServiceSimple>();
-
- test_pref_service_->registry()->RegisterBooleanPref(
- ash::ambient::prefs::kAmbientModeEnabled, true);
-
- handler_ =
- std::make_unique<TestAmbientModeHandler>(test_pref_service_.get());
- handler_->set_web_ui(web_ui_.get());
- handler_->RegisterMessages();
- handler_->AllowJavascript();
- fake_backend_controller_ =
- std::make_unique<ash::FakeAmbientBackendControllerImpl>();
- ambient_ash_test_helper_ = std::make_unique<ash::AmbientAshTestHelper>();
- ambient_ash_test_helper_->ambient_client().SetAutomaticalyIssueToken(true);
- }
-
- void TearDown() override {
- handler_->DisallowJavascript();
- testing::Test::TearDown();
- }
-
- content::TestWebUI* web_ui() { return web_ui_.get(); }
-
- const base::HistogramTester& histogram_tester() const {
- return histogram_tester_;
- }
-
- absl::optional<ash::AmbientSettings>& settings() {
- return handler_->settings_;
- }
-
- void SetEnabledPref(bool enabled) {
- test_pref_service_->SetBoolean(ash::ambient::prefs::kAmbientModeEnabled,
- enabled);
- }
-
- void SetTopicSource(ash::AmbientModeTopicSource topic_source) {
- if (!handler_->settings_)
- handler_->settings_ = ash::AmbientSettings();
-
- handler_->settings_->topic_source = topic_source;
- }
-
- void SetTemperatureUnit(ash::AmbientModeTemperatureUnit temperature_unit) {
- if (!handler_->settings_)
- handler_->settings_ = ash::AmbientSettings();
-
- handler_->settings_->temperature_unit = temperature_unit;
- }
-
- void RequestSettings() {
- handler_->HandleRequestSettings(base::Value::List());
- }
-
- void RequestAlbums(ash::AmbientModeTopicSource topic_source) {
- base::Value args(base::Value::Type::LIST);
- args.Append(static_cast<int>(topic_source));
- handler_->HandleRequestAlbums(args.GetList());
- }
-
- void HandleSetSelectedTemperatureUnit(const base::Value::List& args) {
- handler_->HandleSetSelectedTemperatureUnit(args);
- }
-
- void HandleSetSelectedAlbums(const base::Value::List& args) {
- handler_->HandleSetSelectedAlbums(args);
- }
-
- void FetchSettings() {
- handler_->RequestSettingsAndAlbums(/*topic_source=*/absl::nullopt);
- }
-
- void UpdateSettings() {
- if (!handler_->settings_)
- handler_->settings_ = ash::AmbientSettings();
-
- handler_->UpdateSettings();
- }
-
- bool HasPendingFetchRequestAtHandler() const {
- return handler_->has_pending_fetch_request_;
- }
-
- bool IsUpdateSettingsPendingAtHandler() const {
- return handler_->is_updating_backend_;
- }
-
- bool HasPendingUpdatesAtHandler() const {
- return handler_->has_pending_updates_for_backend_;
- }
-
- base::TimeDelta GetFetchSettingsDelay() {
- return handler_->fetch_settings_retry_backoff_.GetTimeUntilRelease();
- }
-
- base::TimeDelta GetUpdateSettingsDelay() {
- return handler_->update_settings_retry_backoff_.GetTimeUntilRelease();
- }
-
- void FastForwardBy(base::TimeDelta time) {
- task_environment_.FastForwardBy(time);
- }
-
- bool IsFetchSettingsPendingAtBackend() const {
- return fake_backend_controller_->IsFetchSettingsAndAlbumsPending();
- }
-
- void ReplyFetchSettingsAndAlbums(
- bool success,
- absl::optional<ash::AmbientSettings> settings = absl::nullopt) {
- fake_backend_controller_->ReplyFetchSettingsAndAlbums(success,
- std::move(settings));
- }
-
- bool IsUpdateSettingsPendingAtBackend() const {
- return fake_backend_controller_->IsUpdateSettingsPending();
- }
-
- void ReplyUpdateSettings(bool success) {
- fake_backend_controller_->ReplyUpdateSettings(success);
- }
-
- std::string BoolToString(bool x) { return x ? "true" : "false"; }
-
- void VerifySettingsSent(ash::AmbientModeTopicSource topic_source,
- const std::string& temperature_unit) {
- EXPECT_EQ(2U, web_ui_->call_data().size());
-
- // The call is structured such that the function name is the "web callback"
- // name and the first argument is the name of the message being sent.
- const auto& topic_source_call_data = *web_ui_->call_data().front();
- const auto& temperature_unit_call_data = *web_ui_->call_data().back();
-
- // Topic Source
- EXPECT_EQ(kWebCallbackFunctionName, topic_source_call_data.function_name());
- EXPECT_EQ("topic-source-changed",
- topic_source_call_data.arg1()->GetString());
- const base::DictionaryValue* dictionary = nullptr;
- topic_source_call_data.arg2()->GetAsDictionary(&dictionary);
- const base::Value* topic_source_value = dictionary->FindKey("topicSource");
- EXPECT_EQ(static_cast<int>(topic_source), topic_source_value->GetInt());
-
- // Temperature Unit
- EXPECT_EQ(kWebCallbackFunctionName,
- temperature_unit_call_data.function_name());
- EXPECT_EQ("temperature-unit-changed",
- temperature_unit_call_data.arg1()->GetString());
- EXPECT_EQ(temperature_unit, temperature_unit_call_data.arg2()->GetString());
- }
-
- void VerifyAlbumsSent(ash::AmbientModeTopicSource topic_source) {
- // Art gallery has an extra call to update the topic source to Art gallery.
- // And receive the image update.
- std::size_t call_size =
- topic_source == ash::AmbientModeTopicSource::kGooglePhotos ? 3U : 5U;
- EXPECT_EQ(call_size, web_ui_->call_data().size());
-
- if (topic_source == ash::AmbientModeTopicSource::kArtGallery) {
- const auto& topic_source_call_data = *web_ui_->call_data().front();
- const base::DictionaryValue* dictionary = nullptr;
- topic_source_call_data.arg2()->GetAsDictionary(&dictionary);
- const base::Value* topic_source_value =
- dictionary->FindKey("topicSource");
- EXPECT_EQ(static_cast<int>(topic_source), topic_source_value->GetInt());
- }
-
- const content::TestWebUI::CallData& call_data =
- *web_ui_->call_data().back();
-
- // The call is structured such that the function name is the "web callback"
- // name and the first argument is the name of the message being sent.
- EXPECT_EQ(kWebCallbackFunctionName, call_data.function_name());
- EXPECT_EQ("albums-changed", call_data.arg1()->GetString());
-
- // The test data is set in FakeAmbientBackendControllerImpl.
- const base::DictionaryValue* dictionary = nullptr;
- call_data.arg2()->GetAsDictionary(&dictionary);
-
- const base::Value* topic_source_value = dictionary->FindKey("topicSource");
- EXPECT_EQ(static_cast<int>(topic_source), topic_source_value->GetInt());
-
- const base::Value* albums = dictionary->FindKey("albums");
- EXPECT_EQ(2U, albums->GetListDeprecated().size());
-
- const base::DictionaryValue* album0;
- albums->GetListDeprecated()[0].GetAsDictionary(&album0);
- EXPECT_EQ("0", album0->FindKey("albumId")->GetString());
-
- const base::DictionaryValue* album1;
- albums->GetListDeprecated()[1].GetAsDictionary(&album1);
- EXPECT_EQ("1", album1->FindKey("albumId")->GetString());
-
- if (topic_source == ash::AmbientModeTopicSource::kGooglePhotos) {
- EXPECT_EQ(false, album0->FindKey("checked")->GetBool());
- EXPECT_EQ("album0", album0->FindKey("title")->GetString());
-
- EXPECT_EQ(true, album1->FindKey("checked")->GetBool());
- EXPECT_EQ("album1", album1->FindKey("title")->GetString());
- } else {
- EXPECT_EQ(true, album0->FindKey("checked")->GetBool());
- EXPECT_EQ("art0", album0->FindKey("title")->GetString());
-
- EXPECT_EQ(false, album1->FindKey("checked")->GetBool());
- EXPECT_EQ("art1", album1->FindKey("title")->GetString());
- }
- }
-
- private:
- base::test::TaskEnvironment task_environment_{
- base::test::TaskEnvironment::TimeSource::MOCK_TIME};
- base::test::ScopedFeatureList scoped_feature_list_;
- std::unique_ptr<content::TestWebUI> web_ui_;
- std::unique_ptr<ash::AmbientAshTestHelper> ambient_ash_test_helper_;
- std::unique_ptr<ash::FakeAmbientBackendControllerImpl>
- fake_backend_controller_;
- std::unique_ptr<TestAmbientModeHandler> handler_;
- base::HistogramTester histogram_tester_;
- std::unique_ptr<TestingPrefServiceSimple> test_pref_service_;
-};
-
-TEST_F(AmbientModeHandlerTest, TestSendTemperatureUnitAndTopicSource) {
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- // In FakeAmbientBackendControllerImpl, the |topic_source| is kGooglePhotos,
- // the |temperature_unit| is kCelsius.
- VerifySettingsSent(ash::AmbientModeTopicSource::kGooglePhotos, "celsius");
-}
-
-TEST_F(AmbientModeHandlerTest, TestSendAlbumsForGooglePhotos) {
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- VerifyAlbumsSent(topic_source);
-}
-
-TEST_F(AmbientModeHandlerTest, TestSendAlbumsForArtGallery) {
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kArtGallery;
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- VerifyAlbumsSent(topic_source);
-}
-
-TEST_F(AmbientModeHandlerTest, TestFetchSettings) {
- FetchSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestFetchSettingsFailedWillRetry) {
- FetchSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- FastForwardBy(GetFetchSettingsDelay() * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestFetchSettingsSecondRetryWillBackoff) {
- FetchSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- base::TimeDelta delay1 = GetFetchSettingsDelay();
- FastForwardBy(delay1 * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- base::TimeDelta delay2 = GetFetchSettingsDelay();
- EXPECT_GT(delay2, delay1);
-
- FastForwardBy(delay2 * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest,
- TestFetchSettingsWillNotRetryMoreThanThreeTimes) {
- FetchSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- // 1st retry.
- FastForwardBy(GetFetchSettingsDelay() * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- // 2nd retry.
- FastForwardBy(GetFetchSettingsDelay() * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- // 3rd retry.
- FastForwardBy(GetFetchSettingsDelay() * 1.5);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/false);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- // Will not retry.
- FastForwardBy(GetFetchSettingsDelay() * 1.5);
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestUpdateSettings) {
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/true);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestUpdateSettingsTwice) {
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/true);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(HasPendingUpdatesAtHandler());
-
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestUpdateSettingsFailedWillRetry) {
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestUpdateSettingsSecondRetryWillBackoff) {
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- base::TimeDelta delay1 = GetUpdateSettingsDelay();
- FastForwardBy(delay1 * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- base::TimeDelta delay2 = GetUpdateSettingsDelay();
- EXPECT_GT(delay2, delay1);
-
- FastForwardBy(delay2 * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest,
- TestUpdateSettingsWillNotRetryMoreThanThreeTimes) {
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- // 1st retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- // 2nd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- // 3rd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-
- // Will not retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(HasPendingUpdatesAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestNoFetchRequestWhenUpdatingSettings) {
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- UpdateSettings();
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- RequestSettings();
- EXPECT_TRUE(HasPendingFetchRequestAtHandler());
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestSendSettingsWhenUpdatedSettings) {
- // Simulate initial page request.
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- SetTopicSource(ash::AmbientModeTopicSource::kArtGallery);
- UpdateSettings();
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- RequestSettings();
- EXPECT_TRUE(HasPendingFetchRequestAtHandler());
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- web_ui()->ClearTrackedCalls();
- ReplyUpdateSettings(/*success=*/true);
-
- // In FakeAmbientBackendControllerImpl, the |topic_source| is kGooglePhotos,
- // the |temperature_unit| is kCelsius.
- VerifySettingsSent(ash::AmbientModeTopicSource::kArtGallery, "celsius");
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest,
- TestSendAlbumsOfGooglePhotosWhenUpdatedSettings) {
- // Simulate initial page request.
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- web_ui()->ClearTrackedCalls();
-
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- UpdateSettings();
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- RequestAlbums(topic_source);
- EXPECT_TRUE(HasPendingFetchRequestAtHandler());
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- ReplyUpdateSettings(/*success=*/true);
- VerifyAlbumsSent(topic_source);
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestSendAlbumsOfArtGalleryWhenUpdatedSettings) {
- // Simulate initial page request.
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- web_ui()->ClearTrackedCalls();
-
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- UpdateSettings();
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- RequestAlbums(topic_source);
- EXPECT_TRUE(HasPendingFetchRequestAtHandler());
- EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
-
- ReplyUpdateSettings(/*success=*/true);
- VerifyAlbumsSent(topic_source);
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-}
-
-TEST_F(AmbientModeHandlerTest, TestNotUpdateUIWhenFetechedSettings) {
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- RequestSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- EXPECT_EQ(0U, web_ui()->call_data().size());
-}
-
-TEST_F(AmbientModeHandlerTest, TestNotSendSettingsWhenFetechedSettings) {
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
- RequestSettings();
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- EXPECT_EQ(0U, web_ui()->call_data().size());
-}
-
-TEST_F(AmbientModeHandlerTest, TestNotSendAlbumsWhenFetechedSettings) {
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- RequestAlbums(topic_source);
- EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
- EXPECT_FALSE(HasPendingFetchRequestAtHandler());
-
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-
- ReplyFetchSettingsAndAlbums(/*success=*/true);
- EXPECT_EQ(0U, web_ui()->call_data().size());
-}
-
-TEST_F(AmbientModeHandlerTest, TestSendSettingsWhenUpdateSettingsFailed) {
- // Simulate initial page request.
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- SetTopicSource(ash::AmbientModeTopicSource::kArtGallery);
- UpdateSettings();
- ReplyUpdateSettings(/*success=*/false);
-
- // 1st retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- // 2nd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- web_ui()->ClearTrackedCalls();
- EXPECT_EQ(0U, web_ui()->call_data().size());
-
- // 3rd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
- // In FakeAmbientBackendControllerImpl, the |topic_source| is kGooglePhotos,
- // the |temperature_unit| is kCelsius.
- VerifySettingsSent(ash::AmbientModeTopicSource::kGooglePhotos, "celsius");
-}
-
-TEST_F(AmbientModeHandlerTest,
- TestSendAlbumsOfGooglePhotosWhenUpdateSettingsFailed) {
- // Simulate initial page request.
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- SetTopicSource(topic_source);
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- UpdateSettings();
- ReplyUpdateSettings(/*success=*/false);
-
- // 1st retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- // 2nd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- web_ui()->ClearTrackedCalls();
- EXPECT_EQ(0U, web_ui()->call_data().size());
-
- // 3rd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
- VerifyAlbumsSent(topic_source);
-}
-
-TEST_F(AmbientModeHandlerTest,
- TestSendAlbumsOfArtGalleryWhenUpdateSettingsFailed) {
- // Simulate initial page request.
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kArtGallery;
- SetTopicSource(topic_source);
- RequestAlbums(topic_source);
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- UpdateSettings();
- ReplyUpdateSettings(/*success=*/false);
-
- // 1st retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- // 2nd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- web_ui()->ClearTrackedCalls();
- EXPECT_EQ(0U, web_ui()->call_data().size());
-
- // 3rd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
- VerifyAlbumsSent(topic_source);
-}
-
-// Test that there are two updates, the first update succeeded and the second
-// update failed. When the second update failed, it will update UI to restore
-// the latest successfully updated settings.
-TEST_F(AmbientModeHandlerTest, TestSendSettingsWithCachedSettings) {
- ash::AmbientModeTopicSource topic_source_google_photos =
- ash::AmbientModeTopicSource::kGooglePhotos;
- ash::AmbientModeTopicSource topic_source_art_gallery =
- ash::AmbientModeTopicSource::kArtGallery;
-
- // Simulate initial page request.
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- // The first update.
- SetTopicSource(topic_source_art_gallery);
- UpdateSettings();
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
-
- // There is the second change and pending update before retry.
- SetTopicSource(topic_source_google_photos);
- UpdateSettings();
- EXPECT_TRUE(HasPendingUpdatesAtHandler());
-
- // First update returns true and will start the second update.
- ReplyUpdateSettings(/*success=*/true);
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
-
- ReplyUpdateSettings(/*success=*/false);
-
- // 1st retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- // 2nd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
-
- web_ui()->ClearTrackedCalls();
- EXPECT_EQ(0U, web_ui()->call_data().size());
-
- // 3rd retry.
- FastForwardBy(GetUpdateSettingsDelay() * 1.5);
- ReplyUpdateSettings(/*success=*/false);
- VerifySettingsSent(topic_source_art_gallery, "celsius");
-}
-
-TEST_F(AmbientModeHandlerTest, TestAlbumNumbersAreRecorded) {
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- base::ListValue args;
- base::DictionaryValue dictionary;
- ash::AmbientModeTopicSource topic_source =
- ash::AmbientModeTopicSource::kGooglePhotos;
- dictionary.SetKey("topicSource", base::Value(static_cast<int>(topic_source)));
-
- base::Value albums(base::Value::Type::LIST);
- base::Value album(base::Value::Type::DICTIONARY);
- album.SetKey("albumId", base::Value("0"));
- albums.Append(std::move(album));
- dictionary.SetKey("albums", std::move(albums));
-
- args.Append(std::move(dictionary));
- HandleSetSelectedAlbums(args.GetList());
-
- histogram_tester().ExpectTotalCount("Ash.AmbientMode.TotalNumberOfAlbums",
- /*count=*/1);
- histogram_tester().ExpectTotalCount("Ash.AmbientMode.SelectedNumberOfAlbums",
- /*count=*/1);
-}
-
-TEST_F(AmbientModeHandlerTest, TestTemperatureUnitChangeUpdatesSettings) {
- SetTemperatureUnit(ash::AmbientModeTemperatureUnit::kCelsius);
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-
- base::Value args(base::Value::Type::LIST);
- args.Append("fahrenheit");
-
- HandleSetSelectedTemperatureUnit(args.GetList());
-
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-
- ReplyUpdateSettings(/*success=*/true);
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestSameTemperatureUnitSkipsUpdate) {
- SetTemperatureUnit(ash::AmbientModeTemperatureUnit::kCelsius);
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-
- base::Value args(base::Value::Type::LIST);
- args.Append("celsius");
-
- HandleSetSelectedTemperatureUnit(args.GetList());
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestEnabledPrefChangeUpdatesSettings) {
- // Simulate initial page request.
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true);
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-
- // Should not trigger |UpdateSettings|.
- SetEnabledPref(/*enabled=*/false);
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-
- // Settings this to true should trigger |UpdateSettings|.
- SetEnabledPref(/*enabled=*/true);
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-}
-
-TEST_F(AmbientModeHandlerTest, TestWeatherFalseTriggersUpdateSettings) {
- ash::AmbientSettings weather_off_settings;
- weather_off_settings.show_weather = false;
-
- // Simulate initial page request with weather settings false. Because Ambient
- // mode pref is enabled and |settings.show_weather| is false, this should
- // trigger a call to |UpdateSettings| that sets |settings.show_weather| to
- // true.
- RequestSettings();
- ReplyFetchSettingsAndAlbums(/*success=*/true, weather_off_settings);
-
- // A call to |UpdateSettings| should have happened.
- EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
- EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
-
- ReplyUpdateSettings(/*success=*/true);
-
- EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
- EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
-
- // |settings.show_weather| should now be true after the successful settings
- // update.
- EXPECT_TRUE(settings()->show_weather);
-}
-
-} // namespace settings
-} // namespace chromeos
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 ec74788afd0..268621cecf8 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
@@ -5,13 +5,14 @@
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
#include "base/bind.h"
-#include "base/values.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/apps/app_service/launch_utils.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/app_launch_util.h"
+#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/cpp/intent_util.h"
#include "content/public/browser/web_contents.h"
#include "ui/display/display.h"
@@ -79,17 +80,14 @@ void AndroidAppsHandler::OnArcPlayStoreEnabledChanged(bool enabled) {
SendAndroidAppsInfo();
}
-std::unique_ptr<base::DictionaryValue>
-AndroidAppsHandler::BuildAndroidAppsInfo() {
- std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue);
- info->SetBoolKey("playStoreEnabled",
- arc::IsArcPlayStoreEnabledForProfile(profile_));
+base::Value::Dict AndroidAppsHandler::BuildAndroidAppsInfo() {
+ base::Value::Dict info;
+ info.Set("playStoreEnabled", arc::IsArcPlayStoreEnabledForProfile(profile_));
const ArcAppListPrefs* arc_apps_pref = ArcAppListPrefs::Get(profile_);
// TODO(khmel): Inverstigate why in some browser tests
// playStoreEnabled is true but arc_apps_pref is not set.
- info->SetBoolKey(
- "settingsAppAvailable",
- arc_apps_pref && arc_apps_pref->IsRegistered(arc::kSettingsAppId));
+ info.Set("settingsAppAvailable",
+ arc_apps_pref && arc_apps_pref->IsRegistered(arc::kSettingsAppId));
return info;
}
@@ -100,8 +98,7 @@ void AndroidAppsHandler::HandleRequestAndroidAppsInfo(
}
void AndroidAppsHandler::SendAndroidAppsInfo() {
- std::unique_ptr<base::DictionaryValue> info = BuildAndroidAppsInfo();
- FireWebUIListener("android-apps-info-update", *info);
+ FireWebUIListener("android-apps-info-update", BuildAndroidAppsInfo());
}
void AndroidAppsHandler::ShowAndroidAppsSettings(
@@ -112,10 +109,16 @@ void AndroidAppsHandler::ShowAndroidAppsSettings(
activated_from_keyboard = args[0].GetBool();
int flags = activated_from_keyboard ? ui::EF_NONE : ui::EF_LEFT_MOUSE_BUTTON;
- app_service_proxy_->Launch(
- arc::kSettingsAppId, flags,
- apps::mojom::LaunchSource::kFromParentalControls,
- apps::MakeWindowInfo(GetDisplayIdForCurrentProfile()));
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ app_service_proxy_->Launch(
+ arc::kSettingsAppId, flags, apps::LaunchSource::kFromParentalControls,
+ std::make_unique<apps::WindowInfo>(GetDisplayIdForCurrentProfile()));
+ } else {
+ app_service_proxy_->Launch(
+ arc::kSettingsAppId, flags,
+ apps::mojom::LaunchSource::kFromParentalControls,
+ apps::MakeWindowInfo(GetDisplayIdForCurrentProfile()));
+ }
}
int64_t AndroidAppsHandler::GetDisplayIdForCurrentProfile() {
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 4c9bcd1359e..5ad59cb6b01 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
@@ -10,6 +10,7 @@
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
+#include "base/values.h"
#include "chrome/browser/apps/app_service/app_service_proxy_forward.h"
#include "chrome/browser/ash/arc/session/arc_session_manager.h"
#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h"
@@ -18,10 +19,6 @@
class Profile;
-namespace base {
-class DictionaryValue;
-}
-
namespace chromeos {
namespace settings {
@@ -53,7 +50,7 @@ class AndroidAppsHandler : public ::settings::SettingsPageUIHandler,
void OnArcPlayStoreEnabledChanged(bool enabled) override;
private:
- std::unique_ptr<base::DictionaryValue> BuildAndroidAppsInfo();
+ base::Value::Dict BuildAndroidAppsInfo();
void HandleRequestAndroidAppsInfo(const base::Value::List& args);
void HandleAppChanged(const std::string& app_id);
void SendAndroidAppsInfo();
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 3d955a0f359..7eeea9551a5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
@@ -19,10 +19,10 @@
#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/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
@@ -547,6 +547,8 @@ void AppsSection::AddAndroidAppStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_ANDROID_APPS_DISABLE_DIALOG_REMOVE},
{"arcvmSharedUsbDevicesDescription",
IDS_SETTINGS_APPS_ARC_VM_SHARED_USB_DEVICES_DESCRIPTION},
+ {"androidAppsEnableButtonRole",
+ IDS_SETTINGS_ANDROID_APPS_ENABLE_BUTTON_ROLE},
};
html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddLocalizedString("androidAppsPageTitle",
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.cc
index c7075b81ad0..d3e8d43b257 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/ash/quick_pair/fast_pair_support_utils.h"
-#include "chromeos/network/network_event_log.h"
+#include "chromeos/ash/components/network/network_event_log.h"
#include "content/public/browser/web_ui.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler_unittest.cc
index b92a01fbb8a..9c91d2f8bfa 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_handler_unittest.cc
@@ -75,11 +75,10 @@ TEST_F(BluetoothHandlerTest, GetIsDeviceBlockedByPolicy) {
size_t call_data_count_before_call = test_web_ui()->call_data().size();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("handlerFunctionName");
args.Append(kDeviceAddress);
- test_web_ui()->HandleReceivedMessage("isDeviceBlockedByPolicy",
- &base::Value::AsListValue(args));
+ test_web_ui()->HandleReceivedMessage("isDeviceBlockedByPolicy", args);
ASSERT_EQ(call_data_count_before_call + 1u,
test_web_ui()->call_data().size());
@@ -96,9 +95,9 @@ TEST_F(BluetoothHandlerTest, GetRequestFastPairDeviceSupport) {
size_t call_data_count_before_call = test_web_ui()->call_data().size();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
test_web_ui()->HandleReceivedMessage("requestFastPairDeviceSupportStatus",
- &base::Value::AsListValue(args));
+ args);
ASSERT_EQ(call_data_count_before_call + 1u,
test_web_ui()->call_data().size());
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
index 2ddb1202dda..ac593388b86 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
@@ -10,12 +10,13 @@
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_shared_load_time_data_provider.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_result_icon.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/bluetooth_handler.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/search/search.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -152,6 +153,18 @@ const std::vector<SearchConcept>& GetFastPairOnSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetFastPairSavedDevicesSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_FAST_PAIR_SAVED_DEVICES,
+ mojom::kBluetoothSavedDevicesSubpagePath,
+ mojom::SearchResultIcon::kBluetooth,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kFastPairSavedDevices}},
+ });
+ return *tags;
+}
+
} // namespace
BluetoothSection::BluetoothSection(Profile* profile,
@@ -161,7 +174,7 @@ BluetoothSection::BluetoothSection(Profile* profile,
pref_service_(pref_service),
pref_change_registrar_(std::make_unique<PrefChangeRegistrar>()) {
bool is_initialized = false;
- if (base::FeatureList::IsEnabled(floss::features::kFlossEnabled)) {
+ if (floss::features::IsFlossEnabled()) {
is_initialized = floss::FlossDBusManager::IsInitialized();
} else {
is_initialized = bluez::BluezDBusManager::IsInitialized();
@@ -316,6 +329,22 @@ void BluetoothSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"bluetoothManaged", IDS_SETTINGS_BLUETOOTH_MANAGED},
{"enableFastPairLabel", IDS_BLUETOOTH_ENABLE_FAST_PAIR_LABEL},
{"enableFastPairSubtitle", IDS_BLUETOOTH_ENABLE_FAST_PAIR_SUBTITLE},
+ {"savedDevicesLabel", IDS_BLUETOOTH_SAVED_DEVICES_LABEL},
+ {"savedDevicesSubtitle", IDS_BLUETOOTH_SAVED_DEVICES_SUBTITLE},
+ {"savedDevicesPageName", IDS_SETTINGS_BLUETOOTH_SAVED_DEVICES},
+ {"savedDevicesRemove", IDS_BLUETOOTH_SAVED_DEVICES_REMOVE},
+ {"savedDevicesDialogRemove",
+ IDS_SETTINGS_REMOVE_SAVED_DEVICE_DIALOG_REMOVE},
+ {"savedDevicesDialogCancel",
+ IDS_SETTINGS_REMOVE_SAVED_DEVICE_DIALOG_CANCEL},
+ {"savedDevicesDialogLabel",
+ IDS_SETTINGS_REMOVE_SAVED_DEVICE_DIALOG_LABEL},
+ {"bluetoothDevicesDialogForget",
+ IDS_SETTINGS_FORGET_DEVICE_DIALOG_FORGET},
+ {"bluetoothDevicesDialogCancel",
+ IDS_SETTINGS_FORGET_DEVICE_DIALOG_CANCEL},
+ {"bluetoothDevicesDialogLabel", IDS_SETTINGS_FORGET_DEVICE_DIALOG_LABEL},
+ {"bluetoothDevicesDialogTitle", IDS_SETTINGS_FORGET_DEVICE_DIALOG_TITLE},
{"bluetoothPrimaryUserControlled",
IDS_SETTINGS_BLUETOOTH_PRIMARY_USER_CONTROLLED},
{"bluetoothDeviceWithConnectionStatus",
@@ -355,16 +384,29 @@ void BluetoothSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"bluetoothDeviceListNoConnectedDevices",
IDS_BLUETOOTH_DEVICE_LIST_NO_CONNECTED_DEVICES},
{"bluetoothEnabledA11YLabel", IDS_SETTINGS_BLUETOOTH_ENABLED_A11Y_LABEL},
- {"bluetoothDisabledA11YLabel", IDS_SETTINGS_BLUETOOTH_DISABLED_A11Y_LABEL}
+ {"bluetoothDisabledA11YLabel",
+ IDS_SETTINGS_BLUETOOTH_DISABLED_A11Y_LABEL},
+
+ {"savedDeviceItemA11yLabel", IDS_SAVED_DEVICE_ITEM_A11Y_LABEL},
+
+ {"savedDeviceItemButtonA11yLabel",
+ IDS_SAVED_DEVICE_LIST_ITEM_BUTTON_A11Y_LABEL}
};
html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("enableFastPairFlag", features::IsFastPairEnabled());
+ html_source->AddBoolean("enableSavedDevicesFlag",
+ features::IsFastPairSavedDevicesEnabled());
chromeos::bluetooth::AddLoadTimeData(html_source);
}
void BluetoothSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(std::make_unique<BluetoothHandler>());
+
+ if (ash::features::IsFastPairEnabled() &&
+ features::IsFastPairSavedDevicesEnabled()) {
+ web_ui->AddMessageHandler(std::make_unique<FastPairSavedDevicesHandler>());
+ }
}
int BluetoothSection::GetSectionNameMessageId() const {
@@ -404,11 +446,13 @@ void BluetoothSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::kBluetoothDevicesSubpagePath);
static constexpr mojom::Setting kBluetoothDevicesSettings[] = {
mojom::Setting::kBluetoothOnOff, mojom::Setting::kBluetoothPairDevice,
- mojom::Setting::kBluetoothUnpairDevice, mojom::Setting::kFastPairOnOff};
+ mojom::Setting::kBluetoothUnpairDevice, mojom::Setting::kFastPairOnOff,
+ mojom::Setting::kFastPairSavedDevices};
static constexpr mojom::Setting kBluetoothDevicesSettingsLegacy[] = {
mojom::Setting::kBluetoothConnectToDevice,
mojom::Setting::kBluetoothDisconnectFromDevice,
};
+
RegisterNestedSettingBulk(mojom::Subpage::kBluetoothDevices,
kBluetoothDevicesSettings, generator);
generator->RegisterTopLevelAltSetting(mojom::Setting::kBluetoothOnOff);
@@ -422,6 +466,13 @@ void BluetoothSection::RegisterHierarchy(HierarchyGenerator* generator) const {
? mojom::Subpage::kBluetoothDeviceDetail
: mojom::Subpage::kBluetoothDevices,
kBluetoothDevicesSettingsLegacy, generator);
+
+ generator->RegisterNestedSubpage(IDS_SETTINGS_BLUETOOTH_SAVED_DEVICES,
+ mojom::Subpage::kBluetoothSavedDevices,
+ mojom::Subpage::kBluetoothDevices,
+ mojom::SearchResultIcon::kBluetooth,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kBluetoothSavedDevicesSubpagePath);
}
void BluetoothSection::AdapterPresentChanged(device::BluetoothAdapter* adapter,
@@ -469,6 +520,7 @@ void BluetoothSection::UpdateSearchTags() {
updater.RemoveSearchTags(GetBluetoothOffSearchConcepts());
updater.RemoveSearchTags(GetFastPairOnSearchConcepts());
updater.RemoveSearchTags(GetFastPairOffSearchConcepts());
+ updater.RemoveSearchTags(GetFastPairSavedDevicesSearchConcepts());
updater.RemoveSearchTags(GetBluetoothConnectableSearchConcepts());
updater.RemoveSearchTags(GetBluetoothConnectedSearchConcepts());
updater.RemoveSearchTags(GetBluetoothPairableSearchConcepts());
@@ -486,6 +538,10 @@ void BluetoothSection::UpdateSearchTags() {
} else {
updater.AddSearchTags(GetFastPairOffSearchConcepts());
}
+
+ if (features::IsFastPairSavedDevicesEnabled()) {
+ updater.AddSearchTags(GetFastPairSavedDevicesSearchConcepts());
+ }
}
if (!bluetooth_adapter_->IsPowered()) {
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 20351bfec63..3837a293b14 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
@@ -7,7 +7,6 @@
#include <memory>
#include <utility>
-#include "ash/components/audio/sounds.h"
#include "base/base64.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -36,6 +35,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/ash/components/audio/sounds.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_image/user_image.h"
#include "components/user_manager/user_manager.h"
@@ -64,7 +64,10 @@ using ::content::BrowserThread;
} // namespace
ChangePictureHandler::ChangePictureHandler()
- : previous_image_index_(user_manager::User::USER_IMAGE_INVALID) {
+ : previous_image_index_(user_manager::User::USER_IMAGE_INVALID),
+ camera_presence_notifier_(
+ base::BindRepeating(&ChangePictureHandler::SetCameraPresent,
+ base::Unretained(this))) {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
audio::SoundsManager* manager = audio::SoundsManager::Get();
manager->Initialize(static_cast<int>(Sound::kObjectDelete),
@@ -109,7 +112,7 @@ void ChangePictureHandler::RegisterMessages() {
void ChangePictureHandler::OnJavascriptAllowed() {
user_manager_observation_.Observe(user_manager::UserManager::Get());
- camera_observation_.Observe(CameraPresenceNotifier::GetInstance());
+ camera_presence_notifier_.Start();
}
void ChangePictureHandler::OnJavascriptDisallowed() {
@@ -117,20 +120,15 @@ void ChangePictureHandler::OnJavascriptDisallowed() {
user_manager::UserManager::Get()));
user_manager_observation_.Reset();
- DCHECK(camera_observation_.IsObservingSource(
- CameraPresenceNotifier::GetInstance()));
- camera_observation_.Reset();
+ camera_presence_notifier_.Stop();
user_image_file_selector_.reset();
}
void ChangePictureHandler::SendDefaultImages() {
- base::DictionaryValue result;
- std::unique_ptr<base::ListValue> current_default_images =
- default_user_image::GetCurrentImageSetAsListValue();
- result.SetKey(
- "current_default_images",
- base::Value::FromUniquePtrValue(std::move(current_default_images)));
+ base::Value::Dict result;
+ result.Set("current_default_images",
+ default_user_image::GetCurrentImageSetAsListValue());
FireWebUIListener("default-images-changed", result);
}
@@ -237,17 +235,16 @@ void ChangePictureHandler::SendSelectedImage() {
previous_image_bytes_ = nullptr;
previous_image_format_ = user_manager::UserImage::FORMAT_UNKNOWN;
- base::DictionaryValue result;
- result.SetStringPath(
- "url", default_user_image::GetDefaultImageUrl(previous_image_index_)
+ base::Value::Dict result;
+ result.Set("url",
+ default_user_image::GetDefaultImageUrl(previous_image_index_)
.spec());
- auto source_info = default_user_image::GetDefaultImageSourceInfo(
- previous_image_index_);
+ auto source_info =
+ default_user_image::GetDeprecatedDefaultImageSourceInfo(
+ previous_image_index_);
if (source_info.has_value()) {
- result.SetStringPath("author", l10n_util::GetStringUTF16(std::move(
- source_info.value().author_id)));
- result.SetStringPath("website", l10n_util::GetStringUTF16(std::move(
- source_info.value().website_id)));
+ result.Set("author", std::move(source_info.value().author));
+ result.Set("website", source_info.value().website.spec());
}
FireWebUIListener("preview-deprecated-image", result);
}
@@ -384,10 +381,6 @@ void ChangePictureHandler::SetCameraPresent(bool present) {
FireWebUIListener("camera-presence-changed", base::Value(present));
}
-void ChangePictureHandler::OnCameraPresenceCheckDone(bool is_camera_present) {
- SetCameraPresent(is_camera_present);
-}
-
void ChangePictureHandler::OnUserImageChanged(const user_manager::User& user) {
// Not initialized yet.
if (previous_image_index_ == user_manager::User::USER_IMAGE_INVALID)
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
index 7653e9114c8..275a877de03 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h
@@ -25,8 +25,7 @@ namespace settings {
// ChromeOS user image settings page UI handler.
class ChangePictureHandler : public ::settings::SettingsPageUIHandler,
public user_manager::UserManager::Observer,
- public ImageDecoder::ImageRequest,
- public CameraPresenceNotifier::Observer {
+ public ImageDecoder::ImageRequest {
public:
ChangePictureHandler();
@@ -40,9 +39,6 @@ class ChangePictureHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
- // CameraPresenceNotifier::Observer implementation:
- void OnCameraPresenceCheckDone(bool is_camera_present) override;
-
private:
friend class ChangePictureHandlerTest;
@@ -126,9 +122,8 @@ class ChangePictureHandler : public ::settings::SettingsPageUIHandler,
base::ScopedObservation<user_manager::UserManager,
user_manager::UserManager::Observer>
user_manager_observation_{this};
- base::ScopedObservation<CameraPresenceNotifier,
- CameraPresenceNotifier::Observer>
- camera_observation_{this};
+
+ ash::CameraPresenceNotifier camera_presence_notifier_;
std::unique_ptr<ash::UserImageFileSelector> user_image_file_selector_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler_unittest.cc
index 624c1a406c6..bc0832c7fa7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler_unittest.cc
@@ -108,20 +108,20 @@ class ChangePictureHandlerTest : public testing::Test {
}
void SelectNewDefaultImage(int default_image_index) {
- base::ListValue args;
+ base::Value::List args;
args.Append(
default_user_image::GetDefaultImageUrl(default_image_index).spec());
args.Append("default");
- web_ui_->HandleReceivedMessage("selectImage", &args);
+ web_ui_->HandleReceivedMessage("selectImage", args);
}
void SelectProfileImage() {
- base::ListValue args;
+ base::Value::List args;
args.Append("empty url");
args.Append("profile");
- web_ui_->HandleReceivedMessage("selectImage", &args);
+ web_ui_->HandleReceivedMessage("selectImage", args);
}
void SelectImageFromFile(const base::FilePath& path) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn
index 24ae25da1ea..bec584b4c9e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn
@@ -12,4 +12,5 @@ mojom("mojom") {
"routes.mojom",
"setting.mojom",
]
+ webui_module_path = "/"
}
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 6c64f4082dd..3fe3d92f38e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
@@ -47,6 +47,7 @@ enum Subpage {
// Bluetooth section.
kBluetoothDevices = 100,
kBluetoothDeviceDetail = 101,
+ kBluetoothSavedDevices = 102,
// MultiDevice section.
kMultiDeviceFeatures = 200,
@@ -75,13 +76,14 @@ enum Subpage {
// Note: Value 406 was for deprecated DLC Subpage - see
// https://crbug.com/1108093. Do not reuse.
kPower = 407,
+ kAudio = 408,
// Personalization section.
kChangePicture = 500,
- kAmbientMode = 501,
+ // 501 was used for kAmbientMode. Do not reuse.
// Note: Value 502 was for deprecated kAmbientModePhotos. Do not reuse.
- kAmbientModeGooglePhotosAlbum = 503,
- kAmbientModeArtGalleryAlbum = 504,
+ // 503 was used for kAmbientModeGooglePhotosAlbum. Do not reuse.
+ // 504 was used for kAmbientModeArtGalleryAlbum. Do not reuse.
// 505 was used for kWallpaper. Do not reuse.
// 506 was used for kWallpaperImages. Do not reuse.
// 507 was used for kDarkMode. Do not reuse.
@@ -143,6 +145,11 @@ enum Subpage {
kTextToSpeech = 1502,
kSwitchAccessOptions = 1503,
kCaptions = 1504,
+ kTextToSpeechPage = 1505,
+ kDisplayAndMagnification = 1506,
+ kKeyboardAndTextInput = 1507,
+ kCursorAndTouchpad = 1508,
+ kAudioAndCaptions = 1509,
// Note: Reset section has no subpages.
@@ -170,6 +177,7 @@ const string kVpnDetailsSubpagePath = "networkDetail";
const string kBluetoothSectionPath = "bluetooth";
const string kBluetoothDevicesSubpagePath = "bluetoothDevices";
const string kBluetoothDeviceDetailSubpagePath = "bluetoothDeviceDetail";
+const string kBluetoothSavedDevicesSubpagePath = "bluetoothSavedDevices";
// MultiDevice section.
const string kMultiDeviceSectionPath = "multidevice";
@@ -190,6 +198,7 @@ const string kPointersSubpagePath = "pointer-overlay";
const string kKeyboardSubpagePath = "keyboard-overlay";
const string kStylusSubpagePath = "stylus";
const string kDisplaySubpagePath = "display";
+const string kAudioSubpagePath = "audio";
const string kStorageSubpagePath = "storage";
const string kExternalStorageSubpagePath = "storage/externalStoragePreferences";
const string kPowerSubpagePath = "power";
@@ -197,11 +206,6 @@ const string kPowerSubpagePath = "power";
// Personalization section.
const string kPersonalizationSectionPath = "personalization";
const string kChangePictureSubpagePath = "changePicture";
-const string kAmbientModeSubpagePath = "ambientMode";
-const string kAmbientModeGooglePhotosAlbumSubpagePath =
- "ambientMode/photos?topicSource=0";
-const string kAmbientModeArtGalleryAlbumSubpagePath =
- "ambientMode/photos?topicSource=1";
// Search and Assistant section.
const string kSearchAndAssistantSectionPath = "osSearch";
@@ -265,6 +269,11 @@ const string kPrintingDetailsSubpagePath = "cupsPrinters";
// Accessibility section.
const string kAccessibilitySectionPath = "osAccessibility";
const string kManageAccessibilitySubpagePath = "manageAccessibility";
+const string kTextToSpeechPagePath = "textToSpeech";
+const string kDisplayAndMagnificationSubpagePath = "displayAndMagnification";
+const string kKeyboardAndTextInputSubpagePath = "keyboardAndTextInput";
+const string kCursorAndTouchpadSubpagePath = "cursorAndTouchpad";
+const string kAudioAndCaptionsSubpagePath = "audioAndCaptions";
const string kTextToSpeechSubpagePath = "manageAccessibility/tts";
const string kSwitchAccessOptionsSubpagePath =
"manageAccessibility/switchAccess";
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 a352a0eae1e..26201d1cfd1 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
@@ -53,6 +53,7 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
chromeos::settings::mojom::kKeyboardSubpagePath,
chromeos::settings::mojom::kStylusSubpagePath,
chromeos::settings::mojom::kDisplaySubpagePath,
+ chromeos::settings::mojom::kAudioSubpagePath,
chromeos::settings::mojom::kStorageSubpagePath,
chromeos::settings::mojom::kExternalStorageSubpagePath,
chromeos::settings::mojom::kPowerSubpagePath,
@@ -60,7 +61,6 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
// Personalization section.
chromeos::settings::mojom::kPersonalizationSectionPath,
chromeos::settings::mojom::kChangePictureSubpagePath,
- chromeos::settings::mojom::kAmbientModeSubpagePath,
// Search and Assistant section.
chromeos::settings::mojom::kSearchAndAssistantSectionPath,
@@ -118,6 +118,11 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
// Accessibility section.
chromeos::settings::mojom::kAccessibilitySectionPath,
chromeos::settings::mojom::kManageAccessibilitySubpagePath,
+ chromeos::settings::mojom::kTextToSpeechPagePath,
+ chromeos::settings::mojom::kDisplayAndMagnificationSubpagePath,
+ chromeos::settings::mojom::kKeyboardAndTextInputSubpagePath,
+ chromeos::settings::mojom::kCursorAndTouchpadSubpagePath,
+ chromeos::settings::mojom::kAudioAndCaptionsSubpagePath,
chromeos::settings::mojom::kTextToSpeechSubpagePath,
chromeos::settings::mojom::kSwitchAccessOptionsSubpagePath,
chromeos::settings::mojom::kCaptionsSubpagePath,
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 0642fe06df0..e5b6a1ce144 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
@@ -47,6 +47,7 @@ enum Setting {
kBluetoothPairDevice = 103,
kBluetoothUnpairDevice = 104,
kFastPairOnOff = 105,
+ kFastPairSavedDevices= 106,
// MultiDevice section.
kSetUpMultiDevice = 200,
@@ -141,8 +142,8 @@ enum Setting {
// Personalization section.
kOpenWallpaper = 500,
- kAmbientModeOnOff = 501,
- kAmbientModeSource = 502,
+ // 501 was used for kAmbientModeOnOff. Do not reuse.
+ // 502 was used for kAmbientModeSource. Do not reuse.
kChangeDeviceAccountImage = 503,
// Note: Values 504, 505, and 506 were for deprecated
// kAmbientModeUpdatePhotosContainers, kDarkModeOnOff and
@@ -206,6 +207,7 @@ enum Setting {
kSnoopingProtection = 1114,
kQuickDim = 1115,
kCameraOnOff = 1116,
+ kMicrophoneOnOff = 1117,
// Languages and Input section.
kAddLanguage = 1200,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
index dbe5e5257cb..c2dc469b1e6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -15,16 +15,19 @@
#include "chrome/browser/ash/crostini/crostini_installer.h"
#include "chrome/browser/ash/crostini/crostini_port_forwarder.h"
#include "chrome/browser/ash/crostini/crostini_pref_names.h"
-#include "chrome/browser/ash/crostini/crostini_terminal.h"
#include "chrome/browser/ash/crostini/crostini_types.mojom.h"
#include "chrome/browser/ash/crostini/crostini_util.h"
#include "chrome/browser/ash/file_manager/path_util.h"
+#include "chrome/browser/ash/guest_os/guest_os_pref_names.h"
+#include "chrome/browser/ash/guest_os/guest_os_session_tracker.h"
+#include "chrome/browser/ash/guest_os/guest_os_terminal.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
+#include "components/services/app_service/public/cpp/intent_util.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
@@ -205,7 +208,7 @@ void CrostiniHandler::OnJavascriptAllowed() {
// Observe changes to containers in general
pref_change_registrar_.Add(
- crostini::prefs::kCrostiniContainers,
+ guest_os::prefs::kGuestOsContainers,
base::BindRepeating(&CrostiniHandler::HandleRequestContainerInfo,
handler_weak_ptr_factory_.GetWeakPtr(),
base::Value::List()));
@@ -241,28 +244,27 @@ void CrostiniHandler::HandleRequestRemoveCrostini(
namespace {
-base::Value CrostiniDiskInfoToValue(
+base::Value::Dict CrostiniDiskInfoToValue(
std::unique_ptr<crostini::CrostiniDiskInfo> disk_info) {
- base::Value disk_value(base::Value::Type::DICTIONARY);
+ base::Value::Dict disk_value;
if (!disk_info) {
- disk_value.SetBoolKey("succeeded", false);
+ disk_value.Set("succeeded", false);
return disk_value;
}
- disk_value.SetBoolKey("succeeded", true);
- disk_value.SetBoolKey("canResize", disk_info->can_resize);
- disk_value.SetBoolKey("isUserChosenSize", disk_info->is_user_chosen_size);
- disk_value.SetBoolKey("isLowSpaceAvailable",
- disk_info->is_low_space_available);
- disk_value.SetIntKey("defaultIndex", disk_info->default_index);
- base::Value ticks(base::Value::Type::LIST);
+ disk_value.Set("succeeded", true);
+ disk_value.Set("canResize", disk_info->can_resize);
+ disk_value.Set("isUserChosenSize", disk_info->is_user_chosen_size);
+ disk_value.Set("isLowSpaceAvailable", disk_info->is_low_space_available);
+ disk_value.Set("defaultIndex", disk_info->default_index);
+ base::Value::List ticks;
for (const auto& tick : disk_info->ticks) {
- base::Value t(base::Value::Type::DICTIONARY);
- t.SetDoubleKey("value", static_cast<double>(tick->value));
- t.SetStringKey("ariaValue", tick->aria_value);
- t.SetStringKey("label", tick->label);
+ base::Value::Dict t;
+ t.Set("value", static_cast<double>(tick->value));
+ t.Set("ariaValue", tick->aria_value);
+ t.Set("label", tick->label);
ticks.Append(std::move(t));
}
- disk_value.SetKey("ticks", std::move(ticks));
+ disk_value.Set("ticks", std::move(ticks));
return disk_value;
}
} // namespace
@@ -270,7 +272,7 @@ base::Value CrostiniDiskInfoToValue(
void CrostiniHandler::HandleExportCrostiniContainer(
const base::Value::List& args) {
CHECK_EQ(1U, args.size());
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
VLOG(1) << "Exporting = " << container_id;
crostini::CrostiniExportImport::GetForProfile(profile_)->ExportContainer(
@@ -280,7 +282,7 @@ void CrostiniHandler::HandleExportCrostiniContainer(
void CrostiniHandler::HandleImportCrostiniContainer(
const base::Value::List& args) {
CHECK_EQ(1U, args.size());
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
VLOG(1) << "Importing = " << container_id;
crostini::CrostiniExportImport::GetForProfile(profile_)->ImportContainer(
container_id, web_ui()->GetWebContents());
@@ -332,7 +334,7 @@ void CrostiniHandler::OnCrostiniDialogStatusChanged(
}
void CrostiniHandler::OnContainerOsReleaseChanged(
- const crostini::ContainerId& container_id,
+ const guest_os::GuestId& container_id,
bool can_upgrade) {
if (crostini::CrostiniFeatures::Get()->IsContainerUpgradeUIAllowed(
profile_) &&
@@ -403,8 +405,8 @@ void CrostiniHandler::OnCanDisableArcAdbSideloading(
power_manager::REQUEST_RESTART_FOR_USER, "disable adb sideloading");
}
-void CrostiniHandler::LaunchTerminal(apps::mojom::IntentPtr intent) {
- crostini::LaunchTerminalWithIntent(
+void CrostiniHandler::LaunchTerminal(apps::IntentPtr intent) {
+ guest_os::LaunchTerminalWithIntent(
profile_, display::Screen::GetScreen()->GetPrimaryDisplay().id(),
std::move(intent), base::DoNothing());
}
@@ -477,7 +479,8 @@ void CrostiniHandler::HandleCrostiniContainerUpgradeAvailableRequest(
OnContainerOsReleaseChanged(crostini::DefaultContainerId(), can_upgrade);
}
-void CrostiniHandler::OnActivePortsChanged(const base::ListValue& activePorts) {
+void CrostiniHandler::OnActivePortsChanged(
+ const base::Value::List& activePorts) {
// Other side listens with cr.addWebUIListener
FireWebUIListener("crostini-port-forwarder-active-ports-changed",
activePorts);
@@ -488,7 +491,7 @@ void CrostiniHandler::HandleAddCrostiniPortForward(
CHECK_EQ(5U, args.size());
std::string callback_id = args[0].GetString();
- crostini::ContainerId container_id(args[1]);
+ guest_os::GuestId container_id(args[1]);
int port_number = args[2].GetInt();
int protocol_type = args[3].GetInt();
std::string label = args[4].GetString();
@@ -513,7 +516,7 @@ void CrostiniHandler::HandleRemoveCrostiniPortForward(
CHECK_EQ(4U, list.size());
std::string callback_id = list[0].GetString();
- crostini::ContainerId container_id(list[1]);
+ guest_os::GuestId container_id(list[1]);
int port_number = list[2].GetInt();
int protocol_type = list[3].GetInt();
@@ -539,7 +542,7 @@ void CrostiniHandler::HandleRemoveAllCrostiniPortForwards(
}
crostini::CrostiniPortForwarder::GetForProfile(profile_)->RemoveAllPorts(
- crostini::ContainerId(args[0]));
+ guest_os::GuestId(args[0]));
}
void CrostiniHandler::HandleActivateCrostiniPortForward(
@@ -548,7 +551,7 @@ void CrostiniHandler::HandleActivateCrostiniPortForward(
CHECK_EQ(4U, list.size());
std::string callback_id = list[0].GetString();
- crostini::ContainerId container_id(list[1]);
+ guest_os::GuestId container_id(list[1]);
int port_number = list[2].GetInt();
int protocol_type = list[3].GetInt();
@@ -571,7 +574,7 @@ void CrostiniHandler::HandleDeactivateCrostiniPortForward(
CHECK_EQ(4U, list.size());
std::string callback_id = list[0].GetString();
- crostini::ContainerId container_id(list[1]);
+ guest_os::GuestId container_id(list[1]);
int port_number = list[2].GetInt();
int protocol_type = list[3].GetInt();
@@ -657,13 +660,13 @@ void CrostiniHandler::HandleCheckCrostiniIsRunning(
}
void CrostiniHandler::OnContainerStarted(
- const crostini::ContainerId& container_id) {
+ const guest_os::GuestId& container_id) {
FireWebUIListener("crostini-status-changed", base::Value(true));
HandleRequestContainerInfo(base::Value::List());
}
void CrostiniHandler::OnContainerShutdown(
- const crostini::ContainerId& container_id) {
+ const guest_os::GuestId& container_id) {
FireWebUIListener("crostini-status-changed", base::Value(false));
HandleRequestContainerInfo(base::Value::List());
}
@@ -679,7 +682,7 @@ void CrostiniHandler::HandleShutdownCrostini(const base::Value::List& args) {
void CrostiniHandler::HandleCreateContainer(const base::Value::List& args) {
CHECK_EQ(4U, args.size());
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
GURL image_server_url(args[1].GetString());
std::string image_alias(args[2].GetString());
base::FilePath ansible_playbook(args[3].GetString());
@@ -713,7 +716,7 @@ void CrostiniHandler::HandleCreateContainer(const base::Value::List& args) {
crostini::CrostiniManager::GetForProfile(profile_)
->RestartCrostiniWithOptions(container_id, std::move(options),
base::DoNothing());
- apps::mojom::IntentPtr intent = apps::mojom::Intent::New();
+ auto intent = std::make_unique<apps::Intent>(apps_util::kIntentActionView);
intent->extras = container_id.ToMap();
// The Terminal will be added as an observer to the above restart.
@@ -727,7 +730,7 @@ void CrostiniHandler::HandleDeleteContainer(const base::Value::List& args) {
return;
}
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
if (container_id == crostini::DefaultContainerId()) {
LOG(ERROR) << "Deleting " << container_id << " not permitted";
return;
@@ -741,8 +744,7 @@ void CrostiniHandler::HandleDeleteContainer(const base::Value::List& args) {
container_id, std::move(options),
base::BindOnce(
[](base::WeakPtr<crostini::CrostiniManager> crostini_manager,
- crostini::ContainerId container_id,
- crostini::CrostiniResult result) {
+ guest_os::GuestId container_id, crostini::CrostiniResult result) {
if (crostini_manager &&
result == crostini::CrostiniResult::SUCCESS) {
crostini_manager->DeleteLxdContainer(container_id,
@@ -759,18 +761,13 @@ void CrostiniHandler::HandleRequestContainerInfo(
base::Value::List container_info_list;
- const base::Value::List& containers =
- profile_->GetPrefs()
- ->Get(crostini::prefs::kCrostiniContainers)
- ->GetList();
-
- for (const auto& dict : containers) {
- crostini::ContainerId container_id(dict);
+ for (const auto& container_id :
+ guest_os::GetContainers(profile_, guest_os::VmType::TERMINA)) {
base::Value::Dict container_info_value;
container_info_value.Set(kIdKey, container_id.ToDictValue());
auto info =
- crostini::CrostiniManager::GetForProfile(profile_)->GetContainerInfo(
- container_id);
+ guest_os::GuestOsSessionTracker::GetForProfile(profile_)->GetInfo(
+ crostini::DefaultContainerId());
if (info) {
container_info_value.Set(kIpv4Key, info->ipv4_address);
}
@@ -785,15 +782,14 @@ void CrostiniHandler::HandleRequestContainerInfo(
container_info_list.Append(std::move(container_info_value));
}
- FireWebUIListener("crostini-container-info",
- base::Value(std::move(container_info_list)));
+ FireWebUIListener("crostini-container-info", container_info_list);
}
void CrostiniHandler::HandleSetContainerBadgeColor(
const base::Value::List& args) {
CHECK_EQ(2U, args.size());
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
SkColor badge_color(args[1].FindDoubleKey("value").value());
crostini::SetContainerBadgeColor(profile_, container_id, badge_color);
@@ -806,7 +802,7 @@ void CrostiniHandler::HandleStopContainer(const base::Value::List& args) {
return;
}
- crostini::ContainerId container_id(args[0]);
+ guest_os::GuestId container_id(args[0]);
if (crostini::ShouldStopVm(profile_, container_id)) {
crostini::CrostiniManager::GetForProfile(profile_)->StopVm(
container_id.vm_name, base::DoNothing());
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
index 83b9778d9e9..101c11fbc45 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -12,10 +12,12 @@
#include "chrome/browser/ash/crostini/crostini_export_import.h"
#include "chrome/browser/ash/crostini/crostini_manager.h"
#include "chrome/browser/ash/crostini/crostini_port_forwarder.h"
+#include "chrome/browser/ash/guest_os/guest_id.h"
#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/dbus/session_manager/session_manager_client.h"
+#include "chromeos/ash/components/dbus/session_manager/session_manager_client.h"
#include "components/prefs/pref_change_registrar.h"
+#include "components/services/app_service/public/cpp/intent.h"
class Profile;
@@ -60,7 +62,7 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
void OnCrostiniDialogStatusChanged(crostini::DialogType dialog_type,
bool open) override;
// crostini::CrostiniContainerPropertiesObserver
- void OnContainerOsReleaseChanged(const crostini::ContainerId& container_id,
+ void OnContainerOsReleaseChanged(const guest_os::GuestId& container_id,
bool can_upgrade) override;
// Handle a request for the CrostiniExportImport operation status.
void HandleCrostiniExportImportOperationStatusRequest(
@@ -81,7 +83,7 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
void OnCanDisableArcAdbSideloading(bool can_change_adb_sideloading);
// Launch the Crostini terminal, with |intent| specifying any non-default
// container id.
- void LaunchTerminal(apps::mojom::IntentPtr intent);
+ void LaunchTerminal(apps::IntentPtr intent);
// Handle a request for showing the container upgrade view.
void HandleRequestContainerUpgradeView(const base::Value::List& args);
// Callback of HandleQueryArcAdbRequest.
@@ -100,7 +102,7 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
// Handles a request for removing all ports.
void HandleRemoveAllCrostiniPortForwards(const base::Value::List& args);
// CrostiniPortForwarder::Observer.
- void OnActivePortsChanged(const base::ListValue& activePorts) override;
+ void OnActivePortsChanged(const base::Value::List& activePorts) override;
// Handles a request for activating an existing port.
void HandleActivateCrostiniPortForward(const base::Value::List& args);
// Handles a request for deactivating an existing port.
@@ -121,9 +123,9 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
// Checks if Crostini is running.
void HandleCheckCrostiniIsRunning(const base::Value::List& args);
// crostini::ContainerStartedObserver
- void OnContainerStarted(const crostini::ContainerId& container_id) override;
+ void OnContainerStarted(const guest_os::GuestId& container_id) override;
// crostini::ContainerShutdownObserver
- void OnContainerShutdown(const crostini::ContainerId& container_id) override;
+ void OnContainerShutdown(const guest_os::GuestId& container_id) override;
// Handles a request to shut down Crostini.
void HandleShutdownCrostini(const base::Value::List& args);
// Handle a request for checking permission for changing ARC adb sideloading.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
index 193b1eeb7ba..3308eaa7e1d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
@@ -14,12 +14,13 @@
#include "chrome/browser/ash/crostini/crostini_features.h"
#include "chrome/browser/ash/crostini/crostini_pref_names.h"
#include "chrome/browser/ash/crostini/crostini_util.h"
+#include "chrome/browser/ash/guest_os/guest_os_pref_names.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -397,9 +398,9 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CROSTINI_CONTAINER_UPGRADE_MESSAGE));
}
- if (auto* pretty_name_value = crostini::GetContainerPrefValue(
+ if (auto* pretty_name_value = guest_os::GetContainerPrefValue(
profile_, crostini::DefaultContainerId(),
- crostini::prefs::kContainerOsPrettyNameKey)) {
+ guest_os::prefs::kContainerOsPrettyNameKey)) {
std::string pretty_name = pretty_name_value->GetString();
html_source->AddString("crostiniContainerUpgradeSubtext",
l10n_util::GetStringFUTF16(
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 17c33749491..4ae582a101f 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
@@ -39,8 +39,7 @@
#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/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
+#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#include "chromeos/printing/ppd_line_reader.h"
#include "chromeos/printing/printer_configuration.h"
#include "chromeos/printing/printer_translator.h"
@@ -102,16 +101,16 @@ void QueryAutoconf(const Uri& uri, PrinterInfoCallback callback) {
}
// Returns the list of |printers| formatted as a CupsPrintersList.
-base::Value BuildCupsPrintersList(const std::vector<Printer>& printers) {
- base::Value printers_list(base::Value::Type::LIST);
+base::Value::Dict BuildCupsPrintersList(const std::vector<Printer>& printers) {
+ base::Value::List printers_list;
for (const Printer& printer : printers) {
// Some of these printers could be invalid but we want to allow the user
// to edit them. crbug.com/778383
printers_list.Append(GetCupsPrinterInfo(printer));
}
- base::Value response(base::Value::Type::DICTIONARY);
- response.SetKey("printerList", std::move(printers_list));
+ base::Value::Dict response;
+ response.Set("printerList", std::move(printers_list));
return response;
}
@@ -119,19 +118,19 @@ base::Value BuildCupsPrintersList(const std::vector<Printer>& printers) {
// CupsPrinterInfo representation. If any of the required fields are missing,
// returns nullptr.
std::unique_ptr<chromeos::Printer> DictToPrinter(
- const base::DictionaryValue& printer_dict) {
- const std::string* printer_id = printer_dict.FindStringKey("printerId");
- const std::string* printer_name = printer_dict.FindStringKey("printerName");
+ const base::Value::Dict& printer_dict) {
+ const std::string* printer_id = printer_dict.FindString("printerId");
+ const std::string* printer_name = printer_dict.FindString("printerName");
const std::string* printer_description =
- printer_dict.FindStringKey("printerDescription");
+ printer_dict.FindString("printerDescription");
const std::string* printer_make_and_model =
- printer_dict.FindStringKey("printerMakeAndModel");
+ printer_dict.FindString("printerMakeAndModel");
const std::string* printer_address =
- printer_dict.FindStringKey("printerAddress");
+ printer_dict.FindString("printerAddress");
const std::string* printer_protocol =
- printer_dict.FindStringKey("printerProtocol");
+ printer_dict.FindString("printerProtocol");
const std::string* print_server_uri =
- printer_dict.FindStringKey("printServerUri");
+ printer_dict.FindString("printServerUri");
if (!printer_id || !printer_name || !printer_description ||
!printer_make_and_model || !printer_address || !printer_protocol ||
!print_server_uri) {
@@ -141,7 +140,7 @@ std::unique_ptr<chromeos::Printer> DictToPrinter(
std::string printer_queue;
// The protocol "socket" does not allow path.
if (*printer_protocol != "socket") {
- if (const std::string* ptr = printer_dict.FindStringKey("printerQueue")) {
+ if (const std::string* ptr = printer_dict.FindString("printerQueue")) {
printer_queue = *ptr;
// Path must start from '/' character.
if (!printer_queue.empty() && printer_queue.front() != '/')
@@ -198,25 +197,23 @@ bool IsValidUriChange(const Printer& existing_printer,
}
// Assumes |info| is a dictionary.
-void SetPpdReference(const Printer::PpdReference& ppd_ref, base::Value* info) {
+void SetPpdReference(const Printer::PpdReference& ppd_ref,
+ base::Value::Dict* info) {
if (!ppd_ref.user_supplied_ppd_url.empty()) {
- info->SetKey("ppdRefUserSuppliedPpdUrl",
- base::Value(ppd_ref.user_supplied_ppd_url));
+ info->Set("ppdRefUserSuppliedPpdUrl", ppd_ref.user_supplied_ppd_url);
} else if (!ppd_ref.effective_make_and_model.empty()) {
- info->SetKey("ppdRefEffectiveMakeAndModel",
- base::Value(ppd_ref.effective_make_and_model));
+ info->Set("ppdRefEffectiveMakeAndModel", ppd_ref.effective_make_and_model);
} else { // Must be autoconf, shouldn't be possible
NOTREACHED() << "Succeeded in PPD matching without emm";
}
}
-Printer::PpdReference GetPpdReference(const base::Value* info) {
- const char ppd_ref_pathname[] = "printerPpdReference";
+Printer::PpdReference GetPpdReference(const base::Value::Dict* info) {
auto* user_supplied_ppd_url =
- info->FindPath({ppd_ref_pathname, "userSuppliedPPDUrl"});
+ info->FindByDottedPath("printerPpdReference.userSuppliedPPDUrl");
auto* effective_make_and_model =
- info->FindPath({ppd_ref_pathname, "effectiveMakeAndModel"});
- auto* autoconf = info->FindPath({ppd_ref_pathname, "autoconf"});
+ info->FindByDottedPath("printerPpdReference.effectiveMakeAndModel");
+ auto* autoconf = info->FindByDottedPath("printerPpdReference.autoconf");
Printer::PpdReference ret;
@@ -383,8 +380,8 @@ void CupsPrintersHandler::HandleGetCupsSavedPrintersList(
std::vector<Printer> printers =
printers_manager_->GetPrinters(PrinterClass::kSaved);
- auto response = BuildCupsPrintersList(printers);
- ResolveJavascriptCallback(base::Value(callback_id), response);
+ ResolveJavascriptCallback(base::Value(callback_id),
+ BuildCupsPrintersList(printers));
}
void CupsPrintersHandler::HandleGetCupsEnterprisePrintersList(
@@ -397,8 +394,8 @@ void CupsPrintersHandler::HandleGetCupsEnterprisePrintersList(
std::vector<Printer> printers =
printers_manager_->GetPrinters(PrinterClass::kEnterprise);
- auto response = BuildCupsPrintersList(printers);
- ResolveJavascriptCallback(base::Value(callback_id), response);
+ ResolveJavascriptCallback(base::Value(callback_id),
+ BuildCupsPrintersList(printers));
}
void CupsPrintersHandler::HandleUpdateCupsPrinter(
@@ -445,10 +442,9 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(
// Printer is deleted here. Do not access after this line.
printers_manager_->RemoveSavedPrinter(printer_id);
- DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient();
- client->CupsRemovePrinter(printer_id,
- base::BindOnce(&OnRemovedPrinter, protocol),
- base::DoNothing());
+ DebugDaemonClient::Get()->CupsRemovePrinter(
+ printer_id, base::BindOnce(&OnRemovedPrinter, protocol),
+ base::DoNothing());
}
void CupsPrintersHandler::HandleGetPrinterInfo(const base::Value::List& args) {
@@ -468,20 +464,19 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::Value::List& args) {
NOTREACHED() << "Dictionary missing";
return;
}
- const base::DictionaryValue& printer_dict =
- base::Value::AsDictionaryValue(printer_value);
+ const base::Value::Dict& printer_dict = printer_value.GetDict();
AllowJavascript();
const std::string* printer_address =
- printer_dict.FindStringKey("printerAddress");
+ printer_dict.FindString("printerAddress");
if (!printer_address) {
NOTREACHED() << "Address missing";
return;
}
std::string printer_queue;
- if (const std::string* ptr = printer_dict.FindStringKey("printerQueue")) {
+ if (const std::string* ptr = printer_dict.FindString("printerQueue")) {
printer_queue = *ptr;
// Path must start from '/' character.
if (!printer_queue.empty() && printer_queue.front() != '/')
@@ -489,7 +484,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::Value::List& args) {
}
const std::string* printer_protocol =
- printer_dict.FindStringKey("printerProtocol");
+ printer_dict.FindString("printerProtocol");
if (!printer_protocol) {
NOTREACHED() << "Protocol missing";
return;
@@ -587,12 +582,12 @@ void CupsPrintersHandler::OnAutoconfQueried(
<< ")";
// Bundle printer metadata
- base::Value info(base::Value::Type::DICTIONARY);
- info.SetKey("makeAndModel", base::Value(make_and_model));
- info.SetKey("autoconf", base::Value(ipp_everywhere));
+ base::Value::Dict info;
+ info.Set("makeAndModel", make_and_model);
+ info.Set("autoconf", ipp_everywhere);
if (ipp_everywhere) {
- info.SetKey("ppdReferenceResolved", base::Value(true));
+ info.Set("ppdReferenceResolved", true);
ResolveJavascriptCallback(base::Value(callback_id), info);
return;
}
@@ -611,18 +606,18 @@ void CupsPrintersHandler::OnAutoconfQueried(
}
void CupsPrintersHandler::OnPpdResolved(const std::string& callback_id,
- base::Value info,
+ base::Value::Dict info,
PpdProvider::CallbackResultCode res,
const Printer::PpdReference& ppd_ref,
const std::string& usb_manufacturer) {
if (res != PpdProvider::CallbackResultCode::SUCCESS) {
- info.SetKey("ppdReferenceResolved", base::Value(false));
+ info.Set("ppdReferenceResolved", false);
ResolveJavascriptCallback(base::Value(callback_id), info);
return;
}
SetPpdReference(ppd_ref, &info);
- info.SetKey("ppdReferenceResolved", base::Value(true));
+ info.Set("ppdReferenceResolved", true);
ResolveJavascriptCallback(base::Value(callback_id), info);
}
@@ -643,8 +638,7 @@ void CupsPrintersHandler::AddOrReconfigurePrinter(const base::Value::List& args,
std::string callback_id = args[0].GetString();
const base::Value& printer_value = args[1];
CHECK(printer_value.is_dict());
- const base::DictionaryValue& printer_dict =
- base::Value::AsDictionaryValue(printer_value);
+ const base::Value::Dict& printer_dict = printer_value.GetDict();
std::unique_ptr<Printer> printer = DictToPrinter(printer_dict);
if (!printer) {
@@ -687,12 +681,12 @@ void CupsPrintersHandler::AddOrReconfigurePrinter(const base::Value::List& args,
// Read PPD selection if it was used.
const std::string* ppd_manufacturer =
- printer_dict.FindStringKey("ppdManufacturer");
- const std::string* ppd_model = printer_dict.FindStringKey("ppdModel");
+ printer_dict.FindString("ppdManufacturer");
+ const std::string* ppd_model = printer_dict.FindString("ppdModel");
// Read user provided PPD if it was used.
const std::string* printer_ppd_path =
- printer_dict.FindStringKey("printerPPDPath");
+ printer_dict.FindString("printerPPDPath");
// Check if the printer already has a valid ppd_reference.
Printer::PpdReference ppd_ref = GetPpdReference(&printer_dict);
@@ -867,8 +861,7 @@ void CupsPrintersHandler::HandleGetCupsPrinterModels(
base::Value::Dict response;
response.Set("success", true);
response.Set("models", base::Value::List());
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(callback_id), response);
return;
}
@@ -921,8 +914,7 @@ void CupsPrintersHandler::ResolveManufacturersDone(
base::Value::Dict response;
response.Set("success", result_code == PpdProvider::SUCCESS);
response.Set("manufacturers", std::move(manufacturers_value));
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(callback_id), response);
}
void CupsPrintersHandler::ResolvePrintersDone(
@@ -940,8 +932,7 @@ void CupsPrintersHandler::ResolvePrintersDone(
base::Value::Dict response;
response.Set("success", result_code == PpdProvider::SUCCESS);
response.Set("models", std::move(printers_value));
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(callback_id), response);
}
void CupsPrintersHandler::FileSelected(const base::FilePath& path,
@@ -1009,8 +1000,7 @@ void CupsPrintersHandler::HandleSetUpCancel(const base::Value::List& args) {
const base::Value& printer_value = args[0];
CHECK(printer_value.is_dict());
- std::unique_ptr<Printer> printer =
- DictToPrinter(base::Value::AsDictionaryValue(printer_value));
+ std::unique_ptr<Printer> printer = DictToPrinter(printer_value.GetDict());
if (printer) {
printers_manager_->RecordSetupAbandoned(*printer);
}
@@ -1029,14 +1019,14 @@ void CupsPrintersHandler::OnPrintersChanged(
UpdateDiscoveredPrinters();
break;
case PrinterClass::kSaved: {
- auto printers_list = BuildCupsPrintersList(printers);
- FireWebUIListener("on-saved-printers-changed", printers_list);
+ FireWebUIListener("on-saved-printers-changed",
+ BuildCupsPrintersList(printers));
break;
}
case PrinterClass::kEnterprise:
- auto enterprise_printers_list = BuildCupsPrintersList(printers);
FireWebUIListener("on-enterprise-printers-changed",
- enterprise_printers_list);
+ BuildCupsPrintersList(printers));
+ break;
}
}
@@ -1057,9 +1047,8 @@ void CupsPrintersHandler::UpdateDiscoveredPrinters() {
PRINTER_LOG(DEBUG) << "Discovered printers updating. Automatic: "
<< automatic_printers_list.size()
<< " Discovered: " << discovered_printers_list.size();
- FireWebUIListener("on-nearby-printers-changed",
- base::Value(std::move(automatic_printers_list)),
- base::Value(std::move(discovered_printers_list)));
+ FireWebUIListener("on-nearby-printers-changed", automatic_printers_list,
+ discovered_printers_list);
}
void CupsPrintersHandler::HandleAddDiscoveredPrinter(
@@ -1315,8 +1304,8 @@ void CupsPrintersHandler::OnQueryPrintServerCompleted(
server_printers_fetcher_.reset();
// Create result value and finish the callback.
- base::Value result_dict = BuildCupsPrintersList(printers);
- ResolveJavascriptCallback(base::Value(callback_id), result_dict);
+ ResolveJavascriptCallback(base::Value(callback_id),
+ BuildCupsPrintersList(printers));
}
void CupsPrintersHandler::HandleOpenPrintManagementApp(
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 a271068a293..62b64a39faa 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
@@ -108,7 +108,7 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
// Callback for PPD matching attempts;
void OnPpdResolved(const std::string& callback_id,
- base::Value info,
+ base::Value::Dict info,
PpdProvider::CallbackResultCode res,
const Printer::PpdReference& ppd_ref,
const std::string& usb_manufacturer);
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 9e9afa7324e..f8673e683a0 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
@@ -19,8 +19,7 @@
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ash/components/dbus/concierge/concierge_client.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
+#include "chromeos/ash/components/dbus/debug_daemon/debug_daemon_client.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -196,11 +195,11 @@ class CupsPrintersHandlerTest : public testing::Test {
};
TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) {
- DBusThreadManager::Initialize();
ConciergeClient::InitializeFake(
/*fake_cicerone_client=*/nullptr);
+ DebugDaemonClient::InitializeFake();
- DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient();
+ DebugDaemonClient* client = DebugDaemonClient::Get();
client->CupsAddAutoConfiguredPrinter("testprinter1", "fakeuri",
base::BindOnce(&AddedPrinter));
@@ -225,8 +224,8 @@ TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) {
EXPECT_FALSE(expected);
profile_.reset();
+ DebugDaemonClient::Shutdown();
ConciergeClient::Shutdown();
- DBusThreadManager::Shutdown();
}
TEST_F(CupsPrintersHandlerTest, VerifyOnlyPpdFilesAllowed) {
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 6c0bf5eb575..a1c07c78752 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
@@ -128,7 +128,7 @@ void DateTimeHandler::HandleGetTimeZones(const base::Value::List& args) {
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, *system::GetTimezoneList());
+ ResolveJavascriptCallback(callback_id, system::GetTimezoneList());
}
void DateTimeHandler::HandleShowSetDateTimeUI(const base::Value::List& args) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc
index 9c65bcd0e2b..5280753efb3 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc
@@ -12,8 +12,8 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_display_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_display_handler.h
index d3a373071d4..ab829bf28e6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_display_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_display_handler.h
@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_DISPLAY_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_DISPLAY_HANDLER_H_
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chromeos/crosapi/mojom/cros_display_config.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -30,7 +30,8 @@ class DisplayHandler : public ::settings::SettingsPageUIHandler {
void HandleHighlightDisplay(const base::Value::List& args);
void HandleDragDisplayDelta(const base::Value::List& args);
- mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config_;
+ mojo::Remote<crosapi::mojom::CrosDisplayConfigController>
+ cros_display_config_;
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
index a80dad0c76f..ddcb882160e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
@@ -140,24 +140,20 @@ void KeyboardHandler::UpdateShowKeys() {
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kHasChromeOSKeyboard);
- base::Value keyboard_params(base::Value::Type::DICTIONARY);
- keyboard_params.SetKey("showCapsLock", base::Value(has_caps_lock));
- keyboard_params.SetKey(
- "showExternalMetaKey",
- base::Value(keyboards_state.has_external_generic_keyboard));
- keyboard_params.SetKey(
- "showAppleCommandKey",
- base::Value(keyboards_state.has_external_apple_keyboard));
+ base::Value::Dict keyboard_params;
+ keyboard_params.Set("showCapsLock", has_caps_lock);
+ keyboard_params.Set("showExternalMetaKey",
+ keyboards_state.has_external_generic_keyboard);
+ keyboard_params.Set("showAppleCommandKey",
+ keyboards_state.has_external_apple_keyboard);
// An external (USB/BT) ChromeOS keyboard is treated similarly to an internal
// ChromeOS keyboard. i.e. they are functionally the same.
- keyboard_params.SetKey(
- "hasLauncherKey",
- base::Value(keyboards_state.has_launcher_key ||
- keyboards_state.has_external_chromeos_keyboard));
+ keyboard_params.Set("hasLauncherKey",
+ keyboards_state.has_launcher_key ||
+ keyboards_state.has_external_chromeos_keyboard);
const bool show_assistant_key_settings = ui::DeviceKeyboardHasAssistantKey();
- keyboard_params.SetKey("hasAssistantKey",
- base::Value(show_assistant_key_settings));
+ keyboard_params.Set("hasAssistantKey", show_assistant_key_settings);
FireWebUIListener(kShowKeysChangedName, keyboard_params);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc
index 854e5b291ae..793262794c7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc
@@ -51,13 +51,13 @@ void DeviceNameHandler::RegisterMessages() {
base::Unretained(this)));
}
-base::Value DeviceNameHandler::GetDeviceNameMetadata() const {
- base::Value metadata(base::Value::Type::DICTIONARY);
+base::Value::Dict DeviceNameHandler::GetDeviceNameMetadata() const {
+ base::Value::Dict metadata;
DeviceNameStore::DeviceNameMetadata device_name_metadata =
device_name_store_->GetDeviceNameMetadata();
- metadata.SetStringKey(kMetadataFirstKey, device_name_metadata.device_name);
- metadata.SetIntKey(kMetadataSecondKey,
- static_cast<int>(device_name_metadata.device_name_state));
+ metadata.Set(kMetadataFirstKey, device_name_metadata.device_name);
+ metadata.Set(kMetadataSecondKey,
+ static_cast<int>(device_name_metadata.device_name_state));
return metadata;
}
@@ -79,12 +79,12 @@ void DeviceNameHandler::HandleNotifyReadyForDeviceName(
const base::Value::List& args) {
AllowJavascript();
FireWebUIListener("settings.updateDeviceNameMetadata",
- base::Value(GetDeviceNameMetadata()));
+ GetDeviceNameMetadata());
}
void DeviceNameHandler::OnDeviceNameMetadataChanged() {
FireWebUIListener("settings.updateDeviceNameMetadata",
- base::Value(GetDeviceNameMetadata()));
+ GetDeviceNameMetadata());
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
index c27d5f0304e..066a2370f41 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
@@ -41,7 +41,7 @@ class DeviceNameHandler : public ::settings::SettingsPageUIHandler,
explicit DeviceNameHandler(DeviceNameStore* device_name_store);
- base::Value GetDeviceNameMetadata() const;
+ base::Value::Dict GetDeviceNameMetadata() const;
DeviceNameStore* device_name_store_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc
index 49ed6735661..1c727924e34 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc
@@ -68,15 +68,15 @@ class DeviceNameHandlerTest : public testing::Test {
EXPECT_EQ("settings.updateDeviceNameMetadata",
call_data.arg1()->GetString());
- const base::DictionaryValue* returned_data;
- ASSERT_TRUE(call_data.arg2()->GetAsDictionary(&returned_data));
+ ASSERT_TRUE(call_data.arg2()->is_dict());
+ const base::Value::Dict& returned_data = call_data.arg2()->GetDict();
- std::string device_name;
- returned_data->GetString("deviceName", &device_name);
- EXPECT_EQ(expected_device_name, device_name);
+ const std::string* device_name = returned_data.FindString("deviceName");
+ ASSERT_TRUE(device_name);
+ EXPECT_EQ(expected_device_name, *device_name);
absl::optional<int> device_name_state =
- returned_data->FindIntKey("deviceNameState");
+ returned_data.FindInt("deviceNameState");
ASSERT_TRUE(device_name_state);
EXPECT_EQ(static_cast<int>(expected_device_name_state), *device_name_state);
}
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 55ee8bb4db8..a8c3aaee0c3 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
@@ -16,7 +16,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/ash/components/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
@@ -116,29 +116,28 @@ PowerHandler::TestAPI::TestAPI(PowerHandler* handler) : handler_(handler) {}
PowerHandler::TestAPI::~TestAPI() = default;
void PowerHandler::TestAPI::RequestPowerManagementSettings() {
- base::Value args(base::Value::Type::LIST);
- handler_->HandleRequestPowerManagementSettings(args.GetList());
+ handler_->HandleRequestPowerManagementSettings(base::Value::List());
}
void PowerHandler::TestAPI::SetIdleBehavior(IdleBehavior behavior,
bool when_on_ac) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(static_cast<int>(behavior));
args.Append(when_on_ac);
- handler_->HandleSetIdleBehavior(args.GetList());
+ handler_->HandleSetIdleBehavior(args);
}
void PowerHandler::TestAPI::SetLidClosedBehavior(
PowerPolicyController::Action behavior) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(behavior);
- handler_->HandleSetLidClosedBehavior(args.GetList());
+ handler_->HandleSetLidClosedBehavior(args);
}
void PowerHandler::TestAPI::SetAdaptiveCharging(bool enabled) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(enabled);
- handler_->HandleSetAdaptiveCharging(args.GetList());
+ handler_->HandleSetAdaptiveCharging(args);
}
PowerHandler::PowerHandler(PrefService* prefs) : prefs_(prefs) {}
@@ -346,15 +345,15 @@ void PowerHandler::SendBatteryStatus() {
base::NumberToString16(percent));
}
- base::DictionaryValue battery_dict;
- battery_dict.SetBoolKey(
+ base::Value::Dict battery_dict;
+ battery_dict.Set(
"present",
proto->battery_state() !=
power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT);
- battery_dict.SetBoolKey("charging", charging);
- battery_dict.SetBoolKey("calculating", calculating);
- battery_dict.SetIntKey("percent", percent);
- battery_dict.SetStringKey("statusText", status_text);
+ battery_dict.Set("charging", charging);
+ battery_dict.Set("calculating", calculating);
+ battery_dict.Set("percent", percent);
+ battery_dict.Set("statusText", status_text);
FireWebUIListener("battery-status-changed", battery_dict);
}
@@ -375,7 +374,7 @@ void PowerHandler::SendPowerSources() {
}
FireWebUIListener(
- "power-sources-changed", base::Value(std::move(sources_list)),
+ "power-sources-changed", sources_list,
base::Value(proto->external_power_source_id()),
base::Value(proto->external_power() ==
power_manager::PowerSupplyProperties_ExternalPower_USB));
@@ -407,26 +406,25 @@ void PowerHandler::SendPowerManagementSettings(bool force) {
return;
}
- base::DictionaryValue dict;
- base::Value* list = dict.SetKey(kPossibleAcIdleBehaviorsKey,
- base::Value(base::Value::Type::LIST));
+ base::Value::Dict dict;
+ base::Value* list =
+ dict.Set(kPossibleAcIdleBehaviorsKey, base::Value::List());
for (auto idle_behavior : ac_idle_info.possible_behaviors)
list->Append(static_cast<int>(idle_behavior));
- list = dict.SetKey(kPossibleBatteryIdleBehaviorsKey,
- base::Value(base::Value::Type::LIST));
+ list = dict.Set(kPossibleBatteryIdleBehaviorsKey, base::Value::List());
for (auto idle_behavior : battery_idle_info.possible_behaviors)
list->Append(static_cast<int>(idle_behavior));
- dict.SetIntKey(kCurrentAcIdleBehaviorKey,
- static_cast<int>(ac_idle_info.current_behavior));
- dict.SetIntKey(kCurrentBatteryIdleBehaviorKey,
- static_cast<int>(battery_idle_info.current_behavior));
- dict.SetIntKey(kLidClosedBehaviorKey, lid_closed_behavior);
- dict.SetBoolKey(kAcIdleManagedKey, ac_idle_info.is_managed);
- dict.SetBoolKey(kBatteryIdleManagedKey, battery_idle_info.is_managed);
- dict.SetBoolKey(kLidClosedControlledKey, lid_closed_controlled);
- dict.SetBoolKey(kHasLidKey, has_lid);
- dict.SetBoolKey(kAdaptiveChargingKey, adaptive_charging);
+ dict.Set(kCurrentAcIdleBehaviorKey,
+ static_cast<int>(ac_idle_info.current_behavior));
+ dict.Set(kCurrentBatteryIdleBehaviorKey,
+ static_cast<int>(battery_idle_info.current_behavior));
+ dict.Set(kLidClosedBehaviorKey, lid_closed_behavior);
+ dict.Set(kAcIdleManagedKey, ac_idle_info.is_managed);
+ dict.Set(kBatteryIdleManagedKey, battery_idle_info.is_managed);
+ dict.Set(kLidClosedControlledKey, lid_closed_controlled);
+ dict.Set(kHasLidKey, has_lid);
+ dict.Set(kAdaptiveChargingKey, adaptive_charging);
FireWebUIListener(kPowerManagementSettingsChangedName, dict);
last_ac_idle_info_ = ac_idle_info;
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 4a8d78f9b95..9cc12f75782 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
@@ -16,13 +16,13 @@
#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/webui/settings/ash/search/search_tag_registry.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"
#include "chrome/browser/ui/webui/settings/chromeos/device_power_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.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/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
@@ -755,6 +755,17 @@ void AddDeviceStorageStrings(content::WebUIDataSource* html_source,
base::ASCIIToUTF16(chrome::kArcExternalStorageLearnMoreURL)));
}
+void AddDeviceAudioStrings(content::WebUIDataSource* html_source) {
+ static constexpr webui::LocalizedString kAudioStrings[] = {
+ {"audioTitle", IDS_SETTINGS_AUDIO_TITLE},
+ {"audioOutputTitle", IDS_SETTINGS_AUDIO_OUTPUT_TITLE},
+ {"audioVolumeTitle", IDS_SETTINGS_AUDIO_VOLUME_TITLE},
+ {"audioDeviceTitle", IDS_SETTINGS_AUDIO_DEVICE_TITLE},
+ };
+
+ html_source->AddLocalizedStrings(kAudioStrings);
+}
+
void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kPowerStrings[] = {
{"powerTitle", IDS_SETTINGS_POWER_TITLE},
@@ -847,7 +858,8 @@ DeviceSection::DeviceSection(Profile* profile,
// Display search tags are added/removed dynamically.
ash::BindCrosDisplayConfigController(
cros_display_config_.BindNewPipeAndPassReceiver());
- mojo::PendingAssociatedRemote<ash::mojom::CrosDisplayConfigObserver> observer;
+ mojo::PendingAssociatedRemote<crosapi::mojom::CrosDisplayConfigObserver>
+ observer;
cros_display_config_observer_receiver_.Bind(
observer.InitWithNewEndpointAndPassReceiver());
cros_display_config_->AddObserver(std::move(observer));
@@ -890,6 +902,7 @@ void DeviceSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
AddDeviceKeyboardStrings(html_source);
AddDeviceStylusStrings(html_source);
AddDeviceDisplayStrings(html_source);
+ AddDeviceAudioStrings(html_source);
AddDeviceStorageStrings(
html_source, features::ShouldShowExternalStorageSettings(profile()));
AddDevicePowerStrings(html_source);
@@ -1033,6 +1046,12 @@ void DeviceSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::SearchResultDefaultRank::kMedium,
mojom::kExternalStorageSubpagePath);
+ // Audio.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_AUDIO_TITLE, mojom::Subpage::kAudio,
+ mojom::SearchResultIcon::kAudio, mojom::SearchResultDefaultRank::kMedium,
+ mojom::kAudioSubpagePath);
+
// Power.
generator->RegisterTopLevelSubpage(
IDS_SETTINGS_POWER_TITLE, mojom::Subpage::kPower,
@@ -1126,15 +1145,15 @@ void DeviceSection::PowerChanged(
}
void DeviceSection::OnGetDisplayUnitInfoList(
- std::vector<ash::mojom::DisplayUnitInfoPtr> display_unit_info_list) {
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> display_unit_info_list) {
cros_display_config_->GetDisplayLayoutInfo(base::BindOnce(
&DeviceSection::OnGetDisplayLayoutInfo, base::Unretained(this),
std::move(display_unit_info_list)));
}
void DeviceSection::OnGetDisplayLayoutInfo(
- std::vector<ash::mojom::DisplayUnitInfoPtr> display_unit_info_list,
- ash::mojom::DisplayLayoutInfoPtr display_layout_info) {
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> display_unit_info_list,
+ crosapi::mojom::DisplayLayoutInfoPtr display_layout_info) {
bool has_multiple_displays = display_unit_info_list.size() > 1u;
// Mirroring mode is active if there's at least one display and if there's a
@@ -1151,7 +1170,7 @@ void DeviceSection::OnGetDisplayLayoutInfo(
unified_desktop_mode |= display_unit_info->is_primary &&
display_layout_info->layout_mode ==
- ash::mojom::DisplayLayoutMode::kUnified;
+ crosapi::mojom::DisplayLayoutMode::kUnified;
}
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
@@ -1293,6 +1312,9 @@ void DeviceSection::AddDevicePointersStrings(
html_source->AddBoolean("allowTouchpadHapticClickSettings",
base::FeatureList::IsEnabled(
::features::kAllowTouchpadHapticClickSettings));
+ html_source->AddBoolean(
+ "enableAudioSettingsPage",
+ base::FeatureList::IsEnabled(ash::features::kAudioSettingsPage));
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
index e93e3cc173d..5d8a04bbda0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
@@ -8,11 +8,11 @@
#include <vector>
#include "ash/public/cpp/night_light_controller.h"
-#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/ash/system/pointer_device_observer.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "chromeos/crosapi/mojom/cros_display_config.mojom.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
@@ -35,7 +35,7 @@ class DeviceSection : public OsSettingsSection,
public system::PointerDeviceObserver::Observer,
public ui::InputDeviceEventObserver,
public ash::NightLightController::Observer,
- public ash::mojom::CrosDisplayConfigObserver,
+ public crosapi::mojom::CrosDisplayConfigObserver,
public PowerManagerClient::Observer {
public:
DeviceSection(Profile* profile,
@@ -78,17 +78,18 @@ class DeviceSection : public OsSettingsSection,
void UpdateStylusSearchTags();
void OnGetDisplayUnitInfoList(
- std::vector<ash::mojom::DisplayUnitInfoPtr> display_unit_info_list);
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> display_unit_info_list);
void OnGetDisplayLayoutInfo(
- std::vector<ash::mojom::DisplayUnitInfoPtr> display_unit_info_list,
- ash::mojom::DisplayLayoutInfoPtr display_layout_info);
+ std::vector<crosapi::mojom::DisplayUnitInfoPtr> display_unit_info_list,
+ crosapi::mojom::DisplayLayoutInfoPtr display_layout_info);
void AddDevicePointersStrings(content::WebUIDataSource* html_source);
PrefService* pref_service_;
system::PointerDeviceObserver pointer_device_observer_;
- mojo::Remote<ash::mojom::CrosDisplayConfigController> cros_display_config_;
- mojo::AssociatedReceiver<ash::mojom::CrosDisplayConfigObserver>
+ mojo::Remote<crosapi::mojom::CrosDisplayConfigController>
+ cros_display_config_;
+ mojo::AssociatedReceiver<crosapi::mojom::CrosDisplayConfigObserver>
cros_display_config_observer_receiver_{this};
base::WeakPtrFactory<DeviceSection> weak_ptr_factory_{this};
};
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 b0d5b37bbc8..4bf5aceb173 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
@@ -17,6 +17,7 @@
#include "chrome/browser/ash/arc/arc_util.h"
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/platform_util.h"
+#include "chrome/browser/ui/webui/settings/chromeos/device_storage_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -136,31 +137,6 @@ void StorageHandler::OnJavascriptDisallowed() {
StopObservingEvents();
}
-int64_t StorageHandler::RoundByteSize(int64_t bytes) {
- if (bytes < 0) {
- NOTREACHED() << "Negative bytes value";
- return -1;
- }
-
- if (bytes == 0)
- return 0;
-
- // Subtract one to the original number of bytes.
- bytes--;
- // Set all the lower bits to 1.
- bytes |= bytes >> 1;
- bytes |= bytes >> 2;
- bytes |= bytes >> 4;
- bytes |= bytes >> 8;
- bytes |= bytes >> 16;
- bytes |= bytes >> 32;
- // Add one. The one bit beyond the highest set bit is set to 1. All the lower
- // bits are set to 0.
- bytes++;
-
- return bytes;
-}
-
void StorageHandler::HandleUpdateAndroidEnabled(
const base::Value::List& unused_args) {
// OnJavascriptAllowed() calls ArcSessionManager::AddObserver() later.
@@ -199,14 +175,14 @@ void StorageHandler::HandleUpdateExternalStorages(
}
void StorageHandler::UpdateExternalStorages() {
- base::Value devices(base::Value::Type::LIST);
- for (const auto& itr : DiskMountManager::GetInstance()->mount_points()) {
- const DiskMountManager::MountPointInfo& mount_info = itr.second;
- if (!IsEligibleForAndroidStorage(mount_info.source_path))
+ base::Value::List devices;
+ for (const auto& mount_point :
+ DiskMountManager::GetInstance()->mount_points()) {
+ if (!IsEligibleForAndroidStorage(mount_point.source_path))
continue;
const Disk* disk = DiskMountManager::GetInstance()->FindDiskBySourcePath(
- mount_info.source_path);
+ mount_point.source_path);
// Assigning a dummy UUID for diskless volume for testing.
const std::string uuid = disk ? disk->fs_uuid() : kDummyUuid;
@@ -217,11 +193,11 @@ void StorageHandler::UpdateExternalStorages() {
// That is, we use the base name of mount path instead in such cases.
// TODO(fukino): Share the implementation to compute the volume name with
// Files app. crbug.com/1002535.
- label = base::FilePath(mount_info.mount_path).BaseName().AsUTF8Unsafe();
+ label = base::FilePath(mount_point.mount_path).BaseName().AsUTF8Unsafe();
}
- base::Value device(base::Value::Type::DICTIONARY);
- device.SetKey("uuid", base::Value(uuid));
- device.SetKey("label", base::Value(label));
+ base::Value::Dict device;
+ device.Set("uuid", uuid);
+ device.Set("label", label);
devices.Append(std::move(device));
}
FireWebUIListener("onExternalStoragesUpdated", devices);
@@ -229,17 +205,16 @@ void StorageHandler::UpdateExternalStorages() {
void StorageHandler::OnArcPlayStoreEnabledChanged(bool enabled) {
base::Value::Dict update;
- update.Set(
- kAndroidEnabled,
- base::Value(features::ShouldShowExternalStorageSettings(profile_)));
+ update.Set(kAndroidEnabled,
+ features::ShouldShowExternalStorageSettings(profile_));
content::WebUIDataSource::Update(profile_, source_name_, std::move(update));
}
void StorageHandler::OnMountEvent(
DiskMountManager::MountEvent event,
- chromeos::MountError error_code,
- const DiskMountManager::MountPointInfo& mount_info) {
- if (error_code != chromeos::MountError::MOUNT_ERROR_NONE)
+ ash::MountError error_code,
+ const DiskMountManager::MountPoint& mount_info) {
+ if (error_code != ash::MountError::kNone)
return;
if (!IsEligibleForAndroidStorage(mount_info.source_path))
@@ -343,11 +318,10 @@ void StorageHandler::UpdateOverallStatistics() {
return;
}
- base::DictionaryValue size_stat;
- size_stat.SetStringKey("availableSize", ui::FormatBytes(available_bytes));
- size_stat.SetStringKey("usedSize", ui::FormatBytes(in_use_bytes));
- size_stat.SetDoubleKey("usedRatio",
- static_cast<double>(in_use_bytes) / total_bytes);
+ base::Value::Dict size_stat;
+ size_stat.Set("availableSize", ui::FormatBytes(available_bytes));
+ size_stat.Set("usedSize", ui::FormatBytes(in_use_bytes));
+ size_stat.Set("usedRatio", static_cast<double>(in_use_bytes) / total_bytes);
int storage_space_state =
static_cast<int>(StorageSpaceState::kStorageSpaceNormal);
if (available_bytes < kSpaceCriticallyLowBytes)
@@ -355,7 +329,7 @@ void StorageHandler::UpdateOverallStatistics() {
static_cast<int>(StorageSpaceState::kStorageSpaceCriticallyLow);
else if (available_bytes < kSpaceLowBytes)
storage_space_state = static_cast<int>(StorageSpaceState::kStorageSpaceLow);
- size_stat.SetIntKey("spaceState", storage_space_state);
+ size_stat.Set("spaceState", storage_space_state);
FireWebUIListener(CalculationTypeToEventName(
calculator::SizeCalculator::CalculationType::kTotal),
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 2cf82d2cceb..8256831427a 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
@@ -65,8 +65,8 @@ class StorageHandler : public ::settings::SettingsPageUIHandler,
// ash::disks::DiskMountManager::Observer:
void OnMountEvent(
ash::disks::DiskMountManager::MountEvent event,
- chromeos::MountError error_code,
- const ash::disks::DiskMountManager::MountPointInfo& mount_info) override;
+ ash::MountError error_code,
+ const ash::disks::DiskMountManager::MountPoint& mount_info) override;
// chromeos::settings::calculator::SizeCalculator::Observer:
void OnSizeCalculated(
@@ -76,11 +76,6 @@ class StorageHandler : public ::settings::SettingsPageUIHandler,
// Removes the handler from the list of observers of every observed instances.
void StopObservingEvents();
- protected:
- // Round a given number of bytes up to the next power of 2.
- // Ex: 14 => 16, 150 => 256.
- int64_t RoundByteSize(int64_t bytes);
-
private:
// Handlers of JS messages.
void HandleUpdateAndroidEnabled(const base::Value::List& unused_args);
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 606cf86f0d9..160282f7fb7 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
@@ -22,13 +22,13 @@
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/ui/webui/settings/ash/calculator/size_calculator_test_api.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h"
+#include "chrome/browser/ui/webui/settings/chromeos/device_storage_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/ash/components/dbus/concierge/concierge_client.h"
#include "chromeos/ash/components/dbus/spaced/spaced_client.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
@@ -48,7 +48,6 @@ class TestStorageHandler : public StorageHandler {
: StorageHandler(profile, html_source) {}
// Pull WebUIMessageHandler::set_web_ui() into public so tests can call it.
- using StorageHandler::RoundByteSize;
using StorageHandler::set_web_ui;
};
@@ -62,10 +61,6 @@ class StorageHandlerTest : public testing::Test {
~StorageHandlerTest() override = default;
void SetUp() override {
- // Need to initialize DBusThreadManager before ArcSessionManager's
- // constructor calls DBusThreadManager::Get().
- chromeos::DBusThreadManager::Initialize();
-
// Initialize fake DBus clients.
ConciergeClient::InitializeFake(/*fake_cicerone_client=*/nullptr);
chromeos::SpacedClient::InitializeFake();
@@ -140,7 +135,6 @@ class StorageHandlerTest : public testing::Test {
storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
chromeos::SpacedClient::Shutdown();
ConciergeClient::Shutdown();
- chromeos::DBusThreadManager::Shutdown();
}
protected:
@@ -248,7 +242,7 @@ TEST_F(StorageHandlerTest, RoundByteSize) {
};
for (auto& c : cases) {
- int64_t rounded_bytes = handler_->RoundByteSize(c.bytes);
+ int64_t rounded_bytes = RoundByteSize(c.bytes);
EXPECT_EQ(base::ASCIIToUTF16(c.expected), ui::FormatBytes(rounded_bytes));
}
}
@@ -261,7 +255,7 @@ TEST_F(StorageHandlerTest, GlobalSizeStat) {
int64_t available_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path);
// Round the total size.
- int64_t rounded_total_size = handler_->RoundByteSize(total_size);
+ int64_t rounded_total_size = RoundByteSize(total_size);
int64_t used_size = rounded_total_size - available_size;
double used_ratio = static_cast<double>(used_size) / rounded_total_size;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.cc
new file mode 100644
index 00000000000..ddc4035cf79
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.cc
@@ -0,0 +1,39 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/device_storage_util.h"
+
+#include <cstdint>
+#include <iostream>
+
+#include "base/notreached.h"
+
+namespace chromeos::settings {
+
+int64_t RoundByteSize(int64_t bytes) {
+ if (bytes < 0) {
+ NOTREACHED() << "Negative bytes value";
+ return -1;
+ }
+
+ if (bytes == 0)
+ return 0;
+
+ // Subtract one to the original number of bytes.
+ bytes--;
+ // Set all the lower bits to 1.
+ bytes |= bytes >> 1;
+ bytes |= bytes >> 2;
+ bytes |= bytes >> 4;
+ bytes |= bytes >> 8;
+ bytes |= bytes >> 16;
+ bytes |= bytes >> 32;
+ // Add one. The one bit beyond the highest set bit is set to 1. All the lower
+ // bits are set to 0.
+ bytes++;
+
+ return bytes;
+}
+
+} // namespace chromeos::settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.h
new file mode 100644
index 00000000000..df4f94c1b70
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_util.h
@@ -0,0 +1,20 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_UTIL_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_UTIL_H_
+
+#include <cstdint>
+
+namespace chromeos::settings {
+
+// Round |bytes| to the next power of 2, where the next power of 2 is greater
+// than or equal to |bytes|.
+// RoundByteSize(3) will return 4.
+// RoundByteSize(4) will return 4.
+int64_t RoundByteSize(int64_t bytes);
+
+} // namespace chromeos::settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_UTIL_H_
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 0ba696c2222..1d612461cd8 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
@@ -16,6 +16,7 @@
#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"
+#include "components/services/app_service/public/cpp/features.h"
namespace chromeos {
namespace settings {
@@ -110,8 +111,7 @@ void StylusHandler::UpdateNoteTakingApps() {
}
}
- FireWebUIListener("onNoteTakingAppsUpdated",
- base::Value(std::move(apps_list)),
+ FireWebUIListener("onNoteTakingAppsUpdated", apps_list,
base::Value(waiting_for_android));
}
@@ -167,9 +167,15 @@ void StylusHandler::HandleShowPlayStoreApps(const base::Value::List& args) {
DCHECK(
apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(profile));
- apps::AppServiceProxyFactory::GetForProfile(profile)->LaunchAppWithUrl(
- arc::kPlayStoreAppId, ui::EF_NONE, GURL(apps_url),
- apps::mojom::LaunchSource::kFromChromeInternal);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ apps::AppServiceProxyFactory::GetForProfile(profile)->LaunchAppWithUrl(
+ arc::kPlayStoreAppId, ui::EF_NONE, GURL(apps_url),
+ apps::LaunchSource::kFromChromeInternal);
+ } else {
+ apps::AppServiceProxyFactory::GetForProfile(profile)->LaunchAppWithUrl(
+ arc::kPlayStoreAppId, ui::EF_NONE, GURL(apps_url),
+ apps::mojom::LaunchSource::kFromChromeInternal);
+ }
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.cc
new file mode 100644
index 00000000000..0f601049526
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.cc
@@ -0,0 +1,251 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h"
+
+#include "ash/quick_pair/common/fast_pair/fast_pair_metrics.h"
+#include "ash/quick_pair/common/logging.h"
+#include "ash/quick_pair/repository/fast_pair/fast_pair_image_decoder_impl.h"
+#include "ash/quick_pair/repository/fast_pair_repository.h"
+#include "base/base64.h"
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/containers/contains.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/values.h"
+#include "ui/base/webui/web_ui_util.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_operations.h"
+
+namespace {
+
+const char kLoadSavedDevicePage[] = "loadSavedDevicePage";
+const char kRemoveSavedDevice[] = "removeSavedDevice";
+const char kOptInStatusMessage[] = "fast-pair-saved-devices-opt-in-status";
+const char kSavedDevicesListMessage[] = "fast-pair-saved-devices-list";
+
+std::string EncodeKey(const std::string& decoded_key) {
+ return base::HexEncode(
+ std::vector<uint8_t>(decoded_key.begin(), decoded_key.end()));
+}
+
+// Keys in the JSON representation of a SavedDevice
+const char kSavedDeviceNameKey[] = "name";
+const char kSavedDeviceImageUrlKey[] = "imageUrl";
+const char kSavedDeviceAccountKeyKey[] = "accountKey";
+
+// Converts |device| to a raw dictionary value used as a JSON
+// argument to JavaScript functions.
+base::Value::Dict SavedDeviceToDictionary(const std::string& device_name,
+ const std::string& image_url,
+ const std::string account_key) {
+ base::Value::Dict dictionary;
+ dictionary.Set(kSavedDeviceNameKey, device_name);
+ dictionary.Set(kSavedDeviceImageUrlKey, image_url);
+ dictionary.Set(kSavedDeviceAccountKeyKey, EncodeKey(account_key));
+ return dictionary;
+}
+
+} // namespace
+
+namespace chromeos::settings {
+
+FastPairSavedDevicesHandler::FastPairSavedDevicesHandler()
+ : image_decoder_(
+ std::make_unique<ash::quick_pair::FastPairImageDecoderImpl>()) {}
+
+FastPairSavedDevicesHandler::FastPairSavedDevicesHandler(
+ std::unique_ptr<ash::quick_pair::FastPairImageDecoder> image_decoder)
+ : image_decoder_(std::move(image_decoder)) {}
+
+FastPairSavedDevicesHandler::~FastPairSavedDevicesHandler() = default;
+
+void FastPairSavedDevicesHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ kLoadSavedDevicePage,
+ base::BindRepeating(
+ &FastPairSavedDevicesHandler::HandleLoadSavedDevicePage,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kRemoveSavedDevice,
+ base::BindRepeating(&FastPairSavedDevicesHandler::HandleRemoveSavedDevice,
+ base::Unretained(this)));
+}
+
+void FastPairSavedDevicesHandler::HandleRemoveSavedDevice(
+ const base::Value::List& args) {
+ QP_LOG(VERBOSE) << __func__;
+ std::vector<uint8_t> account_key;
+ base::HexStringToBytes(args[0].GetString(), &account_key);
+ ash::quick_pair::FastPairRepository::Get()
+ ->DeleteAssociatedDeviceByAccountKey(
+ account_key,
+ base::BindOnce(&FastPairSavedDevicesHandler::OnSavedDeviceDeleted,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void FastPairSavedDevicesHandler::OnSavedDeviceDeleted(bool success) {
+ QP_LOG(INFO) << __func__ << ": " << (success ? "success" : "failed");
+ ash::quick_pair::RecordSavedDevicesRemoveResult(/*success=*/success);
+}
+
+void FastPairSavedDevicesHandler::HandleLoadSavedDevicePage(
+ const base::Value::List& args) {
+ QP_LOG(VERBOSE) << __func__;
+ AllowJavascript();
+
+ // If the page is already loading, we ignore any new requests to load the
+ // page.
+ if (loading_saved_device_page_)
+ return;
+
+ loading_saved_device_page_ = true;
+ loading_start_time_ = base::TimeTicks::Now();
+ ash::quick_pair::FastPairRepository::Get()->GetSavedDevices(
+ base::BindOnce(&FastPairSavedDevicesHandler::OnGetSavedDevices,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void FastPairSavedDevicesHandler::OnGetSavedDevices(
+ nearby::fastpair::OptInStatus status,
+ std::vector<nearby::fastpair::FastPairDevice> devices) {
+ QP_LOG(VERBOSE) << __func__;
+
+ // The JavaScript WebUI layer needs an enum to stay in sync with the
+ // nearby::fastpair::OptInStatus enum from ash/quick_pair/proto/enums.proto
+ // to properly handle this message.
+ FireWebUIListener(kOptInStatusMessage, base::Value(static_cast<int>(status)));
+ QP_LOG(VERBOSE) << __func__ << ": Sending opt-in status";
+
+ // If the device list is empty, we communicate it to the settings page to
+ // stop the loading UX screen.
+ if (devices.empty()) {
+ QP_LOG(VERBOSE) << __func__ << ": No devices saved to the user's account";
+ base::Value::List saved_devices_list;
+ ash::quick_pair::RecordSavedDevicesCount(
+ /*num_devices=*/saved_devices_list.size());
+ FireWebUIListener(kSavedDevicesListMessage, saved_devices_list);
+ loading_saved_device_page_ = false;
+ base::TimeDelta total_load_time =
+ base::TimeTicks::Now() - loading_start_time_;
+ ash::quick_pair::RecordSavedDevicesTotalUxLoadTime(total_load_time);
+ return;
+ }
+
+ // The difference between a nearby::fastpair::FastPairDevice and a
+ // nearby::fastpair::StoredDiscoveryItem is that although they represent the
+ // same devices saved to a user's account, the FastPairDevice contains the
+ // raw byte array with the device name and the image bytes, which we will
+ // parse into a StoredDiscoveryItem to access the image bytes as strings. We
+ // create a flat set of these strings in the case that the
+ // user has the same device multiple times, we only decode the image bytes
+ // once.
+ devices_ = devices;
+ base::flat_set<std::string> image_byte_strings;
+ for (const auto& device : devices) {
+ nearby::fastpair::StoredDiscoveryItem item;
+ if (item.ParseFromString(device.discovery_item_bytes()) &&
+ item.has_icon_png()) {
+ image_byte_strings.insert(item.icon_png());
+ }
+ }
+
+ if (image_byte_strings.empty()) {
+ QP_LOG(VERBOSE) << __func__ << ": no device images";
+ DecodingUrlsFinished();
+ return;
+ }
+
+ // Image decoding occurs asynchronously in a separate process, so we use
+ // a AtomicRefCounter to keep track of the pending tasks remaining, and once
+ // they complete, we can continue parsing the saved device data to communicate
+ // with the settings page.
+ pending_decoding_tasks_count_ =
+ std::make_unique<base::AtomicRefCount>(image_byte_strings.size());
+ for (std::string image_byte_string : image_byte_strings) {
+ image_decoder_->DecodeImage(
+ std::vector<uint8_t>(image_byte_string.begin(),
+ image_byte_string.end()),
+ /*resize_to_notification_size=*/false,
+ base::BindOnce(&FastPairSavedDevicesHandler::SaveImageAsBase64,
+ weak_ptr_factory_.GetWeakPtr(), image_byte_string));
+ }
+}
+
+void FastPairSavedDevicesHandler::SaveImageAsBase64(
+ const std::string& image_byte_string,
+ gfx::Image image) {
+ if (!image.IsEmpty()) {
+ std::string encoded_image = webui::GetBitmapDataUrl(image.AsBitmap());
+ image_byte_string_to_encoded_url_map_[image_byte_string] = encoded_image;
+ }
+
+ // Even if the image is empty, we want to decrement our task counter to
+ // handle when the tasks are completed, and ultimately communicate the
+ // list to the settings page. If we don't have an image, we will
+ // send the settings page a null url, and it is up to the settings page
+ // to handle this case as needed.
+ if (!pending_decoding_tasks_count_->Decrement())
+ DecodingUrlsFinished();
+}
+
+void FastPairSavedDevicesHandler::DecodingUrlsFinished() {
+ QP_LOG(VERBOSE) << __func__;
+
+ // We initialize a list of the saved devices that we will parse with the
+ // decoded urls we have.
+ base::Value::List saved_devices_list;
+ saved_devices_list.reserve(devices_.size());
+
+ // |nearby::fastpair::StoredDiscoveryItem| contains information about
+ // the device name, |image_byte_string_to_encoded_url_map_| contains the
+ // base64 encoded urls for the images, and |nearby::fastpair::FastPairDevice|
+ // contains the account key. Here, we reconcile this data for each device
+ // and convert it to dictionary, to be communicated to the settings page.
+ for (const auto& device : devices_) {
+ // If the device does not have an account key, then it was not properly
+ // saved to the user's account, and we ignore these devices. Android
+ // has devices still in Footprints but marked as deleted by removing the
+ // account key, so it is not expected for all of these devices to have
+ // account keys.
+ if (!device.has_account_key())
+ continue;
+
+ std::string account_key = device.account_key();
+ std::string image_url = "";
+ nearby::fastpair::StoredDiscoveryItem item;
+ if (item.ParseFromString(device.discovery_item_bytes()) &&
+ item.has_icon_png() &&
+ base::Contains(image_byte_string_to_encoded_url_map_,
+ item.icon_png())) {
+ image_url = image_byte_string_to_encoded_url_map_[item.icon_png()];
+ }
+
+ saved_devices_list.Append(SavedDeviceToDictionary(
+ /*device_name=*/item.has_title() ? item.title() : "",
+ /*image_url=*/image_url,
+ /*account_key=*/account_key));
+ }
+
+ ash::quick_pair::RecordSavedDevicesCount(
+ /*num_devices=*/saved_devices_list.size());
+ FireWebUIListener(kSavedDevicesListMessage, saved_devices_list);
+ QP_LOG(VERBOSE) << __func__ << ": Sending device list";
+ base::TimeDelta total_load_time =
+ base::TimeTicks::Now() - loading_start_time_;
+ ash::quick_pair::RecordSavedDevicesTotalUxLoadTime(total_load_time);
+
+ // We reset the state here for another page load that may happened while
+ // chrome://os-settings is open, since our decoding tasks are completed.
+ devices_.clear();
+ image_byte_string_to_encoded_url_map_.clear();
+ pending_decoding_tasks_count_.reset();
+ loading_saved_device_page_ = false;
+}
+
+void FastPairSavedDevicesHandler::OnJavascriptAllowed() {}
+
+void FastPairSavedDevicesHandler::OnJavascriptDisallowed() {}
+
+} // namespace chromeos::settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h
new file mode 100644
index 00000000000..cf0f6984f0e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h
@@ -0,0 +1,71 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FAST_PAIR_SAVED_DEVICES_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FAST_PAIR_SAVED_DEVICES_HANDLER_H_
+
+#include "ash/quick_pair/proto/fastpair.pb.h"
+#include "base/atomic_ref_count.h"
+#include "base/containers/flat_set.h"
+#include "base/memory/scoped_refptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "ui/gfx/image/image.h"
+
+namespace ash::quick_pair {
+class FastPairImageDecoder;
+} // namespace ash::quick_pair
+
+namespace chromeos::settings {
+
+// Chrome OS Fast Pair Saved Devices subpage UI handler.
+class FastPairSavedDevicesHandler : public ::settings::SettingsPageUIHandler {
+ public:
+ FastPairSavedDevicesHandler();
+ explicit FastPairSavedDevicesHandler(
+ std::unique_ptr<ash::quick_pair::FastPairImageDecoder> image_decoder);
+ FastPairSavedDevicesHandler(const FastPairSavedDevicesHandler&) = delete;
+ FastPairSavedDevicesHandler& operator=(const FastPairSavedDevicesHandler&) =
+ delete;
+ ~FastPairSavedDevicesHandler() override;
+
+ // SettingsPageUIHandler implementation.
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ void HandleLoadSavedDevicePage(const base::Value::List& args);
+ void OnGetSavedDevices(nearby::fastpair::OptInStatus status,
+ std::vector<nearby::fastpair::FastPairDevice> devices);
+ void SaveImageAsBase64(const std::string& image_byte_string,
+ gfx::Image image);
+ void DecodingUrlsFinished();
+
+ void HandleRemoveSavedDevice(const base::Value::List& args);
+ void OnSavedDeviceDeleted(bool success);
+
+ bool loading_saved_device_page_ = false;
+ base::TimeTicks loading_start_time_;
+
+ std::unique_ptr<base::AtomicRefCount> pending_decoding_tasks_count_;
+ std::vector<nearby::fastpair::FastPairDevice> devices_;
+ std::unique_ptr<ash::quick_pair::FastPairImageDecoder> image_decoder_;
+
+ // For each device image, we need to convert the device image from the proto
+ // into a base64 encoded data URL to be displayed in the settings UX because
+ // external image URLs cannot be directly downloaded into chrome://os-settings
+ // for security reasons. This map is used to store the encoded urls created
+ // in async calls to be used when we create our dictionary to give to
+ // chrome://os-settings for display.
+ base::flat_map<std::string, std::string>
+ image_byte_string_to_encoded_url_map_;
+
+ base::WeakPtrFactory<FastPairSavedDevicesHandler> weak_ptr_factory_{this};
+};
+
+} // namespace chromeos::settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FAST_PAIR_SAVED_DEVICES_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler_unittest.cc
new file mode 100644
index 00000000000..439ad8e025c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler_unittest.cc
@@ -0,0 +1,618 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/fast_pair_saved_devices_handler.h"
+
+#include "ash/quick_pair/common/logging.h"
+#include "ash/quick_pair/common/mock_quick_pair_browser_delegate.h"
+#include "ash/quick_pair/proto/fastpair.pb.h"
+#include "ash/quick_pair/proto/fastpair_data.pb.h"
+#include "ash/quick_pair/repository/fake_fast_pair_repository.h"
+#include "ash/quick_pair/repository/fast_pair/mock_fast_pair_image_decoder.h"
+#include "ash/quick_pair/repository/fast_pair_repository.h"
+#include "base/base64.h"
+#include "base/callback_helpers.h"
+#include "base/memory/weak_ptr.h"
+#include "base/run_loop.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/task/thread_pool.h"
+#include "base/task/thread_pool/thread_pool_instance.h"
+#include "base/test/bind.h"
+#include "base/test/gmock_callback_support.h"
+#include "base/test/metrics/histogram_tester.h"
+#include "base/test/mock_callback.h"
+#include "base/test/task_environment.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/image/image_unittest_util.h"
+
+namespace chromeos::settings {
+
+namespace {
+
+const char kLoadSavedDevicePage[] = "loadSavedDevicePage";
+const char kRemoveSavedDevice[] = "removeSavedDevice";
+const char kOptInStatusMessage[] = "fast-pair-saved-devices-opt-in-status";
+const char kSavedDevicesListMessage[] = "fast-pair-saved-devices-list";
+
+const char kSavedDeviceNameKey[] = "name";
+const char kSavedDeviceImageUrlKey[] = "imageUrl";
+const char kSavedDeviceAccountKeyKey[] = "accountKey";
+
+const char kDisplayUrlBase64[] =
+ "data:image/"
+ "png;base64,"
+ "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAABAElEQVR4nO3RQQ0AIBDAsAP/"
+ "nuGNAvZoFSzZmjNnyNi/"
+ "A3gZEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhs"
+ "QYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQY"
+ "EmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEm"
+ "NIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNI"
+ "zAXrTQLGi/OgEwAAAABJRU5ErkJggg==";
+
+const char kDeviceName1[] = "I16max";
+const char kImageBytes1[] = "01010101001010101010101010101";
+const std::vector<uint8_t> kAccountKey1 = {0xA0, 0xBA, 0xF0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB6, 0xCF, 0x5E, 0x3F, 0x45,
+ 0x61, 0xC3, 0x32, 0x1D};
+const char kDeviceName2[] = "JBL Flip 6";
+const char kImageBytes2[] = "111110101001010101001010101111";
+const std::vector<uint8_t> kAccountKey2 = {0xA1, 0xBA, 0xF0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB6, 0xCD, 0x5E, 0x3F, 0x45,
+ 0x61, 0xC3, 0x32, 0x1D};
+const char kDeviceName3[] = "Pixel Buds";
+const char kImageBytes3[] = "00000010101100110101010010101001";
+const std::vector<uint8_t> kAccountKey3 = {0xA6, 0xB0, 0xF0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB6, 0xCD, 0x5E, 0x3F, 0x45,
+ 0x68, 0xC3, 0x32, 0x1D};
+const char kDeviceName4[] = "Wyze Buds";
+const char kImageBytes4[] = "11111000101010010101";
+const std::vector<uint8_t> kAccountKey4 = {0xB0, 0xB6, 0xF0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB6, 0xCF, 0x5E, 0x3F, 0x45,
+ 0x61, 0xC3, 0x32, 0x1D};
+
+const char kDeviceName5[] = "B&O Beoplay E6";
+const char kImageBytes5[] = "110000100010000100010100000001001000100001";
+const std::vector<uint8_t> kAccountKey5 = {0xC0, 0xC6, 0xD0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB6, 0xCF, 0x5E, 0x3F, 0x45,
+ 0x61, 0xC3, 0x32, 0x1D};
+
+const char kDeviceName6[] = "LG HBS-830";
+const char kImageBytes6[] = "11110100011111111010100101001010100101010011";
+const std::vector<uint8_t> kAccountKey6 = {0xB5, 0xB6, 0xF0, 0xBB, 0x95, 0x1F,
+ 0xF7, 0xB8, 0xCF, 0x5E, 0x3F, 0x45,
+ 0x61, 0xC3, 0x36, 0x1D};
+
+const char kSavedDeviceRemoveResultMetricName[] =
+ "Bluetooth.ChromeOS.FastPair.SavedDevices.Remove.Result";
+const char kSavedDevicesTotalUxLoadTimeMetricName[] =
+ "Bluetooth.ChromeOS.FastPair.SavedDevices.TotalUxLoadTime";
+const char kSavedDevicesCountMetricName[] =
+ "Bluetooth.ChromeOS.FastPair.SavedDevices.DeviceCount";
+
+nearby::fastpair::FastPairDevice CreateFastPairDevice(
+ const std::string device_name,
+ const std::string image_bytes,
+ const std::vector<uint8_t>& account_key) {
+ nearby::fastpair::StoredDiscoveryItem item;
+ item.set_title(device_name);
+ item.set_icon_png(image_bytes);
+
+ nearby::fastpair::FastPairDevice device;
+ device.set_account_key(std::string(account_key.begin(), account_key.end()));
+
+ std::string item_str;
+ item.SerializeToString(&item_str);
+ device.set_discovery_item_bytes(item_str);
+ return device;
+}
+
+std::string EncodeKey(const std::vector<uint8_t>& decoded_key) {
+ return base::HexEncode(decoded_key);
+}
+
+bool VerifyDeviceInList(const base::Value& device,
+ const std::string& expected_device_name,
+ const std::string& expected_base64_image_url,
+ const std::vector<uint8_t> expected_account_key) {
+ const auto* device_dict = device.GetIfDict();
+
+ const base::Value* device_name = device_dict->Find(kSavedDeviceNameKey);
+ const base::Value* device_url = device_dict->Find(kSavedDeviceImageUrlKey);
+ const base::Value* device_account_key =
+ device_dict->Find(kSavedDeviceAccountKeyKey);
+
+ return (expected_device_name == device_name->GetString()) &&
+ (expected_base64_image_url == device_url->GetString()) &&
+ (EncodeKey(expected_account_key) == device_account_key->GetString());
+}
+
+class TestFastPairSavedDevicesHandler : public FastPairSavedDevicesHandler {
+ public:
+ explicit TestFastPairSavedDevicesHandler(
+ std::unique_ptr<ash::quick_pair::FastPairImageDecoder> image_decoder)
+ : FastPairSavedDevicesHandler(std::move(image_decoder)) {}
+ ~TestFastPairSavedDevicesHandler() override = default;
+
+ // Make public for testing.
+ using FastPairSavedDevicesHandler::AllowJavascript;
+ using FastPairSavedDevicesHandler::RegisterMessages;
+ using FastPairSavedDevicesHandler::set_web_ui;
+};
+
+} // namespace
+
+class FastPairSavedDevicesHandlerTest : public testing::Test {
+ public:
+ FastPairSavedDevicesHandlerTest() = default;
+ FastPairSavedDevicesHandlerTest(const FastPairSavedDevicesHandlerTest&) =
+ delete;
+ FastPairSavedDevicesHandlerTest& operator=(
+ const FastPairSavedDevicesHandlerTest&) = delete;
+ ~FastPairSavedDevicesHandlerTest() override = default;
+
+ // testing::Test:
+ void SetUp() override {
+ test_web_ui_ = std::make_unique<content::TestWebUI>();
+
+ test_image_ = gfx::test::CreateImage(100, 100);
+ auto mock_decoder =
+ std::make_unique<ash::quick_pair::MockFastPairImageDecoder>();
+ mock_decoder_ = mock_decoder.get();
+ // On call to DecodeImage, run the third argument callback with test_image_.
+ ON_CALL(*mock_decoder, DecodeImage(testing::_, testing::_, testing::_))
+ .WillByDefault(base::test::RunOnceCallback<2>(test_image_));
+
+ handler_ = std::make_unique<TestFastPairSavedDevicesHandler>(
+ std::move(mock_decoder));
+ handler_->set_web_ui(test_web_ui_.get());
+ handler_->RegisterMessages();
+ }
+
+ content::TestWebUI* test_web_ui() { return test_web_ui_.get(); }
+
+ void InitializeSavedDevicesList(const std::string& device_name1,
+ const std::string& device_image_bytes1,
+ const std::vector<uint8_t>& account_key1,
+ const std::string& device_name2,
+ const std::string& device_image_bytes2,
+ const std::vector<uint8_t>& account_key2,
+ const std::string& device_name3,
+ const std::string& device_image_bytes3,
+ const std::vector<uint8_t>& account_key3,
+ nearby::fastpair::OptInStatus opt_in_status) {
+ std::vector<nearby::fastpair::FastPairDevice> devices{
+ CreateFastPairDevice(/*device_name=*/device_name1,
+ /*image_bytes=*/device_image_bytes1,
+ /*account_key=*/account_key1),
+ CreateFastPairDevice(/*device_name=*/device_name2,
+ /*image_bytes=*/device_image_bytes2,
+ /*account_key=*/account_key2),
+ CreateFastPairDevice(/*device_name=*/device_name3,
+ /*image_bytes=*/device_image_bytes3,
+ /*account_key=*/account_key3)};
+ fast_pair_repository_.SetSavedDevices(
+ /*status=*/opt_in_status,
+ /*devices=*/std::move(devices));
+ }
+
+ void VerifySavedDevicesList(
+ const content::TestWebUI::CallData& saved_devices_list_call_data,
+ const std::string& device_name1,
+ const std::string& expected_device_url1,
+ const std::vector<uint8_t>& account_key1,
+ const std::string& device_name2,
+ const std::string& expected_device_url2,
+ const std::vector<uint8_t>& account_key2,
+ const std::string& device_name3,
+ const std::string& expected_device_url3,
+ const std::vector<uint8_t>& account_key3) {
+ // The call is structured such that the first argument is the name of the
+ // first message being sent, and the second argument is the name of the
+ // second message being sent.
+ ASSERT_EQ(kSavedDevicesListMessage,
+ saved_devices_list_call_data.arg1()->GetString());
+
+ // Size should be in sync with size of devices list created in
+ // |InitializeSavedDevicesList|
+ const base::Value::List* saved_devices_list =
+ saved_devices_list_call_data.arg2()->GetIfList();
+ ASSERT_EQ(3u, saved_devices_list->size());
+
+ ASSERT_TRUE(
+ VerifyDeviceInList(/*device=*/*(saved_devices_list->begin()),
+ /*expected_device_name=*/device_name1,
+ /*expected_base64_image_url=*/expected_device_url1,
+ /*expected_account_key=*/account_key1));
+ ASSERT_TRUE(
+ VerifyDeviceInList(/*device=*/*(saved_devices_list->begin() + 1),
+ /*expected_device_name=*/device_name2,
+ /*expected_base64_image_url=*/expected_device_url2,
+ /*expected_account_key=*/account_key2));
+ ASSERT_TRUE(
+ VerifyDeviceInList(/*device=*/*(saved_devices_list->begin() + 2),
+ /*expected_device_name=*/device_name3,
+ /*expected_base64_image_url=*/expected_device_url3,
+ /*expected_account_key=*/account_key3));
+ }
+
+ void VerifyEmptySavedDevicesList(
+ const content::TestWebUI::CallData& saved_devices_list_call_data) {
+ ASSERT_EQ(kSavedDevicesListMessage,
+ saved_devices_list_call_data.arg1()->GetString());
+ const base::Value::List* saved_devices_list =
+ saved_devices_list_call_data.arg2()->GetIfList();
+ ASSERT_TRUE(saved_devices_list->empty());
+ }
+
+ void VerifyOptInStatus(
+ const content::TestWebUI::CallData& opt_in_status_call_data,
+ nearby::fastpair::OptInStatus opt_in_status) {
+ // The call is structured such that the first argument is the name of the
+ // first message being sent, and the second argument is the name of the
+ // second message being sent.
+ ASSERT_EQ(kOptInStatusMessage, opt_in_status_call_data.arg1()->GetString());
+ ASSERT_EQ(static_cast<int>(opt_in_status),
+ opt_in_status_call_data.arg2()->GetInt());
+ }
+
+ void LoadPage() {
+ // `HandleReceivedMessages` has to use a ListValue due to the API.
+ base::Value::List args;
+ test_web_ui()->HandleReceivedMessage(kLoadSavedDevicePage, args);
+ }
+
+ void RemoveDevice(const std::vector<uint8_t>& account_key) {
+ // `HandleReceivedMessages` has to use a ListValue due to the API.
+ base::Value::List args;
+ args.Append(EncodeKey(account_key));
+ test_web_ui()->HandleReceivedMessage(kRemoveSavedDevice, args);
+ }
+
+ base::HistogramTester& histogram_tester() { return histogram_tester_; }
+
+ protected:
+ base::test::TaskEnvironment task_environment_;
+ base::HistogramTester histogram_tester_;
+ ash::quick_pair::FakeFastPairRepository fast_pair_repository_;
+ gfx::Image test_image_;
+ ash::quick_pair::MockFastPairImageDecoder* mock_decoder_;
+ std::unique_ptr<content::TestWebUI> test_web_ui_;
+ std::unique_ptr<TestFastPairSavedDevicesHandler> handler_;
+ base::WeakPtrFactory<FastPairSavedDevicesHandlerTest> weak_ptr_factory_{this};
+};
+
+TEST_F(FastPairSavedDevicesHandlerTest, GetSavedDevices) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+
+ // We mock the image decoder to return the same test image, which is why
+ // the base64 encoded images are all the same here.
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, ReloadBeforePageLoadsIgnored) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+
+ // Simulate two page loads at the same time.
+ base::ThreadPool::PostTask(
+ FROM_HERE, {base::MayBlock()},
+ base::BindOnce(&FastPairSavedDevicesHandlerTest::LoadPage,
+ weak_ptr_factory_.GetWeakPtr()));
+ LoadPage();
+ base::ThreadPoolInstance::Get()->FlushForTesting();
+
+ // If we load the page while we are already fetching and decoding saved
+ // device data, we should ignore the second load attempt and it should
+ // behave like if only one call was made.
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, ReloadAfterPageLoads) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ // We only expect two calls at this point: one for the opt in status, one
+ // for the saved device list.
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ // We expect now the WebUI to have handled four calls: two opt in status,
+ // two for saved device list.
+ EXPECT_EQ(4u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ VerifyOptInStatus(*test_web_ui()->call_data()[2],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 2);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, EmptyListSentToWebUi) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/0, 0);
+ fast_pair_repository_.SetSavedDevices(
+ /*status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_OUT,
+ /*devices=*/{});
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_OUT);
+ VerifyEmptySavedDevicesList(*test_web_ui()->call_data()[1]);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/0, 1);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, SavedDevicesBecomesEmpty) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/0, 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/0, 0);
+
+ fast_pair_repository_.SetSavedDevices(
+ /*status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_OUT,
+ /*devices=*/{});
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ // At this point, we have had four total calls handled by our webui, but now
+ // we should have the data reflect any empty list.
+ EXPECT_EQ(4u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[2],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_OUT);
+ VerifyEmptySavedDevicesList(*test_web_ui()->call_data()[3]);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 2);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/0, 1);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, SavedDevicesChanges) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName4, /*device_image_bytes1=*/kImageBytes4,
+ /*account_key1=*/kAccountKey4, /*device_name2=*/kDeviceName5,
+ /*device_image_bytes2=*/kImageBytes5, /*account_key2=*/kAccountKey5,
+ /*device_name3=*/kDeviceName6, /*device_image_bytes3=*/kImageBytes6,
+ /*account_key3=*/kAccountKey6,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(4u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[2],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[3], /*device_name1=*/kDeviceName4,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey4,
+ /*device_name2=*/kDeviceName5, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey5, /*device_name3=*/kDeviceName6,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey6);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 2);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, EmptyImageSentToWebUi) {
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 0);
+ ON_CALL(*mock_decoder_, DecodeImage(testing::_, testing::_, testing::_))
+ .WillByDefault(base::test::RunOnceCallback<2>(gfx::Image()));
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifyOptInStatus(*test_web_ui()->call_data()[0],
+ nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+
+ // If we decode an empty image, we will send a null image url to the WebUI.
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/"", /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/"",
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/"", /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectTotalCount(kSavedDevicesTotalUxLoadTimeMetricName,
+ 1);
+}
+
+TEST_F(FastPairSavedDevicesHandlerTest, RemoveSavedDevice) {
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/3, 0);
+ InitializeSavedDevicesList(
+ /*device_name1=*/kDeviceName1, /*device_image_bytes1=*/kImageBytes1,
+ /*account_key1=*/kAccountKey1, /*device_name2=*/kDeviceName2,
+ /*device_image_bytes2=*/kImageBytes2, /*account_key2=*/kAccountKey2,
+ /*device_name3=*/kDeviceName3, /*device_image_bytes3=*/kImageBytes3,
+ /*account_key3=*/kAccountKey3,
+ /*opt_in_status=*/nearby::fastpair::OptInStatus::STATUS_OPTED_IN);
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(2u, test_web_ui()->call_data().size());
+ VerifySavedDevicesList(
+ *test_web_ui()->call_data()[1], /*device_name1=*/kDeviceName1,
+ /*expected_device_url1=*/kDisplayUrlBase64, /*account_key1=*/kAccountKey1,
+ /*device_name2=*/kDeviceName2, /*expected_device_url2=*/kDisplayUrlBase64,
+ /*account_key2=*/kAccountKey2, /*device_name3=*/kDeviceName3,
+ /*expected_device_url3=*/kDisplayUrlBase64,
+ /*account_key3=*/kAccountKey3);
+ histogram_tester().ExpectBucketCount(kSavedDeviceRemoveResultMetricName,
+ /*success=*/true, 0);
+ histogram_tester().ExpectBucketCount(kSavedDeviceRemoveResultMetricName,
+ /*success=*/false, 0);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/2, 0);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/3, 1);
+
+ RemoveDevice(kAccountKey3);
+ base::RunLoop().RunUntilIdle();
+
+ LoadPage();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(4u, test_web_ui()->call_data().size());
+
+ const base::Value::List* saved_devices_list =
+ test_web_ui()->call_data()[3]->arg2()->GetIfList();
+ ASSERT_EQ(2u, saved_devices_list->size());
+ ASSERT_TRUE(
+ VerifyDeviceInList(/*device=*/*(saved_devices_list->begin()),
+ /*expected_device_name=*/kDeviceName1,
+ /*expected_base64_image_url=*/kDisplayUrlBase64,
+ /*expected_account_key=*/kAccountKey1));
+ ASSERT_TRUE(
+ VerifyDeviceInList(/*device=*/*(saved_devices_list->begin() + 1),
+ /*expected_device_name=*/kDeviceName2,
+ /*expected_base64_image_url=*/kDisplayUrlBase64,
+ /*expected_account_key=*/kAccountKey2));
+
+ histogram_tester().ExpectBucketCount(kSavedDeviceRemoveResultMetricName,
+ /*success=*/true, 1);
+ histogram_tester().ExpectBucketCount(kSavedDeviceRemoveResultMetricName,
+ /*success=*/false, 0);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/2, 1);
+ histogram_tester().ExpectBucketCount(kSavedDevicesCountMetricName,
+ /*num_devices=*/3, 1);
+}
+
+} // namespace chromeos::settings
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 ff4ff98f1af..7f1bd7b3956 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
index 9a6dfff4c5f..2c3ae43a001 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -33,21 +33,20 @@ namespace {
// The max number of fingerprints that can be stored.
constexpr int kMaxAllowedFingerprints = 3;
-std::unique_ptr<base::DictionaryValue> GetFingerprintsInfo(
+base::Value::Dict GetFingerprintsInfo(
const std::vector<std::string>& fingerprints_list) {
- auto response = std::make_unique<base::DictionaryValue>();
- base::ListValue fingerprints;
+ base::Value::Dict response;
+ base::Value::List fingerprints;
DCHECK_LE(static_cast<int>(fingerprints_list.size()),
kMaxAllowedFingerprints);
for (auto& fingerprint_name: fingerprints_list) {
- base::Value str(fingerprint_name);
- fingerprints.Append(std::move(str));
+ fingerprints.Append(fingerprint_name);
}
- response->SetKey("fingerprintsList", std::move(fingerprints));
- response->SetBoolKey("isMaxed", static_cast<int>(fingerprints_list.size()) >=
- kMaxAllowedFingerprints);
+ response.Set("fingerprintsList", std::move(fingerprints));
+ response.Set("isMaxed", static_cast<int>(fingerprints_list.size()) >=
+ kMaxAllowedFingerprints);
return response;
}
@@ -115,19 +114,17 @@ void FingerprintHandler::OnEnrollScanDone(device::mojom::ScanResult scan_result,
<< scan_result
<< ", enroll_session_complete=" << enroll_session_complete
<< ", percent_complete=" << percent_complete;
- auto scan_attempt = std::make_unique<base::DictionaryValue>();
- scan_attempt->SetIntKey("result", static_cast<int>(scan_result));
- scan_attempt->SetBoolKey("isComplete", enroll_session_complete);
- scan_attempt->SetIntKey("percentComplete", percent_complete);
+ base::Value::Dict scan_attempt;
+ scan_attempt.Set("result", static_cast<int>(scan_result));
+ scan_attempt.Set("isComplete", enroll_session_complete);
+ scan_attempt.Set("percentComplete", percent_complete);
- FireWebUIListener("on-fingerprint-scan-received", *scan_attempt);
+ FireWebUIListener("on-fingerprint-scan-received", scan_attempt);
}
void FingerprintHandler::OnAuthScanDone(
const device::mojom::FingerprintMessagePtr msg,
- const base::flat_map<std::string, std::vector<std::string>>& matches) {
- NOTREACHED();
-}
+ const base::flat_map<std::string, std::vector<std::string>>& matches) {}
void FingerprintHandler::OnSessionFailed() {
LOG(ERROR) << "Fingerprint session failed.";
@@ -165,9 +162,8 @@ void FingerprintHandler::OnGetFingerprintsList(
profile_->GetPrefs()->SetInteger(prefs::kQuickUnlockFingerprintRecord,
fingerprints_list_mapping.size());
- std::unique_ptr<base::DictionaryValue> fingerprint_info =
- GetFingerprintsInfo(fingerprints_labels_);
- ResolveJavascriptCallback(base::Value(callback_id), *fingerprint_info);
+ ResolveJavascriptCallback(base::Value(callback_id),
+ GetFingerprintsInfo(fingerprints_labels_));
}
void FingerprintHandler::HandleGetNumFingerprints(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
index 46df6fbb5be..7cd42cf6962 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
@@ -8,14 +8,14 @@
#include "ash/components/arc/arc_prefs.h"
#include "ash/components/arc/session/arc_service_manager.h"
-#include "ash/components/audio/cras_audio_handler.h"
#include "ash/public/cpp/assistant/assistant_setup.h"
#include "ash/public/cpp/assistant/controller/assistant_controller.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
-#include "chromeos/services/assistant/public/cpp/assistant_service.h"
+#include "chromeos/ash/components/audio/cras_audio_handler.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_service.h"
#include "content/public/browser/browser_context.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
index 551441ca9b6..002db578862 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h
@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_GOOGLE_ASSISTANT_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_GOOGLE_ASSISTANT_HANDLER_H_
-#include "ash/components/audio/cras_audio_handler.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chromeos/ash/components/audio/cras_audio_handler.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
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 58594841de2..966b43d5cd9 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
@@ -19,15 +19,15 @@ namespace chromeos {
namespace {
-base::ListValue GetSharableUsbDevices(CrosUsbDetector* detector) {
- base::ListValue usb_devices_list;
+base::Value::List GetSharableUsbDevices(CrosUsbDetector* detector) {
+ base::Value::List usb_devices_list;
for (const auto& device : detector->GetShareableDevices()) {
- base::Value device_info(base::Value::Type::DICTIONARY);
- device_info.SetStringKey("guid", device.guid);
- device_info.SetStringKey("label", device.label);
- if (device.shared_vm_name)
- device_info.SetStringKey("sharedWith", device.shared_vm_name.value());
- device_info.SetBoolKey("promptBeforeSharing", device.prompt_before_sharing);
+ base::Value::Dict device_info;
+ device_info.Set("guid", device.guid);
+ device_info.Set("label", device.label);
+ if (device.shared_guest_id.has_value())
+ device_info.Set("sharedWith", device.shared_guest_id->vm_name);
+ device_info.Set("promptBeforeSharing", device.prompt_before_sharing);
usb_devices_list.Append(std::move(device_info));
}
return usb_devices_list;
@@ -78,7 +78,7 @@ void GuestOsHandler::HandleGetGuestOsSharedPathsDisplayText(
CHECK_EQ(2U, args.size());
std::string callback_id = args[0].GetString();
- base::Value texts(base::Value::Type::LIST);
+ base::Value::List texts;
for (const auto& path : args[1].GetListDeprecated()) {
texts.Append(file_manager::util::GetPathDisplayTextForSettings(
profile_, path.GetString()));
@@ -120,19 +120,20 @@ void GuestOsHandler::HandleNotifyGuestOsSharedUsbDevicesPageReady(
void GuestOsHandler::HandleSetGuestOsUsbDeviceShared(
const base::Value::List& args) {
CHECK_EQ(3U, args.size());
- const std::string& vm_name = args[0].GetString();
const std::string& guid = args[1].GetString();
bool shared = args[2].GetBool();
+ const auto guest_id = guest_os::GuestId(args[0].GetString(), "");
+
chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
if (!detector)
return;
if (shared) {
- detector->AttachUsbDeviceToVm(vm_name, guid, base::DoNothing());
+ detector->AttachUsbDeviceToGuest(guest_id, guid, base::DoNothing());
return;
}
- detector->DetachUsbDeviceFromVm(vm_name, guid, base::DoNothing());
+ detector->DetachUsbDeviceFromVm(guest_id.vm_name, guid, base::DoNothing());
}
void GuestOsHandler::OnUsbDevicesChanged() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h
index 8ca5a796ac2..905105129d8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/hierarchy.h
@@ -10,10 +10,10 @@
#include <utility>
#include <vector>
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom.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"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
index 8138071a992..87a99db3e72 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -21,12 +21,13 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
-#include "chromeos/network/network_connect.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_state.h"
-#include "chromeos/network/network_state_handler.h"
+#include "chromeos/ash/components/network/network_connect.h"
+#include "chromeos/ash/components/network/network_event_log.h"
+#include "chromeos/ash/components/network/network_state.h"
+#include "chromeos/ash/components/network/network_state_handler.h"
#include "components/onc/onc_constants.h"
#include "components/prefs/pref_service.h"
+#include "components/services/app_service/public/cpp/features.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -133,8 +134,14 @@ void InternetHandler::AddThirdPartyVpn(const base::Value::List& args) {
if (arc_app_list_prefs && arc_app_list_prefs->GetApp(app_id)) {
DCHECK(apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(
profile_));
- apps::AppServiceProxyFactory::GetForProfile(profile_)->Launch(
- app_id, ui::EF_NONE, apps::mojom::LaunchSource::kFromParentalControls);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->Launch(
+ app_id, ui::EF_NONE, apps::LaunchSource::kFromParentalControls);
+ } else {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->Launch(
+ app_id, ui::EF_NONE,
+ apps::mojom::LaunchSource::kFromParentalControls);
+ }
return;
}
@@ -245,7 +252,7 @@ void InternetHandler::SendGmsCoreNotificationsDisabledDeviceNames() {
if (!IsJavascriptAllowed())
return;
- base::ListValue device_names_value;
+ base::Value::List device_names_value;
for (const auto& device_name : device_names_without_notifications_)
device_names_value.Append(device_name.Clone());
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 f0d78303dbf..bfa4bb96dcb 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
@@ -14,16 +14,16 @@
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/hermes/hermes_manager_client.h"
+#include "chromeos/ash/components/dbus/hermes/hermes_manager_client.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -572,9 +572,6 @@ bool AllowAddESim(const network_config::mojom::GlobalPolicyPtr& global_policy) {
if (HermesManagerClient::Get()->GetAvailableEuiccs().size() == 0)
return false;
- if (!base::FeatureList::IsEnabled(ash::features::kESimPolicy))
- return true;
-
return !global_policy->allow_only_policy_cellular_networks;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
index 3805f8840a9..62d17c2ed1b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
@@ -10,7 +10,7 @@
#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
-#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
+#include "chromeos/services/network_config/public/cpp/cros_network_config_observer.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
@@ -26,9 +26,8 @@ namespace settings {
class SearchTagRegistry;
-class InternetSection
- : public OsSettingsSection,
- public network_config::mojom::CrosNetworkConfigObserver {
+class InternetSection : public OsSettingsSection,
+ public network_config::CrosNetworkConfigObserver {
public:
InternetSection(Profile* profile, SearchTagRegistry* search_tag_registry);
~InternetSection() override;
@@ -48,18 +47,11 @@ class InternetSection
OsSettingsIdentifier id,
const std::string& url_to_modify) const override;
- // network_config::mojom::CrosNetworkConfigObserver:
+ // network_config::CrosNetworkConfigObserver:
void OnActiveNetworksChanged(
std::vector<network_config::mojom::NetworkStatePropertiesPtr> networks)
override;
void OnDeviceStateListChanged() override;
- void OnNetworkStateChanged(
- chromeos::network_config::mojom::NetworkStatePropertiesPtr network)
- override {}
- void OnNetworkStateListChanged() override {}
- void OnVpnProvidersChanged() override {}
- void OnNetworkCertificatesChanged() override {}
- void OnPoliciesApplied(const std::string& userhash) override {}
void FetchDeviceList();
void OnGlobalPolicy(network_config::mojom::GlobalPolicyPtr global_policy);
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 ffcc1193d58..3030a6b5901 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
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/ash/kerberos/kerberos_credentials_manager.h"
#include "chrome/browser/ash/kerberos/kerberos_credentials_manager_factory.h"
@@ -121,10 +122,16 @@ void AddKerberosAddAccountDialogStrings(content::WebUIDataSource* html_source) {
"kerberosRememberPasswordEnabled",
local_state->GetBoolean(::prefs::kKerberosRememberPasswordEnabled));
+ // Prefilled domain if policy is enabled. Note that Kerberos
+ // domains should be in all uppercase.
+ html_source->AddString("kerberosDomainAutocomplete",
+ base::ToUpperASCII(local_state->GetString(
+ ::prefs::kKerberosDomainAutocomplete)));
+
// Kerberos default configuration.
html_source->AddString(
"defaultKerberosConfig",
- chromeos::KerberosCredentialsManager::GetDefaultKerberosConfig());
+ local_state->GetString(::prefs::kKerberosDefaultConfiguration));
}
// Adds load time strings to Kerberos Accounts page.
@@ -244,7 +251,7 @@ void KerberosAccountsHandler::HandleGetKerberosAccounts(
void KerberosAccountsHandler::OnListAccounts(
const std::string& callback_id,
const kerberos::ListAccountsResponse& response) {
- base::ListValue accounts;
+ base::Value::List accounts;
// Ticket icon is a key.
gfx::ImageSkia skia_ticket_icon =
@@ -267,21 +274,20 @@ void KerberosAccountsHandler::OnListAccounts(
ui::TimeFormat::FORMAT_DURATION, ui::TimeFormat::LENGTH_LONG,
tgt_validity < base::Days(1) ? -1 : 0, tgt_validity);
- base::DictionaryValue account_dict;
- account_dict.SetStringKey("principalName", account.principal_name());
- account_dict.SetStringKey("config", account.krb5conf());
- account_dict.SetBoolKey("isSignedIn", account.tgt_validity_seconds() > 0);
- account_dict.SetStringKey("validForDuration", valid_for_duration);
- account_dict.SetBoolKey("isActive",
- account.principal_name() == active_principal);
- account_dict.SetBoolKey("isManaged", account.is_managed());
- account_dict.SetBoolKey("passwordWasRemembered",
- account.password_was_remembered());
- account_dict.SetStringKey("pic", ticket_icon);
+ base::Value::Dict account_dict;
+ account_dict.Set("principalName", account.principal_name());
+ account_dict.Set("config", account.krb5conf());
+ account_dict.Set("isSignedIn", account.tgt_validity_seconds() > 0);
+ account_dict.Set("validForDuration", valid_for_duration);
+ account_dict.Set("isActive", account.principal_name() == active_principal);
+ account_dict.Set("isManaged", account.is_managed());
+ account_dict.Set("passwordWasRemembered",
+ account.password_was_remembered());
+ account_dict.Set("pic", ticket_icon);
accounts.Append(std::move(account_dict));
}
- ResolveJavascriptCallback(base::Value(callback_id), std::move(accounts));
+ ResolveJavascriptCallback(base::Value(callback_id), accounts);
}
void KerberosAccountsHandler::HandleAddKerberosAccount(
@@ -367,17 +373,16 @@ void KerberosAccountsHandler::HandleValidateKerberosConfig(
void KerberosAccountsHandler::OnValidateConfig(
const std::string& callback_id,
const kerberos::ValidateConfigResponse& response) {
- base::Value error_info(base::Value::Type::DICTIONARY);
- error_info.SetKey("code", base::Value(response.error_info().code()));
+ base::Value::Dict error_info;
+ error_info.Set("code", response.error_info().code());
if (response.error_info().has_line_index()) {
- error_info.SetKey("lineIndex",
- base::Value(response.error_info().line_index()));
+ error_info.Set("lineIndex", response.error_info().line_index());
}
- base::Value value(base::Value::Type::DICTIONARY);
- value.SetKey("error", base::Value(static_cast<int>(response.error())));
- value.SetKey("errorInfo", std::move(error_info));
- ResolveJavascriptCallback(base::Value(callback_id), std::move(value));
+ base::Value::Dict value;
+ value.Set("error", static_cast<int>(response.error()));
+ value.Set("errorInfo", std::move(error_info));
+ ResolveJavascriptCallback(base::Value(callback_id), value);
}
void KerberosAccountsHandler::HandleSetAsActiveKerberosAccount(
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 4bda75a807d..caa6029e930 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc
@@ -6,8 +6,8 @@
#include "base/no_destructor.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
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 d74a9ddd7b5..1133a283537 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
@@ -10,8 +10,8 @@
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.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/languages_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
@@ -103,11 +103,6 @@ const std::vector<SearchConcept>& GetEditDictionarySearchConceptsV2() {
return *tags;
}
-bool IsLanguageSettingsV2Update2Enabled() {
- return base::FeatureList::IsEnabled(
- ::chromeos::features::kLanguageSettingsUpdate2);
-}
-
const std::vector<SearchConcept>& GetSmartInputsSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_LANGUAGES_SUGGESTIONS,
@@ -204,6 +199,8 @@ void AddInputMethodOptionsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_INPUT_METHOD_OPTIONS_AUTO_CORRECTION},
{"inputMethodOptionsPredictiveWriting",
IDS_SETTINGS_INPUT_METHOD_OPTIONS_PREDICTIVE_WRITING},
+ {"inputMethodOptionsDiacriticsOnPhysicalKeyboardLongpress",
+ IDS_SETTINGS_INPUT_METHOD_OPTIONS_DIACRITICS_ON_PHYSICAL_KEYBOARD_LONGPRESS},
{"inputMethodOptionsXkbLayout",
IDS_SETTINGS_INPUT_METHOD_OPTIONS_XKB_LAYOUT},
{"inputMethodOptionsZhuyinKeyboardLayout",
@@ -252,6 +249,10 @@ void AddInputMethodOptionsStrings(content::WebUIDataSource* html_source) {
html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("allowPredictiveWriting",
IsPredictiveWritingAllowed());
+ html_source->AddBoolean(
+ "allowDiacriticsOnPhysicalKeyboardLongpress",
+ base::FeatureList::IsEnabled(
+ ::chromeos::features::kDiacriticsOnPhysicalKeyboardLongpress));
}
void AddLanguagesPageStringsV2(content::WebUIDataSource* html_source) {
@@ -447,8 +448,7 @@ void LanguagesSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
AddLanguagesPageStringsV2(html_source);
AddInputPageStringsV2(html_source);
- html_source->AddBoolean("enableLanguageSettingsV2Update2",
- IsLanguageSettingsV2Update2Enabled());
+ html_source->AddBoolean("enableLanguageSettingsV2Update2", true);
html_source->AddBoolean("onDeviceGrammarCheckEnabled",
base::FeatureList::IsEnabled(
::chromeos::features::kOnDeviceGrammarCheck));
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 91d3ce85598..8b9bc94cbaf 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
@@ -172,9 +172,12 @@ void MainSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddBoolean("isChildAccount", profile()->IsChild());
// Personalization hub is only enabled for regular (non-guest) users.
+ // b/238455906 also call |!features::IsGuestModeActive()| since this
+ // additionally checks for enterprise managed guest users.
html_source->AddBoolean("isPersonalizationHubEnabled",
ash::features::IsPersonalizationHubEnabled() &&
- profile()->IsRegularProfile());
+ profile()->IsRegularProfile() &&
+ !features::IsGuestModeActive());
// Add the System Web App resources for Settings.
html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
@@ -254,6 +257,14 @@ void MainSection::AddChromeOSUserStrings(
"secondaryUserBannerText",
l10n_util::GetStringFUTF16(IDS_SETTINGS_SECONDARY_USER_BANNER,
base::ASCIIToUTF16(primary_user_email)));
+ html_source->AddString(
+ "sublabelWithEmail",
+ l10n_util::GetStringFUTF16(IDS_BLUETOOTH_SAVED_DEVICES_SUBTITLE,
+ base::ASCIIToUTF16(primary_user_email)));
+ html_source->AddString(
+ "noDevicesWithEmail",
+ l10n_util::GetStringFUTF16(IDS_BLUETOOTH_NO_SAVED_DEVICES_LABEL,
+ base::ASCIIToUTF16(primary_user_email)));
}
std::unique_ptr<PluralStringHandler> MainSection::CreatePluralStringHandler() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.cc
index 19c4ccdad08..6cd2641ac16 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.cc
@@ -58,16 +58,15 @@ void MetricsConsentHandler::HandleGetMetricsConsentState(
const base::Value& callback_id = args[0];
- base::Value response(base::Value::Type::DICTIONARY);
+ base::Value::Dict response;
base::Value consent_pref =
ShouldUseUserConsent()
? base::Value(::metrics::prefs::kMetricsUserConsent)
: base::Value(::ash::kStatsReportingPref);
- response.SetKey("prefName", std::move(consent_pref));
- response.SetKey("isConfigurable",
- base::Value(IsMetricsConsentConfigurable()));
+ response.Set("prefName", std::move(consent_pref));
+ response.Set("isConfigurable", base::Value(IsMetricsConsentConfigurable()));
ResolveJavascriptCallback(callback_id, response);
}
@@ -79,7 +78,7 @@ void MetricsConsentHandler::HandleUpdateMetricsConsent(
CHECK_EQ(args[1].type(), base::Value::Type::DICTIONARY);
const base::Value& callback_id = args[0];
- absl::optional<bool> metrics_consent = args[1].FindBoolKey("consent");
+ absl::optional<bool> metrics_consent = args[1].GetDict().FindBool("consent");
CHECK(metrics_consent);
if (!ShouldUseUserConsent()) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler_unittest.cc
index ff8f26cfb78..506e1df7a38 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler_unittest.cc
@@ -22,7 +22,7 @@
#include "chrome/browser/metrics/profile_pref_names.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/test/base/testing_profile.h"
-#include "chromeos/dbus/session_manager/fake_session_manager_client.h"
+#include "chromeos/ash/components/dbus/session_manager/fake_session_manager_client.h"
#include "components/metrics/metrics_state_manager.h"
#include "components/metrics/test/test_enabled_state_provider.h"
#include "components/metrics/test/test_metrics_service_client.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
index ed621aac62f..91ea925424d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -342,18 +342,17 @@ void MultideviceHandler::OnNearbySharingEnabledChanged() {
}
void MultideviceHandler::UpdatePageContent() {
- std::unique_ptr<base::DictionaryValue> page_content_dictionary =
+ base::Value::Dict page_content_dictionary =
GeneratePageContentDataDictionary();
- DCHECK(page_content_dictionary);
PA_LOG(INFO) << "Updating MultiDevice settings page content with: "
- << *page_content_dictionary << ".";
+ << page_content_dictionary << ".";
FireWebUIListener("settings.updateMultidevicePageContentData",
- *page_content_dictionary);
+ page_content_dictionary);
}
void MultideviceHandler::NotifyAndroidSmsInfoChange() {
- auto android_sms_info = GenerateAndroidSmsInfo();
- FireWebUIListener("settings.onAndroidSmsInfoChange", *android_sms_info);
+ FireWebUIListener("settings.onAndroidSmsInfoChange",
+ GenerateAndroidSmsInfo());
}
void MultideviceHandler::HandleShowMultiDeviceSetupDialog(
@@ -370,13 +369,12 @@ void MultideviceHandler::HandleGetPageContent(const base::Value::List& args) {
const base::Value& callback_id = args[0];
DCHECK(callback_id.is_string());
- std::unique_ptr<base::DictionaryValue> page_content_dictionary =
+ base::Value::Dict page_content_dictionary =
GeneratePageContentDataDictionary();
- DCHECK(page_content_dictionary);
PA_LOG(INFO) << "Responding to getPageContentData() request with: "
- << *page_content_dictionary << ".";
+ << page_content_dictionary << ".";
- ResolveJavascriptCallback(callback_id, *page_content_dictionary);
+ ResolveJavascriptCallback(callback_id, page_content_dictionary);
}
void MultideviceHandler::HandleSetFeatureEnabledState(
@@ -471,16 +469,15 @@ void MultideviceHandler::HandleGetSmartLockSignInAllowed(
ResolveJavascriptCallback(callback_id, base::Value(sign_in_allowed));
}
-std::unique_ptr<base::DictionaryValue>
-MultideviceHandler::GenerateAndroidSmsInfo() {
+base::Value::Dict MultideviceHandler::GenerateAndroidSmsInfo() {
absl::optional<GURL> app_url;
if (android_sms_app_manager_)
app_url = android_sms_app_manager_->GetCurrentAppUrl();
if (!app_url)
app_url = android_sms::GetAndroidMessagesURL();
- auto android_sms_info = std::make_unique<base::DictionaryValue>();
- android_sms_info->SetStringKey(
+ base::Value::Dict android_sms_info;
+ android_sms_info.Set(
kAndroidSmsInfoOriginKey,
ContentSettingsPattern::FromURLNoWildcard(*app_url).ToString());
@@ -492,7 +489,7 @@ MultideviceHandler::GenerateAndroidSmsInfo() {
multidevice_setup::mojom::FeatureState::kEnabledByUser ||
messages_state ==
multidevice_setup::mojom::FeatureState::kFurtherSetupRequired;
- android_sms_info->SetBoolKey(kAndroidSmsInfoEnabledKey, enabled_state);
+ android_sms_info.Set(kAndroidSmsInfoEnabledKey, enabled_state);
return android_sms_info;
}
@@ -501,7 +498,7 @@ void MultideviceHandler::HandleGetAndroidSmsInfo(
const base::Value::List& args) {
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, *GenerateAndroidSmsInfo());
+ ResolveJavascriptCallback(callback_id, GenerateAndroidSmsInfo());
}
void MultideviceHandler::HandleAttemptNotificationSetup(
@@ -556,6 +553,7 @@ void MultideviceHandler::HandleCancelAppsSetup(const base::Value::List& args) {
DCHECK(features::IsEcheSWAEnabled());
DCHECK(apps_access_operation_);
+ apps_access_manager_->NotifyAppsAccessCanceled();
apps_access_operation_.reset();
}
@@ -661,37 +659,36 @@ void MultideviceHandler::OnSetFeatureStateEnabledResult(
ResolveJavascriptCallback(base::Value(js_callback_id), base::Value(success));
}
-std::unique_ptr<base::DictionaryValue>
-MultideviceHandler::GeneratePageContentDataDictionary() {
- auto page_content_dictionary = std::make_unique<base::DictionaryValue>();
+base::Value::Dict MultideviceHandler::GeneratePageContentDataDictionary() {
+ base::Value::Dict page_content_dictionary;
multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice
host_status_with_device = GetHostStatusWithDevice();
multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap feature_states =
GetFeatureStatesMap();
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataModeKey,
static_cast<int32_t>(host_status_with_device.first));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataBetterTogetherStateKey,
static_cast<int32_t>(
feature_states
[multidevice_setup::mojom::Feature::kBetterTogetherSuite]));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataInstantTetheringStateKey,
static_cast<int32_t>(
feature_states
[multidevice_setup::mojom::Feature::kInstantTethering]));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataMessagesStateKey,
static_cast<int32_t>(
feature_states[multidevice_setup::mojom::Feature::kMessages]));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataSmartLockStateKey,
static_cast<int32_t>(
feature_states[multidevice_setup::mojom::Feature::kSmartLock]));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataPhoneHubStateKey,
static_cast<int32_t>(
feature_states[multidevice_setup::mojom::Feature::kPhoneHub]));
@@ -700,15 +697,14 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
? feature_states
[multidevice_setup::mojom::Feature::kPhoneHubCameraRoll]
: multidevice_setup::mojom::FeatureState::kNotSupportedByChromebook;
- page_content_dictionary->SetIntKey(
- kPageContentDataPhoneHubCameraRollStateKey,
- static_cast<int32_t>(cameraRoll_feature_state));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(kPageContentDataPhoneHubCameraRollStateKey,
+ static_cast<int32_t>(cameraRoll_feature_state));
+ page_content_dictionary.Set(
kPageContentDataPhoneHubNotificationsStateKey,
static_cast<int32_t>(
feature_states
[multidevice_setup::mojom::Feature::kPhoneHubNotifications]));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataPhoneHubTaskContinuationStateKey,
static_cast<int32_t>(
feature_states
@@ -717,21 +713,20 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
base::FeatureList::IsEnabled(chromeos::features::kEcheSWA)
? feature_states[multidevice_setup::mojom::Feature::kEche]
: multidevice_setup::mojom::FeatureState::kNotSupportedByChromebook;
- page_content_dictionary->SetIntKey(kPageContentDataPhoneHubAppsStateKey,
- static_cast<int32_t>(eche_feature_state));
+ page_content_dictionary.Set(kPageContentDataPhoneHubAppsStateKey,
+ static_cast<int32_t>(eche_feature_state));
- page_content_dictionary->SetIntKey(
+ page_content_dictionary.Set(
kPageContentDataWifiSyncStateKey,
static_cast<int32_t>(
feature_states[multidevice_setup::mojom::Feature::kWifiSync]));
if (host_status_with_device.second) {
- page_content_dictionary->SetStringKey(
- kPageContentDataHostDeviceNameKey,
- host_status_with_device.second->name());
+ page_content_dictionary.Set(kPageContentDataHostDeviceNameKey,
+ host_status_with_device.second->name());
}
- page_content_dictionary->SetBoolKey(
+ page_content_dictionary.Set(
kIsAndroidSmsPairingComplete,
android_sms_pairing_state_tracker_
? android_sms_pairing_state_tracker_->IsAndroidSmsPairingComplete()
@@ -750,11 +745,10 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
->GetNotificationAccessProhibitedReason();
}
- page_content_dictionary->SetInteger(
- kNotificationAccessStatus,
- static_cast<int32_t>(notification_access_status));
- page_content_dictionary->SetIntKey(kNotificationAccessProhibitedReason,
- static_cast<int32_t>(reason));
+ page_content_dictionary.Set(kNotificationAccessStatus,
+ static_cast<int32_t>(notification_access_status));
+ page_content_dictionary.Set(kNotificationAccessProhibitedReason,
+ static_cast<int32_t>(reason));
phonehub::MultideviceFeatureAccessManager::AccessStatus
camera_roll_access_status = phonehub::MultideviceFeatureAccessManager::
@@ -762,8 +756,8 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
if (multidevice_feature_access_manager_)
camera_roll_access_status =
multidevice_feature_access_manager_->GetCameraRollAccessStatus();
- page_content_dictionary->SetInteger(
- kCameraRollAccessStatus, static_cast<int32_t>(camera_roll_access_status));
+ page_content_dictionary.Set(kCameraRollAccessStatus,
+ static_cast<int32_t>(camera_roll_access_status));
phonehub::MultideviceFeatureAccessManager::AccessStatus apps_access_status =
phonehub::MultideviceFeatureAccessManager::AccessStatus::
@@ -771,8 +765,8 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
if (apps_access_manager_)
apps_access_status = apps_access_manager_->GetAccessStatus();
- page_content_dictionary->SetInteger(kAppsAccessStatus,
- static_cast<int32_t>(apps_access_status));
+ page_content_dictionary.Set(kAppsAccessStatus,
+ static_cast<int32_t>(apps_access_status));
bool is_camera_roll_file_permission_granted = false;
if (camera_roll_manager_) {
@@ -781,29 +775,27 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
ash::phonehub::CameraRollManager::CameraRollUiState::
NO_STORAGE_PERMISSION;
}
- page_content_dictionary->SetBoolKey(kIsCameraRollFilePermissionGranted,
- is_camera_roll_file_permission_granted);
+ page_content_dictionary.Set(kIsCameraRollFilePermissionGranted,
+ is_camera_roll_file_permission_granted);
bool is_nearby_share_disallowed_by_policy =
NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
Profile::FromWebUI(web_ui())) &&
(GetNearbyShareEnabledState(prefs_) ==
NearbyShareEnabledState::kDisallowedByPolicy);
- page_content_dictionary->SetBoolKey(kIsNearbyShareDisallowedByPolicy,
- is_nearby_share_disallowed_by_policy);
+ page_content_dictionary.Set(kIsNearbyShareDisallowedByPolicy,
+ is_nearby_share_disallowed_by_policy);
bool is_phone_hub_permissions_dialog_supported =
features::IsEcheSWAEnabled() || features::IsPhoneHubCameraRollEnabled();
- page_content_dictionary->SetBoolean(
- kIsPhoneHubPermissionsDialogSupported,
- is_phone_hub_permissions_dialog_supported);
-
- page_content_dictionary->SetBoolKey(
- kIsPhoneHubFeatureCombinedSetupSupported,
- multidevice_feature_access_manager_
- ? multidevice_feature_access_manager_
- ->GetFeatureSetupRequestSupported()
- : false);
+ page_content_dictionary.Set(kIsPhoneHubPermissionsDialogSupported,
+ is_phone_hub_permissions_dialog_supported);
+
+ page_content_dictionary.Set(kIsPhoneHubFeatureCombinedSetupSupported,
+ multidevice_feature_access_manager_
+ ? multidevice_feature_access_manager_
+ ->GetFeatureSetupRequestSupported()
+ : false);
return page_content_dictionary;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
index 7ba32a17567..23a3dc9ca3e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
@@ -23,10 +23,6 @@
class PrefService;
-namespace base {
-class DictionaryValue;
-} // namespace base
-
namespace chromeos {
namespace settings {
@@ -145,7 +141,7 @@ class MultideviceHandler
void NotifySmartLockSignInAllowedChanged();
// Generate android sms info dictionary containing the messages for web
// content settings origin url and messages feature state.
- std::unique_ptr<base::DictionaryValue> GenerateAndroidSmsInfo();
+ base::Value::Dict GenerateAndroidSmsInfo();
void NotifyAndroidSmsInfoChange();
// Returns true if |auth_token| matches the current auth token stored in
@@ -161,7 +157,7 @@ class MultideviceHandler
// Returns null if requisite data has not yet been fetched (i.e., if one or
// both of |last_host_status_update_| and |last_feature_states_update_| is
// null).
- std::unique_ptr<base::DictionaryValue> GeneratePageContentDataDictionary();
+ base::Value::Dict GeneratePageContentDataDictionary();
multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice
GetHostStatusWithDevice();
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 ebc51dfbbf8..05b0e6b3b88 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
@@ -342,10 +342,9 @@ class MultideviceHandlerTest : public testing::Test {
void CallGetPageContentData() {
size_t call_data_count_before_call = test_web_ui()->call_data().size();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("handlerFunctionName");
- test_web_ui()->HandleReceivedMessage("getPageContentData",
- &base::Value::AsListValue(args));
+ test_web_ui()->HandleReceivedMessage("getPageContentData", args);
EXPECT_EQ(call_data_count_before_call + 1u,
test_web_ui()->call_data().size());
@@ -361,8 +360,8 @@ class MultideviceHandlerTest : public testing::Test {
void CallRemoveHostDevice() {
size_t num_remote_host_device_calls_before_call =
fake_multidevice_setup_client()->num_remove_host_device_called();
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("removeHostDevice", &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("removeHostDevice", empty_args);
EXPECT_EQ(num_remote_host_device_calls_before_call + 1u,
fake_multidevice_setup_client()->num_remove_host_device_called());
}
@@ -370,10 +369,9 @@ class MultideviceHandlerTest : public testing::Test {
void CallGetAndroidSmsInfo(bool expected_enabled, const GURL& expected_url) {
size_t call_data_count_before_call = test_web_ui()->call_data().size();
- base::ListValue args;
+ base::Value::List args;
args.Append("handlerFunctionName");
- test_web_ui()->HandleReceivedMessage("getAndroidSmsInfo",
- &base::Value::AsListValue(args));
+ test_web_ui()->HandleReceivedMessage("getAndroidSmsInfo", args);
ASSERT_EQ(call_data_count_before_call + 1u,
test_web_ui()->call_data().size());
@@ -399,15 +397,14 @@ class MultideviceHandlerTest : public testing::Test {
kAvailableButNotGranted,
phonehub::MultideviceFeatureAccessManager::AccessProhibitedReason::
kUnknown);
- base::ListValue empty_args;
+ base::Value::List empty_args;
test_web_ui()->HandleReceivedMessage("attemptNotificationSetup",
- &empty_args);
+ empty_args);
}
void CallCancelNotificationSetup() {
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("cancelNotificationSetup",
- &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("cancelNotificationSetup", empty_args);
}
void CallAttemptAppsSetup(bool has_access_been_granted) {
@@ -416,13 +413,13 @@ class MultideviceHandlerTest : public testing::Test {
AccessStatus::kAccessGranted
: phonehub::MultideviceFeatureAccessManager::
AccessStatus::kAvailableButNotGranted);
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("attemptAppsSetup", &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("attemptAppsSetup", empty_args);
}
void CallCancelAppsSetup() {
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("cancelAppsSetup", &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("cancelAppsSetup", empty_args);
}
void CallAttemptCameraRollSetup(bool has_camera_roll_access_been_granted) {
@@ -433,16 +430,16 @@ class MultideviceHandlerTest : public testing::Test {
kAccessGranted
: phonehub::MultideviceFeatureAccessManager::AccessStatus::
kAvailableButNotGranted);
- base::ListValue args;
+ base::Value::List args;
args.Append(/*camera_roll=*/true);
args.Append(/*notifications=*/false);
- test_web_ui()->HandleReceivedMessage("attemptCombinedFeatureSetup", &args);
+ test_web_ui()->HandleReceivedMessage("attemptCombinedFeatureSetup", args);
}
void CallCancelCameraRollSetup() {
- base::ListValue empty_args;
+ base::Value::List empty_args;
test_web_ui()->HandleReceivedMessage("cancelCombinedFeatureSetup",
- &empty_args);
+ empty_args);
}
void SimulateHostStatusUpdate(
@@ -607,15 +604,15 @@ class MultideviceHandlerTest : public testing::Test {
}
void CallRetryPendingHostSetup(bool success) {
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("retryPendingHostSetup", &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("retryPendingHostSetup", empty_args);
fake_multidevice_setup_client()->InvokePendingRetrySetHostNowCallback(
success);
}
void CallSetUpAndroidSms() {
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("setUpAndroidSms", &empty_args);
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("setUpAndroidSms", empty_args);
}
void CallSetFeatureEnabledState(multidevice_setup::mojom::Feature feature,
@@ -624,16 +621,15 @@ class MultideviceHandlerTest : public testing::Test {
bool success) {
size_t call_data_count_before_call = test_web_ui()->call_data().size();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("handlerFunctionName");
args.Append(static_cast<int>(feature));
args.Append(enabled);
if (auth_token)
args.Append(*auth_token);
- base::ListValue empty_args;
- test_web_ui()->HandleReceivedMessage("setFeatureEnabledState",
- &base::Value::AsListValue(args));
+ base::Value::List empty_args;
+ test_web_ui()->HandleReceivedMessage("setFeatureEnabledState", args);
fake_multidevice_setup_client()
->InvokePendingSetFeatureEnabledStateCallback(
feature /* expected_feature */, enabled /* expected_enabled */,
@@ -842,10 +838,9 @@ class MultideviceHandlerTest : public testing::Test {
TEST_F(MultideviceHandlerTest, PageContentDataRequestedWithNullManagers) {
SetUpHandlerWithEmptyManagers();
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("handlerFunctionName");
- test_web_ui()->HandleReceivedMessage("getPageContentData",
- &base::Value::AsListValue(args));
+ test_web_ui()->HandleReceivedMessage("getPageContentData", args);
}
TEST_F(MultideviceHandlerTest, NotificationSetupFlow) {
@@ -1007,113 +1002,113 @@ TEST_F(MultideviceHandlerTest, LogUmaMetricsForSetupFlow) {
base::HistogramTester histogram_tester;
histogram_tester.ExpectTotalCount(kDialogIntroActionHistogram, 0);
- base::ListValue set_up_screen_args;
+ base::Value::List set_up_screen_args;
set_up_screen_args.Append(/*irrelivant_set_up_dialog=*/0);
set_up_screen_args.Append(/*action_cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectTotalCount(kDialogIntroActionHistogram, 0);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*intro_screen_index=*/1);
set_up_screen_args.Append(/*learn_more=*/2);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogIntroActionHistogram,
/*learn_more=*/2, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*intro_screen_index=*/1);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogIntroActionHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*intro_screen_index=*/1);
set_up_screen_args.Append(/*next=*/5);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogIntroActionHistogram,
/*done=*/5, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*finish_on_phone_screen_index=*/2);
set_up_screen_args.Append(/*learn_more=*/2);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogFinishOnPhoneActionHistogram,
/*learn_more=*/2, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*finish_on_phone_screen_index=*/2);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogFinishOnPhoneActionHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connecting_screen_index=*/3);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogConnectingActionHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connected_screen_index=*/6);
set_up_screen_args.Append(/*done=*/4);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogSetupFinishedActionHistogram,
/*done=*/4, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connection_error_screen_index=*/4);
set_up_screen_args.Append(/*try_again=*/5);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogConnectionErrorActionHistogram,
/*try_again=*/5, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connection_error_screen_index=*/4);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogConnectionErrorActionHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connection_time_out_screen_index=*/5);
set_up_screen_args.Append(/*try_again=*/5);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogConnectionTimeOutActionHistogram,
/*try_again=*/5, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*connection_time_out_screen_index=*/5);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogConnectionTimeOutActionHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*set_a_pin_screen_index=*/7);
set_up_screen_args.Append(/*cancel=*/3);
test_web_ui()->HandleReceivedMessage("logPhoneHubPermissionSetUpScreenAction",
- &set_up_screen_args);
+ set_up_screen_args);
histogram_tester.ExpectBucketCount(kDialogSetAPinOrPasswordHistogram,
/*cancel=*/3, 1);
- set_up_screen_args.ClearList();
+ set_up_screen_args.clear();
set_up_screen_args.Append(/*camera_roll_setup=*/3);
test_web_ui()->HandleReceivedMessage(
- "logPhoneHubPermissionSetUpButtonClicked", &set_up_screen_args);
+ "logPhoneHubPermissionSetUpButtonClicked", set_up_screen_args);
histogram_tester.ExpectBucketCount(kSetupButtonInSettingsClikedHistogram,
/*camera_roll_setup=*/3, 1);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
index d719788cd25..3655435b886 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
@@ -24,8 +24,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/session_controller_client_impl.h"
#include "chrome/browser/ui/webui/nearby_share/shared_resources.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
@@ -406,6 +406,8 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_SCREEN_LOCK_TITLE},
{"multideviceNotificationAccessSetupScreenLockInstruction",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_SCREEN_LOCK_INSTRUCTION},
+ {"multideviceNotificationAccessSetupScreenLockIconInstruction",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_SCREEN_LOCK_ICON_INSTRUCTION},
{"multideviceNotificationAccessSetupAwaitingResponseTitle",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_AWAITING_RESPONSE_TITLE},
{"multideviceNotificationAccessSetupInstructions",
@@ -464,6 +466,8 @@ void MultiDeviceSection::AddLoadTimeData(
{"multidevicePhoneHubCameraRollNotificationsAndAppsItemSummary",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_CAMERA_ROLL_NOTIFICATIONS_AND_APPS_SUMMARY},
{"multideviceLearnMoreWithoutURL", IDS_SETTINGS_LEARN_MORE},
+ {"multidevicePhoneHubLearnMoreAriaLabel",
+ IDS_SETTINGS_PHONE_HUB_LEARN_MORE_ARIA_LABEL},
{"multidevicePermissionsSetupCameraRollSummary",
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_CAMERA_ROLL_ITEM_SUMMARY},
{"multidevicePermissionsSetupNotificationsSummary",
@@ -474,8 +478,6 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_INSTRUCTIONS},
{"multidevicePermissionsSetupOperationsInstructions",
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_OPERATION_INSTRUCTIONS},
- {"multidevicePermissionsSetupCompletedSummary",
- IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_COMPLETED_SUMMARY},
{"multidevicePermissionsSetupAwaitingResponseTitle",
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_AWAITING_RESPONSE_TITLE},
{"multidevicePermissionsSetupCouldNotEstablishConnectionTitle",
@@ -486,6 +488,24 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_CONNECTION_LOST_WITH_PHONE_SUMMARY},
{"multidevicePermissionsSetupNotificationAccessProhibitedTitle",
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_NOTIFICATION_ACCESS_PROHIBITED_TITLE},
+ {"multidevicePermissionsSetupCompletedMoreFeaturesSummary",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_COMPLETED_MORE_FEATURES_SUMMARY},
+ {"multidevicePermissionsSetupAllCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_ALL_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupCameraRollAndNotificationsCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_CAMERA_ROLL_AND_NOTIFICATIONS_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupNotificationsAndAppsCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_NOTIFICATIONS_AND_APPS_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupCameraRollAndAppsCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_CAMERA_ROLL_AND_APPS_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupCameraRollCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_CAMERA_ROLL_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupNotificationsCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_NOTIFICATIONS_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupAppssCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_APPS_COMPLETED_TITLE},
+ {"multidevicePermissionsSetupAppssCompletedFailedTitle",
+ IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_COMPLETED_FAILED_TITLE},
};
html_source->AddLocalizedStrings(kLocalizedStrings);
@@ -595,10 +615,6 @@ void MultiDeviceSection::AddLoadTimeData(
ui::SubstituteChromeOSDeviceType(
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_ACK_SUBTITLE));
html_source->AddString(
- "multidevicePermissionsSetupCompletedTitle",
- ui::SubstituteChromeOSDeviceType(
- IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_COMPLETED_TITLE));
- html_source->AddString(
"multidevicePermissionsSetupNotificationAccessProhibitedSummary",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_PERMISSIONS_SETUP_DIALOG_NOTIFICATION_ACCESS_PROHIBITED_SUMMARY,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section_unittest.cc
index af114a16dcd..48a481dcc48 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section_unittest.cc
@@ -14,10 +14,10 @@
#include "base/values.h"
#include "chrome/browser/ash/android_sms/android_sms_service_factory.h"
#include "chrome/browser/ash/eche_app/eche_app_manager_factory.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/browser/web_ui_data_source.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 f7af139b3b5..7ee91f95598 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
@@ -7,10 +7,10 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/hierarchy.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc
index e705b2c7db1..2cd73306ee7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc
index ef1a0732995..8f68ac7c869 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc
@@ -26,11 +26,12 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
-#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
-#include "chromeos/components/local_search_service/search_metrics_reporter.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy.h"
+#include "chromeos/ash/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
+#include "chromeos/ash/components/local_search_service/search_metrics_reporter.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/accessibility/accessibility_features.h"
namespace chromeos {
namespace settings {
@@ -45,6 +46,9 @@ class OsSettingsManagerTest : public testing::Test {
// testing::Test:
void SetUp() override {
+ scoped_feature_list_.InitWithFeatures(
+ {features::kAccessibilityOSSettingsVisibility}, {});
+
ASSERT_TRUE(profile_manager_.SetUp());
TestingProfile* profile =
profile_manager_.CreateTestingProfile("TestingProfile");
@@ -78,6 +82,7 @@ class OsSettingsManagerTest : public testing::Test {
std::make_unique<local_search_service::LocalSearchServiceProxy>(
/*for_testing=*/true);
std::unique_ptr<OsSettingsManager> manager_;
+ base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(OsSettingsManagerTest, Initialization) {
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 6ea23f8a295..49119bbf1e8 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
@@ -11,10 +11,10 @@
#include "base/containers/span.h"
#include "base/gtest_prod_util.h"
#include "base/values.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search.mojom.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_concept.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/search/search.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_concept.h"
class Profile;
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 8a54f75ffc4..5f03674675e 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
@@ -7,6 +7,7 @@
#include <utility>
#include "ash/constants/ash_features.h"
+#include "ash/public/cpp/audio_config_service.h"
#include "ash/public/cpp/bluetooth_config_service.h"
#include "ash/public/cpp/esim_manager.h"
#include "ash/public/cpp/network_config_service.h"
@@ -24,18 +25,20 @@
#include "chrome/browser/nearby_sharing/nearby_sharing_service_impl.h"
#include "chrome/browser/ui/webui/managed_ui_handler.h"
#include "chrome/browser/ui/webui/settings/ash/os_apps_page/app_notification_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/os_settings_resources.h"
#include "chrome/grit/os_settings_resources_map.h"
+#include "chromeos/ash/services/auth_factor_config/in_process_instances.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
@@ -220,6 +223,22 @@ void OSSettingsUI::BindInterface(
ash::GetBluetoothConfigService(std::move(receiver));
}
+void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<ash::audio_config::mojom::CrosAudioConfig> receiver) {
+ DCHECK(features::IsAudioSettingsPageEnabled());
+ ash::GetAudioConfigService(std::move(receiver));
+}
+
+void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<ash::auth::mojom::AuthFactorConfig> receiver) {
+ ash::auth::BindToAuthFactorConfig(std::move(receiver));
+}
+
+void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<ash::auth::mojom::RecoveryFactorEditor> receiver) {
+ ash::auth::BindToRecoveryFactorEditor(std::move(receiver));
+}
+
WEB_UI_CONTROLLER_TYPE_IMPL(OSSettingsUI)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
index 3003a50ec87..95af1514ac7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
@@ -16,8 +16,10 @@
#include "chrome/browser/ui/webui/nearby_share/nearby_share.mojom.h"
#include "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom.h"
#include "chrome/browser/ui/webui/settings/ash/os_apps_page/mojom/app_notification_handler.mojom-forward.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom-forward.h"
+#include "chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom-forward.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
+#include "chromeos/ash/components/audio/public/mojom/cros_audio_config.mojom-forward.h"
+#include "chromeos/ash/services/auth_factor_config/public/mojom/auth_factor_config.mojom-forward.h"
#include "chromeos/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-forward.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@@ -59,6 +61,12 @@ class OSSettingsUI : public ui::MojoWebUIController {
void BindInterface(
mojo::PendingReceiver<ash::cellular_setup::mojom::ESimManager> receiver);
+ // Instantiates implementor of the mojom::CrosAudioConfig mojo interface
+ // passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<ash::audio_config::mojom::CrosAudioConfig>
+ receiver);
+
// Instantiates implementor of the mojom::CrosNetworkConfig mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
@@ -110,6 +118,12 @@ class OSSettingsUI : public ui::MojoWebUIController {
mojo::PendingReceiver<bluetooth_config::mojom::CrosBluetoothConfig>
receiver);
+ // Binds to the cros authentication factor editing services.
+ void BindInterface(
+ mojo::PendingReceiver<ash::auth::mojom::AuthFactorConfig> receiver);
+ void BindInterface(
+ mojo::PendingReceiver<ash::auth::mojom::RecoveryFactorEditor> receiver);
+
private:
base::TimeTicks time_when_opened_;
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 3299cfffb37..58570979b80 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
@@ -15,9 +15,11 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.h"
+#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/app_update.h"
+#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
@@ -70,18 +72,31 @@ void ParentalControlsHandler::HandleLaunchFamilyLinkSettings(
chromeos::ChildUserService::kFamilyLinkHelperAppPackageName, profile_);
if (registry.GetAppType(app_id) != apps::AppType::kUnknown) {
// Launch FLH app since it is available.
- proxy->Launch(app_id, ui::EF_NONE,
- apps::mojom::LaunchSource::kFromParentalControls,
- apps::MakeWindowInfo(display::kDefaultDisplayId));
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ proxy->Launch(
+ app_id, ui::EF_NONE, apps::LaunchSource::kFromParentalControls,
+ std::make_unique<apps::WindowInfo>(display::kDefaultDisplayId));
+ } else {
+ proxy->Launch(app_id, ui::EF_NONE,
+ apps::mojom::LaunchSource::kFromParentalControls,
+ apps::MakeWindowInfo(display::kDefaultDisplayId));
+ }
return;
}
// No FLH app installed, so try to launch Play Store to FLH app install page.
if (registry.GetAppType(arc::kPlayStoreAppId) != apps::AppType::kUnknown) {
- proxy->LaunchAppWithUrl(
- arc::kPlayStoreAppId, ui::EF_NONE,
- GURL(chromeos::ChildUserService::kFamilyLinkHelperAppPlayStoreURL),
- apps::mojom::LaunchSource::kFromChromeInternal);
+ if (base::FeatureList::IsEnabled(apps::kAppServiceLaunchWithoutMojom)) {
+ proxy->LaunchAppWithUrl(
+ arc::kPlayStoreAppId, ui::EF_NONE,
+ GURL(chromeos::ChildUserService::kFamilyLinkHelperAppPlayStoreURL),
+ apps::LaunchSource::kFromChromeInternal);
+ } else {
+ proxy->LaunchAppWithUrl(
+ arc::kPlayStoreAppId, ui::EF_NONE,
+ GURL(chromeos::ChildUserService::kFamilyLinkHelperAppPlayStoreURL),
+ apps::mojom::LaunchSource::kFromChromeInternal);
+ }
return;
}
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 11229c41a21..112d997c9bd 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
@@ -4,10 +4,10 @@
#include "chrome/browser/ui/webui/settings/chromeos/people_section.h"
-#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_pref_names.h"
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/i18n/number_formatting.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
@@ -27,12 +27,12 @@
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/chromeos/sync/os_sync_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/people_handler.h"
#include "chrome/browser/ui/webui/settings/profile_info_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
@@ -41,6 +41,7 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/account_manager_facade.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
#include "components/account_manager_core/pref_names.h"
@@ -48,6 +49,7 @@
#include "components/omnibox/common/omnibox_features.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
+#include "components/sync/base/features.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
#include "components/user_manager/user.h"
@@ -313,6 +315,8 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_PIN_AUTOSUBMIT_ERROR_PIN_INCORRECT},
{"passwordPromptEnterPasswordLoginLock",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_ENTER_PASSWORD_LOGIN_LOCK},
+ {"recoveryToggleLabel", IDS_SETTINGS_PEOPLE_RECOVERY_TOGGLE_LABEL},
+ {"recoveryToggleSubLabel", IDS_SETTINGS_PEOPLE_RECOVERY_TOGGLE_SUB_LABEL},
};
html_source->AddLocalizedStrings(kLocalizedStrings);
@@ -398,6 +402,14 @@ void AddFingerprintResources(content::WebUIDataSource* html_source,
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_LEFT_SIDE_ARIA_LABEL;
aria_label_includes_device = true;
break;
+ case FingerprintLocation::LEFT_OF_POWER_BUTTON_TOP_RIGHT:
+ DCHECK(ash::quick_unlock::IsLeftOfPowerButtonTopRightFingerprint());
+ instruction_id =
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_LEFT_OF_POWER_BUTTON_TOP_RIGHT;
+ // Use the dialog title as the aria-label, since this location does not
+ // require an aria-label.
+ aria_label_id = IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TITLE;
+ break;
case FingerprintLocation::UNKNOWN:
instruction_id =
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD;
@@ -405,8 +417,14 @@ void AddFingerprintResources(content::WebUIDataSource* html_source,
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD;
break;
}
- html_source->AddLocalizedString(
- "configureFingerprintInstructionLocateScannerStep", instruction_id);
+ if (ash::quick_unlock::IsLeftOfPowerButtonTopRightFingerprint()) {
+ html_source->AddString("configureFingerprintInstructionLocateScannerStep",
+ l10n_util::GetStringFUTF16(
+ instruction_id, ui::GetChromeOSDeviceName()));
+ } else {
+ html_source->AddLocalizedString(
+ "configureFingerprintInstructionLocateScannerStep", instruction_id);
+ }
if (aria_label_includes_device) {
html_source->AddString(
"configureFingerprintScannerStepAriaLabel",
@@ -472,6 +490,8 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
{"osSyncWifiConfigurationsCheckboxLabel",
IDS_OS_SETTINGS_WIFI_CONFIGURATIONS_CHECKBOX_LABEL},
{"osSyncAppsCheckboxLabel", IDS_OS_SETTINGS_SYNC_APPS_CHECKBOX_LABEL},
+ {"osSyncAppsCheckboxSublabel",
+ IDS_OS_SETTINGS_SYNC_APPS_CHECKBOX_SUBLABEL},
{"osSyncTurnOn", IDS_OS_SETTINGS_SYNC_TURN_ON},
{"osSyncFeatureLabel", IDS_OS_SETTINGS_SYNC_FEATURE_LABEL},
};
@@ -480,6 +500,10 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean(
"syncSettingsCategorizationEnabled",
chromeos::features::IsSyncSettingsCategorizationEnabled());
+ html_source->AddBoolean(
+ "appsToggleSharingEnabled",
+ base::FeatureList::IsEnabled(syncer::kSyncChromeOSAppsToggleSharing) &&
+ crosapi::browser_util::IsLacrosEnabled());
html_source->AddString(
"browserSettingsSyncSetupUrl",
base::StrCat({chrome::kChromeUISettingsURL, chrome::kSyncSetupSubPage}));
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc
index 0c37b10774d..9a19da0139a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc
@@ -9,7 +9,6 @@
#include "ash/components/peripheral_notification/peripheral_notification_manager.h"
#include "ash/components/settings/cros_settings_names.h"
-#include "ash/components/tpm/install_attributes.h"
#include "ash/constants/ash_pref_names.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -21,6 +20,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chromeos/ash/components/dbus/pciguard/pciguard_client.h"
+#include "chromeos/ash/components/install_attributes/install_attributes.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
@@ -113,9 +113,9 @@ void PeripheralDataAccessHandler::HandleGetPolicyState(
? local_state_pref_name
: cros_setting_pref_name;
- base::Value response(base::Value::Type::DICTIONARY);
- response.SetKey("prefName", base::Value(pref_name));
- response.SetKey("isUserConfigurable", base::Value(is_user_configurable_));
+ base::Value::Dict response;
+ response.Set("prefName", pref_name);
+ response.Set("isUserConfigurable", is_user_configurable_);
ResolveJavascriptCallback(base::Value(callback_id), response);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.cc
index dec8fb241c9..dedfe45409a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "chrome/browser/ash/web_applications/personalization_app/personalization_app_metrics.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h"
+#include "chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h"
#include "content/public/browser/web_ui.h"
namespace chromeos {
@@ -34,8 +34,8 @@ void PersonalizationHubHandler::HandleOpenPersonalizationHub(
// Record entry point metric to Personalization Hub through Settings.
ash::personalization_app::LogPersonalizationEntryPoint(
ash::PersonalizationEntryPoint::kSettings);
- web_app::LaunchSystemWebAppAsync(Profile::FromWebUI(web_ui()),
- ash::SystemWebAppType::PERSONALIZATION);
+ ash::LaunchSystemWebAppAsync(Profile::FromWebUI(web_ui()),
+ ash::SystemWebAppType::PERSONALIZATION);
}
} // namespace settings
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 8668b951a1a..d63b87ff2d6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
@@ -5,29 +5,19 @@
#include "chrome/browser/ui/webui/settings/chromeos/personalization_section.h"
#include "ash/constants/ash_features.h"
-#include "ash/constants/ash_pref_names.h"
-#include "ash/public/cpp/ambient/ambient_client.h"
-#include "ash/public/cpp/ambient/ambient_prefs.h"
-#include "base/bind.h"
#include "base/no_destructor.h"
-#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/personalization_hub_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h"
-#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
-#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
-#include "url/gurl.h"
namespace chromeos {
namespace settings {
@@ -66,87 +56,13 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() {
return *tags;
}
-const std::vector<SearchConcept>& GetAmbientModeSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE,
- mojom::kAmbientModeSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kAmbientMode}},
- });
- return *tags;
-}
-
-const std::vector<SearchConcept>& GetAmbientModeOnSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_CHOOSE_SOURCE,
- mojom::kAmbientModeSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAmbientModeSource}},
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_TURN_OFF,
- mojom::kAmbientModeSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAmbientModeOnOff},
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_TURN_OFF_ALT1,
- SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_GOOGLE_PHOTOS_ALBUM,
- mojom::kAmbientModeGooglePhotosAlbumSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kAmbientModeGooglePhotosAlbum}},
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_ART_GALLERY_ALBUM,
- mojom::kAmbientModeArtGalleryAlbumSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kAmbientModeArtGalleryAlbum}},
- });
- return *tags;
-}
-
-const std::vector<SearchConcept>& GetAmbientModeOffSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_TURN_ON,
- mojom::kAmbientModeSubpagePath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAmbientModeOnOff},
- {IDS_OS_SETTINGS_TAG_AMBIENT_MODE_TURN_ON_ALT1,
- SearchConcept::kAltTagEnd}},
- });
- return *tags;
-}
-
-bool IsAmbientModeAllowed() {
- // TODO(b/172029925): Set up to test this code.
- return chromeos::features::IsAmbientModeEnabled() &&
- ash::AmbientClient::Get() &&
- ash::AmbientClient::Get()->IsAmbientModeAllowed();
-}
-
-bool IsAmbientModePhotoPreviewAllowed() {
- return chromeos::features::IsAmbientModePhotoPreviewEnabled();
-}
-
-GURL GetGooglePhotosURL() {
- return GURL(chrome::kGooglePhotosURL);
-}
-
} // namespace
PersonalizationSection::PersonalizationSection(
Profile* profile,
SearchTagRegistry* search_tag_registry,
PrefService* pref_service)
- : OsSettingsSection(profile, search_tag_registry),
- pref_service_(pref_service) {
+ : OsSettingsSection(profile, search_tag_registry) {
// Personalization search tags are not added in guest mode.
if (features::IsGuestModeActive())
return;
@@ -159,17 +75,6 @@ PersonalizationSection::PersonalizationSection(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetPersonalizationSearchConcepts());
-
- if (IsAmbientModeAllowed()) {
- updater.AddSearchTags(GetAmbientModeSearchConcepts());
- pref_change_registrar_.Init(pref_service_);
- pref_change_registrar_.Add(
- ash::ambient::prefs::kAmbientModeEnabled,
- base::BindRepeating(
- &PersonalizationSection::OnAmbientModeEnabledStateChanged,
- base::Unretained(this)));
- OnAmbientModeEnabledStateChanged();
- }
}
PersonalizationSection::~PersonalizationSection() = default;
@@ -177,44 +82,6 @@ PersonalizationSection::~PersonalizationSection() = default;
void PersonalizationSection::AddLoadTimeData(
content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"ambientModeTitle", IDS_OS_SETTINGS_AMBIENT_MODE_TITLE},
- {"ambientModeEnabled", IDS_OS_SETTINGS_AMBIENT_MODE_ENABLED},
- {"ambientModeDisabled", IDS_OS_SETTINGS_AMBIENT_MODE_DISABLED},
- {"ambientModePageDescription",
- IDS_OS_SETTINGS_AMBIENT_MODE_PAGE_DESCRIPTION},
- {"ambientModeOn", IDS_OS_SETTINGS_AMBIENT_MODE_ON},
- {"ambientModeOff", IDS_OS_SETTINGS_AMBIENT_MODE_OFF},
- {"ambientModeTopicSourceTitle",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_TITLE},
- {"ambientModeTopicSourceGooglePhotos",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_GOOGLE_PHOTOS},
- {"ambientModeTopicSourceGooglePhotosDescription",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_GOOGLE_PHOTOS_DESC},
- {"ambientModeTopicSourceGooglePhotosDescriptionNoAlbum",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_GOOGLE_PHOTOS_DESC_NO_ALBUM},
- {"ambientModeTopicSourceArtGallery",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_ART_GALLERY},
- {"ambientModeTopicSourceArtGalleryDescription",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_ART_GALLERY_DESCRIPTION},
- {"ambientModeTopicSourceSelectedRow",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_SELECTED_ROW},
- {"ambientModeTopicSourceUnselectedRow",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_UNSELECTED_ROW},
- {"ambientModeTopicSourceSubpage",
- IDS_OS_SETTINGS_AMBIENT_MODE_TOPIC_SOURCE_SUBPAGE},
- {"ambientModeWeatherTitle", IDS_OS_SETTINGS_AMBIENT_MODE_WEATHER_TITLE},
- {"ambientModeTemperatureUnitFahrenheit",
- IDS_OS_SETTINGS_AMBIENT_MODE_TEMPERATURE_UNIT_FAHRENHEIT},
- {"ambientModeTemperatureUnitCelsius",
- IDS_OS_SETTINGS_AMBIENT_MODE_TEMPERATURE_UNIT_CELSIUS},
- {"ambientModeAlbumsSubpageAlbumSelected",
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_ALBUM_SELECTED},
- {"ambientModeAlbumsSubpageAlbumUnselected",
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_ALBUM_UNSELECTED},
- {"ambientModeLastArtAlbumMessage",
- IDS_OS_SETTINGS_AMBIENT_MODE_LAST_ART_ALBUM_MESSAGE},
- {"ambientModeArtAlbumDialogCloseButtonLabel",
- IDS_OS_SETTINGS_AMBIENT_MODE_ART_ALBUM_DIALOG_CLOSE_BUTTON_LABEL},
{"changePictureTitle", IDS_OS_SETTINGS_CHANGE_PICTURE_TITLE},
{"openWallpaperApp", IDS_OS_SETTINGS_OPEN_WALLPAPER_APP},
{"personalizationPageTitle", IDS_OS_SETTINGS_PERSONALIZATION},
@@ -246,19 +113,6 @@ void PersonalizationSection::AddLoadTimeData(
html_source->AddBoolean(
"changePictureVideoModeEnabled",
base::FeatureList::IsEnabled(::features::kChangePictureVideoMode));
- html_source->AddBoolean("isAmbientModeEnabled", IsAmbientModeAllowed());
- html_source->AddBoolean("isAmbientModePhotoPreviewEnabled",
- IsAmbientModePhotoPreviewAllowed());
- html_source->AddString(
- "ambientModeAlbumsSubpageGooglePhotosTitle",
- l10n_util::GetStringFUTF16(
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_GOOGLE_PHOTOS_TITLE,
- base::UTF8ToUTF16(GetGooglePhotosURL().spec())));
- html_source->AddString(
- "ambientModeAlbumsSubpageGooglePhotosNoAlbum",
- l10n_util::GetStringFUTF16(
- IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_GOOGLE_PHOTOS_NO_ALBUM,
- base::UTF8ToUTF16(GetGooglePhotosURL().spec())));
}
void PersonalizationSection::AddHandlers(content::WebUI* web_ui) {
@@ -270,13 +124,6 @@ void PersonalizationSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::settings::PersonalizationHubHandler>());
}
-
- if (!profile()->IsGuestSession() &&
- chromeos::features::IsAmbientModeEnabled()) {
- web_ui->AddMessageHandler(
- std::make_unique<chromeos::settings::AmbientModeHandler>(
- pref_service_));
- }
}
int PersonalizationSection::GetSectionNameMessageId() const {
@@ -312,42 +159,6 @@ void PersonalizationSection::RegisterHierarchy(
mojom::kChangePictureSubpagePath);
generator->RegisterNestedSetting(mojom::Setting::kChangeDeviceAccountImage,
mojom::Subpage::kChangePicture);
-
- // Ambient mode.
- generator->RegisterTopLevelSubpage(
- IDS_OS_SETTINGS_AMBIENT_MODE_TITLE, mojom::Subpage::kAmbientMode,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium, mojom::kAmbientModeSubpagePath);
- static constexpr mojom::Setting kAmbientModeSettings[] = {
- mojom::Setting::kAmbientModeOnOff,
- mojom::Setting::kAmbientModeSource,
- };
- RegisterNestedSettingBulk(mojom::Subpage::kAmbientMode, kAmbientModeSettings,
- generator);
- generator->RegisterNestedSubpage(
- IDS_OS_SETTINGS_AMBIENT_MODE_TITLE,
- mojom::Subpage::kAmbientModeGooglePhotosAlbum,
- mojom::Subpage::kAmbientMode, mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::kAmbientModeGooglePhotosAlbumSubpagePath);
- generator->RegisterNestedSubpage(
- IDS_OS_SETTINGS_AMBIENT_MODE_TITLE,
- mojom::Subpage::kAmbientModeArtGalleryAlbum, mojom::Subpage::kAmbientMode,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::kAmbientModeArtGalleryAlbumSubpagePath);
-}
-
-void PersonalizationSection::OnAmbientModeEnabledStateChanged() {
- SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
-
- if (pref_service_->GetBoolean(ash::ambient::prefs::kAmbientModeEnabled)) {
- updater.AddSearchTags(GetAmbientModeOnSearchConcepts());
- updater.RemoveSearchTags(GetAmbientModeOffSearchConcepts());
- } else {
- updater.RemoveSearchTags(GetAmbientModeOnSearchConcepts());
- updater.AddSearchTags(GetAmbientModeOffSearchConcepts());
- }
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
index 31e52ce5770..ca8d94e9bf8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
@@ -41,10 +41,6 @@ class PersonalizationSection : public OsSettingsSection {
bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
- // ash::AmbientModeService::Observer:
- void OnAmbientModeEnabledStateChanged();
-
- PrefService* pref_service_;
PrefChangeRegistrar pref_change_registrar_;
};
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 0ac876f683d..fd472f7941b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/printing_section.h"
#include "base/no_destructor.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.cc
new file mode 100644
index 00000000000..9856a6fd243
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.cc
@@ -0,0 +1,99 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h"
+
+#include "base/bind.h"
+
+namespace {
+
+base::Value CameraPrivacySwitchStateToBaseValue(
+ cros::mojom::CameraPrivacySwitchState state) {
+ switch (state) {
+ case cros::mojom::CameraPrivacySwitchState::ON:
+ return base::Value(true);
+ case cros::mojom::CameraPrivacySwitchState::OFF:
+ return base::Value(false);
+ case cros::mojom::CameraPrivacySwitchState::UNKNOWN:
+ return base::Value();
+ }
+}
+
+} // namespace
+
+namespace chromeos::settings {
+
+PrivacyHubHandler::PrivacyHubHandler()
+ : camera_privacy_switch_state_(media::CameraHalDispatcherImpl::GetInstance()
+ ->AddCameraPrivacySwitchObserver(this)) {
+ ui::MicrophoneMuteSwitchMonitor::Get()->AddObserver(this);
+}
+
+PrivacyHubHandler::~PrivacyHubHandler() {
+ media::CameraHalDispatcherImpl::GetInstance()
+ ->RemoveCameraPrivacySwitchObserver(this);
+ ui::MicrophoneMuteSwitchMonitor::Get()->RemoveObserver(this);
+}
+
+void PrivacyHubHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getInitialCameraHardwareToggleState",
+ base::BindRepeating(&PrivacyHubHandler::HandleInitialCameraSwitchState,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getInitialMicrophoneHardwareToggleState",
+ base::BindRepeating(
+ &PrivacyHubHandler::HandleInitialMicrophoneSwitchState,
+ base::Unretained(this)));
+}
+
+void PrivacyHubHandler::OnCameraHWPrivacySwitchStatusChanged(
+ int32_t camera_id,
+ cros::mojom::CameraPrivacySwitchState state) {
+ camera_privacy_switch_state_ = state;
+ if (IsJavascriptAllowed()) {
+ const base::Value value =
+ CameraPrivacySwitchStateToBaseValue(camera_privacy_switch_state_);
+ FireWebUIListener("camera-hardware-toggle-changed", value);
+ } else {
+ DVLOG(1) << "JS disabled. Skip camera privacy switch update until enabled";
+ }
+}
+
+void PrivacyHubHandler::OnMicrophoneMuteSwitchValueChanged(bool muted) {
+ if (IsJavascriptAllowed()) {
+ FireWebUIListener("microphone-hardware-toggle-changed", base::Value(muted));
+ } else {
+ DVLOG(1) << "JS disabled. Skip microphone hardware privacy switch update "
+ "until enabled";
+ }
+}
+
+void PrivacyHubHandler::HandleInitialCameraSwitchState(
+ const base::Value::List& args) {
+ AllowJavascript();
+
+ DCHECK_GE(1U, args.size()) << ": Did not expect arguments";
+ DCHECK_EQ(1U, args.size()) << ": Callback ID is required";
+ const auto& callback_id = args[0];
+ const base::Value value =
+ CameraPrivacySwitchStateToBaseValue(camera_privacy_switch_state_);
+
+ ResolveJavascriptCallback(callback_id, value);
+}
+
+void PrivacyHubHandler::HandleInitialMicrophoneSwitchState(
+ const base::Value::List& args) {
+ AllowJavascript();
+
+ DCHECK_GE(1U, args.size()) << ": Did not expect arguments";
+ DCHECK_EQ(1U, args.size()) << ": Callback ID is required";
+ const auto& callback_id = args[0];
+ const base::Value value = base::Value(
+ ui::MicrophoneMuteSwitchMonitor::Get()->microphone_mute_switch_on());
+
+ ResolveJavascriptCallback(callback_id, value);
+}
+
+} // namespace chromeos::settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h
new file mode 100644
index 00000000000..2da658cff44
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h
@@ -0,0 +1,47 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRIVACY_HUB_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRIVACY_HUB_HANDLER_H_
+
+#include "content/public/browser/web_ui_message_handler.h"
+#include "media/capture/video/chromeos/camera_hal_dispatcher_impl.h"
+#include "ui/events/devices/microphone_mute_switch_monitor.h"
+
+namespace chromeos::settings {
+
+class PrivacyHubHandler : public content::WebUIMessageHandler,
+ public media::CameraPrivacySwitchObserver,
+ public ui::MicrophoneMuteSwitchMonitor::Observer {
+ public:
+ PrivacyHubHandler();
+ ~PrivacyHubHandler() override;
+
+ PrivacyHubHandler(const PrivacyHubHandler&) = delete;
+
+ PrivacyHubHandler& operator=(const PrivacyHubHandler&) = delete;
+
+ protected:
+ // content::WebUIMessageHandler
+ void RegisterMessages() override;
+
+ // media::CameraPrivacySwitchObserver
+ void OnCameraHWPrivacySwitchStatusChanged(
+ int32_t camera_id,
+ cros::mojom::CameraPrivacySwitchState state) override;
+
+ // ui::MicrophoneMuteSwitchMonitor::Observer
+ void OnMicrophoneMuteSwitchValueChanged(bool muted) override;
+
+ void HandleInitialCameraSwitchState(const base::Value::List& args);
+
+ void HandleInitialMicrophoneSwitchState(const base::Value::List& args);
+
+ private:
+ cros::mojom::CameraPrivacySwitchState camera_privacy_switch_state_;
+};
+
+} // namespace chromeos::settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRIVACY_HUB_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler_unittest.cc
new file mode 100644
index 00000000000..86d6e7af6c2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler_unittest.cc
@@ -0,0 +1,214 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h"
+
+#include "base/containers/adapters.h"
+#include "base/test/task_environment.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos::settings {
+
+namespace {
+class TestPrivacyHubHandler : public PrivacyHubHandler {
+ public:
+ using content::WebUIMessageHandler::set_web_ui;
+
+ using PrivacyHubHandler::HandleInitialCameraSwitchState;
+ using PrivacyHubHandler::HandleInitialMicrophoneSwitchState;
+ using PrivacyHubHandler::OnCameraHWPrivacySwitchStatusChanged;
+};
+
+using cps = cros::mojom::CameraPrivacySwitchState;
+} // namespace
+
+class PrivacyHubHandlerTest : public testing::Test {
+ // This has to go before privacy_hub_handler_ because in the
+ // CameraHalDispatcherImpl constructor a call to
+ // base::SequencedTaskRunnerHandle::Get() is made which requires a
+ // task_environment. Initialization order of the members takes care
+ // of providing this before privacy_hub_handler_ is constructed.
+ base::test::SingleThreadTaskEnvironment task_environment_;
+
+ // Has to go before privacy_hub_handler_ as it references its
+ // address and destruction order guarantees no invalid pointers.
+ content::TestWebUI web_ui_;
+
+ public:
+ PrivacyHubHandlerTest()
+ : this_test_name_(
+ testing::UnitTest::GetInstance()->current_test_info()->name()) {
+ privacy_hub_handler_.set_web_ui(&web_ui_);
+ privacy_hub_handler_.AllowJavascriptForTesting();
+ }
+
+ [[nodiscard]] base::Value GetLastWebUIListenerData(
+ const std::string& callback) const {
+ return GetLastWebUIData("cr.webUIListenerCallback", callback);
+ }
+
+ [[nodiscard]] base::Value GetLastWebUIResponse(
+ const std::string& callback) const {
+ return GetLastWebUIData("cr.webUIResponse", callback);
+ }
+
+ TestPrivacyHubHandler privacy_hub_handler_;
+ const std::string this_test_name_;
+
+ protected:
+ void ExpectValueMatchesBoolParam(bool param, const base::Value& value) const {
+ ASSERT_TRUE(value.is_bool());
+ EXPECT_EQ(param, value.GetBool());
+ }
+
+ private:
+ [[nodiscard]] base::Value GetLastWebUIData(
+ const std::string& function_name,
+ const std::string& callback_name) const {
+ for (const auto& data : base::Reversed(web_ui_.call_data())) {
+ const std::string* name = data->arg1()->GetIfString();
+
+ if (data->function_name() != function_name || !name ||
+ *name != callback_name) {
+ continue;
+ }
+
+ // Assume that the data is stored in the last valid arg.
+ for (const auto& arg : base::Reversed(data->args())) {
+ if (&arg != data->arg1())
+ return arg.Clone();
+ }
+ }
+
+ ADD_FAILURE() << "None of the " << web_ui_.call_data().size()
+ << " CallData objects matched for function '" << function_name
+ << "' and callback '" << callback_name
+ << "' with a valid arg";
+ return base::Value();
+ }
+};
+
+class PrivacyHubHandlerMicrophoneTest
+ : public PrivacyHubHandlerTest,
+ public testing::WithParamInterface<bool> {
+ public:
+ void SetParamValueMicrophoneMute() const {
+ // Have to set it to not-param once before to ensure the observers are
+ // triggered from MicrophoneMuteSwitchMonitor.
+ ui::MicrophoneMuteSwitchMonitor::Get()->SetMicrophoneMuteSwitchValue(
+ !GetParam());
+ ui::MicrophoneMuteSwitchMonitor::Get()->SetMicrophoneMuteSwitchValue(
+ GetParam());
+ }
+
+ void ExpectValueMatchesBoolParam(const base::Value& value) const {
+ PrivacyHubHandlerTest::ExpectValueMatchesBoolParam(GetParam(), value);
+ }
+};
+
+class PrivacyHubHandlerCameraTest : public PrivacyHubHandlerTest,
+ public testing::WithParamInterface<cps> {
+ public:
+ void ExpectValueMatchesEnumParam(const base::Value& value) const {
+ if (GetParam() == cps::UNKNOWN) {
+ EXPECT_TRUE(value.is_none());
+ } else {
+ ExpectValueMatchesBoolParam(GetParam() == cps::ON, value);
+ }
+ }
+};
+
+TEST_P(PrivacyHubHandlerCameraTest, CameraHardwarePrivacySwitchChanged) {
+ privacy_hub_handler_.OnCameraHWPrivacySwitchStatusChanged(/*camera_id=*/0,
+ GetParam());
+
+ const base::Value data =
+ GetLastWebUIListenerData("camera-hardware-toggle-changed");
+
+ ExpectValueMatchesEnumParam(data);
+}
+
+INSTANTIATE_TEST_SUITE_P(HardwareSwitchStates,
+ PrivacyHubHandlerCameraTest,
+ testing::Values(cps::ON, cps::OFF, cps::UNKNOWN),
+ testing::PrintToStringParamName());
+
+TEST_F(PrivacyHubHandlerCameraTest, HandleInitialCameraSwitchState) {
+ base::Value::List args;
+ args.Append(this_test_name_);
+
+ privacy_hub_handler_.HandleInitialCameraSwitchState(args);
+
+ const base::Value data = GetLastWebUIResponse(this_test_name_);
+
+ // The initial state is always UNKNOWN which is communicated as NONE
+ EXPECT_TRUE(data.is_none());
+}
+
+TEST_P(PrivacyHubHandlerMicrophoneTest,
+ MicrophoneHardwarePrivacySwitchChanged) {
+ SetParamValueMicrophoneMute();
+
+ const base::Value data =
+ GetLastWebUIListenerData("microphone-hardware-toggle-changed");
+
+ ExpectValueMatchesBoolParam(data);
+}
+
+TEST_P(PrivacyHubHandlerMicrophoneTest, HandleInitialMicrophoneSwitchState) {
+ SetParamValueMicrophoneMute();
+
+ base::Value::List args;
+ args.Append(this_test_name_);
+
+ privacy_hub_handler_.HandleInitialMicrophoneSwitchState(args);
+
+ const base::Value data = GetLastWebUIResponse(this_test_name_);
+
+ ExpectValueMatchesBoolParam(data);
+}
+
+INSTANTIATE_TEST_SUITE_P(HardwareSwitchStates,
+ PrivacyHubHandlerMicrophoneTest,
+ testing::Values(true, false),
+ testing::PrintToStringParamName());
+
+#if DCHECK_IS_ON()
+using PrivacyHubHandlerDeathTest = PrivacyHubHandlerTest;
+
+TEST_F(PrivacyHubHandlerDeathTest, HandleInitialCameraSwitchStateNoCallbackId) {
+ base::Value::List args;
+
+ EXPECT_DEATH(privacy_hub_handler_.HandleInitialCameraSwitchState(args),
+ ".*Callback ID is required.*");
+}
+
+TEST_F(PrivacyHubHandlerDeathTest, HandleInitialCameraSwitchStateWithArgs) {
+ base::Value::List args;
+ args.Append(this_test_name_);
+ args.Append(base::Value());
+
+ EXPECT_DEATH(privacy_hub_handler_.HandleInitialCameraSwitchState(args),
+ ".*Did not expect arguments.*");
+}
+
+TEST_F(PrivacyHubHandlerDeathTest,
+ HandleInitialMicrophoneSwitchStateNoCallbackId) {
+ base::Value::List args;
+
+ EXPECT_DEATH(privacy_hub_handler_.HandleInitialMicrophoneSwitchState(args),
+ ".*Callback ID is required.*");
+}
+
+TEST_F(PrivacyHubHandlerDeathTest, HandleInitialMicrophoneSwitchStateWithArgs) {
+ base::Value::List args;
+ args.Append(this_test_name_);
+ args.Append(base::Value());
+
+ EXPECT_DEATH(privacy_hub_handler_.HandleInitialMicrophoneSwitchState(args),
+ ".*Did not expect arguments.*");
+}
+#endif
+} // namespace chromeos::settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
index 8f958ce808a..d9332d4503f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
@@ -15,10 +15,11 @@
#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/metrics_consent_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/chromeos/privacy_hub_handler.h"
#include "chrome/browser/ui/webui/settings/settings_secure_dns_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/webui_util.h"
@@ -281,6 +282,9 @@ void PrivacySection::AddHandlers(content::WebUI* web_ui) {
profile(), g_browser_process->metrics_service(),
user_manager::UserManager::Get()));
+ if (ash::features::IsCrosPrivacyHubEnabled())
+ web_ui->AddMessageHandler(std::make_unique<PrivacyHubHandler>());
+
if (IsSecureDnsAvailable())
web_ui->AddMessageHandler(std::make_unique<::settings::SecureDnsHandler>());
}
@@ -322,6 +326,11 @@ void PrivacySection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_OS_SETTINGS_SMART_PRIVACY_SNOOPING_NOTIFICATIONS},
{"privacyHubTitle", IDS_OS_SETTINGS_PRIVACY_HUB_TITLE},
{"cameraToggleTitle", IDS_OS_SETTINGS_CAMERA_TOGGLE_TITLE},
+ {"cameraToggleSublabelActive",
+ IDS_OS_SETTINGS_PRIVACY_HUB_CAMERA_HARDWARE_TOGGLE_ACTIVE_SUBTEXT},
+ {"microphoneToggleTitle", IDS_OS_SETTINGS_MICROPHONE_TOGGLE_TITLE},
+ {"microphoneToggleSublabelActive",
+ IDS_OS_SETTINGS_PRIVACY_HUB_MICROPHONE_HARDWARE_TOGGLE_ACTIVE_SUBTEXT},
};
html_source->AddLocalizedStrings(kLocalizedStrings);
@@ -330,8 +339,11 @@ void PrivacySection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddBoolean("isQuickDimEnabled",
ash::features::IsQuickDimEnabled());
- html_source->AddBoolean("showPrivacyHub", base::FeatureList::IsEnabled(
- ::features::kCrosPrivacyHub));
+ html_source->AddBoolean("showPrivacyHub",
+ ash::features::IsCrosPrivacyHubEnabled());
+
+ html_source->AddBoolean("showPrivacyHubFuture",
+ ash::features::IsCrosPrivacyHubFutureEnabled());
html_source->AddString(
"smartPrivacyDesc",
@@ -464,8 +476,10 @@ void PrivacySection::RegisterHierarchy(HierarchyGenerator* generator) const {
IDS_OS_SETTINGS_PRIVACY_HUB_TITLE, mojom::Subpage::kPrivacyHub,
mojom::SearchResultIcon::kShield, mojom::SearchResultDefaultRank::kMedium,
mojom::kPrivacyHubSubpagePath);
- RegisterNestedSettingBulk(mojom::Subpage::kPrivacyHub,
- {{mojom::Setting::kCameraOnOff}}, generator);
+ RegisterNestedSettingBulk(
+ mojom::Subpage::kPrivacyHub,
+ {{mojom::Setting::kCameraOnOff, mojom::Setting::kMicrophoneOnOff}},
+ generator);
}
bool PrivacySection::AreFingerprintSettingsAllowed() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
index 3f146060065..ef7fcfff7c6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
@@ -6,7 +6,7 @@
#include "base/no_destructor.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/chromium_strings.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
index 840b22f0404..eb84ed0c2d3 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
@@ -15,15 +15,15 @@
#include "chrome/browser/ash/assistant/assistant_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
+#include "chrome/browser/ui/webui/settings/ash/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/search_engines_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/ash/services/assistant/public/cpp/assistant_prefs.h"
+#include "chromeos/ash/services/assistant/public/cpp/features.h"
#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
-#include "chromeos/services/assistant/public/cpp/features.h"
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -41,16 +41,27 @@ bool ShouldShowQuickAnswersSettings() {
}
const std::vector<SearchConcept>& GetSearchPageSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_PREFERRED_SEARCH_ENGINE,
- ShouldShowQuickAnswersSettings() ? mojom::kSearchSubpagePath
- : mojom::kSearchAndAssistantSectionPath,
- mojom::SearchResultIcon::kMagnifyingGlass,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kPreferredSearchEngine}},
- });
- return *tags;
+ if (ShouldShowQuickAnswersSettings()) {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_PREFERRED_SEARCH_ENGINE,
+ mojom::kSearchSubpagePath,
+ mojom::SearchResultIcon::kMagnifyingGlass,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kPreferredSearchEngine}},
+ });
+ return *tags;
+ } else {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_PREFERRED_SEARCH_ENGINE,
+ mojom::kSearchAndAssistantSectionPath,
+ mojom::SearchResultIcon::kMagnifyingGlass,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kPreferredSearchEngine}},
+ });
+ return *tags;
+ }
}
const std::vector<SearchConcept>& GetQuickAnswersSearchConcepts() {
@@ -242,25 +253,6 @@ void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean("voiceMatchDisabled", !IsVoiceMatchAllowed());
}
-const std::vector<mojom::Setting>& GetSearchSettings() {
- static const base::NoDestructor<std::vector<mojom::Setting>> settings([] {
- std::vector<mojom::Setting> base_settings{
- mojom::Setting::kQuickAnswersOnOff,
- mojom::Setting::kQuickAnswersDefinition,
- mojom::Setting::kQuickAnswersTranslation,
- mojom::Setting::kQuickAnswersUnitConversion,
- };
-
- if (ShouldShowQuickAnswersSettings()) {
- base_settings.insert(base_settings.end(),
- mojom::Setting::kPreferredSearchEngine);
- }
-
- return base_settings;
- }());
- return *settings;
-}
-
} // namespace
SearchSection::SearchSection(Profile* profile,
@@ -354,6 +346,8 @@ bool SearchSection::LogMetric(mojom::Setting setting,
}
void SearchSection::RegisterHierarchy(HierarchyGenerator* generator) const {
+ // Register Preferred search engine as top level settings if Quick answers is
+ // not available.
if (!ShouldShowQuickAnswersSettings())
generator->RegisterTopLevelSetting(mojom::Setting::kPreferredSearchEngine);
@@ -362,8 +356,32 @@ void SearchSection::RegisterHierarchy(HierarchyGenerator* generator) const {
IDS_SETTINGS_SEARCH_SUBPAGE_TITLE, mojom::Subpage::kSearch,
mojom::SearchResultIcon::kMagnifyingGlass,
mojom::SearchResultDefaultRank::kMedium, mojom::kSearchSubpagePath);
- RegisterNestedSettingBulk(mojom::Subpage::kSearch, GetSearchSettings(),
- generator);
+ // Register Preferred search engine under Search subpage if Quick answers is
+ // available.
+ if (ShouldShowQuickAnswersSettings()) {
+ static constexpr mojom::Setting kSearchSettingsWithPreferredSearchEngine[] =
+ {
+ mojom::Setting::kQuickAnswersOnOff,
+ mojom::Setting::kQuickAnswersDefinition,
+ mojom::Setting::kQuickAnswersTranslation,
+ mojom::Setting::kQuickAnswersUnitConversion,
+ mojom::Setting::kPreferredSearchEngine,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kSearch,
+ kSearchSettingsWithPreferredSearchEngine,
+ generator);
+ } else {
+ static constexpr mojom::Setting
+ kSearchSettingsWithoutPreferredSearchEngine[] = {
+ mojom::Setting::kQuickAnswersOnOff,
+ mojom::Setting::kQuickAnswersDefinition,
+ mojom::Setting::kQuickAnswersTranslation,
+ mojom::Setting::kQuickAnswersUnitConversion,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kSearch,
+ kSearchSettingsWithoutPreferredSearchEngine,
+ generator);
+ }
// Assistant.
generator->RegisterTopLevelSubpage(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h
index f05770d09a2..ff57567f716 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h
@@ -8,9 +8,9 @@
#include <memory>
#include "base/gtest_prod_util.h"
+#include "chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc
index 0adb5d6669a..96416845cf4 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc
@@ -6,12 +6,12 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
+#include "chrome/browser/ui/webui/settings/ash/search/per_session_settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/ash/search/user_action_recorder.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_hierarchy.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_os_settings_sections.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc
index 5fc76004016..f5492f0047e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc
@@ -22,7 +22,7 @@
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/dom/dom_code.h"
-#include "ui/events/keycodes/dom/dom_codes.h"
+#include "ui/events/keycodes/dom/dom_codes_array.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
@@ -39,7 +39,7 @@ struct AssignmentInfo {
std::string GetStringForKeyboardCode(ui::KeyboardCode key_code) {
ui::DomKey dom_key;
ui::KeyboardCode key_code_to_compare = ui::VKEY_UNKNOWN;
- for (const auto& dom_code : ui::dom_codes) {
+ for (const auto& dom_code : ui::kDomCodesArray) {
if (!ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup(
dom_code, /*flags=*/ui::EF_NONE, &dom_key, &key_code_to_compare)) {
continue;
@@ -136,9 +136,9 @@ void SwitchAccessHandler::OnKeyEvent(ui::KeyEvent* event) {
if (event->type() == ui::ET_KEY_RELEASED)
return;
- base::DictionaryValue response;
- response.SetIntPath("keyCode", static_cast<int>(event->key_code()));
- response.SetStringPath("key", GetStringForKeyboardCode(event->key_code()));
+ base::Value::Dict response;
+ response.Set("keyCode", static_cast<int>(event->key_code()));
+ response.Set("key", GetStringForKeyboardCode(event->key_code()));
ui::InputDeviceType deviceType = ui::INPUT_DEVICE_UNKNOWN;
int source_device_id = event->source_device_id();
@@ -149,7 +149,7 @@ void SwitchAccessHandler::OnKeyEvent(ui::KeyEvent* event) {
break;
}
}
- response.SetStringPath("device", GetSwitchAccessDevice(deviceType));
+ response.Set("device", GetSwitchAccessDevice(deviceType));
FireWebUIListener("switch-access-got-key-press-for-assignment", response);
}
@@ -175,7 +175,7 @@ void SwitchAccessHandler::HandleNotifySwitchAccessActionAssignmentPaneInactive(
}
void SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated() {
- base::DictionaryValue response;
+ base::Value::Dict response;
static base::NoDestructor<std::vector<AssignmentInfo>> kAssignmentInfo({
{"select", ash::prefs::kAccessibilitySwitchAccessSelectDeviceKeyCodes},
@@ -185,23 +185,23 @@ void SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated() {
});
for (const AssignmentInfo& info : *kAssignmentInfo) {
- auto* keycodes = prefs_->GetDictionary(info.pref_name);
- base::ListValue keys;
- for (const auto item : keycodes->DictItems()) {
+ const auto& keycodes = prefs_->GetValueDict(info.pref_name);
+ base::Value::List keys;
+ for (const auto item : keycodes) {
int key_code;
if (!base::StringToInt(item.first, &key_code)) {
NOTREACHED();
return;
}
for (const base::Value& device_type : item.second.GetListDeprecated()) {
- base::DictionaryValue key;
- key.SetStringPath("key", GetStringForKeyboardCode(
- static_cast<ui::KeyboardCode>(key_code)));
- key.SetStringPath("device", device_type.GetString());
+ base::Value::Dict key;
+ key.Set("key", GetStringForKeyboardCode(
+ static_cast<ui::KeyboardCode>(key_code)));
+ key.Set("device", device_type.GetString());
keys.Append(std::move(key));
}
}
- response.SetPath(info.action_name_for_js, std::move(keys));
+ response.SetByDottedPath(info.action_name_for_js, std::move(keys));
}
FireWebUIListener("switch-access-assignments-changed", response);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc
index 8e61955f12a..49bff61529f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc
@@ -39,7 +39,7 @@ void TtsHandler::HandleGetTtsExtensions(const base::Value::List& args) {
// Ensure the built in tts engine is loaded to be able to respond to messages.
WakeTtsEngine(base::Value::List());
- base::ListValue responses;
+ base::Value::List responses;
Profile* profile = Profile::FromWebUI(web_ui());
extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(profile);
@@ -58,11 +58,11 @@ void TtsHandler::HandleGetTtsExtensions(const base::Value::List& args) {
// be updated again after extension load.
continue;
}
- base::DictionaryValue response;
- response.SetStringKey("name", extension->name());
- response.SetStringKey("extensionId", extension_id);
+ base::Value::Dict response;
+ response.Set("name", extension->name());
+ response.Set("extensionId", extension_id);
if (extensions::OptionsPageInfo::HasOptionsPage(extension)) {
- response.SetStringKey(
+ response.Set(
"optionsPage",
extensions::OptionsPageInfo::GetOptionsPage(extension).spec());
}
@@ -78,28 +78,28 @@ void TtsHandler::OnVoicesChanged() {
std::vector<content::VoiceData> voices;
tts_controller->GetVoices(Profile::FromWebUI(web_ui()), GURL(), &voices);
const std::string& app_locale = g_browser_process->GetApplicationLocale();
- base::ListValue responses;
+ base::Value::List responses;
for (const auto& voice : voices) {
- base::DictionaryValue response;
+ base::Value::Dict response;
int language_score = GetVoiceLangMatchScore(&voice, app_locale);
std::string language_code;
if (voice.lang.empty()) {
language_code = "noLanguageCode";
- response.SetStringKey(
+ response.Set(
"displayLanguage",
l10n_util::GetStringUTF8(IDS_TEXT_TO_SPEECH_SETTINGS_NO_LANGUAGE));
} else {
language_code = l10n_util::GetLanguage(voice.lang);
- response.SetStringKey(
+ response.Set(
"displayLanguage",
l10n_util::GetDisplayNameForLocale(
language_code, g_browser_process->GetApplicationLocale(), true));
}
- response.SetStringKey("name", voice.name);
- response.SetStringKey("languageCode", language_code);
- response.SetStringKey("fullLanguageCode", voice.lang);
- response.SetIntKey("languageScore", language_score);
- response.SetStringKey("extensionId", voice.engine_id);
+ response.Set("name", voice.name);
+ response.Set("languageCode", language_code);
+ response.Set("fullLanguageCode", voice.lang);
+ response.Set("languageScore", language_score);
+ response.Set("extensionId", voice.engine_id);
responses.Append(std::move(response));
}
AllowJavascript();
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 d724b704126..131eef70301 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
@@ -68,14 +68,15 @@ void CustomHomePagesTableModel::SetURLs(const std::vector<GURL>& urls) {
* elements, compact the remaining ones, and re-insert moved elements.
* Expects |index_list| to be ordered ascending.
*/
-void CustomHomePagesTableModel::MoveURLs(int insert_before,
- const std::vector<int>& index_list) {
+void CustomHomePagesTableModel::MoveURLs(
+ size_t insert_before,
+ const std::vector<size_t>& index_list) {
if (index_list.empty()) return;
- DCHECK(insert_before >= 0 && insert_before <= RowCount());
+ DCHECK(insert_before <= RowCount());
// The range of elements that needs to be reshuffled is [ |first|, |last| ).
- int first = std::min(insert_before, index_list.front());
- int last = std::max(insert_before, index_list.back() + 1);
+ size_t first = std::min(insert_before, index_list.front());
+ size_t last = std::max(insert_before, index_list.back() + 1);
// Save the dragged elements. Also, adjust insertion point if it is before a
// dragged element.
@@ -88,7 +89,7 @@ void CustomHomePagesTableModel::MoveURLs(int insert_before,
// Compact the range between beginning and insertion point, moving downwards.
size_t skip_count = 0;
- for (int i = first; i < insert_before; ++i) {
+ for (size_t i = first; i < insert_before; ++i) {
if (skip_count < index_list.size() && index_list[skip_count] == i)
skip_count++;
else
@@ -101,12 +102,13 @@ void CustomHomePagesTableModel::MoveURLs(int insert_before,
// Now compact up for elements after the insertion point.
skip_count = 0;
- for (int i = last - 1; i >= first; --i) {
+ for (size_t i = last; i > first; --i) {
+ const size_t index = i - 1;
if (skip_count < index_list.size() &&
- index_list[index_list.size() - skip_count - 1] == i) {
+ index_list[index_list.size() - skip_count - 1] == index) {
skip_count++;
} else {
- entries_[i + skip_count] = entries_[i];
+ entries_[index + skip_count] = entries_[index];
}
}
@@ -119,22 +121,22 @@ void CustomHomePagesTableModel::MoveURLs(int insert_before,
observer_->OnModelChanged();
}
-void CustomHomePagesTableModel::AddWithoutNotification(
- int index, const GURL& url) {
- DCHECK(index >= 0 && index <= RowCount());
- entries_.insert(entries_.begin() + static_cast<size_t>(index), Entry());
+void CustomHomePagesTableModel::AddWithoutNotification(size_t index,
+ const GURL& url) {
+ DCHECK(index <= RowCount());
+ entries_.insert(entries_.begin() + index, Entry());
entries_[index].url = url;
}
-void CustomHomePagesTableModel::Add(int index, const GURL& url) {
+void CustomHomePagesTableModel::Add(size_t index, const GURL& url) {
AddWithoutNotification(index, url);
LoadTitle(&(entries_[index]));
if (observer_)
observer_->OnItemsAdded(index, 1);
}
-void CustomHomePagesTableModel::RemoveWithoutNotification(int index) {
- DCHECK(index >= 0 && index < RowCount());
+void CustomHomePagesTableModel::RemoveWithoutNotification(size_t index) {
+ DCHECK(index < RowCount());
Entry* entry = &(entries_[index]);
// Cancel any pending load requests now so we don't deref a bogus pointer when
// we get the loaded notification.
@@ -142,10 +144,10 @@ void CustomHomePagesTableModel::RemoveWithoutNotification(int index) {
task_tracker_.TryCancel(entry->task_id);
entry->task_id = base::CancelableTaskTracker::kBadTaskId;
}
- entries_.erase(entries_.begin() + static_cast<size_t>(index));
+ entries_.erase(entries_.begin() + index);
}
-void CustomHomePagesTableModel::Remove(int index) {
+void CustomHomePagesTableModel::Remove(size_t index) {
RemoveWithoutNotification(index);
if (observer_)
observer_->OnItemsRemoved(index, 1);
@@ -158,7 +160,7 @@ void CustomHomePagesTableModel::SetToCurrentlyOpenPages(
RemoveWithoutNotification(0);
// Add tabs from appropriate browser windows.
- int add_index = 0;
+ size_t add_index = 0;
for (auto* browser : *BrowserList::GetInstance()) {
if (!ShouldIncludeBrowser(browser))
continue;
@@ -185,17 +187,17 @@ std::vector<GURL> CustomHomePagesTableModel::GetURLs() {
return urls;
}
-int CustomHomePagesTableModel::RowCount() {
- return static_cast<int>(entries_.size());
+size_t CustomHomePagesTableModel::RowCount() {
+ return entries_.size();
}
-std::u16string CustomHomePagesTableModel::GetText(int row, int column_id) {
+std::u16string CustomHomePagesTableModel::GetText(size_t row, int column_id) {
DCHECK(column_id == 0);
- DCHECK(row >= 0 && row < RowCount());
+ DCHECK(row < RowCount());
return entries_[row].title.empty() ? FormattedURL(row) : entries_[row].title;
}
-std::u16string CustomHomePagesTableModel::GetTooltip(int row) {
+std::u16string CustomHomePagesTableModel::GetTooltip(size_t row) {
return entries_[row].title.empty()
? std::u16string()
: l10n_util::GetStringFUTF16(IDS_SETTINGS_ON_STARTUP_PAGE_TOOLTIP,
@@ -284,11 +286,11 @@ void CustomHomePagesTableModel::OnGotTitle(const GURL& entry_url,
if (result.success && !result.row.title().empty()) {
entry->title = result.row.title();
if (observer_ && observable)
- observer_->OnItemsChanged(static_cast<int>(entry_index), 1);
+ observer_->OnItemsChanged(entry_index, 1);
}
}
-std::u16string CustomHomePagesTableModel::FormattedURL(int row) const {
+std::u16string CustomHomePagesTableModel::FormattedURL(size_t 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 3c74a6326df..8aa563cc4ff 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
@@ -44,13 +44,13 @@ class CustomHomePagesTableModel : public ui::TableModel {
// Collect all entries indexed by |index_list|, and moves them to be right
// before the element addressed by |insert_before|. Used by Drag&Drop.
// Expects |index_list| to be ordered ascending.
- void MoveURLs(int insert_before, const std::vector<int>& index_list);
+ void MoveURLs(size_t insert_before, const std::vector<size_t>& index_list);
// Adds an entry at the specified index.
- void Add(int index, const GURL& url);
+ void Add(size_t index, const GURL& url);
// Removes the entry at the specified index.
- void Remove(int index);
+ void Remove(size_t index);
// Clears any entries and fills the list with pages currently opened in the
// browser. |ignore_contents| is omitted from the open pages.
@@ -60,9 +60,9 @@ class CustomHomePagesTableModel : public ui::TableModel {
std::vector<GURL> GetURLs();
// TableModel overrides:
- int RowCount() override;
- std::u16string GetText(int row, int column_id) override;
- std::u16string GetTooltip(int row) override;
+ size_t RowCount() override;
+ std::u16string GetText(size_t row, int column_id) override;
+ std::u16string GetTooltip(size_t row) override;
void SetObserver(ui::TableModelObserver* observer) override;
private:
@@ -94,13 +94,13 @@ class CustomHomePagesTableModel : public ui::TableModel {
// Adds an entry at the specified index, but doesn't load the title or tell
// the observer.
- void AddWithoutNotification(int index, const GURL& url);
+ void AddWithoutNotification(size_t index, const GURL& url);
// Removes the entry at the specified index, but doesn't tell the observer.
- void RemoveWithoutNotification(int index);
+ void RemoveWithoutNotification(size_t index);
// Returns the URL for a particular row, formatted for display to the user.
- std::u16string FormattedURL(int row) const;
+ std::u16string FormattedURL(size_t row) const;
// Set of entries we're showing.
std::vector<Entry> entries_;
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
index a918e80e5fc..ed960d3c033 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
@@ -210,17 +210,17 @@ void DownloadsHandler::SendDownloadsConnectionInfoToJavascript() {
settings.value(), profile_->GetPrefs()))
.has_value();
// Dict to match the fields used in downloads_page.html.
- base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetBoolKey("linked", got_linked_account);
+ base::Value::Dict dict;
+ dict.Set("linked", got_linked_account);
if (got_linked_account) {
- base::Value account(base::Value::Type::DICTIONARY);
- account.SetStringKey("name", info->account_name);
- account.SetStringKey("login", info->account_login);
- dict.SetKey("account", std::move(account));
- base::Value folder(base::Value::Type::DICTIONARY);
- folder.SetStringKey("name", info->folder_name);
- folder.SetStringKey("link", info->folder_link);
- dict.SetKey("folder", std::move(folder));
+ base::Value::Dict account;
+ account.Set("name", info->account_name);
+ account.Set("login", info->account_login);
+ dict.Set("account", std::move(account));
+ base::Value::Dict folder;
+ folder.Set("name", info->folder_name);
+ folder.Set("link", info->folder_link);
+ dict.Set("folder", std::move(folder));
}
FireWebUIListener("downloads-connection-link-changed", dict);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.cc b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
index 371a26e75b4..e57acb50f42 100644
--- a/chromium/chrome/browser/ui/webui/settings/font_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
@@ -58,12 +58,11 @@ void FontHandler::HandleFetchFontsData(const base::Value::List& args) {
}
void FontHandler::FontListHasLoaded(std::string callback_id,
- std::unique_ptr<base::ListValue> list) {
- base::Value::ListView list_view = list->GetListDeprecated();
+ base::Value::List list) {
// Font list. Selects the directionality for the fonts in the given list.
- for (auto& i : list_view) {
+ for (auto& i : list) {
DCHECK(i.is_list());
- base::Value::ConstListView font = i.GetListDeprecated();
+ base::Value::List& font = i.GetList();
DCHECK(font.size() >= 2u && font[1].is_string());
std::u16string value = base::UTF8ToUTF16(font[1].GetString());
@@ -72,8 +71,8 @@ void FontHandler::FontListHasLoaded(std::string callback_id,
i.Append(has_rtl_chars ? "rtl" : "ltr");
}
- base::DictionaryValue response;
- response.SetKey("fontList", base::Value::FromUniquePtrValue(std::move(list)));
+ base::Value::Dict response;
+ response.Set("fontList", std::move(list));
ResolveJavascriptCallback(base::Value(callback_id), response);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.h b/chromium/chrome/browser/ui/webui/settings/font_handler.h
index bfbdb3a86bf..e26f7860dd0 100644
--- a/chromium/chrome/browser/ui/webui/settings/font_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/font_handler.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/memory/weak_ptr.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
@@ -35,8 +36,7 @@ class FontHandler : public SettingsPageUIHandler {
void HandleFetchFontsData(const base::Value::List& args);
// Callback to handle fonts loading.
- void FontListHasLoaded(std::string callback_id,
- std::unique_ptr<base::ListValue> list);
+ void FontListHasLoaded(std::string callback_id, base::Value::List list);
base::WeakPtrFactory<FontHandler> weak_ptr_factory_{this};
};
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 73ad5260441..042b1f1c5a8 100644
--- a/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc
@@ -72,9 +72,14 @@ void ImportDataHandler::OnJavascriptDisallowed() {
// Cancels outstanding profile list detections.
importer_list_.reset();
- // Stops listening to updates from any ongoing imports.
- if (importer_host_)
+ // When the WebUI is unloading, we ignore all further updates from the host.
+ // Because we're no longer listening to the `ImportEnded` callback, we must
+ // also clear our pointer, as otherwise this can lead to a use-after-free
+ // in the destructor. https://crbug.com/1302813.
+ if (importer_host_) {
importer_host_->set_observer(nullptr);
+ importer_host_ = nullptr;
+ }
}
void ImportDataHandler::StartImport(
@@ -211,8 +216,7 @@ void ImportDataHandler::SendBrowserProfileData(const std::string& callback_id) {
browser_profiles.Append(std::move(browser_profile));
}
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(browser_profiles)));
+ ResolveJavascriptCallback(base::Value(callback_id), browser_profiles);
}
void ImportDataHandler::ImportStarted() {
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 e0a91aec4dc..b960d67204d 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
@@ -75,7 +75,7 @@ void IncompatibleApplicationsHandler::HandleRequestIncompatibleApplicationsList(
incompatible_applications =
IncompatibleApplicationsUpdater::GetCachedApplications();
- base::Value application_list(base::Value::Type::LIST);
+ base::Value::List application_list;
for (const auto& application : incompatible_applications) {
// Set up a registry watcher for each problem application.
@@ -99,12 +99,10 @@ 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(base::WideToUTF8(application.info.name)));
- dict.SetKey("type",
- base::Value(application.blocklist_action->message_type()));
- dict.SetKey("url",
- base::Value(application.blocklist_action->message_url()));
+ base::Value::Dict dict;
+ dict.Set("name", base::WideToUTF8(application.info.name));
+ dict.Set("type", application.blocklist_action->message_type());
+ dict.Set("url", application.blocklist_action->message_url());
application_list.Append(std::move(dict));
}
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 f4bebe8840c..9b6206f7547 100644
--- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc
@@ -22,7 +22,7 @@
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/crosapi/mojom/metrics_reporting.mojom.h" // nogncheck
#include "chromeos/lacros/lacros_service.h"
-#include "chromeos/startup/browser_init_params.h"
+#include "chromeos/startup/browser_params_proxy.h"
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
namespace settings {
@@ -60,24 +60,21 @@ void MetricsReportingHandler::HandleGetMetricsReporting(
AllowJavascript();
CHECK_GT(args.size(), 0u);
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, *CreateMetricsReportingDict());
+ ResolveJavascriptCallback(callback_id, CreateMetricsReportingDict());
}
-std::unique_ptr<base::DictionaryValue>
- MetricsReportingHandler::CreateMetricsReportingDict() {
- std::unique_ptr<base::DictionaryValue> dict(
- std::make_unique<base::DictionaryValue>());
- dict->SetBoolKey(
- "enabled",
- ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
+base::Value::Dict MetricsReportingHandler::CreateMetricsReportingDict() {
+ base::Value::Dict dict;
+ dict.Set("enabled",
+ ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// To match the pre-Lacros settings UX, we show the managed icon if the ash
// device-level metrics reporting pref is managed. https://crbug.com/1148604
- bool managed = chromeos::BrowserInitParams::Get()->ash_metrics_managed ==
+ bool managed = chromeos::BrowserParamsProxy::Get()->AshMetricsManaged() ==
crosapi::mojom::MetricsReportingManaged::kManaged;
- dict->SetBoolKey("managed", managed);
+ dict.Set("managed", managed);
#else
- dict->SetBoolKey("managed", IsMetricsReportingPolicyManaged());
+ dict.Set("managed", IsMetricsReportingPolicyManaged());
#endif
return dict;
}
@@ -129,7 +126,7 @@ void MetricsReportingHandler::OnPrefChanged(const std::string& pref_name) {
}
void MetricsReportingHandler::SendMetricsReportingChange() {
- FireWebUIListener("metrics-reporting-change", *CreateMetricsReportingDict());
+ FireWebUIListener("metrics-reporting-change", CreateMetricsReportingDict());
}
} // namespace settings
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 2130839f5e0..dd9fbe1b430 100644
--- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h
@@ -48,7 +48,7 @@ class MetricsReportingHandler : public SettingsPageUIHandler {
private:
// Describes the state of metrics reporting in a base::DictionaryValue.
// Friends with ChromeMetricsServiceAccessor.
- std::unique_ptr<base::DictionaryValue> CreateMetricsReportingDict();
+ base::Value::Dict CreateMetricsReportingDict();
// Handler for "setMetricsReportingEnabled" message. Passed a single,
// |enabled| boolean argument.
diff --git a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc
index dbc605a0e80..1c8588ceb13 100644
--- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc
@@ -69,14 +69,13 @@ base::Value OnStartupHandler::GetNtpExtension() {
return base::Value();
}
- base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetStringKey("id", ntp_extension->id());
- dict.SetStringKey("name", ntp_extension->name());
- dict.SetBoolKey("canBeDisabled",
- !extensions::ExtensionSystem::Get(profile_)
- ->management_policy()
- ->MustRemainEnabled(ntp_extension, nullptr));
- return dict;
+ base::Value::Dict dict;
+ dict.Set("id", ntp_extension->id());
+ dict.Set("name", ntp_extension->name());
+ dict.Set("canBeDisabled", !extensions::ExtensionSystem::Get(profile_)
+ ->management_policy()
+ ->MustRemainEnabled(ntp_extension, nullptr));
+ return base::Value(std::move(dict));
}
void OnStartupHandler::HandleGetNtpExtension(const base::Value::List& args) {
diff --git a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h
index 98003851075..4c5967f498a 100644
--- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h
@@ -8,6 +8,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index fb7235c6287..6eaf74064b4 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -69,7 +69,6 @@
#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/signin/account_consistency_mode_manager.h"
-#include "components/signin/public/base/signin_switches.h"
#endif
using content::WebContents;
@@ -116,8 +115,8 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
return false;
}
- absl::optional<bool> sync_everything =
- parsed_value->FindBoolKey("syncAllDataTypes");
+ const base::Value::Dict& root = parsed_value->GetDict();
+ absl::optional<bool> sync_everything = root.FindBool("syncAllDataTypes");
if (!sync_everything.has_value()) {
DLOG(ERROR) << "GetConfiguration() not passed a syncAllDataTypes value";
return false;
@@ -125,7 +124,7 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
config->sync_everything = *sync_everything;
absl::optional<bool> payments_integration_enabled =
- parsed_value->FindBoolKey("paymentsIntegrationEnabled");
+ root.FindBool("paymentsIntegrationEnabled");
if (!payments_integration_enabled.has_value()) {
DLOG(ERROR) << "GetConfiguration() not passed a paymentsIntegrationEnabled "
<< "value";
@@ -136,7 +135,7 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
for (syncer::UserSelectableType type : syncer::UserSelectableTypeSet::All()) {
std::string key_name =
syncer::GetUserSelectableTypeName(type) + std::string("Synced");
- absl::optional<bool> type_synced = parsed_value->FindBoolKey(key_name);
+ absl::optional<bool> type_synced = root.FindBool(key_name);
if (!type_synced.has_value()) {
DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name;
return false;
@@ -182,18 +181,17 @@ std::string GetSyncErrorAction(SyncStatusActionType action_type) {
// Returns the base::Value associated with the account, to use in the stored
// accounts list.
-base::Value GetAccountValue(const AccountInfo& account) {
+base::Value::Dict GetAccountValue(const AccountInfo& account) {
DCHECK(!account.IsEmpty());
- base::Value dictionary(base::Value::Type::DICTIONARY);
- dictionary.SetStringKey("email", account.email);
- dictionary.SetStringKey("fullName", account.full_name);
- dictionary.SetStringKey("givenName", account.given_name);
+ base::Value::Dict dict;
+ dict.Set("email", account.email);
+ dict.Set("fullName", account.full_name);
+ dict.Set("givenName", account.given_name);
if (!account.account_image.IsEmpty()) {
- dictionary.SetStringKey(
- "avatarImage",
- webui::GetBitmapDataUrl(account.account_image.AsBitmap()));
+ dict.Set("avatarImage",
+ webui::GetBitmapDataUrl(account.account_image.AsBitmap()));
}
- return dictionary;
+ return dict;
}
} // namespace
@@ -434,16 +432,14 @@ void PeopleHandler::OnExtendedAccountInfoRemoved(const AccountInfo& info) {
FireWebUIListener("stored-accounts-updated", GetStoredAccountsList());
}
-base::Value PeopleHandler::GetStoredAccountsList() {
- base::Value accounts(base::Value::Type::LIST);
+base::Value::List PeopleHandler::GetStoredAccountsList() {
+ base::Value::List accounts;
bool populate_accounts_list = false;
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
populate_accounts_list =
AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_);
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
- populate_accounts_list =
- base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles) &&
- !profile_->IsMainProfile();
+ populate_accounts_list = !profile_->IsMainProfile();
#endif
if (populate_accounts_list) {
@@ -457,7 +453,7 @@ base::Value PeopleHandler::GetStoredAccountsList() {
// Guest mode does not have a primary account (or an IdentityManager).
if (profile_->IsGuestSession())
- return base::Value(base::Value::Type::LIST);
+ return base::Value::List();
// If DICE is disabled for this profile or unsupported on this platform (e.g.
// Chrome OS) or Lacros main profile (sync with a different account than the
// device account is not allowed), then show only the primary account,
@@ -772,15 +768,9 @@ void PeopleHandler::CloseSyncSetup() {
sync_service->StopAndClear();
// ChromeOS ash doesn't support signing out.
#if !BUILDFLAG(IS_CHROMEOS_ASH)
- bool should_revoke_sync_consent =
- !sync_service->GetUserSettings()->IsFirstSetupComplete();
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- should_revoke_sync_consent &=
- base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles);
-#endif
// Revoke sync consent on desktop Chrome if they click cancel during
// initial setup or close sync setup without confirming sync.
- if (should_revoke_sync_consent) {
+ if (!sync_service->GetUserSettings()->IsFirstSetupComplete()) {
IdentityManagerFactory::GetForProfile(profile_)
->GetPrimaryAccountMutator()
->RevokeSyncConsent(
@@ -875,16 +865,16 @@ void PeopleHandler::BeforeUnloadDialogCancelled() {
base::UserMetricsAction("Signin_Signin_CancelAbortAdvancedSyncSettings"));
}
-base::Value PeopleHandler::GetSyncStatusDictionary() const {
- base::Value sync_status(base::Value::Type::DICTIONARY);
+base::Value::Dict PeopleHandler::GetSyncStatusDictionary() const {
+ base::Value::Dict sync_status;
if (profile_->IsGuestSession()) {
// Cannot display signin status when running in guest mode on chromeos
// because there is no IdentityManager.
return sync_status;
}
- sync_status.SetBoolKey("supervisedUser", profile_->IsChild());
- sync_status.SetBoolKey("childUser", profile_->IsChild());
+ sync_status.Set("supervisedUser", profile_->IsChild());
+ sync_status.Set("childUser", profile_->IsChild());
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
DCHECK(identity_manager);
@@ -898,7 +888,7 @@ base::Value PeopleHandler::GetSyncStatusDictionary() const {
// If there is no one logged in or if the profile name is empty then the
// domain name is empty. This happens in browser tests.
if (!username.empty())
- sync_status.SetStringKey("domain", gaia::ExtractDomainName(username));
+ sync_status.Set("domain", gaia::ExtractDomainName(username));
}
// This is intentionally not using GetSyncService(), in order to access more
@@ -908,8 +898,8 @@ base::Value PeopleHandler::GetSyncStatusDictionary() const {
bool disallowed_by_policy =
service && service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY);
- sync_status.SetBoolKey("syncSystemEnabled", (service != nullptr));
- sync_status.SetBoolKey(
+ sync_status.Set("syncSystemEnabled", (service != nullptr));
+ sync_status.Set(
"firstSetupInProgress",
service && !disallowed_by_policy && service->IsSetupInProgress() &&
!service->GetUserSettings()->IsFirstSetupComplete() &&
@@ -918,34 +908,34 @@ base::Value PeopleHandler::GetSyncStatusDictionary() const {
const SyncStatusLabels status_labels = GetSyncStatusLabels(profile_);
// TODO(crbug.com/1027467): Consider unifying some of the fields below to
// avoid redundancy.
- sync_status.SetStringKey(
- "statusText", GetStringUTF16(status_labels.status_label_string_id));
- sync_status.SetStringKey("statusActionText",
- GetStringUTF16(status_labels.button_string_id));
- sync_status.SetBoolKey(
+ sync_status.Set("statusText",
+ GetStringUTF16(status_labels.status_label_string_id));
+ sync_status.Set("statusActionText",
+ GetStringUTF16(status_labels.button_string_id));
+ sync_status.Set(
"hasError",
status_labels.message_type == SyncStatusMessageType::kSyncError ||
status_labels.message_type ==
SyncStatusMessageType::kPasswordsOnlySyncError);
- sync_status.SetBoolKey("hasPasswordsOnlyError",
- status_labels.message_type ==
- SyncStatusMessageType::kPasswordsOnlySyncError);
- sync_status.SetStringKey("statusAction",
- GetSyncErrorAction(status_labels.action_type));
+ sync_status.Set("hasPasswordsOnlyError",
+ status_labels.message_type ==
+ SyncStatusMessageType::kPasswordsOnlySyncError);
+ sync_status.Set("statusAction",
+ GetSyncErrorAction(status_labels.action_type));
- sync_status.SetBoolKey("managed", disallowed_by_policy);
+ sync_status.Set("managed", disallowed_by_policy);
// TODO(crbug.com/1171279): audit js usages of |disabled| and |signedIn|
// fields, update it to use the right field, comments around and conditions
// here. Perhaps removal of one of these to fields is possible.
- sync_status.SetBoolKey("disabled", !service || disallowed_by_policy);
+ sync_status.Set("disabled", !service || disallowed_by_policy);
// NOTE: This means signed-in for *sync*. It can be false when the user is
// signed-in to the content area or to the browser.
- sync_status.SetBoolKey("signedIn", identity_manager->HasPrimaryAccount(
- signin::ConsentLevel::kSync));
- sync_status.SetStringKey("signedInUsername",
- signin_ui_util::GetAuthenticatedUsername(profile_));
- sync_status.SetBoolKey("hasUnrecoverableError",
- service && service->HasUnrecoverableError());
+ sync_status.Set("signedIn", identity_manager->HasPrimaryAccount(
+ signin::ConsentLevel::kSync));
+ sync_status.Set("signedInUsername",
+ signin_ui_util::GetAuthenticatedUsername(profile_));
+ sync_status.Set("hasUnrecoverableError",
+ service && service->HasUnrecoverableError());
return sync_status;
}
@@ -973,7 +963,7 @@ void PeopleHandler::PushSyncPrefs() {
// epoch); undefined if the time is unknown or no explicit
// passphrase is set.
//
- base::Value args(base::Value::Type::DICTIONARY);
+ base::Value::Dict args;
syncer::SyncUserSettings* sync_user_settings = service->GetUserSettings();
// Tell the UI layer which data types are registered/enabled by the user.
@@ -983,34 +973,30 @@ void PeopleHandler::PushSyncPrefs() {
sync_user_settings->GetSelectedTypes();
for (syncer::UserSelectableType type : syncer::UserSelectableTypeSet::All()) {
const std::string type_name = syncer::GetUserSelectableTypeName(type);
- args.SetBoolKey(type_name + "Registered", registered_types.Has(type));
- args.SetBoolKey(type_name + "Synced", selected_types.Has(type));
+ args.Set(type_name + "Registered", registered_types.Has(type));
+ args.Set(type_name + "Synced", selected_types.Has(type));
}
- args.SetBoolKey("syncAllDataTypes",
- sync_user_settings->IsSyncEverythingEnabled());
- args.SetBoolKey(
- "paymentsIntegrationEnabled",
- autofill::prefs::IsPaymentsIntegrationEnabled(profile_->GetPrefs()));
- args.SetBoolKey("encryptAllData",
- sync_user_settings->IsEncryptEverythingEnabled());
- args.SetBoolKey("customPassphraseAllowed",
- sync_user_settings->IsCustomPassphraseAllowed());
+ args.Set("syncAllDataTypes", sync_user_settings->IsSyncEverythingEnabled());
+ args.Set("paymentsIntegrationEnabled",
+ autofill::prefs::IsPaymentsIntegrationEnabled(profile_->GetPrefs()));
+ args.Set("encryptAllData", sync_user_settings->IsEncryptEverythingEnabled());
+ args.Set("customPassphraseAllowed",
+ sync_user_settings->IsCustomPassphraseAllowed());
// We call IsPassphraseRequired() here, instead of calling
// IsPassphraseRequiredForPreferredDataTypes(), because we want to show the
// passphrase UI even if no encrypted data types are enabled.
- args.SetBoolKey("passphraseRequired",
- sync_user_settings->IsPassphraseRequired());
+ args.Set("passphraseRequired", sync_user_settings->IsPassphraseRequired());
// Same as above, we call IsTrustedVaultKeyRequired() here instead of.
// IsTrustedVaultKeyRequiredForPreferredDataTypes().
- args.SetBoolKey("trustedVaultKeysRequired",
- sync_user_settings->IsTrustedVaultKeyRequired());
+ args.Set("trustedVaultKeysRequired",
+ sync_user_settings->IsTrustedVaultKeyRequired());
base::Time passphrase_time = sync_user_settings->GetExplicitPassphraseTime();
if (!passphrase_time.is_null()) {
- args.SetStringKey("explicitPassphraseTime",
- base::TimeFormatShortDate(passphrase_time));
+ args.Set("explicitPassphraseTime",
+ base::TimeFormatShortDate(passphrase_time));
}
FireWebUIListener("sync-prefs-changed", args);
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h
index 53142301da0..6ad9bac8c72 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -148,7 +148,7 @@ class PeopleHandler : public SettingsPageUIHandler,
// Returns a newly created dictionary with a number of properties that
// correspond to the status of sync.
- base::Value GetSyncStatusDictionary() const;
+ base::Value::Dict GetSyncStatusDictionary() const;
// Helper routine that gets the SyncService associated with the parent
// profile.
@@ -195,7 +195,7 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleGetStoredAccounts(const base::Value::List& args);
void HandleStartSyncingWithEmail(const base::Value::List& args);
- base::Value GetStoredAccountsList();
+ base::Value::List GetStoredAccountsList();
// Pushes the updated sync prefs to JavaScript.
void PushSyncPrefs();
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 a19fa5f2453..41045c86776 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -38,7 +38,6 @@
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/consent_level.h"
-#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/accounts_mutator.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
@@ -85,34 +84,33 @@ enum SyncAllDataConfig {
// to HandleSetDatatypes().
std::string GetConfiguration(SyncAllDataConfig sync_all,
syncer::UserSelectableTypeSet types) {
- base::Value result(base::Value::Type::DICTIONARY);
- result.SetBoolKey("syncAllDataTypes", sync_all == SYNC_ALL_DATA);
+ base::Value::Dict result;
+ result.Set("syncAllDataTypes", sync_all == SYNC_ALL_DATA);
// Add all of our data types.
- result.SetBoolKey("appsSynced", types.Has(syncer::UserSelectableType::kApps));
- result.SetBoolKey("autofillSynced",
- types.Has(syncer::UserSelectableType::kAutofill));
- result.SetBoolKey("bookmarksSynced",
- types.Has(syncer::UserSelectableType::kBookmarks));
- result.SetBoolKey("extensionsSynced",
- types.Has(syncer::UserSelectableType::kExtensions));
- result.SetBoolKey("passwordsSynced",
- types.Has(syncer::UserSelectableType::kPasswords));
- result.SetBoolKey("preferencesSynced",
- types.Has(syncer::UserSelectableType::kPreferences));
- result.SetBoolKey("readingListSynced",
- types.Has(syncer::UserSelectableType::kReadingList));
- result.SetBoolKey("tabsSynced", types.Has(syncer::UserSelectableType::kTabs));
- result.SetBoolKey("themesSynced",
- types.Has(syncer::UserSelectableType::kThemes));
- result.SetBoolKey("typedUrlsSynced",
- types.Has(syncer::UserSelectableType::kHistory));
- result.SetBoolKey("wifiConfigurationsSynced",
- types.Has(syncer::UserSelectableType::kWifiConfigurations));
- result.SetBoolKey("paymentsIntegrationEnabled", false);
+ result.Set("appsSynced", types.Has(syncer::UserSelectableType::kApps));
+ result.Set("autofillSynced",
+ types.Has(syncer::UserSelectableType::kAutofill));
+ result.Set("bookmarksSynced",
+ types.Has(syncer::UserSelectableType::kBookmarks));
+ result.Set("extensionsSynced",
+ types.Has(syncer::UserSelectableType::kExtensions));
+ result.Set("passwordsSynced",
+ types.Has(syncer::UserSelectableType::kPasswords));
+ result.Set("preferencesSynced",
+ types.Has(syncer::UserSelectableType::kPreferences));
+ result.Set("readingListSynced",
+ types.Has(syncer::UserSelectableType::kReadingList));
+ result.Set("tabsSynced", types.Has(syncer::UserSelectableType::kTabs));
+ result.Set("themesSynced", types.Has(syncer::UserSelectableType::kThemes));
+ result.Set("typedUrlsSynced",
+ types.Has(syncer::UserSelectableType::kHistory));
+ result.Set("wifiConfigurationsSynced",
+ types.Has(syncer::UserSelectableType::kWifiConfigurations));
+ result.Set("paymentsIntegrationEnabled", false);
// Reading list doesn't really have a UI and is supported on ios only.
- result.SetBoolKey("readingListSynced",
- types.Has(syncer::UserSelectableType::kReadingList));
+ result.Set("readingListSynced",
+ types.Has(syncer::UserSelectableType::kReadingList));
std::string args;
base::JSONWriter::Write(result, &args);
@@ -641,7 +639,7 @@ TEST_F(PeopleHandlerTest, TestSyncEverything) {
SigninUser();
CreatePeopleHandler();
std::string args = GetConfiguration(SYNC_ALL_DATA, GetAllTypes());
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append(args);
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
@@ -652,7 +650,7 @@ TEST_F(PeopleHandlerTest, TestSyncEverything) {
SetupInitializedSyncService();
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetSelectedTypes(true, _));
- handler_->HandleSetDatatypes(list_args.GetList());
+ handler_->HandleSetDatatypes(list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
@@ -678,10 +676,10 @@ TEST_F(PeopleHandlerTest, EnterCorrectExistingPassphrase) {
SetDecryptionPassphrase("correct_passphrase"))
.WillOnce(Return(true));
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("correct_passphrase");
- handler_->HandleSetDecryptionPassphrase(list_args.GetList());
+ handler_->HandleSetDecryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(true);
}
@@ -706,10 +704,10 @@ TEST_F(PeopleHandlerTest, SuccessfullyCreateCustomPassphrase) {
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetEncryptionPassphrase("custom_passphrase"));
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("custom_passphrase");
- handler_->HandleSetEncryptionPassphrase(list_args.GetList());
+ handler_->HandleSetEncryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(true);
}
@@ -735,10 +733,10 @@ TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) {
SetDecryptionPassphrase("invalid_passphrase"))
.WillOnce(Return(false));
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("invalid_passphrase");
- handler_->HandleSetDecryptionPassphrase(list_args.GetList());
+ handler_->HandleSetDecryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(false);
}
@@ -764,10 +762,10 @@ TEST_F(PeopleHandlerTest, CannotCreateBlankPassphrase) {
SetEncryptionPassphrase)
.Times(0);
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("");
- handler_->HandleSetEncryptionPassphrase(list_args.GetList());
+ handler_->HandleSetEncryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(false);
}
@@ -782,7 +780,7 @@ TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
syncer::UserSelectableTypeSet type_to_set;
type_to_set.Put(type);
std::string args = GetConfiguration(CHOOSE_WHAT_TO_SYNC, type_to_set);
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append(args);
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
@@ -794,7 +792,7 @@ TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetSelectedTypes(false, type_to_set));
- handler_->HandleSetDatatypes(list_args.GetList());
+ handler_->HandleSetDatatypes(list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
Mock::VerifyAndClearExpectations(mock_sync_service_);
}
@@ -805,7 +803,7 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
CreatePeopleHandler();
SetDefaultExpectationsForConfigPage();
std::string args = GetConfiguration(CHOOSE_WHAT_TO_SYNC, GetAllTypes());
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append(args);
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
@@ -816,7 +814,7 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
SetupInitializedSyncService();
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetSelectedTypes(false, GetAllTypes()));
- handler_->HandleSetDatatypes(list_args.GetList());
+ handler_->HandleSetDatatypes(list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
@@ -837,14 +835,14 @@ TEST_F(PeopleHandlerTest, NonRegisteredType) {
// Simulate "Sync everything" being turned off, but all individual
// toggles left on.
std::string config = GetConfiguration(CHOOSE_WHAT_TO_SYNC, GetAllTypes());
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append(config);
// Only the registered types are selected.
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetSelectedTypes(/*sync_everything=*/false, registered_types));
- handler_->HandleSetDatatypes(list_args.GetList());
+ handler_->HandleSetDatatypes(list_args);
}
TEST_F(PeopleHandlerTest, ShowSyncSetup) {
@@ -1080,10 +1078,10 @@ TEST_F(PeopleHandlerTest, CannotCreatePassphraseIfCustomPassphraseDisallowed) {
SetEncryptionPassphrase)
.Times(0);
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("passphrase123");
- handler_->HandleSetEncryptionPassphrase(list_args.GetList());
+ handler_->HandleSetEncryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(false);
}
@@ -1109,10 +1107,10 @@ TEST_F(PeopleHandlerTest, CannotOverwritePassphraseWithNewOne) {
SetEncryptionPassphrase)
.Times(0);
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append(kTestCallbackId);
list_args.Append("passphrase123");
- handler_->HandleSetEncryptionPassphrase(list_args.GetList());
+ handler_->HandleSetEncryptionPassphrase(list_args);
ExpectSetPassphraseSuccess(false);
}
@@ -1167,9 +1165,9 @@ TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmSoon) {
NotifySyncStateChanged();
});
- base::Value did_abort(base::Value::Type::LIST);
- did_abort.Append(base::Value(false));
- handler_->OnDidClosePage(did_abort.GetList());
+ base::Value::List did_abort;
+ did_abort.Append(false);
+ handler_->OnDidClosePage(did_abort);
}
TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmLater) {
@@ -1238,9 +1236,9 @@ TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmLater) {
});
}
- base::Value did_abort(base::Value::Type::LIST);
- did_abort.Append(base::Value(false));
- handler_->OnDidClosePage(did_abort.GetList());
+ base::Value::List did_abort;
+ did_abort.Append(false);
+ handler_->OnDidClosePage(did_abort);
}
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
@@ -1274,16 +1272,13 @@ TEST(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
signin::ConsentLevel::kSignin);
PeopleHandler handler(profile.get());
- base::Value accounts = handler.GetStoredAccountsList();
+ base::Value::List accounts = handler.GetStoredAccountsList();
- ASSERT_TRUE(accounts.is_list());
- const base::Value::List& accounts_list = accounts.GetList();
-
- ASSERT_EQ(2u, accounts_list.size());
- ASSERT_TRUE(accounts_list[0].FindKey("email"));
- ASSERT_TRUE(accounts_list[1].FindKey("email"));
- EXPECT_EQ("a@gmail.com", accounts_list[0].FindKey("email")->GetString());
- EXPECT_EQ("b@gmail.com", accounts_list[1].FindKey("email")->GetString());
+ ASSERT_EQ(2u, accounts.size());
+ ASSERT_TRUE(accounts[0].GetDict().FindString("email"));
+ ASSERT_TRUE(accounts[1].GetDict().FindString("email"));
+ EXPECT_EQ("a@gmail.com", *accounts[0].GetDict().FindString("email"));
+ EXPECT_EQ("b@gmail.com", *accounts[1].GetDict().FindString("email"));
}
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
@@ -1313,7 +1308,7 @@ TEST(PeopleHandlerMainProfile, Signout) {
PeopleHandler handler(profile.get());
base::Value::List args;
- args.Append(base::Value(/*delete_profile=*/false));
+ args.Append(/*delete_profile=*/false);
handler.HandleSignout(args);
EXPECT_FALSE(identity_manager->HasPrimaryAccount(ConsentLevel::kSync));
@@ -1346,7 +1341,7 @@ TEST(PeopleHandlerSecondaryProfile, SignoutWhenSyncing) {
PeopleHandler handler(profile.get());
base::Value::List args;
- args.Append(base::Value(/*delete_profile=*/false));
+ args.Append(/*delete_profile=*/false);
handler.HandleSignout(args);
EXPECT_FALSE(identity_manager->HasPrimaryAccount(ConsentLevel::kSync));
EXPECT_FALSE(identity_manager->HasPrimaryAccount(ConsentLevel::kSignin));
@@ -1354,8 +1349,6 @@ TEST(PeopleHandlerSecondaryProfile, SignoutWhenSyncing) {
}
TEST(PeopleHandlerMainProfile, GetStoredAccountsList) {
- base::test::ScopedFeatureList scoped_feature_list{
- switches::kLacrosNonSyncingProfiles};
content::BrowserTaskEnvironment task_environment;
TestingProfile::Builder builder;
@@ -1379,20 +1372,14 @@ TEST(PeopleHandlerMainProfile, GetStoredAccountsList) {
EXPECT_EQ(2U, identity_manager->GetAccountsWithRefreshTokens().size());
PeopleHandler handler(profile.get());
- base::Value accounts = handler.GetStoredAccountsList();
-
- ASSERT_TRUE(accounts.is_list());
- base::Value::List& accounts_list = accounts.GetList();
+ base::Value::List accounts = handler.GetStoredAccountsList();
- ASSERT_EQ(1u, accounts_list.size());
- ASSERT_TRUE(accounts_list[0].FindKey("email"));
- EXPECT_EQ("user@gmail.com", accounts_list[0].FindKey("email")->GetString());
+ ASSERT_EQ(1u, accounts.size());
+ ASSERT_TRUE(accounts[0].GetDict().FindString("email"));
+ EXPECT_EQ("user@gmail.com", *accounts[0].GetDict().FindString("email"));
}
TEST(PeopleHandlerSecondaryProfile, GetStoredAccountsList) {
- base::test::ScopedFeatureList scoped_feature_list{
- switches::kLacrosNonSyncingProfiles};
-
ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
content::BrowserTaskEnvironment task_environment;
@@ -1416,16 +1403,13 @@ TEST(PeopleHandlerSecondaryProfile, GetStoredAccountsList) {
EXPECT_EQ(2U, identity_manager->GetAccountsWithRefreshTokens().size());
PeopleHandler handler(profile.get());
- base::Value accounts = handler.GetStoredAccountsList();
-
- ASSERT_TRUE(accounts.is_list());
- base::Value::List& accounts_list = accounts.GetList();
+ base::Value::List accounts = handler.GetStoredAccountsList();
- ASSERT_EQ(2u, accounts_list.size());
- ASSERT_TRUE(accounts_list[0].FindKey("email"));
- ASSERT_TRUE(accounts_list[1].FindKey("email"));
- EXPECT_EQ(account_2.email, accounts_list[0].FindKey("email")->GetString());
- EXPECT_EQ(account_1.email, accounts_list[1].FindKey("email")->GetString());
+ ASSERT_EQ(2u, accounts.size());
+ ASSERT_TRUE(accounts[0].GetDict().FindString("email"));
+ ASSERT_TRUE(accounts[1].GetDict().FindString("email"));
+ EXPECT_EQ(account_2.email, *accounts[0].GetDict().FindString("email"));
+ EXPECT_EQ(account_1.email, *accounts[1].GetDict().FindString("email"));
}
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -1438,8 +1422,8 @@ TEST(PeopleHandlerGuestModeTest, GetStoredAccountsList) {
std::unique_ptr<Profile> profile = builder.Build();
PeopleHandler handler(profile.get());
- base::Value accounts = handler.GetStoredAccountsList();
- EXPECT_TRUE(accounts.GetList().empty());
+ base::Value::List accounts = handler.GetStoredAccountsList();
+ EXPECT_TRUE(accounts.empty());
}
TEST_F(PeopleHandlerTest, TurnOffSync) {
@@ -1462,10 +1446,9 @@ TEST_F(PeopleHandlerTest, GetStoredAccountsList) {
ASSERT_FALSE(identity_manager()->HasPrimaryAccount(ConsentLevel::kSync));
CreatePeopleHandler();
- base::Value accounts = handler_->GetStoredAccountsList();
- const base::Value::List& accounts_list = accounts.GetList();
- ASSERT_EQ(1u, accounts_list.size());
- EXPECT_EQ("user@gmail.com", accounts_list[0].FindKey("email")->GetString());
+ base::Value::List accounts = handler_->GetStoredAccountsList();
+ ASSERT_EQ(1u, accounts.size());
+ EXPECT_EQ("user@gmail.com", *accounts[0].GetDict().FindString("email"));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.cc b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.cc
index 27ec1d11c1d..06add290d17 100644
--- a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.cc
@@ -12,12 +12,6 @@ namespace settings {
namespace {
-// Keys of the dictionary returned by GetFlocIdInformation.
-constexpr char kTrialStatus[] = "trialStatus";
-constexpr char kCohort[] = "cohort";
-constexpr char kNextUpdate[] = "nextUpdate";
-constexpr char kCanReset[] = "canReset";
-
// Keys of the dictionary returned by getFledgeState.
constexpr char kJoiningSites[] = "joiningSites";
constexpr char kBlockedSites[] = "blockedSites";
@@ -31,33 +25,12 @@ constexpr char kDisplayString[] = "displayString";
constexpr char kTopTopics[] = "topTopics";
constexpr char kBlockedTopics[] = "blockedTopics";
-base::Value GetFlocIdInformation(Profile* profile) {
- auto* privacy_sandbox_service =
- PrivacySandboxServiceFactory::GetForProfile(profile);
- DCHECK(privacy_sandbox_service);
-
- base::DictionaryValue floc_id_information;
- floc_id_information.SetKey(
- kTrialStatus,
- base::Value(privacy_sandbox_service->GetFlocStatusForDisplay()));
- floc_id_information.SetKey(
- kCohort, base::Value(privacy_sandbox_service->GetFlocIdForDisplay()));
- floc_id_information.SetKey(
- kNextUpdate,
- base::Value(privacy_sandbox_service->GetFlocIdNextUpdateForDisplay(
- base::Time::Now())));
- floc_id_information.SetKey(
- kCanReset, base::Value(privacy_sandbox_service->IsFlocIdResettable()));
-
- return std::move(floc_id_information);
-}
-
-base::Value ConvertTopicToValue(const privacy_sandbox::CanonicalTopic& topic) {
- base::Value topic_value(base::Value::Type::DICTIONARY);
- topic_value.SetKey(kTopicId, base::Value(topic.topic_id().value()));
- topic_value.SetKey(kTaxonomyVersion, base::Value(topic.taxonomy_version()));
- topic_value.SetKey(kDisplayString,
- base::Value(topic.GetLocalizedRepresentation()));
+base::Value::Dict ConvertTopicToValue(
+ const privacy_sandbox::CanonicalTopic& topic) {
+ base::Value::Dict topic_value;
+ topic_value.Set(kTopicId, topic.topic_id().value());
+ topic_value.Set(kTaxonomyVersion, topic.taxonomy_version());
+ topic_value.Set(kDisplayString, topic.GetLocalizedRepresentation());
return topic_value;
}
@@ -68,13 +41,6 @@ PrivacySandboxHandler::~PrivacySandboxHandler() = default;
void PrivacySandboxHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "getFlocId", base::BindRepeating(&PrivacySandboxHandler::HandleGetFlocId,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "resetFlocId",
- base::BindRepeating(&PrivacySandboxHandler::HandleResetFlocId,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"setFledgeJoiningAllowed",
base::BindRepeating(&PrivacySandboxHandler::HandleSetFledgeJoiningAllowed,
base::Unretained(this)));
@@ -92,35 +58,6 @@ void PrivacySandboxHandler::RegisterMessages() {
base::Unretained(this)));
}
-void PrivacySandboxHandler::HandleGetFlocId(const base::Value::List& args) {
- AllowJavascript();
-
- CHECK_EQ(1U, args.size());
- const base::Value& callback_id = args[0];
-
- ResolveJavascriptCallback(callback_id,
- GetFlocIdInformation(Profile::FromWebUI(web_ui())));
-}
-
-void PrivacySandboxHandler::HandleResetFlocId(const base::Value::List& args) {
- CHECK_EQ(0U, args.size());
- AllowJavascript();
-
- auto* privacy_sandbox_service =
- PrivacySandboxServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
- DCHECK(privacy_sandbox_service);
-
- privacy_sandbox_service->ResetFlocId(/*user_initiated=*/true);
-
- // The identifier will have been immediately invalidated in response to
- // the clearing action, so synchronously retrieving the FLoC ID will retrieve
- // the appropriate invalid ID string.
- // TODO(crbug.com/1207891): Have this handler listen to an event directly
- // from the FLoC provider, rather than inferring behavior.
- FireWebUIListener("floc-id-changed",
- GetFlocIdInformation(Profile::FromWebUI(web_ui())));
-}
-
void PrivacySandboxHandler::HandleSetFledgeJoiningAllowed(
const base::Value::List& args) {
const std::string& site = args[0].GetString();
@@ -130,6 +67,7 @@ void PrivacySandboxHandler::HandleSetFledgeJoiningAllowed(
void PrivacySandboxHandler::HandleGetFledgeState(
const base::Value::List& args) {
+ AllowJavascript();
const std::string& callback_id = args[0].GetString();
GetPrivacySandboxService()->GetFledgeJoiningEtldPlusOneForDisplay(
base::BindOnce(&PrivacySandboxHandler::OnFledgeJoiningSitesRecieved,
@@ -149,17 +87,18 @@ void PrivacySandboxHandler::HandleSetTopicAllowed(
void PrivacySandboxHandler::HandleGetTopicsState(
const base::Value::List& args) {
- base::Value top_topics_list(base::Value::Type::LIST);
+ AllowJavascript();
+ base::Value::List top_topics_list;
for (const auto& topic : GetPrivacySandboxService()->GetCurrentTopTopics())
top_topics_list.Append(ConvertTopicToValue(topic));
- base::Value blocked_topics_list(base::Value::Type::LIST);
+ base::Value::List blocked_topics_list;
for (const auto& topic : GetPrivacySandboxService()->GetBlockedTopics())
blocked_topics_list.Append(ConvertTopicToValue(topic));
- base::DictionaryValue topics_state;
- topics_state.SetKey(kTopTopics, std::move(top_topics_list));
- topics_state.SetKey(kBlockedTopics, std::move(blocked_topics_list));
+ base::Value::Dict topics_state;
+ topics_state.Set(kTopTopics, std::move(top_topics_list));
+ topics_state.Set(kBlockedTopics, std::move(blocked_topics_list));
ResolveJavascriptCallback(args[0], std::move(topics_state));
}
@@ -168,19 +107,19 @@ void PrivacySandboxHandler::OnFledgeJoiningSitesRecieved(
std::vector<std::string> joining_sites) {
// Combine |joining_sites| with the blocked FLEDGE sites information. The
// latter is available synchronously.
- base::Value joining_sites_list(base::Value::Type::LIST);
+ base::Value::List joining_sites_list;
for (const auto& site : joining_sites)
- joining_sites_list.Append(base::Value(site));
+ joining_sites_list.Append(site);
const auto blocked_sites =
GetPrivacySandboxService()->GetBlockedFledgeJoiningTopFramesForDisplay();
- base::Value blocked_sites_list(base::Value::Type::LIST);
+ base::Value::List blocked_sites_list;
for (const auto& site : blocked_sites)
- blocked_sites_list.Append(base::Value(site));
+ blocked_sites_list.Append(site);
- base::DictionaryValue fledge_state;
- fledge_state.SetKey(kJoiningSites, std::move(joining_sites_list));
- fledge_state.SetKey(kBlockedSites, std::move(blocked_sites_list));
+ base::Value::Dict fledge_state;
+ fledge_state.Set(kJoiningSites, std::move(joining_sites_list));
+ fledge_state.Set(kBlockedSites, std::move(blocked_sites_list));
ResolveJavascriptCallback(base::Value(callback_id), std::move(fledge_state));
}
diff --git a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.h b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.h
index 3c38b92ec70..6c7a1b9e94c 100644
--- a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler.h
@@ -23,8 +23,6 @@ class PrivacySandboxHandler : public SettingsPageUIHandler {
private:
friend class PrivacySandboxHandlerTest;
- FRIEND_TEST_ALL_PREFIXES(PrivacySandboxHandlerTest, GetFlocId);
- FRIEND_TEST_ALL_PREFIXES(PrivacySandboxHandlerTest, ResetFlocId);
FRIEND_TEST_ALL_PREFIXES(PrivacySandboxHandlerTestMockService,
SetFledgeJoiningAllowed);
FRIEND_TEST_ALL_PREFIXES(PrivacySandboxHandlerTestMockService,
@@ -34,8 +32,6 @@ class PrivacySandboxHandler : public SettingsPageUIHandler {
FRIEND_TEST_ALL_PREFIXES(PrivacySandboxHandlerTestMockService,
GetTopicsState);
- void HandleGetFlocId(const base::Value::List& args);
- void HandleResetFlocId(const base::Value::List& args);
void HandleSetFledgeJoiningAllowed(const base::Value::List& args);
void HandleGetFledgeState(const base::Value::List& args);
void HandleSetTopicAllowed(const base::Value::List& args);
diff --git a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler_unittest.cc
index 0522fb888f0..534914501b8 100644
--- a/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/privacy_sandbox_handler_unittest.cc
@@ -59,26 +59,6 @@ std::unique_ptr<KeyedService> BuildMockPrivacySandboxService(
return std::make_unique<::testing::StrictMock<MockPrivacySandboxService>>();
}
-// Confirms that the |floc_id| dictionary provided matches the current FLoC
-// information for |profile|.
-void ValidateFlocId(const base::Value* floc_id, Profile* profile) {
- auto* privacy_sandbox_service =
- PrivacySandboxServiceFactory::GetForProfile(profile);
-
- ASSERT_TRUE(floc_id->is_dict());
- EXPECT_EQ(
- base::UTF16ToUTF8(privacy_sandbox_service->GetFlocStatusForDisplay()),
- *floc_id->FindStringPath("trialStatus"));
- EXPECT_EQ(base::UTF16ToUTF8(privacy_sandbox_service->GetFlocIdForDisplay()),
- *floc_id->FindStringPath("cohort"));
- EXPECT_EQ(
- base::UTF16ToUTF8(privacy_sandbox_service->GetFlocIdNextUpdateForDisplay(
- base::Time::Now())),
- *floc_id->FindStringPath("nextUpdate"));
- EXPECT_EQ(privacy_sandbox_service->IsFlocIdResettable(),
- floc_id->FindBoolPath("canReset"));
-}
-
void ValidateFledgeInfo(content::TestWebUI* web_ui,
std::string expected_callback_id,
std::vector<std::string> expected_joining_sites,
@@ -167,29 +147,6 @@ class PrivacySandboxHandlerTest : public testing::Test {
std::unique_ptr<PrivacySandboxHandler> handler_;
};
-TEST_F(PrivacySandboxHandlerTest, GetFlocId) {
- base::Value args(base::Value::Type::LIST);
- args.Append(kCallbackId1);
- handler()->HandleGetFlocId(args.GetList());
-
- const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- EXPECT_EQ(kCallbackId1, data.arg1()->GetString());
- EXPECT_EQ("cr.webUIResponse", data.function_name());
- ASSERT_TRUE(data.arg2()->GetBool());
- ValidateFlocId(data.arg3(), profile());
-}
-
-TEST_F(PrivacySandboxHandlerTest, ResetFlocId) {
- base::Value args(base::Value::Type::LIST);
- handler()->HandleResetFlocId(args.GetList());
-
- // Resetting the FLoC ID should fire the appropriate WebUI listener.
- const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
- EXPECT_EQ("floc-id-changed", data.arg1()->GetString());
- ValidateFlocId(data.arg2(), profile());
-}
-
class PrivacySandboxHandlerTestMockService : public PrivacySandboxHandlerTest {
public:
void SetUp() override {
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 ab9a7c73e76..5135e2a9549 100644
--- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -103,7 +103,7 @@ void ProfileInfoHandler::HandleGetProfileInfo(const base::Value::List& args) {
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, *GetAccountNameAndIcon());
+ ResolveJavascriptCallback(callback_id, GetAccountNameAndIcon());
}
#if !BUILDFLAG(IS_CHROMEOS_ASH)
@@ -129,11 +129,10 @@ void ProfileInfoHandler::PushProfileStatsCount(
#endif
void ProfileInfoHandler::PushProfileInfo() {
- FireWebUIListener(kProfileInfoChangedEventName, *GetAccountNameAndIcon());
+ FireWebUIListener(kProfileInfoChangedEventName, GetAccountNameAndIcon());
}
-std::unique_ptr<base::DictionaryValue>
-ProfileInfoHandler::GetAccountNameAndIcon() {
+base::Value::Dict ProfileInfoHandler::GetAccountNameAndIcon() {
std::string name;
std::string icon_url;
@@ -165,9 +164,9 @@ ProfileInfoHandler::GetAccountNameAndIcon() {
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- auto response = std::make_unique<base::DictionaryValue>();
- response->SetStringKey("name", name);
- response->SetStringKey("iconUrl", icon_url);
+ base::Value::Dict response;
+ response.Set("name", name);
+ response.Set("iconUrl", icon_url);
return response;
}
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 75cc9cd788b..bf466fe9e3e 100644
--- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h
@@ -74,7 +74,7 @@ class ProfileInfoHandler : public SettingsPageUIHandler,
void PushProfileStatsCount(profiles::ProfileCategoryStats stats);
#endif
- std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon();
+ base::Value::Dict GetAccountNameAndIcon();
// Weak pointer.
raw_ptr<Profile> profile_;
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 51a5f393b24..252f1328d3d 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
@@ -72,22 +72,22 @@ class ProfileInfoHandlerTest : public testing::Test {
}
void VerifyProfileInfo(const base::Value* call_argument) {
- const base::DictionaryValue* response = nullptr;
- ASSERT_TRUE(call_argument->GetAsDictionary(&response));
+ ASSERT_TRUE(call_argument->is_dict());
+ const base::Value::Dict& dict = call_argument->GetDict();
- std::string name;
- std::string icon_url;
- ASSERT_TRUE(response->GetString("name", &name));
- ASSERT_TRUE(response->GetString("iconUrl", &icon_url));
+ const std::string* name = dict.FindString("name");
+ const std::string* icon_url = dict.FindString("iconUrl");
+ ASSERT_TRUE(name);
+ ASSERT_TRUE(icon_url);
#if BUILDFLAG(IS_CHROMEOS_ASH)
- EXPECT_EQ(fake_id, name);
- EXPECT_FALSE(icon_url.empty());
+ EXPECT_EQ(fake_id, *name);
+ EXPECT_FALSE(icon_url->empty());
#else
- EXPECT_EQ("Profile 1", name);
+ EXPECT_EQ("Profile 1", *name);
std::string mime, charset, data;
- EXPECT_TRUE(net::DataURL::Parse(GURL(icon_url), &mime, &charset, &data));
+ EXPECT_TRUE(net::DataURL::Parse(GURL(*icon_url), &mime, &charset, &data));
EXPECT_EQ("image/png", mime);
SkBitmap bitmap;
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 9a981eaf7bb..102af01954f 100644
--- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
@@ -27,24 +27,25 @@ namespace settings {
namespace {
// TODO(https://crbug.com/1251039): Remove usages of base::ListValue
-void GetHandlersAsListValue(
+base::Value::List GetHandlersAsListValue(
const custom_handlers::ProtocolHandlerRegistry* registry,
const custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList&
- handlers,
- base::ListValue* handler_list) {
+ handlers) {
+ base::Value::List handler_list;
for (const auto& handler : handlers) {
- base::DictionaryValue handler_value;
- handler_value.SetStringPath("protocol_display_name",
- handler.GetProtocolDisplayName());
- handler_value.SetStringPath("protocol", handler.protocol());
- handler_value.SetStringPath("spec", handler.url().spec());
- handler_value.SetStringPath("host", handler.url().host());
+ base::Value::Dict handler_value;
+ handler_value.Set("protocol_display_name",
+ handler.GetProtocolDisplayName());
+ handler_value.Set("protocol", handler.protocol());
+ handler_value.Set("spec", handler.url().spec());
+ handler_value.Set("host", handler.url().host());
if (registry)
- handler_value.SetBoolPath("is_default", registry->IsDefault(handler));
+ handler_value.Set("is_default", registry->IsDefault(handler));
if (handler.web_app_id().has_value())
- handler_value.SetStringPath("app_id", handler.web_app_id().value());
- handler_list->Append(std::move(handler_value));
+ handler_value.Set("app_id", handler.web_app_id().value());
+ handler_list.Append(std::move(handler_value));
}
+ return handler_list;
}
} // namespace
@@ -130,28 +131,28 @@ void ProtocolHandlersHandler::OnWebAppInstallManagerDestroyed() {
install_manager_observation_.Reset();
}
-void ProtocolHandlersHandler::GetHandlersForProtocol(
- const std::string& protocol,
- base::Value::Dict* handlers_value) {
+base::Value::Dict ProtocolHandlersHandler::GetHandlersForProtocol(
+ const std::string& protocol) {
+ base::Value::Dict handlers_value;
custom_handlers::ProtocolHandlerRegistry* registry =
GetProtocolHandlerRegistry();
- handlers_value->Set(
+ handlers_value.Set(
"protocol_display_name",
custom_handlers::ProtocolHandler::GetProtocolDisplayName(protocol));
- handlers_value->Set("protocol", protocol);
+ handlers_value.Set("protocol", protocol);
- base::ListValue handlers_list;
- GetHandlersAsListValue(registry, registry->GetHandlersFor(protocol),
- &handlers_list);
- handlers_value->Set("handlers", std::move(handlers_list));
+ base::Value::List handlers_list =
+ GetHandlersAsListValue(registry, registry->GetHandlersFor(protocol));
+ handlers_value.Set("handlers", std::move(handlers_list));
+ return handlers_value;
}
-void ProtocolHandlersHandler::GetIgnoredHandlers(base::ListValue* handlers) {
+base::Value::List ProtocolHandlersHandler::GetIgnoredHandlers() {
custom_handlers::ProtocolHandlerRegistry* registry =
GetProtocolHandlerRegistry();
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList
ignored_handlers = registry->GetIgnoredHandlers();
- return GetHandlersAsListValue(registry, ignored_handlers, handlers);
+ return GetHandlersAsListValue(registry, ignored_handlers);
}
void ProtocolHandlersHandler::UpdateHandlerList() {
@@ -160,18 +161,14 @@ void ProtocolHandlersHandler::UpdateHandlerList() {
std::vector<std::string> protocols;
registry->GetRegisteredProtocols(&protocols);
- base::ListValue handlers;
+ base::Value::List handlers;
for (auto protocol = protocols.begin(); protocol != protocols.end();
protocol++) {
- base::Value::Dict handler_value;
- GetHandlersForProtocol(*protocol, &handler_value);
- handlers.Append(std::move(handler_value));
+ handlers.Append(GetHandlersForProtocol(*protocol));
}
- std::unique_ptr<base::ListValue> ignored_handlers(new base::ListValue());
- GetIgnoredHandlers(ignored_handlers.get());
FireWebUIListener("setProtocolHandlers", handlers);
- FireWebUIListener("setIgnoredProtocolHandlers", *ignored_handlers);
+ FireWebUIListener("setIgnoredProtocolHandlers", GetIgnoredHandlers());
}
void ProtocolHandlersHandler::HandleObserveProtocolHandlers(
@@ -238,21 +235,17 @@ ProtocolHandlersHandler::GetProtocolHandlerRegistry() {
// App Protocol Handler specific functions
-std::unique_ptr<base::DictionaryValue>
-ProtocolHandlersHandler::GetAppHandlersForProtocol(
+base::Value::Dict ProtocolHandlersHandler::GetAppHandlersForProtocol(
const std::string& protocol,
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList handlers) {
- auto handlers_value = std::make_unique<base::DictionaryValue>();
+ base::Value::Dict handlers_value;
if (!handlers.empty()) {
- handlers_value->SetStringPath(
+ handlers_value.Set(
"protocol_display_name",
custom_handlers::ProtocolHandler::GetProtocolDisplayName(protocol));
- handlers_value->SetStringPath("protocol", protocol);
-
- base::ListValue handlers_list;
- GetHandlersAsListValue(nullptr, handlers, &handlers_list);
- handlers_value->SetKey("handlers", std::move(handlers_list));
+ handlers_value.Set("protocol", protocol);
+ handlers_value.Set("handlers", GetHandlersAsListValue(nullptr, handlers));
}
return handlers_value;
}
@@ -266,14 +259,13 @@ void ProtocolHandlersHandler::UpdateAllAllowedLaunchProtocols() {
web_app::OsIntegrationManager& os_integration_manager =
web_app_provider_->os_integration_manager();
- base::Value handlers(base::Value::Type::LIST);
+ base::Value::List handlers;
for (auto& protocol : protocols) {
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList
protocol_handlers =
os_integration_manager.GetAllowedHandlersForProtocol(protocol);
- auto handler_value(GetAppHandlersForProtocol(protocol, protocol_handlers));
- handlers.Append(std::move(*handler_value));
+ handlers.Append(GetAppHandlersForProtocol(protocol, protocol_handlers));
}
FireWebUIListener("setAppAllowedProtocolHandlers", handlers);
@@ -288,13 +280,12 @@ void ProtocolHandlersHandler::UpdateAllDisallowedLaunchProtocols() {
web_app::OsIntegrationManager& os_integration_manager =
web_app_provider_->os_integration_manager();
- base::Value handlers(base::Value::Type::LIST);
+ base::Value::List handlers;
for (auto& protocol : protocols) {
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList
protocol_handlers =
os_integration_manager.GetDisallowedHandlersForProtocol(protocol);
- auto handler_value(GetAppHandlersForProtocol(protocol, protocol_handlers));
- handlers.Append(std::move(*handler_value));
+ handlers.Append(GetAppHandlersForProtocol(protocol, protocol_handlers));
}
FireWebUIListener("setAppDisallowedProtocolHandlers", handlers);
diff --git a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
index 8e0255f9d65..3406a264f1e 100644
--- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
@@ -84,11 +84,10 @@ class ProtocolHandlersHandler
// Populates a JSON object describing the set of protocol handlers for the
// given protocol.
- void GetHandlersForProtocol(const std::string& protocol,
- base::Value::Dict* value);
+ base::Value::Dict GetHandlersForProtocol(const std::string& protocol);
// Returns a JSON list of the ignored protocol handlers.
- void GetIgnoredHandlers(base::ListValue* handlers);
+ base::Value::List GetIgnoredHandlers();
// Called when the JS PasswordManager object is initialized.
void UpdateHandlerList();
@@ -113,9 +112,9 @@ class ProtocolHandlersHandler
custom_handlers::ProtocolHandler ParseAppHandlerFromArgs(
const base::Value::List& args) const;
- // Returns a DictionaryValue describing the set of app protocol handlers for
+ // Returns a Value::Dict describing the set of app protocol handlers for
// the given |protocol| in the given |handlers| list.
- std::unique_ptr<base::DictionaryValue> GetAppHandlersForProtocol(
+ base::Value::Dict GetAppHandlersForProtocol(
const std::string& protocol,
custom_handlers::ProtocolHandlerRegistry::ProtocolHandlerList handlers);
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 0e5399aa6ed..f1c21916a57 100644
--- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
@@ -186,9 +186,9 @@ void ResetSettingsHandler::HandleGetReportedSettings(
}
void ResetSettingsHandler::OnGetReportedSettingsDone(std::string callback_id) {
- std::unique_ptr<base::ListValue> list =
+ base::Value::List list =
GetReadableFeedbackForSnapshot(profile_, *setting_snapshot_);
- ResolveJavascriptCallback(base::Value(callback_id), *list);
+ ResolveJavascriptCallback(base::Value(callback_id), list);
}
void ResetSettingsHandler::OnShowResetProfileDialog(
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 7ae143fdfc8..41a69e29a63 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
@@ -30,7 +30,6 @@
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/strings/grit/components_strings.h"
-#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/blocklist_extension_prefs.h"
@@ -82,6 +81,7 @@ SafetyCheckHandler::UpdateStatus ConvertToUpdateStatus(
return SafetyCheckHandler::UpdateStatus::kUpdated;
case VersionUpdater::UPDATING:
return SafetyCheckHandler::UpdateStatus::kUpdating;
+ case VersionUpdater::DEFERRED:
case VersionUpdater::NEED_PERMISSION_TO_UPDATE:
case VersionUpdater::NEARLY_UPDATED:
return SafetyCheckHandler::UpdateStatus::kRelaunch;
@@ -380,9 +380,9 @@ void SafetyCheckHandler::HandleGetParentRanDisplayString(
// such strings.
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
// String update for Chrome Cleaner.
- base::DictionaryValue event;
- event.SetIntKey(kNewState, static_cast<int>(chrome_cleaner_status_));
- event.SetStringKey(
+ base::Value::Dict event;
+ event.Set(kNewState, static_cast<int>(chrome_cleaner_status_));
+ event.Set(
kDisplayString,
GetStringForChromeCleaner(
chrome_cleaner_status_,
@@ -512,10 +512,10 @@ void SafetyCheckHandler::OnPasswordsCheckResult(PasswordsStatus status,
Weak weak,
Done done,
Total total) {
- base::DictionaryValue event;
- event.SetIntKey(kNewState, static_cast<int>(status));
- event.SetStringKey(kDisplayString, GetStringForPasswords(status, compromised,
- weak, done, total));
+ base::Value::Dict event;
+ event.Set(kNewState, static_cast<int>(status));
+ event.Set(kDisplayString,
+ GetStringForPasswords(status, compromised, weak, done, total));
FireWebUIListener(kPasswordsEvent, event);
if (status != PasswordsStatus::kChecking) {
base::UmaHistogramEnumeration("Settings.SafetyCheck.PasswordsResult",
@@ -530,11 +530,11 @@ void SafetyCheckHandler::OnExtensionsCheckResult(
Blocklisted blocklisted,
ReenabledUser reenabled_user,
ReenabledAdmin reenabled_admin) {
- base::DictionaryValue event;
- event.SetIntKey(kNewState, static_cast<int>(status));
- event.SetStringKey(kDisplayString,
- GetStringForExtensions(status, Blocklisted(blocklisted),
- reenabled_user, reenabled_admin));
+ base::Value::Dict event;
+ event.Set(kNewState, static_cast<int>(status));
+ event.Set(kDisplayString,
+ GetStringForExtensions(status, Blocklisted(blocklisted),
+ reenabled_user, reenabled_admin));
FireWebUIListener(kExtensionsEvent, event);
if (status != ExtensionsStatus::kChecking) {
base::UmaHistogramEnumeration("Settings.SafetyCheck.ExtensionsResult",
@@ -547,12 +547,11 @@ void SafetyCheckHandler::OnExtensionsCheckResult(
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
void SafetyCheckHandler::OnChromeCleanerCheckResult(
SafetyCheckHandler::ChromeCleanerResult result) {
- base::DictionaryValue event;
- event.SetIntKey(kNewState, static_cast<int>(result.status));
- event.SetStringKey(
- kDisplayString,
- GetStringForChromeCleaner(result.status, result.cct_completion_time,
- timestamp_delegate_->GetSystemTime()));
+ base::Value::Dict event;
+ event.Set(kNewState, static_cast<int>(result.status));
+ event.Set(kDisplayString,
+ GetStringForChromeCleaner(result.status, result.cct_completion_time,
+ timestamp_delegate_->GetSystemTime()));
FireWebUIListener(kChromeCleanerEvent, event);
chrome_cleaner_status_ = result.status;
}
@@ -598,15 +597,7 @@ std::u16string SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) {
IDS_SETTINGS_SAFETY_CHECK_UPDATES_FAILED,
base::ASCIIToUTF16(chrome::kChromeFixUpdateProblems));
case UpdateStatus::kUnknown:
- return l10n_util::GetStringFUTF16(
- IDS_SETTINGS_ABOUT_PAGE_BROWSER_VERSION,
- base::UTF8ToUTF16(version_info::GetVersionNumber()),
- l10n_util::GetStringUTF16(version_info::IsOfficialBuild()
- ? IDS_VERSION_UI_OFFICIAL
- : IDS_VERSION_UI_UNOFFICIAL),
- base::UTF8ToUTF16(
- chrome::GetChannelName(chrome::WithExtendedStable(true))),
- l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation()));
+ return VersionUI::GetAnnotatedVersionStringForUi();
// This state is only used on Android for recording metrics. This codepath
// is unreachable.
case UpdateStatus::kOutdated:
@@ -983,8 +974,7 @@ void SafetyCheckHandler::OnCredentialDone(
}
}
-void SafetyCheckHandler::OnInsecureCredentialsChanged(
- password_manager::InsecureCredentialsManager::CredentialsView credentials) {
+void SafetyCheckHandler::OnInsecureCredentialsChanged() {
extensions::api::passwords_private::PasswordCheckStatus status =
passwords_delegate_->GetPasswordCheckStatus();
// Ignore the event, unless the password check is idle with no errors.
@@ -1093,8 +1083,8 @@ void SafetyCheckHandler::FireBasicSafetyCheckWebUiListener(
const std::string& event_name,
int new_state,
const std::u16string& display_string) {
- base::DictionaryValue event;
- event.SetIntKey(kNewState, new_state);
- event.SetStringKey(kDisplayString, display_string);
+ base::Value::Dict event;
+ event.Set(kNewState, new_state);
+ event.Set(kDisplayString, display_string);
FireWebUIListener(event_name, event);
}
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 bdfee49b2ca..9874fada635 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
@@ -281,9 +281,7 @@ class SafetyCheckHandler
password_manager::IsLeaked is_leaked) override;
// InsecureCredentialsManager::Observer implementation.
- void OnInsecureCredentialsChanged(
- password_manager::InsecureCredentialsManager::CredentialsView credentials)
- override;
+ void OnInsecureCredentialsChanged() override;
// SettingsPageUIHandler implementation.
void OnJavascriptAllowed() override;
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 9063f5b1f32..439641b5140 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
@@ -24,6 +24,7 @@
#include "chrome/browser/extensions/api/passwords_private/test_passwords_private_delegate.h"
#include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/ui/webui/help/test_version_updater.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/passwords_private.h"
@@ -186,9 +187,9 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
base::RunLoop().RunUntilIdle();
}
- std::vector<extensions::api::passwords_private::InsecureCredential>
+ std::vector<extensions::api::passwords_private::PasswordUiEntry>
GetCompromisedCredentials() override {
- std::vector<extensions::api::passwords_private::InsecureCredential>
+ std::vector<extensions::api::passwords_private::PasswordUiEntry>
compromised(compromised_password_count_);
for (int i = 0; i < compromised_password_count_; ++i) {
compromised[i].username = "test" + base::NumberToString(i);
@@ -196,9 +197,9 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
return compromised;
}
- std::vector<extensions::api::passwords_private::InsecureCredential>
+ std::vector<extensions::api::passwords_private::PasswordUiEntry>
GetWeakCredentials() override {
- std::vector<extensions::api::passwords_private::InsecureCredential> weak(
+ std::vector<extensions::api::passwords_private::PasswordUiEntry> weak(
weak_password_count_);
for (int i = 0; i < weak_password_count_; ++i) {
weak[i].username = "test" + base::NumberToString(i);
@@ -492,27 +493,6 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Relaunch) {
}
TEST_F(SafetyCheckHandlerTest, CheckUpdates_Disabled) {
- const char* processor_variation = nullptr;
-#if BUILDFLAG(IS_MAC)
- switch (base::mac::GetCPUType()) {
- case base::mac::CPUType::kIntel:
- processor_variation = " (x86_64)";
- break;
- case base::mac::CPUType::kTranslatedIntel:
- processor_variation = " (x86_64 translated)";
- break;
- case base::mac::CPUType::kArm:
- processor_variation = " (arm64)";
- break;
- }
-#elif defined(ARCH_CPU_64_BITS)
- processor_variation = " (64-bit)";
-#elif defined(ARCH_CPU_32_BITS)
- processor_variation = " (32-bit)";
-#else
-#error Update for a processor that is neither 32-bit nor 64-bit.
-#endif // OS_*
-
version_updater_->SetReturnedStatus(VersionUpdater::Status::DISABLED);
safety_check_->PerformSafetyCheck();
// TODO(crbug/1072432): Since the UNKNOWN state is not present in JS in M83,
@@ -523,12 +503,7 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Disabled) {
static_cast<int>(SafetyCheckHandler::UpdateStatus::kFailedOffline));
ASSERT_TRUE(event);
VerifyDisplayString(
- event, "Version " + version_info::GetVersionNumber() + " (" +
- (version_info::IsOfficialBuild() ? "Official Build"
- : "Developer Build") +
- ") " +
- chrome::GetChannelName(chrome::WithExtendedStable(true)) +
- processor_variation);
+ event, base::UTF16ToUTF8(VersionUI::GetAnnotatedVersionStringForUi()));
histogram_tester_.ExpectBucketCount(
"Settings.SafetyCheck.UpdatesResult",
SafetyCheckHandler::UpdateStatus::kUnknown, 1);
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 7fc77aae62e..fa61ed68990 100644
--- a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc
@@ -103,101 +103,91 @@ void SearchEnginesHandler::OnJavascriptDisallowed() {
pref_change_registrar_.RemoveAll();
}
-std::unique_ptr<base::DictionaryValue>
-SearchEnginesHandler::GetSearchEnginesList() {
+base::Value::Dict SearchEnginesHandler::GetSearchEnginesList() {
// Find the default engine.
const TemplateURL* default_engine =
list_controller_.GetDefaultSearchProvider();
- int default_index =
+ absl::optional<size_t> default_index =
list_controller_.table_model()->IndexOfTemplateURL(default_engine);
// Build the first list (default search engines).
- base::ListValue defaults;
- int last_default_engine_index =
+ base::Value::List defaults;
+ size_t last_default_engine_index =
list_controller_.table_model()->last_search_engine_index();
- // Sanity check for https://crbug.com/781703.
- CHECK_GE(last_default_engine_index, 0);
-
- for (int i = 0; i < last_default_engine_index; ++i) {
+ for (size_t i = 0; i < last_default_engine_index; ++i) {
// Third argument is false, as the engine is not from an extension.
- defaults.Append(
- base::Value(CreateDictionaryForEngine(i, i == default_index)));
+ defaults.Append(CreateDictionaryForEngine(i, i == default_index));
}
// Build the second list (active search engines). This will not have any
// entries if the new Search Engines page is not enabled.
- base::ListValue actives;
- int last_active_engine_index =
+ base::Value::List actives;
+ size_t last_active_engine_index =
list_controller_.table_model()->last_active_engine_index();
CHECK_LE(last_default_engine_index, last_active_engine_index);
- for (int i = std::max(last_default_engine_index, 0);
- i < last_active_engine_index; ++i) {
+ for (size_t i = last_default_engine_index; i < last_active_engine_index;
+ ++i) {
// Third argument is false, as the engine is not from an extension.
- actives.Append(
- base::Value(CreateDictionaryForEngine(i, i == default_index)));
+ actives.Append(CreateDictionaryForEngine(i, i == default_index));
}
// Build the second list (other search engines).
- base::ListValue others;
- int last_other_engine_index =
+ base::Value::List others;
+ size_t last_other_engine_index =
list_controller_.table_model()->last_other_engine_index();
// Sanity check for https://crbug.com/781703.
CHECK_LE(last_active_engine_index, last_other_engine_index);
- for (int i = std::max(last_active_engine_index, 0);
- i < last_other_engine_index; ++i) {
- others.Append(
- base::Value(CreateDictionaryForEngine(i, i == default_index)));
+ for (size_t i = last_active_engine_index; i < last_other_engine_index; ++i) {
+ others.Append(CreateDictionaryForEngine(i, i == default_index));
}
// Build the third list (omnibox extensions).
- base::ListValue extensions;
- int engine_count = list_controller_.table_model()->RowCount();
+ base::Value::List extensions;
+ size_t engine_count = list_controller_.table_model()->RowCount();
// Sanity check for https://crbug.com/781703.
CHECK_LE(last_other_engine_index, engine_count);
- for (int i = std::max(last_other_engine_index, 0); i < engine_count; ++i) {
- extensions.Append(
- base::Value(CreateDictionaryForEngine(i, i == default_index)));
+ for (size_t i = last_other_engine_index; i < engine_count; ++i) {
+ extensions.Append(CreateDictionaryForEngine(i, i == default_index));
}
- auto search_engines_info = std::make_unique<base::DictionaryValue>();
- search_engines_info->SetKey("defaults", std::move(defaults));
- search_engines_info->SetKey("actives", std::move(actives));
- search_engines_info->SetKey("others", std::move(others));
- search_engines_info->SetKey("extensions", std::move(extensions));
+ base::Value::Dict search_engines_info;
+ search_engines_info.Set("defaults", std::move(defaults));
+ search_engines_info.Set("actives", std::move(actives));
+ search_engines_info.Set("others", std::move(others));
+ search_engines_info.Set("extensions", std::move(extensions));
return search_engines_info;
}
void SearchEnginesHandler::OnModelChanged() {
AllowJavascript();
- FireWebUIListener("search-engines-changed", *GetSearchEnginesList());
+ FireWebUIListener("search-engines-changed", GetSearchEnginesList());
}
-void SearchEnginesHandler::OnItemsChanged(int start, int length) {
+void SearchEnginesHandler::OnItemsChanged(size_t start, size_t length) {
OnModelChanged();
}
-void SearchEnginesHandler::OnItemsAdded(int start, int length) {
+void SearchEnginesHandler::OnItemsAdded(size_t start, size_t length) {
OnModelChanged();
}
-void SearchEnginesHandler::OnItemsRemoved(int start, int length) {
+void SearchEnginesHandler::OnItemsRemoved(size_t start, size_t length) {
OnModelChanged();
}
base::Value::Dict SearchEnginesHandler::CreateDictionaryForEngine(
- int index,
+ size_t index,
bool is_default) {
TemplateURLTableModel* table_model = list_controller_.table_model();
const TemplateURL* template_url = list_controller_.GetTemplateURL(index);
// Sanity check for https://crbug.com/781703.
- CHECK_GE(index, 0);
CHECK_LT(index, table_model->RowCount());
CHECK(template_url);
@@ -216,11 +206,12 @@ base::Value::Dict SearchEnginesHandler::CreateDictionaryForEngine(
Profile* profile = Profile::FromWebUI(web_ui());
dict.Set("url",
template_url->url_ref().DisplayURL(UIThreadSearchTermsData()));
- dict.Set("urlLocked", template_url->prepopulate_id() > 0);
+ dict.Set("urlLocked", ((template_url->prepopulate_id() > 0) ||
+ (template_url->starter_pack_id() > 0)));
GURL icon_url = template_url->favicon_url();
if (icon_url.is_valid())
dict.Set("iconURL", icon_url.spec());
- dict.Set("modelIndex", index);
+ dict.Set("modelIndex", base::checked_cast<int>(index));
dict.Set("canBeRemoved", list_controller_.CanRemove(template_url));
dict.Set("canBeDefault", list_controller_.CanMakeDefault(template_url));
@@ -239,14 +230,13 @@ base::Value::Dict SearchEnginesHandler::CreateDictionaryForEngine(
template_url->GetExtensionId(),
extensions::ExtensionRegistry::EVERYTHING);
if (extension) {
- std::unique_ptr<base::DictionaryValue> ext_info =
+ base::Value::Dict ext_info =
extensions::util::GetExtensionInfo(extension);
- ext_info->SetBoolKey("canBeDisabled",
- !extensions::ExtensionSystem::Get(profile)
- ->management_policy()
- ->MustRemainEnabled(extension, nullptr));
- dict.Set("extension",
- base::Value::FromUniquePtrValue(std::move(ext_info)));
+ ext_info.Set("canBeDisabled",
+ !extensions::ExtensionSystem::Get(profile)
+ ->management_policy()
+ ->MustRemainEnabled(extension, nullptr));
+ dict.Set("extension", std::move(ext_info));
}
}
return dict;
@@ -257,15 +247,17 @@ void SearchEnginesHandler::HandleGetSearchEnginesList(
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
AllowJavascript();
- ResolveJavascriptCallback(callback_id, *GetSearchEnginesList());
+ ResolveJavascriptCallback(callback_id, GetSearchEnginesList());
}
void SearchEnginesHandler::HandleSetDefaultSearchEngine(
const base::Value::List& args) {
CHECK_EQ(1U, args.size());
int index = args[0].GetInt();
- if (index < 0 || index >= list_controller_.table_model()->RowCount())
+ if (index < 0 || static_cast<size_t>(index) >=
+ list_controller_.table_model()->RowCount()) {
return;
+ }
list_controller_.MakeDefaultTemplateURL(index);
@@ -278,8 +270,10 @@ void SearchEnginesHandler::HandleSetIsActiveSearchEngine(
const int index = args[0].GetInt();
const bool is_active = args[1].GetBool();
- if (index < 0 || index >= list_controller_.table_model()->RowCount())
+ if (index < 0 || static_cast<size_t>(index) >=
+ list_controller_.table_model()->RowCount()) {
return;
+ }
list_controller_.SetIsActiveTemplateURL(index, is_active);
}
@@ -288,8 +282,10 @@ void SearchEnginesHandler::HandleRemoveSearchEngine(
const base::Value::List& args) {
CHECK_EQ(1U, args.size());
int index = args[0].GetInt();
- if (index < 0 || index >= list_controller_.table_model()->RowCount())
+ if (index < 0 || static_cast<size_t>(index) >=
+ list_controller_.table_model()->RowCount()) {
return;
+ }
if (list_controller_.CanRemove(list_controller_.GetTemplateURL(index))) {
list_controller_.RemoveTemplateURL(index);
@@ -302,16 +298,16 @@ void SearchEnginesHandler::HandleSearchEngineEditStarted(
CHECK_EQ(1U, args.size());
int index = args[0].GetInt();
- // Allow -1, which means we are adding a new engine.
- if (index < kNewSearchEngineIndex ||
- index >= list_controller_.table_model()->RowCount()) {
+ TemplateURL* engine = nullptr;
+ if (index >= 0 &&
+ static_cast<size_t>(index) < list_controller_.table_model()->RowCount()) {
+ engine = list_controller_.GetTemplateURL(index);
+ } else if (index != kNewSearchEngineIndex) {
return;
}
edit_controller_ = std::make_unique<EditSearchEngineController>(
- index == kNewSearchEngineIndex ? nullptr
- : list_controller_.GetTemplateURL(index),
- this, Profile::FromWebUI(web_ui()));
+ engine, this, Profile::FromWebUI(web_ui()));
}
void SearchEnginesHandler::OnEditedKeyword(TemplateURL* 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 8a061fc7789..c5c0538b161 100644
--- a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.h
@@ -37,9 +37,9 @@ class SearchEnginesHandler : public SettingsPageUIHandler,
// ui::TableModelObserver implementation.
void OnModelChanged() override;
- void OnItemsChanged(int start, int length) override;
- void OnItemsAdded(int start, int length) override;
- void OnItemsRemoved(int start, int length) override;
+ void OnItemsChanged(size_t start, size_t length) override;
+ void OnItemsAdded(size_t start, size_t length) override;
+ void OnItemsRemoved(size_t start, size_t length) override;
// EditSearchEngineControllerDelegate implementation.
void OnEditedKeyword(TemplateURL* template_url,
@@ -56,7 +56,7 @@ class SearchEnginesHandler : public SettingsPageUIHandler,
// Retrieves all search engines and returns them to WebUI.
void HandleGetSearchEnginesList(const base::Value::List& args);
- std::unique_ptr<base::DictionaryValue> GetSearchEnginesList();
+ base::Value::Dict GetSearchEnginesList();
// Removes the search engine at the given index. Called from WebUI.
void HandleRemoveSearchEngine(const base::Value::List& args);
@@ -91,7 +91,7 @@ class SearchEnginesHandler : public SettingsPageUIHandler,
void HandleSearchEngineEditCompleted(const base::Value::List& args);
// Returns a dictionary to pass to WebUI representing the given search engine.
- base::Value::Dict CreateDictionaryForEngine(int index, bool is_default);
+ base::Value::Dict CreateDictionaryForEngine(size_t index, bool is_default);
// Returns a dictionary to pass to WebUI representing the extension.
base::DictionaryValue* CreateDictionaryForExtension(
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
index 127cfd09637..c045b3cc85c 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
@@ -153,17 +153,17 @@ void ClearBrowsingDataHandler::HandleClearBrowsingDataForTest() {
// types that the user cleared from the clear browsing data UI and time period
// of the data to be cleared.
- base::Value data_types(base::Value::Type::LIST);
+ base::Value::List data_types;
data_types.Append("browser.clear_data.browsing_history");
- base::Value installed_apps(base::Value::Type::LIST);
+ base::Value::List installed_apps;
- base::Value list_args(base::Value::Type::LIST);
+ base::Value::List list_args;
list_args.Append("webui_callback_id");
list_args.Append(std::move(data_types));
list_args.Append(1);
list_args.Append(std::move(installed_apps));
- HandleClearBrowsingData(list_args.GetList());
+ HandleClearBrowsingData(list_args);
}
void ClearBrowsingDataHandler::GetRecentlyLaunchedInstalledApps(
@@ -186,46 +186,45 @@ void ClearBrowsingDataHandler::OnGotInstalledApps(
const std::string& webui_callback_id,
const std::vector<site_engagement::ImportantSitesUtil::ImportantDomainInfo>&
installed_apps) {
- std::vector<base::Value> installed_apps_list;
+ base::Value::List installed_apps_list;
for (const auto& info : installed_apps) {
- base::Value entry(base::Value::Type::DICTIONARY);
+ base::Value::Dict entry;
// Used to get favicon in ClearBrowsingDataDialog and display URL next to
// app name in the dialog.
- entry.SetStringKey(kRegisterableDomainField, info.registerable_domain);
+ entry.Set(kRegisterableDomainField, info.registerable_domain);
// The |reason_bitfield| is only passed to Javascript to be logged
// from |HandleClearBrowsingData|.
- entry.SetIntKey(kReasonBitfieldField, info.reason_bitfield);
+ entry.Set(kReasonBitfieldField, info.reason_bitfield);
// Initially all sites are selected for deletion.
- entry.SetBoolKey(kIsCheckedField, true);
+ entry.Set(kIsCheckedField, true);
// User friendly name for the installed app.
DCHECK(info.app_name);
- entry.SetStringKey(kAppName, info.app_name.value());
- installed_apps_list.push_back(std::move(entry));
+ entry.Set(kAppName, info.app_name.value());
+ installed_apps_list.Append(std::move(entry));
}
ResolveJavascriptCallback(base::Value(webui_callback_id),
- base::Value(std::move(installed_apps_list)));
+ installed_apps_list);
}
std::unique_ptr<content::BrowsingDataFilterBuilder>
ClearBrowsingDataHandler::ProcessInstalledApps(
- base::Value::ConstListView installed_apps) {
+ const base::Value::List& installed_apps) {
std::vector<std::string> excluded_domains;
std::vector<int32_t> excluded_domain_reasons;
std::vector<std::string> ignored_domains;
std::vector<int32_t> ignored_domain_reasons;
for (const auto& item : installed_apps) {
- const base::DictionaryValue* site = nullptr;
- CHECK(item.GetAsDictionary(&site));
- bool is_checked = site->FindBoolPath(kIsCheckedField).value();
- std::string domain;
- CHECK(site->GetString(kRegisterableDomainField, &domain));
- absl::optional<int> domain_reason = site->FindIntKey(kReasonBitfieldField);
+ const base::Value::Dict& site = item.GetDict();
+ bool is_checked = site.FindBool(kIsCheckedField).value();
+ const std::string* domain = site.FindString(kRegisterableDomainField);
+ CHECK(domain);
+ absl::optional<int> domain_reason = site.FindInt(kReasonBitfieldField);
CHECK(domain_reason);
if (is_checked) { // Selected installed apps should be deleted.
- ignored_domains.push_back(domain);
+ ignored_domains.push_back(*domain);
ignored_domain_reasons.push_back(*domain_reason);
} else { // Unselected sites should be kept.
- excluded_domains.push_back(domain);
+ excluded_domains.push_back(*domain);
excluded_domain_reasons.push_back(*domain_reason);
}
}
@@ -259,7 +258,7 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
std::vector<BrowsingDataType> data_type_vector;
CHECK(args_list[1].is_list());
- base::Value::ConstListView data_type_list = args_list[1].GetListDeprecated();
+ const base::Value::List& data_type_list = args_list[1].GetList();
for (const base::Value& type : data_type_list) {
const std::string pref_name = type.GetString();
BrowsingDataType data_type =
@@ -358,8 +357,7 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
int period_selected = args_list[2].GetInt();
- const base::Value::ConstListView installed_apps =
- args_list[3].GetListDeprecated();
+ const base::Value::List& installed_apps = args_list[3].GetList();
std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder =
ProcessInstalledApps(installed_apps);
@@ -410,11 +408,11 @@ void ClearBrowsingDataHandler::OnClearingTaskFinished(
bool show_passwords_notice =
(failed_data_types & chrome_browsing_data_remover::DATA_TYPE_PASSWORDS);
- base::Value result(base::Value::Type::DICTIONARY);
- result.SetBoolKey("showHistoryNotice", show_history_notice);
- result.SetBoolKey("showPasswordsNotice", show_passwords_notice);
+ base::Value::Dict result;
+ result.Set("showHistoryNotice", show_history_notice);
+ result.Set("showPasswordsNotice", show_passwords_notice);
- ResolveJavascriptCallback(base::Value(webui_callback_id), std::move(result));
+ ResolveJavascriptCallback(base::Value(webui_callback_id), result);
}
void ClearBrowsingDataHandler::HandleInitialize(const base::Value::List& args) {
@@ -449,33 +447,31 @@ void ClearBrowsingDataHandler::UpdateSyncState() {
FireWebUIListener("update-sync-state", CreateSyncStateEvent());
}
-base::DictionaryValue ClearBrowsingDataHandler::CreateSyncStateEvent() {
+base::Value::Dict ClearBrowsingDataHandler::CreateSyncStateEvent() {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_);
- base::DictionaryValue event;
- event.SetBoolKey("signedIn",
- identity_manager && identity_manager->HasPrimaryAccount(
- signin::ConsentLevel::kSignin));
- event.SetBoolKey("syncConsented",
- identity_manager && identity_manager->HasPrimaryAccount(
- signin::ConsentLevel::kSync));
- event.SetBoolKey("syncingHistory",
- sync_service_ && sync_service_->IsSyncFeatureActive() &&
- sync_service_->GetActiveDataTypes().Has(
- syncer::HISTORY_DELETE_DIRECTIVES));
- event.SetBoolKey(
- "shouldShowCookieException",
- browsing_data_counter_utils::ShouldShowCookieException(profile_));
-
- event.SetBoolKey("isNonGoogleDse", false);
+ base::Value::Dict event;
+ event.Set("signedIn", identity_manager && identity_manager->HasPrimaryAccount(
+ signin::ConsentLevel::kSignin));
+ event.Set("syncConsented",
+ identity_manager && identity_manager->HasPrimaryAccount(
+ signin::ConsentLevel::kSync));
+ event.Set("syncingHistory", sync_service_ &&
+ sync_service_->IsSyncFeatureActive() &&
+ sync_service_->GetActiveDataTypes().Has(
+ syncer::HISTORY_DELETE_DIRECTIVES));
+ event.Set("shouldShowCookieException",
+ browsing_data_counter_utils::ShouldShowCookieException(profile_));
+
+ event.Set("isNonGoogleDse", false);
const TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(profile_);
const TemplateURL* dse = template_url_service->GetDefaultSearchProvider();
if (dse && dse->GetEngineType(template_url_service->search_terms_data()) !=
SearchEngineType::SEARCH_ENGINE_GOOGLE) {
// Non-Google DSE. Prepopulated DSEs have an ID > 0.
- event.SetBoolKey("isNonGoogleDse", true);
- event.SetStringKey(
+ event.Set("isNonGoogleDse", true);
+ event.Set(
"nonGoogleSearchHistoryString",
(dse->prepopulate_id() > 0)
? l10n_util::GetStringFUTF16(
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
index 798bb9adecf..e3a867e88cb 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
@@ -77,7 +77,7 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
// based on whether installed apps were marked for deletion by the checkbox on
// the installed apps warning dialog.
std::unique_ptr<content::BrowsingDataFilterBuilder> ProcessInstalledApps(
- base::Value::ConstListView installed_apps);
+ const base::Value::List& installed_apps);
// Clears browsing data, called by Javascript.
void HandleClearBrowsingData(const base::Value::List& value);
@@ -105,7 +105,7 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
virtual void UpdateSyncState();
// Create a SyncStateEvent containing the current sync state.
- base::DictionaryValue CreateSyncStateEvent();
+ base::Value::Dict CreateSyncStateEvent();
// Finds out whether we should show notice about other forms of history stored
// in user's account.
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler_browsertest.cc
index f3b22d4391b..ae9284c5cd2 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler_browsertest.cc
@@ -82,12 +82,11 @@ class ClearBrowsingDataHandlerBrowserTest
IN_PROC_BROWSER_TEST_F(ClearBrowsingDataHandlerBrowserTest, GetInstalledApps) {
GURL url(https_server()->GetURL("/title1.html"));
InstallAndLaunchApp(url);
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kWebUiFunctionName);
args.Append(1);
- web_ui()->HandleReceivedMessage(kGetInstalledApps,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetInstalledApps, args);
const content::TestWebUI::CallData& call_data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
EXPECT_EQ(kWebUiFunctionName, call_data.arg1()->GetString());
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 9e1c2c1e32e..531308b33f3 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
@@ -74,10 +74,8 @@ int GetCategoryLabelID(CookieTreeNode::DetailedInfo::NodeType node_type) {
{CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE,
IDS_SETTINGS_COOKIES_CACHE_STORAGE},
- {CookieTreeNode::DetailedInfo::TYPE_MEDIA_LICENSES,
- IDS_SETTINGS_COOKIES_MEDIA_LICENSE},
- {CookieTreeNode::DetailedInfo::TYPE_MEDIA_LICENSE,
- IDS_SETTINGS_COOKIES_MEDIA_LICENSE},
+ {CookieTreeNode::DetailedInfo::TYPE_QUOTA,
+ IDS_SETTINGS_COOKIES_QUOTA_STORAGE},
};
// Before optimizing, consider the data size and the cost of L2 cache misses.
// A linear search over a couple dozen integers is very fast.
@@ -225,10 +223,10 @@ void CookiesViewHandler::SetCookiesTreeModelForTesting(
void CookiesViewHandler::RecreateCookiesTreeModel() {
cookies_tree_model_.reset();
filter_.clear();
- cookies_tree_model_ =
- cookies_tree_model_for_testing_.get()
- ? std::move(cookies_tree_model_for_testing_)
- : CookiesTreeModel::CreateForProfile(Profile::FromWebUI(web_ui()));
+ cookies_tree_model_ = cookies_tree_model_for_testing_.get()
+ ? std::move(cookies_tree_model_for_testing_)
+ : CookiesTreeModel::CreateForProfileDeprecated(
+ Profile::FromWebUI(web_ui()));
cookies_tree_model_->AddCookiesTreeObserver(this);
}
@@ -255,13 +253,9 @@ void CookiesViewHandler::GetCookieDetails(const std::string& callback_id,
return;
}
- // TODO (crbug.com/642955): Pass true for `include_quota_nodes` parameter
- // when quota nodes include local/session storage in the total.
- base::Value::List children =
- model_util_->GetChildNodeDetails(node, /* include_quota_nodes */ false);
+ base::Value::List children = model_util_->GetChildNodeDetailsDeprecated(node);
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(children)));
+ ResolveJavascriptCallback(base::Value(callback_id), children);
}
void CookiesViewHandler::HandleGetNumCookiesString(
@@ -440,14 +434,12 @@ void CookiesViewHandler::ReturnLocalDataList(const std::string& callback_id) {
for (const auto& site : parent->children()) {
std::u16string description;
for (const auto& category : site->children()) {
+ const auto node_type = category->GetDetailedInfo().node_type;
if (!description.empty())
description += u", ";
- const auto node_type = category->GetDetailedInfo().node_type;
size_t item_count = category->children().size();
+
switch (node_type) {
- case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
- // TODO(crbug.com/642955): Omit quota values until bug is addressed.
- continue;
case CookieTreeNode::DetailedInfo::TYPE_COOKIE:
DCHECK_EQ(0u, item_count);
item_count = 1;
@@ -480,8 +472,7 @@ void CookiesViewHandler::ReturnLocalDataList(const std::string& callback_id) {
return *a.FindStringKey(kSite) < *b.FindStringKey(kSite);
});
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(std::move(site_list)));
+ ResolveJavascriptCallback(base::Value(callback_id), site_list);
}
void CookiesViewHandler::ProcessPendingRequests() {
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc
index f83deab8e18..af4ad1c6056 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc
@@ -64,8 +64,7 @@ class CookiesViewHandlerTest : public ChromeRenderViewHostTestHarness {
/*quota_helper=*/nullptr,
/*service_worker_helper=*/nullptr,
/*data_shared_worker_helper=*/nullptr,
- /*cache_storage_helper=*/nullptr,
- /*media_license_helper=*/nullptr);
+ /*cache_storage_helper=*/nullptr);
auto mock_cookies_tree_model = std::make_unique<CookiesTreeModel>(
std::move(container), profile()->GetExtensionSpecialStoragePolicy());
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 90a9107cd9a..3e319941ad1 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
@@ -98,12 +98,11 @@ void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished(
ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui()));
}
- base::DictionaryValue dict;
- dict.SetBoolKey("isDefault", state == shell_integration::IS_DEFAULT);
- dict.SetBoolKey("canBeDefault", shell_integration::CanSetAsDefaultBrowser());
- dict.SetBoolKey("isUnknownError",
- state == shell_integration::UNKNOWN_DEFAULT);
- dict.SetBoolKey("isDisabledByPolicy", DefaultBrowserIsDisabledByPolicy());
+ base::Value::Dict dict;
+ dict.Set("isDefault", state == shell_integration::IS_DEFAULT);
+ dict.Set("canBeDefault", shell_integration::CanSetAsDefaultBrowser());
+ dict.Set("isUnknownError", state == shell_integration::UNKNOWN_DEFAULT);
+ dict.Set("isDisabledByPolicy", DefaultBrowserIsDisabledByPolicy());
if (!check_default_callback_id_.empty()) {
ResolveJavascriptCallback(base::Value(check_default_callback_id_), dict);
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_interactive_uitest.cc b/chromium/chrome/browser/ui/webui/settings/settings_interactive_uitest.cc
index 8c24791d83d..6ef6642a9e7 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_interactive_uitest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_interactive_uitest.cc
@@ -10,7 +10,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/interaction/interaction_sequence_browser_util.h"
+#include "chrome/test/interaction/webui_interaction_test_util.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/base/interaction/expect_call_in_scope.h"
@@ -21,10 +21,9 @@
#endif
namespace {
-DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kInteractionSequenceBrowserUtilTestId);
-DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kInteractionSequenceBrowserUtilTestId2);
-DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE(
- kInteractionSequenceBrowserUtilCustomEventId);
+DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kWebUIInteractionTestUtilTestId);
+DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kWebUIInteractionTestUtilTestId2);
+DEFINE_LOCAL_CUSTOM_ELEMENT_EVENT_TYPE(kWebUIInteractionTestUtilCustomEventId);
} // namespace
class SettingsInteractiveUiTest : public InProcessBrowserTest {
@@ -53,18 +52,18 @@ class SettingsInteractiveUiTest : public InProcessBrowserTest {
// Helper function to wait for element in DOM visible.
// This function will be implemented by a test util framework later.
- auto WaitFor(const InteractionSequenceBrowserUtil::DeepQuery& element,
+ auto WaitFor(const WebUIInteractionTestUtil::DeepQuery& element,
const ui::InteractionSequence::StepType type =
ui::InteractionSequence::StepType::kShown) {
return ui::InteractionSequence::StepBuilder()
- .SetElementID(kInteractionSequenceBrowserUtilTestId)
+ .SetElementID(kWebUIInteractionTestUtilTestId)
.SetStartCallback(base::BindLambdaForTesting(
// FIXME: type has to be copied.
[&, type](ui::InteractionSequence*,
ui::TrackedElement* tracked_elem) {
auto* util = tracked_elem->AsA<TrackedElementWebPage>()->owner();
- InteractionSequenceBrowserUtil::StateChange state_change;
+ WebUIInteractionTestUtil::StateChange state_change;
state_change.where = element;
if (type == ui::InteractionSequence::StepType::kShown) {
state_change.test_function =
@@ -73,7 +72,7 @@ class SettingsInteractiveUiTest : public InProcessBrowserTest {
state_change.test_function =
"(el, err) => !el || el.offsetParent === null";
}
- state_change.event = kInteractionSequenceBrowserUtilCustomEventId;
+ state_change.event = kWebUIInteractionTestUtilCustomEventId;
util->SendEventOnStateChange(state_change);
}))
.Build();
@@ -81,11 +80,11 @@ class SettingsInteractiveUiTest : public InProcessBrowserTest {
// Click has to set after a WaitFor step, or reset SetType.
// This function will be implemented by a test util framework later.
- auto Click(const InteractionSequenceBrowserUtil::DeepQuery& element) {
+ auto Click(const WebUIInteractionTestUtil::DeepQuery& element) {
return ui::InteractionSequence::StepBuilder()
.SetType(ui::InteractionSequence::StepType::kCustomEvent,
- kInteractionSequenceBrowserUtilCustomEventId)
- .SetElementID(kInteractionSequenceBrowserUtilTestId)
+ kWebUIInteractionTestUtilCustomEventId)
+ .SetElementID(kWebUIInteractionTestUtilTestId)
.SetStartCallback(base::BindLambdaForTesting(
[&](ui::InteractionSequence*, ui::TrackedElement* tracked_elem) {
auto* util = tracked_elem->AsA<TrackedElementWebPage>()->owner();
@@ -101,24 +100,23 @@ IN_PROC_BROWSER_TEST_F(SettingsInteractiveUiTest,
UNCALLED_MOCK_CALLBACK(ui::InteractionSequence::AbortedCallback, aborted);
const GURL cookie_setting_url("chrome://settings/privacy");
- const InteractionSequenceBrowserUtil::DeepQuery cookies_link_row = {
+ const WebUIInteractionTestUtil::DeepQuery cookies_link_row = {
"settings-ui", "settings-main", "settings-basic-page",
"settings-privacy-page", "cr-link-row#cookiesLinkRow"};
- const InteractionSequenceBrowserUtil::DeepQuery
- cookies_setting_page_help_icon = {
- "settings-ui",
- "settings-main",
- "settings-basic-page",
- "settings-privacy-page",
- "settings-subpage",
- "div#headerLine cr-icon-button[iron-icon='cr:help-outline']"};
-
- auto util = InteractionSequenceBrowserUtil::ForExistingTabInBrowser(
- browser(), kInteractionSequenceBrowserUtilTestId);
+ const WebUIInteractionTestUtil::DeepQuery cookies_setting_page_help_icon = {
+ "settings-ui",
+ "settings-main",
+ "settings-basic-page",
+ "settings-privacy-page",
+ "settings-subpage",
+ "div#headerLine cr-icon-button[iron-icon='cr:help-outline']"};
+
+ auto util = WebUIInteractionTestUtil::ForExistingTabInBrowser(
+ browser(), kWebUIInteractionTestUtilTestId);
util->LoadPage(cookie_setting_url);
- auto util2 = InteractionSequenceBrowserUtil::ForNextTabInContext(
+ auto util2 = WebUIInteractionTestUtil::ForNextTabInContext(
browser()->window()->GetElementContext(),
- kInteractionSequenceBrowserUtilTestId2);
+ kWebUIInteractionTestUtilTestId2);
auto sequence =
ui::InteractionSequence::Builder()
@@ -133,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(SettingsInteractiveUiTest,
.AddStep(Click(cookies_setting_page_help_icon))
// Verify the new page opened.
.AddStep(ui::InteractionSequence::StepBuilder()
- .SetElementID(kInteractionSequenceBrowserUtilTestId2)
+ .SetElementID(kWebUIInteractionTestUtilTestId2)
.SetStartCallback(base::BindLambdaForTesting(
[&](ui::InteractionSequence*,
ui::TrackedElement* element) {
@@ -163,12 +161,12 @@ IN_PROC_BROWSER_TEST_F(ThemeSettingsInteractiveUiTest,
UNCALLED_MOCK_CALLBACK(ui::InteractionSequence::AbortedCallback, aborted);
const GURL appearance_setting_url("chrome://settings/appearance");
- const InteractionSequenceBrowserUtil::DeepQuery reset_to_default_btn = {
+ const WebUIInteractionTestUtil::DeepQuery reset_to_default_btn = {
"settings-ui", "settings-main", "settings-basic-page",
"settings-appearance-page", "cr-button#useDefault"};
- auto util = InteractionSequenceBrowserUtil::ForExistingTabInBrowser(
- browser(), kInteractionSequenceBrowserUtilTestId);
+ auto util = WebUIInteractionTestUtil::ForExistingTabInBrowser(
+ browser(), kWebUIInteractionTestUtilTestId);
util->LoadPage(appearance_setting_url);
auto sequence =
@@ -178,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(ThemeSettingsInteractiveUiTest,
.SetContext(browser()->window()->GetElementContext())
// Verify the current theme is not set as default.
.AddStep(ui::InteractionSequence::StepBuilder()
- .SetElementID(kInteractionSequenceBrowserUtilTestId)
+ .SetElementID(kWebUIInteractionTestUtilTestId)
.SetStartCallback(base::BindLambdaForTesting(
[&](ui::InteractionSequence*,
ui::TrackedElement* element) {
@@ -196,8 +194,8 @@ IN_PROC_BROWSER_TEST_F(ThemeSettingsInteractiveUiTest,
ui::InteractionSequence::StepType::kHidden))
.AddStep(ui::InteractionSequence::StepBuilder()
.SetType(ui::InteractionSequence::StepType::kCustomEvent,
- kInteractionSequenceBrowserUtilCustomEventId)
- .SetElementID(kInteractionSequenceBrowserUtilTestId)
+ kWebUIInteractionTestUtilCustomEventId)
+ .SetElementID(kWebUIInteractionTestUtilTestId)
.SetStartCallback(base::BindLambdaForTesting(
[&](ui::InteractionSequence*, ui::TrackedElement*) {
auto* theme_service =
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 46347927c02..de3ef4167bf 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
@@ -74,7 +74,6 @@
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_service_utils.h"
#include "components/sync/driver/sync_user_settings.h"
-#include "components/version_info/version_info.h"
#include "components/zoom/page_zoom_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -84,6 +83,7 @@
#include "device/fido/features.h"
#include "media/base/media_switches.h"
#include "net/base/url_util.h"
+#include "net/net_buildflags.h"
#include "services/device/public/cpp/device_features.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/base/accelerators/accelerator.h"
@@ -92,7 +92,7 @@
#include "ui/strings/grit/ui_strings.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-#include "chromeos/startup/browser_init_params.h"
+#include "chromeos/startup/browser_params_proxy.h"
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
#if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -141,6 +141,10 @@
#include "ui/ozone/public/ozone_platform.h"
#endif
+#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED)
+#include "net/base/features.h"
+#endif
+
namespace settings {
namespace {
@@ -210,7 +214,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
user_manager::UserManager::Get()->IsLoggedInAsPublicAccount());
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
- chromeos::BrowserInitParams::Get()->session_type ==
+ chromeos::BrowserParamsProxy::Get()->SessionType() ==
crosapi::mojom::SessionType::kPublicSession ||
profile->IsGuestSession());
#else
@@ -273,10 +277,6 @@ void AddAboutStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"aboutGetHelpUsingChrome", IDS_SETTINGS_GET_HELP_USING_CHROME},
{"aboutPageTitle", IDS_SETTINGS_ABOUT_PROGRAM},
{"aboutProductTitle", IDS_PRODUCT_NAME},
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- {"aboutUpdateOsSettingsLink",
- IDS_SETTINGS_ABOUT_SEE_OS_SETTINGS_FOR_UPDATE_MESSAGE},
-#endif
};
html_source->AddLocalizedStrings(kLocalizedStrings);
@@ -290,23 +290,7 @@ void AddAboutStrings(content::WebUIDataSource* html_source, Profile* profile) {
l10n_util::GetStringUTF16(IDS_SETTINGS_UPGRADE_UP_TO_DATE));
#endif
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- // On Lacros, we don't have the concept of channels, in their usual semantics.
- // Replace the channel string with "Lacros". https://crbug.com/1215734.
- std::string channel_name = "Lacros";
-#else
- std::string channel_name =
- chrome::GetChannelName(chrome::WithExtendedStable(true));
-#endif
-
- std::u16string browser_version = l10n_util::GetStringFUTF16(
- IDS_SETTINGS_ABOUT_PAGE_BROWSER_VERSION,
- base::UTF8ToUTF16(version_info::GetVersionNumber()),
- l10n_util::GetStringUTF16(version_info::IsOfficialBuild()
- ? IDS_VERSION_UI_OFFICIAL
- : IDS_VERSION_UI_UNOFFICIAL),
- base::UTF8ToUTF16(channel_name),
- l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation()));
+ std::u16string browser_version = VersionUI::GetAnnotatedVersionStringForUi();
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Lacros is in development so we don't worry about l10n for now. This message
@@ -356,6 +340,7 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source,
{"chromeColors", IDS_SETTINGS_CHROME_COLORS},
{"showHomeButton", IDS_SETTINGS_SHOW_HOME_BUTTON},
{"showBookmarksBar", IDS_SETTINGS_SHOW_BOOKMARKS_BAR},
+ {"sidePanel", IDS_SETTINGS_SIDE_PANEL},
{"homePageNtp", IDS_SETTINGS_HOME_PAGE_NTP},
{"changeHomePage", IDS_SETTINGS_CHANGE_HOME_PAGE},
{"themesGalleryUrl", IDS_THEMES_GALLERY_URL},
@@ -371,6 +356,8 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source,
{"minimumFont", IDS_SETTINGS_MINIMUM_FONT_SIZE_LABEL},
{"tiny", IDS_SETTINGS_TINY_FONT_SIZE},
{"huge", IDS_SETTINGS_HUGE_FONT_SIZE},
+ {"sidePanelAlignLeft", IDS_SETTINGS_SIDE_PANEL_ALIGN_LEFT},
+ {"sidePanelAlignRight", IDS_SETTINGS_SIDE_PANEL_ALIGN_RIGHT},
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -399,6 +386,9 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source,
zoom::GetPresetZoomFactorsAsJSON());
html_source->AddBoolean("showReaderModeOption",
dom_distiller::OfferReaderModeInSettings());
+ html_source->AddBoolean(
+ "showSidePanelOptions",
+ base::FeatureList::IsEnabled(features::kUnifiedSidePanel));
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
// of lacros-chrome is complete.
@@ -735,14 +725,14 @@ void AddImportDataStrings(content::WebUIDataSource* html_source) {
void AddLanguagesStrings(content::WebUIDataSource* html_source,
Profile* profile) {
-#if !BUILDFLAG(IS_CHROMEOS_ASH)
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"languagesPageTitle", IDS_SETTINGS_LANGUAGES_PAGE_TITLE},
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+ {"languagesCardTitle", IDS_SETTINGS_LANGUAGES_CARD_TITLE},
{"searchLanguages", IDS_SETTINGS_LANGUAGE_SEARCH},
{"languagesExpandA11yLabel",
IDS_SETTINGS_LANGUAGES_EXPAND_ACCESSIBILITY_LABEL},
- {"orderBrowserLanguagesInstructions",
- IDS_SETTINGS_LANGUAGES_BROWSER_LANGUAGES_LIST_ORDERING_INSTRUCTIONS},
+ {"preferredLanguagesDesc", IDS_SETTINGS_LANGUAGES_PREFERRED_LANGUAGES_DESC},
{"moveToTop", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_MOVE_TO_TOP},
{"moveUp", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_MOVE_UP},
{"moveDown", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_MOVE_DOWN},
@@ -758,7 +748,11 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_LANGUAGES_OFFER_TO_TRANSLATE_IN_THIS_LANGUAGE},
{"offerToEnableTranslate",
IDS_SETTINGS_LANGUAGES_OFFER_TO_ENABLE_TRANSLATE},
+ {"offerToEnableTranslateSublabel",
+ IDS_SETTINGS_LANGUAGES_OFFER_TO_ENABLE_TRANSLATE_SUBLABEL},
{"noLanguagesAdded", IDS_SETTINGS_LANGUAGES_NO_LANGUAGES_ADDED},
+ {"translatePageTitle", IDS_SETTINGS_TRANSLATE_PAGE_TITLE},
+ {"targetLanguageLabel", IDS_SETTINGS_TARGET_TRANSLATE_LABEL},
{"automaticallyTranslateLanguages",
IDS_SETTINGS_LANGUAGES_AUTOMATIC_TRANSLATE},
{"neverTranslateLanguages", IDS_SETTINGS_LANGUAGES_NEVER_LANGUAGES},
@@ -769,6 +763,8 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_LABEL},
{"spellCheckEnhancedDescription",
IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_DESCRIPTION},
+ {"offerToEnableSpellCheck",
+ IDS_SETTINGS_LANGUAGES_OFFER_TO_ENABLE_SPELL_CHECK},
// Managed dialog strings:
{"languageManagedDialogTitle", IDS_SETTINGS_LANGUAGES_MANAGED_DIALOG_TITLE},
{"languageManagedDialogBody", IDS_SETTINGS_LANGUAGES_MANAGED_DIALOG_BODY},
@@ -796,31 +792,20 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
{"languagesDictionaryDownloadErrorHelp",
IDS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_FAILED_HELP},
#endif
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {"openChromeOSLanguagesSettingsLabel",
+ IDS_SETTINGS_LANGUAGES_OPEN_CHROME_OS_SETTINGS_LABEL},
+#endif
};
html_source->AddLocalizedStrings(kLocalizedStrings);
-#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
- html_source->AddLocalizedString("languagesPageTitle",
- IDS_SETTINGS_LANGUAGES_PAGE_TITLE);
- html_source->AddLocalizedString(
- "openChromeOSLanguagesSettingsLabel",
- IDS_SETTINGS_LANGUAGES_OPEN_CHROME_OS_SETTINGS_LABEL);
html_source->AddString(
"chromeOSLanguagesSettingsPath",
chromeos::settings::mojom::kLanguagesAndInputSectionPath);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
-#if BUILDFLAG(IS_CHROMEOS)
-void AddChromeOSSettingsStrings(content::WebUIDataSource* html_source) {
- html_source->AddString(
- "osSettingsBannerText",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_OS_SETTINGS_BANNER,
- base::ASCIIToUTF16(chrome::kChromeUIOSSettingsURL)));
-}
-#endif
-
void AddOnStartupStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"onStartup", IDS_SETTINGS_ON_STARTUP},
@@ -874,264 +859,302 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
Profile* profile,
content::WebContents* web_contents) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"autofillPageTitle", IDS_SETTINGS_AUTOFILL},
- {"passwordsDescription", IDS_SETTINGS_PASSWORD_MANAGER_DESCRIPTION},
- {"passwordsDevice", IDS_SETTINGS_DEVICE_PASSWORDS},
- {"checkPasswords", IDS_SETTINGS_CHECK_PASSWORDS},
- {"checkPasswordsCanceled", IDS_SETTINGS_CHECK_PASSWORDS_CANCELED},
- {"checkedPasswords", IDS_SETTINGS_CHECKED_PASSWORDS},
- {"checkPasswordsDescription", IDS_SETTINGS_CHECK_PASSWORDS_DESCRIPTION},
- {"checkPasswordsErrorOffline",
- IDS_SETTINGS_CHECK_PASSWORDS_ERROR_OFFLINE},
- {"checkPasswordsErrorSignedOut",
- IDS_SETTINGS_CHECK_PASSWORDS_ERROR_SIGNED_OUT},
- {"checkPasswordsErrorNoPasswords",
- IDS_SETTINGS_CHECK_PASSWORDS_ERROR_NO_PASSWORDS},
- {"checkPasswordsErrorQuota",
- IDS_SETTINGS_CHECK_PASSWORDS_ERROR_QUOTA_LIMIT},
- {"checkPasswordsErrorGeneric",
- IDS_SETTINGS_CHECK_PASSWORDS_ERROR_GENERIC},
- {"noCompromisedCredentials",
- IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL},
- {"checkPasswordsAgain", IDS_SETTINGS_CHECK_PASSWORDS_AGAIN},
- {"checkPasswordsAgainAfterError",
- IDS_SETTINGS_CHECK_PASSWORDS_AGAIN_AFTER_ERROR},
- {"checkPasswordsProgress", IDS_SETTINGS_CHECK_PASSWORDS_PROGRESS},
- {"checkPasswordsStop", IDS_SETTINGS_CHECK_PASSWORDS_STOP},
- {"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS},
- {"compromisedPasswordsDescription",
- IDS_SETTINGS_COMPROMISED_PASSWORDS_ADVICE},
- {"mutedPasswords", IDS_SETTINGS_MUTED_PASSWORDS},
- {"weakPasswords", IDS_SETTINGS_WEAK_PASSWORDS},
- {"changePasswordButton", IDS_SETTINGS_CHANGE_PASSWORD_BUTTON},
- {"changePasswordInApp", IDS_SETTINGS_CHANGE_PASSWORD_IN_APP_LABEL},
- {"leakedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_LEAKED},
- {"phishedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED},
- {"phishedAndLeakedPassword",
- IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED_AND_LEAKED},
- {"showCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_SHOW},
- {"hideCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_HIDE},
- {"removeCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REMOVE},
- {"muteCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_MUTE},
- {"unmuteMutedCompromisedPassword",
- IDS_SETTINGS_COMPROMISED_PASSWORD_UNMUTE},
- {"removeCompromisedPasswordConfirmationTitle",
- IDS_SETTINGS_REMOVE_COMPROMISED_PASSWORD_CONFIRMATION_TITLE},
- {"removeCompromisedPasswordConfirmationDescription",
- IDS_SETTINGS_REMOVE_COMPROMISED_PASSWORD_CONFIRMATION_DESCRIPTION},
- {"editCompromisedPasswordSite",
- IDS_SETTINGS_COMPROMISED_EDIT_PASSWORD_SITE},
- {"editCompromisedPasswordApp",
- IDS_SETTINGS_COMPROMISED_EDIT_PASSWORD_APP},
- {"alreadyChangedPasswordLink",
- IDS_SETTINGS_COMPROMISED_ALREADY_CHANGED_PASSWORD},
- {"editDisclaimerTitle", IDS_SETTINGS_COMPROMISED_EDIT_DISCLAIMER_TITLE},
- {"editDisclaimerDescription",
- IDS_SETTINGS_COMPROMISED_EDIT_DISCLAIMER_DESCRIPTION},
- {"genericCreditCard", IDS_AUTOFILL_CC_GENERIC},
- {"creditCards", IDS_AUTOFILL_PAYMENT_METHODS},
- {"noPaymentMethodsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE},
- {"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
- {"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED},
- {"enableProfilesLabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL},
- {"enableProfilesSublabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_SUBLABEL},
- {"enableCreditCardsLabel", IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_LABEL},
- {"enableCreditCardsSublabel",
- IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_SUBLABEL},
- {"enableCreditCardFIDOAuthLabel", IDS_ENABLE_CREDIT_CARD_FIDO_AUTH_LABEL},
- {"enableCreditCardFIDOAuthSublabel",
- IDS_ENABLE_CREDIT_CARD_FIDO_AUTH_SUBLABEL},
- {"addresses", IDS_AUTOFILL_ADDRESSES},
- {"addressesTitle", IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE},
- {"addAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_ADD_TITLE},
- {"editAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_EDIT_TITLE},
- {"addressCountry", IDS_SETTINGS_AUTOFILL_ADDRESSES_COUNTRY},
- {"addressPhone", IDS_SETTINGS_AUTOFILL_ADDRESSES_PHONE},
- {"addressEmail", IDS_SETTINGS_AUTOFILL_ADDRESSES_EMAIL},
- {"honorificLabel", IDS_SETTINGS_AUTOFILL_ADDRESS_HONORIFIC_LABEL},
- {"moreActionsForAddress", IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_FOR_ADDRESS},
- {"moreActionsForCreditCard",
- IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_FOR_CREDIT_CARD},
- {"moreActionsCreditCardDescription",
- IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_CARD_DESCRIPTION},
- {"removeAddress", IDS_SETTINGS_ADDRESS_REMOVE},
- {"removeAddressConfirmationTitle",
- IDS_SETTINGS_ADDRESS_REMOVE_CONFIRMATION_TITLE},
- {"removeAddressConfirmationDescription",
- IDS_SETTINGS_ADDRESS_REMOVE_CONFIRMATION_DESCRIPTION},
- {"removeCreditCard", IDS_SETTINGS_CREDIT_CARD_REMOVE},
- {"clearCreditCard", IDS_SETTINGS_CREDIT_CARD_CLEAR},
- {"creditCardType", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_TYPE_COLUMN_LABEL},
- {"creditCardExpiration", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_DATE},
- {"creditCardName", IDS_SETTINGS_NAME_ON_CREDIT_CARD},
- {"creditCardNickname", IDS_SETTINGS_CREDIT_CARD_NICKNAME},
- {"creditCardNicknameInvalid", IDS_SETTINGS_CREDIT_CARD_NICKNAME_INVALID},
- {"creditCardNumber", IDS_SETTINGS_CREDIT_CARD_NUMBER},
- {"creditCardExpirationMonth", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_MONTH},
- {"creditCardExpirationYear", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_YEAR},
- {"creditCardExpired", IDS_SETTINGS_CREDIT_CARD_EXPIRED},
- {"editCreditCardTitle", IDS_SETTINGS_EDIT_CREDIT_CARD_TITLE},
- {"addCreditCardTitle", IDS_SETTINGS_ADD_CREDIT_CARD_TITLE},
- {"migrateCreditCardsLabel", IDS_SETTINGS_MIGRATABLE_CARDS_LABEL},
- {"migratableCardsInfoSingle", IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_INFO},
- {"migratableCardsInfoMultiple",
- IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_INFO},
- {"remoteCreditCardLinkLabel", IDS_SETTINGS_REMOTE_CREDIT_CARD_LINK_LABEL},
- {"upiIdLabel", IDS_SETTINGS_UPI_ID_LABEL},
- {"upiIdExpirationNever", IDS_SETTINGS_UPI_ID_EXPIRATION_NEVER},
- {"canMakePaymentToggleLabel", IDS_SETTINGS_CAN_MAKE_PAYMENT_TOGGLE_LABEL},
- {"autofillDetail", IDS_SETTINGS_AUTOFILL_DETAIL},
- {"passwordsSavePasswordsLabel",
- IDS_SETTINGS_PASSWORDS_SAVE_PASSWORDS_TOGGLE_LABEL},
- {"passwordsAutosigninLabel",
- IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_LABEL},
- {"passwordsAutosigninDescription",
- IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_DESC},
- {"passwordsLeakDetectionLabel",
- IDS_SETTINGS_PASSWORDS_LEAK_DETECTION_LABEL},
- {"passwordsLeakDetectionGeneralDescription",
- IDS_PASSWORD_MANAGER_LEAK_HELP_MESSAGE},
- {"passwordsLeakDetectionSignedOutEnabledDescription",
- IDS_SETTINGS_PASSWORDS_LEAK_DETECTION_SIGNED_OUT_ENABLED_DESC},
- {"savedPasswordsHeading", IDS_SETTINGS_PASSWORDS_SAVED_HEADING},
- {"passwordExceptionsHeading", IDS_SETTINGS_PASSWORDS_EXCEPTIONS_HEADING},
- {"deviceOnlyPasswordsHeading",
- IDS_SETTINGS_DEVICE_PASSWORDS_ON_DEVICE_ONLY_HEADING},
- {"deviceAndAccountPasswordsHeading",
- IDS_SETTINGS_DEVICE_PASSWORDS_ON_DEVICE_AND_ACCOUNT_HEADING},
- {"deletePasswordException", IDS_SETTINGS_PASSWORDS_DELETE_EXCEPTION},
- {"removePassword", IDS_SETTINGS_PASSWORD_REMOVE},
- {"searchPasswords", IDS_SETTINGS_PASSWORD_SEARCH},
- {"showPassword", IDS_SETTINGS_PASSWORD_SHOW},
- {"hidePassword", IDS_SETTINGS_PASSWORD_HIDE},
- {"passwordDetailsTitle", IDS_SETTINGS_PASSWORDS_VIEW_DETAILS_TITLE},
- {"passwordViewDetails", IDS_SETTINGS_PASSWORD_DETAILS},
- {"editPasswordTitle", IDS_SETTINGS_PASSWORD_EDIT_TITLE},
- {"editPassword", IDS_SETTINGS_PASSWORD_EDIT},
- {"editPasswordFootnote", IDS_SETTINGS_PASSWORD_EDIT_FOOTNOTE},
- {"addPasswordTitle", IDS_SETTINGS_PASSWORD_ADD_TITLE},
- {"addPasswordFootnote", IDS_SETTINGS_PASSWORD_ADD_FOOTNOTE},
- {"addPasswordStoreOptionAccount",
- IDS_SETTINGS_PASSWORD_ADD_STORE_OPTION_ACCOUNT},
- {"addPasswordStoreOptionDevice",
- IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_SAVE_TO_DEVICE},
- {"addPasswordStorePickerA11yDescription",
- IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_ACCESSIBLE_NAME},
- {"usernameAlreadyUsed", IDS_SETTINGS_PASSWORD_USERNAME_ALREADY_USED},
- {"missingTLD", IDS_SETTINGS_PASSWORD_MISSING_TLD},
- {"viewExistingPassword", IDS_SETTINGS_PASSWORD_VIEW_EXISTING_PASSWORD},
- {"viewExistingPasswordAriaDescription",
- IDS_SETTINGS_PASSWORD_VIEW_EXISTING_PASSWORD_ARIA_DESCRIPTION},
- {"copyPassword", IDS_SETTINGS_PASSWORD_COPY},
- {"sendPassword", IDS_SETTINGS_PASSWORD_SEND},
- {"copyUsername", IDS_SETTINGS_USERNAME_COPY},
- {"passwordStoredOnDevice", IDS_SETTINGS_PASSWORD_STORED_ON_DEVICE},
- {"passwordStoredInAccount", IDS_SETTINGS_PASSWORD_STORED_IN_ACCOUNT},
- {"passwordStoredInAccountAndOnDevice",
- IDS_SETTINGS_PASSWORD_STORED_IN_ACCOUNT_AND_ON_DEVICE},
- {"editPasswordWebsiteLabel", IDS_SETTINGS_PASSWORDS_WEBSITE},
- {"editPasswordUsernameLabel", IDS_SETTINGS_PASSWORDS_USERNAME},
- {"editPasswordPasswordLabel", IDS_SETTINGS_PASSWORDS_PASSWORD},
- {"passwordNoteLabel", IDS_SETTINGS_PASSWORDS_NOTE},
- {"passwordNoNoteAdded", IDS_SETTINGS_PASSWORDS_NO_NOTE_ADDED},
- {"passwordNoteCharacterCount",
- IDS_SETTINGS_PASSWORDS_NOTE_CHARACTER_COUNT},
- {"passwordNoteCharacterCountWarning",
- IDS_SETTINGS_PASSWORDS_NOTE_CHARACTER_COUNT_WARNING},
- {"noAddressesFound", IDS_SETTINGS_ADDRESS_NONE},
- {"noPasswordsFound", IDS_SETTINGS_PASSWORDS_NONE},
- {"noExceptionsFound", IDS_SETTINGS_PASSWORDS_EXCEPTIONS_NONE},
- {"import", IDS_PASSWORD_MANAGER_IMPORT_BUTTON},
- {"exportMenuItem", IDS_SETTINGS_PASSWORDS_EXPORT_MENU_ITEM},
- {"optInAccountStorageLabel",
- IDS_SETTINGS_PASSWORDS_OPT_IN_ACCOUNT_STORAGE_LABEL},
- {"optOutAccountStorageLabel",
- IDS_SETTINGS_PASSWORDS_OPT_OUT_ACCOUNT_STORAGE_LABEL},
- {"undoRemovePassword", IDS_SETTINGS_PASSWORD_UNDO},
- {"movePasswordToAccount", IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT},
- {"passwordDeleted", IDS_SETTINGS_PASSWORD_DELETED_PASSWORD},
- {"passwordDeletedFromDevice",
- IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_DEVICE},
- {"passwordDeletedFromAccount",
- IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT},
- {"passwordDeletedFromAccountAndDevice",
- IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT_AND_DEVICE},
- {"passwordCopiedToClipboard", IDS_SETTINGS_PASSWORD_COPIED_TO_CLIPBOARD},
- {"passwordUsernameCopiedToClipboard",
- IDS_SETTINGS_PASSWORD_USERNAME_COPIED_TO_CLIPBOARD},
- {"passwordMovePasswordsToAccount",
- IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT},
- {"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",
- IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_CANCEL_BUTTON_TEXT},
- {"passwordOpenMoveMultiplePasswordsToAccountDialogButtonText",
- IDS_SETTINGS_PASSWORD_OPEN_MOVE_MULTIPLE_PASSWORDS_TO_ACCOUNT_DIALOG_BUTTON_TEXT},
- {"passwordRemoveDialogTitle", IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_TITLE},
- {"passwordRemoveDialogBody", IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_BODY},
- {"passwordRemoveDialogRemoveButtonText",
- IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_REMOVE_BUTTON_TEXT},
- {"passwordRemoveDialogCancelButtonText",
- IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_CANCEL_BUTTON_TEXT},
- {"passwordRemoveDialogFromAccountCheckboxLabel",
- IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_ACCOUNT_CHECKBOX_LABEL},
- {"passwordRemoveDialogFromDeviceCheckboxLabel",
- IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_DEVICE_CHECKBOX_LABEL},
- {"devicePasswordsLinkLabel", IDS_SETTINGS_DEVICE_PASSWORDS_LINK_LABEL},
- {"devicePasswordsMoved",
- IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_SNACKBAR},
- {"passwordRowMoreActionsButton", IDS_SETTINGS_PASSWORD_ROW_MORE_ACTIONS},
- {"passwordRowFederatedMoreActionsButton",
- IDS_SETTINGS_PASSWORD_ROW_FEDERATED_MORE_ACTIONS},
- {"passwordRowPasswordDetailPageButton",
- IDS_SETTINGS_PASSWORD_ROW_PASSWORD_DETAIL_PAGE},
- {"exportPasswordsTitle", IDS_SETTINGS_PASSWORDS_EXPORT_TITLE},
- {"exportPasswordsDescription", IDS_SETTINGS_PASSWORDS_EXPORT_DESCRIPTION},
- {"exportPasswords", IDS_SETTINGS_PASSWORDS_EXPORT},
- {"exportingPasswordsTitle", IDS_SETTINGS_PASSWORDS_EXPORTING_TITLE},
- {"exportPasswordsTryAgain", IDS_SETTINGS_PASSWORDS_EXPORT_TRY_AGAIN},
- {"exportPasswordsFailTitle",
- IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TITLE},
- {"exportPasswordsFailTips",
- IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIPS},
- {"exportPasswordsFailTipsEnoughSpace",
- IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ENOUGH_SPACE},
- {"exportPasswordsFailTipsAnotherFolder",
- IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ANOTHER_FOLDER},
- {"managePasswordsPlaintext",
- IDS_SETTINGS_PASSWORDS_MANAGE_PASSWORDS_PLAINTEXT},
- {"savedToThisDeviceOnly",
- IDS_SETTINGS_PAYMENTS_SAVED_TO_THIS_DEVICE_ONLY},
- {"trustedVaultBannerLabel", IDS_SETTINGS_TRUSTED_VAULT_BANNER_LABEL},
- {"trustedVaultBannerSubLabelOfferOptIn",
- IDS_SETTINGS_TRUSTED_VAULT_BANNER_SUB_LABEL_OFFER_OPT_IN},
- {"trustedVaultBannerSubLabelOptedIn",
- IDS_SETTINGS_TRUSTED_VAULT_BANNER_SUB_LABEL_OPTED_IN},
- {"noSearchResults", IDS_SEARCH_NO_RESULTS},
- {"searchResultsPlural", IDS_SEARCH_RESULTS_PLURAL},
- {"searchResultsSingular", IDS_SEARCH_RESULTS_SINGULAR},
- {"showPasswordLabel", IDS_SETTINGS_PASSWORD_SHOW_PASSWORD_A11Y},
- {"hidePasswordLabel", IDS_SETTINGS_PASSWORD_HIDE_PASSWORD_A11Y},
- {"addVirtualCard", IDS_AUTOFILL_ADD_VIRTUAL_CARD},
- {"removeVirtualCard", IDS_AUTOFILL_REMOVE_VIRTUAL_CARD},
- {"editServerCard", IDS_AUTOFILL_EDIT_SERVER_CREDIT_CARD},
- {"virtualCardEnabled", IDS_AUTOFILL_VIRTUAL_CARD_ENABLED_LABEL},
- {"unenrollVirtualCardDialogTitle",
- IDS_AUTOFILL_VIRTUAL_CARD_UNENROLL_DIALOG_TITLE},
- {"unenrollVirtualCardDialogConfirm",
- IDS_AUTOFILL_VIRTUAL_CARD_UNENROLL_DIALOG_CONFIRM_BUTTON_LABEL}};
+ {"autofillPageTitle", IDS_SETTINGS_AUTOFILL},
+ {"passwordsDescription", IDS_SETTINGS_PASSWORD_MANAGER_DESCRIPTION},
+ {"passwordsDevice", IDS_SETTINGS_DEVICE_PASSWORDS},
+ {"checkPasswords", IDS_SETTINGS_CHECK_PASSWORDS},
+ {"checkPasswordsCanceled", IDS_SETTINGS_CHECK_PASSWORDS_CANCELED},
+ {"checkedPasswords", IDS_SETTINGS_CHECKED_PASSWORDS},
+ {"checkPasswordsDescription", IDS_SETTINGS_CHECK_PASSWORDS_DESCRIPTION},
+ {"checkPasswordsErrorOffline", IDS_SETTINGS_CHECK_PASSWORDS_ERROR_OFFLINE},
+ {"checkPasswordsErrorSignedOut",
+ IDS_SETTINGS_CHECK_PASSWORDS_ERROR_SIGNED_OUT},
+ {"checkPasswordsErrorNoPasswords",
+ IDS_SETTINGS_CHECK_PASSWORDS_ERROR_NO_PASSWORDS},
+ {"checkPasswordsErrorQuota",
+ IDS_SETTINGS_CHECK_PASSWORDS_ERROR_QUOTA_LIMIT},
+ {"checkPasswordsErrorGeneric", IDS_SETTINGS_CHECK_PASSWORDS_ERROR_GENERIC},
+ {"noCompromisedCredentials", IDS_SETTINGS_NO_COMPROMISED_CREDENTIALS_LABEL},
+ {"checkPasswordsAgain", IDS_SETTINGS_CHECK_PASSWORDS_AGAIN},
+ {"checkPasswordsAgainAfterError",
+ IDS_SETTINGS_CHECK_PASSWORDS_AGAIN_AFTER_ERROR},
+ {"checkPasswordsProgress", IDS_SETTINGS_CHECK_PASSWORDS_PROGRESS},
+ {"checkPasswordsStop", IDS_SETTINGS_CHECK_PASSWORDS_STOP},
+ {"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS},
+ {"compromisedPasswordsDescription",
+ IDS_SETTINGS_COMPROMISED_PASSWORDS_ADVICE},
+ {"mutedPasswords", IDS_SETTINGS_MUTED_PASSWORDS},
+ {"weakPasswords", IDS_SETTINGS_WEAK_PASSWORDS},
+ {"changePasswordButton", IDS_SETTINGS_CHANGE_PASSWORD_BUTTON},
+ {"changePasswordInApp", IDS_SETTINGS_CHANGE_PASSWORD_IN_APP_LABEL},
+ {"leakedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_LEAKED},
+ {"phishedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED},
+ {"phishedAndLeakedPassword",
+ IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_PHISHED_AND_LEAKED},
+ {"showCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_SHOW},
+ {"hideCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_HIDE},
+ {"removeCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REMOVE},
+ {"muteCompromisedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_MUTE},
+ {"unmuteMutedCompromisedPassword",
+ IDS_SETTINGS_COMPROMISED_PASSWORD_UNMUTE},
+ {"removeCompromisedPasswordConfirmationTitle",
+ IDS_SETTINGS_REMOVE_COMPROMISED_PASSWORD_CONFIRMATION_TITLE},
+ {"removeCompromisedPasswordConfirmationDescription",
+ IDS_SETTINGS_REMOVE_COMPROMISED_PASSWORD_CONFIRMATION_DESCRIPTION},
+ {"alreadyChangedPasswordLink",
+ IDS_SETTINGS_COMPROMISED_ALREADY_CHANGED_PASSWORD},
+ {"editDisclaimerTitle", IDS_SETTINGS_COMPROMISED_EDIT_DISCLAIMER_TITLE},
+ {"editDisclaimerDescription",
+ IDS_SETTINGS_COMPROMISED_EDIT_DISCLAIMER_DESCRIPTION},
+ {"genericCreditCard", IDS_AUTOFILL_CC_GENERIC},
+ {"creditCards", IDS_AUTOFILL_PAYMENT_METHODS},
+ {"noPaymentMethodsFound", IDS_SETTINGS_PAYMENT_METHODS_NONE},
+ {"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
+ {"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED},
+ {"enableProfilesLabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL},
+ {"enableProfilesSublabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_SUBLABEL},
+ {"enableCreditCardsLabel", IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_LABEL},
+ {"enableCreditCardsSublabel",
+ IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_SUBLABEL},
+ {"enableCreditCardFIDOAuthLabel", IDS_ENABLE_CREDIT_CARD_FIDO_AUTH_LABEL},
+ {"enableCreditCardFIDOAuthSublabel",
+ IDS_ENABLE_CREDIT_CARD_FIDO_AUTH_SUBLABEL},
+ {"addresses", IDS_AUTOFILL_ADDRESSES},
+ {"addressesTitle", IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE},
+ {"addAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_ADD_TITLE},
+ {"editAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_EDIT_TITLE},
+ {"addressCountry", IDS_SETTINGS_AUTOFILL_ADDRESSES_COUNTRY},
+ {"addressPhone", IDS_SETTINGS_AUTOFILL_ADDRESSES_PHONE},
+ {"addressEmail", IDS_SETTINGS_AUTOFILL_ADDRESSES_EMAIL},
+ {"honorificLabel", IDS_SETTINGS_AUTOFILL_ADDRESS_HONORIFIC_LABEL},
+ {"moreActionsForAddress", IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_FOR_ADDRESS},
+ {"moreActionsForCreditCard",
+ IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_FOR_CREDIT_CARD},
+ {"moreActionsCreditCardDescription",
+ IDS_SETTINGS_AUTOFILL_MORE_ACTIONS_CARD_DESCRIPTION},
+ {"removeAddress", IDS_SETTINGS_ADDRESS_REMOVE},
+ {"removeAddressConfirmationTitle",
+ IDS_SETTINGS_ADDRESS_REMOVE_CONFIRMATION_TITLE},
+ {"removeAddressConfirmationDescription",
+ IDS_SETTINGS_ADDRESS_REMOVE_CONFIRMATION_DESCRIPTION},
+ {"removeCreditCard", IDS_SETTINGS_CREDIT_CARD_REMOVE},
+ {"clearCreditCard", IDS_SETTINGS_CREDIT_CARD_CLEAR},
+ {"creditCardType", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_TYPE_COLUMN_LABEL},
+ {"creditCardExpiration", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_DATE},
+ {"creditCardName", IDS_SETTINGS_NAME_ON_CREDIT_CARD},
+ {"creditCardNickname", IDS_SETTINGS_CREDIT_CARD_NICKNAME},
+ {"creditCardNicknameInvalid", IDS_SETTINGS_CREDIT_CARD_NICKNAME_INVALID},
+ {"creditCardNumber", IDS_SETTINGS_CREDIT_CARD_NUMBER},
+ {"creditCardExpirationMonth", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_MONTH},
+ {"creditCardExpirationYear", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_YEAR},
+ {"creditCardExpired", IDS_SETTINGS_CREDIT_CARD_EXPIRED},
+ {"editCreditCardTitle", IDS_SETTINGS_EDIT_CREDIT_CARD_TITLE},
+ {"addCreditCardTitle", IDS_SETTINGS_ADD_CREDIT_CARD_TITLE},
+ {"migrateCreditCardsLabel", IDS_SETTINGS_MIGRATABLE_CARDS_LABEL},
+ {"migratableCardsInfoSingle", IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_INFO},
+ {"migratableCardsInfoMultiple",
+ IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_INFO},
+ {"remoteCreditCardLinkLabel", IDS_SETTINGS_REMOTE_CREDIT_CARD_LINK_LABEL},
+ {"upiIdLabel", IDS_SETTINGS_UPI_ID_LABEL},
+ {"upiIdExpirationNever", IDS_SETTINGS_UPI_ID_EXPIRATION_NEVER},
+ {"canMakePaymentToggleLabel", IDS_SETTINGS_CAN_MAKE_PAYMENT_TOGGLE_LABEL},
+ {"autofillDetail", IDS_SETTINGS_AUTOFILL_DETAIL},
+ {"passwordsSavePasswordsLabel",
+ IDS_SETTINGS_PASSWORDS_SAVE_PASSWORDS_TOGGLE_LABEL},
+ {"passwordsAutosigninLabel",
+ IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_LABEL},
+ {"passwordsAutosigninDescription",
+ IDS_SETTINGS_PASSWORDS_AUTOSIGNIN_CHECKBOX_DESC},
+ {"passwordsLeakDetectionLabel",
+ IDS_SETTINGS_PASSWORDS_LEAK_DETECTION_LABEL},
+ {"passwordsLeakDetectionGeneralDescription",
+ IDS_PASSWORD_MANAGER_LEAK_HELP_MESSAGE},
+ {"passwordsLeakDetectionSignedOutEnabledDescription",
+ IDS_SETTINGS_PASSWORDS_LEAK_DETECTION_SIGNED_OUT_ENABLED_DESC},
+ {"savedPasswordsHeading", IDS_SETTINGS_PASSWORDS_SAVED_HEADING},
+ {"passwordExceptionsHeading", IDS_SETTINGS_PASSWORDS_EXCEPTIONS_HEADING},
+ {"deviceOnlyPasswordsHeading",
+ IDS_SETTINGS_DEVICE_PASSWORDS_ON_DEVICE_ONLY_HEADING},
+ {"deviceAndAccountPasswordsHeading",
+ IDS_SETTINGS_DEVICE_PASSWORDS_ON_DEVICE_AND_ACCOUNT_HEADING},
+ {"deletePasswordException", IDS_SETTINGS_PASSWORDS_DELETE_EXCEPTION},
+ {"removePassword", IDS_SETTINGS_PASSWORD_REMOVE},
+ {"searchPasswords", IDS_SETTINGS_PASSWORD_SEARCH},
+ {"showPassword", IDS_SETTINGS_PASSWORD_SHOW},
+ {"hidePassword", IDS_SETTINGS_PASSWORD_HIDE},
+ {"passwordDetailsTitle", IDS_SETTINGS_PASSWORDS_VIEW_DETAILS_TITLE},
+ {"passwordViewDetails", IDS_SETTINGS_PASSWORD_DETAILS},
+ {"editPasswordTitle", IDS_SETTINGS_PASSWORD_EDIT_TITLE},
+ {"editPassword", IDS_SETTINGS_PASSWORD_EDIT},
+ {"editPasswordFootnote", IDS_SETTINGS_PASSWORD_EDIT_FOOTNOTE},
+ {"addPasswordTitle", IDS_SETTINGS_PASSWORD_ADD_TITLE},
+ {"addPasswordFootnote", IDS_SETTINGS_PASSWORD_ADD_FOOTNOTE},
+ {"addPasswordStoreOptionAccount",
+ IDS_SETTINGS_PASSWORD_STORE_PICKER_OPTION_ACCOUNT},
+ {"addPasswordStoreOptionDevice",
+ IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_SAVE_TO_DEVICE},
+ {"addPasswordStorePickerA11yDescription",
+ IDS_PASSWORD_MANAGER_DESTINATION_DROPDOWN_ACCESSIBLE_NAME},
+ {"usernameAlreadyUsed", IDS_SETTINGS_PASSWORD_USERNAME_ALREADY_USED},
+ {"missingTLD", IDS_SETTINGS_PASSWORD_MISSING_TLD},
+ {"viewExistingPassword", IDS_SETTINGS_PASSWORD_VIEW_EXISTING_PASSWORD},
+ {"viewExistingPasswordAriaDescription",
+ IDS_SETTINGS_PASSWORD_VIEW_EXISTING_PASSWORD_ARIA_DESCRIPTION},
+ {"copyPassword", IDS_SETTINGS_PASSWORD_COPY},
+ {"sendPassword", IDS_SETTINGS_PASSWORD_SEND},
+ {"copyUsername", IDS_SETTINGS_USERNAME_COPY},
+ {"passwordStoredOnDevice", IDS_SETTINGS_PASSWORD_STORED_ON_DEVICE},
+ {"passwordStoredInAccount", IDS_SETTINGS_PASSWORD_STORED_IN_ACCOUNT},
+ {"passwordStoredInAccountAndOnDevice",
+ IDS_SETTINGS_PASSWORD_STORED_IN_ACCOUNT_AND_ON_DEVICE},
+ {"editPasswordWebsiteLabel", IDS_SETTINGS_PASSWORDS_WEBSITE},
+ {"editPasswordAppLabel", IDS_SETTINGS_COMPROMISED_EDIT_PASSWORD_APP},
+ {"editPasswordUsernameLabel", IDS_SETTINGS_PASSWORDS_USERNAME},
+ {"editPasswordPasswordLabel", IDS_SETTINGS_PASSWORDS_PASSWORD},
+ {"passwordNoteLabel", IDS_SETTINGS_PASSWORDS_NOTE},
+ {"passwordNoNoteAdded", IDS_SETTINGS_PASSWORDS_NO_NOTE_ADDED},
+ {"passwordNoteCharacterCount", IDS_SETTINGS_PASSWORDS_NOTE_CHARACTER_COUNT},
+ {"passwordNoteCharacterCountWarning",
+ IDS_SETTINGS_PASSWORDS_NOTE_CHARACTER_COUNT_WARNING},
+ {"noAddressesFound", IDS_SETTINGS_ADDRESS_NONE},
+ {"noPasswordsFound", IDS_SETTINGS_PASSWORDS_NONE},
+ {"noExceptionsFound", IDS_SETTINGS_PASSWORDS_EXCEPTIONS_NONE},
+ {"optInAccountStorageLabel",
+ IDS_SETTINGS_PASSWORDS_OPT_IN_ACCOUNT_STORAGE_LABEL},
+ {"optOutAccountStorageLabel",
+ IDS_SETTINGS_PASSWORDS_OPT_OUT_ACCOUNT_STORAGE_LABEL},
+ {"undoRemovePassword", IDS_SETTINGS_PASSWORD_UNDO},
+ {"movePasswordToAccount", IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT},
+ {"passwordDeleted", IDS_SETTINGS_PASSWORD_DELETED_PASSWORD},
+ {"passwordDeletedFromDevice",
+ IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_DEVICE},
+ {"passwordDeletedFromAccount",
+ IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT},
+ {"passwordDeletedFromAccountAndDevice",
+ IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT_AND_DEVICE},
+ {"passwordCopiedToClipboard", IDS_SETTINGS_PASSWORD_COPIED_TO_CLIPBOARD},
+ {"passwordUsernameCopiedToClipboard",
+ IDS_SETTINGS_PASSWORD_USERNAME_COPIED_TO_CLIPBOARD},
+ {"passwordMovePasswordsToAccount",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT},
+ {"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",
+ IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_CANCEL_BUTTON_TEXT},
+ {"passwordOpenMoveMultiplePasswordsToAccountDialogButtonText",
+ IDS_SETTINGS_PASSWORD_OPEN_MOVE_MULTIPLE_PASSWORDS_TO_ACCOUNT_DIALOG_BUTTON_TEXT},
+ {"passwordRemoveDialogTitle", IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_TITLE},
+ {"passwordRemoveDialogBody", IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_BODY},
+ {"passwordRemoveDialogRemoveButtonText",
+ IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_REMOVE_BUTTON_TEXT},
+ {"passwordRemoveDialogCancelButtonText",
+ IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_CANCEL_BUTTON_TEXT},
+ {"passwordRemoveDialogFromAccountCheckboxLabel",
+ IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_ACCOUNT_CHECKBOX_LABEL},
+ {"passwordRemoveDialogFromDeviceCheckboxLabel",
+ IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_DEVICE_CHECKBOX_LABEL},
+ {"devicePasswordsLinkLabel", IDS_SETTINGS_DEVICE_PASSWORDS_LINK_LABEL},
+ {"devicePasswordsMoved",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_SNACKBAR},
+ {"passwordRowMoreActionsButton", IDS_SETTINGS_PASSWORD_ROW_MORE_ACTIONS},
+ {"passwordRowFederatedMoreActionsButton",
+ IDS_SETTINGS_PASSWORD_ROW_FEDERATED_MORE_ACTIONS},
+ {"passwordRowPasswordDetailPageButton",
+ IDS_SETTINGS_PASSWORD_ROW_PASSWORD_DETAIL_PAGE},
+ {"importMenuItem", IDS_SETTINGS_PASSWORDS_IMPORT_MENU_ITEM},
+ {"importPasswordsTitle", IDS_SETTINGS_PASSWORDS_IMPORT_TITLE},
+ {"importPasswordsChooseFile", IDS_SETTINGS_PASSWORDS_IMPORT_CHOOSE_FILE},
+ {"importPasswordsSuccessTip", IDS_SETTINGS_PASSWORDS_IMPORT_SUCCESS_TIP},
+ {"importPasswordsFailuresSummary",
+ IDS_SETTINGS_PASSWORDS_IMPORT_FAILURES_SUMMARY},
+ {"importPasswordsMissingPassword",
+ IDS_SETTINGS_PASSWORDS_IMPORT_MISSING_PASSWORD},
+ {"importPasswordsMissingURL", IDS_SETTINGS_PASSWORDS_IMPORT_MISSING_URL},
+ {"importPasswordsInvalidURL", IDS_SETTINGS_PASSWORDS_IMPORT_INVALID_URL},
+ {"importPasswordsLongPassword",
+ IDS_SETTINGS_PASSWORDS_IMPORT_LONG_PASSWORD},
+ {"importPasswordsLongUsername",
+ IDS_SETTINGS_PASSWORDS_IMPORT_LONG_USERNAME},
+ {"importPasswordsConflictDevice",
+ IDS_SETTINGS_PASSWORDS_IMPORT_CONFLICT_DEVICE},
+ {"importPasswordsConflictAccount",
+ IDS_SETTINGS_PASSWORDS_IMPORT_CONFLICT_ACCOUNT},
+ {"importPasswordsUnknownError",
+ IDS_SETTINGS_PASSWORDS_IMPORT_ERROR_UNKNOWN},
+ {"importPasswordsBadFormatError",
+ IDS_SETTINGS_PASSWORDS_IMPORT_ERROR_BAD_FORMAT},
+ {"importPasswordsGenericDescription",
+ IDS_SETTINGS_PASSWORDS_IMPORT_DESCRIPTION_ACCOUNT_STORE_USERS},
+ {"importPasswordsDescriptionAccount",
+ IDS_SETTINGS_PASSWORDS_IMPORT_DESCRIPTION_SYNCING_USERS},
+ {"importPasswordsDescriptionDevice",
+ IDS_SETTINGS_PASSWORDS_IMPORT_DESCRIPTION_SIGNEDOUT_USERS},
+ {"importPasswordsStorePickerA11yDescription",
+ IDS_SETTINGS_PASSWORDS_IMPORT_STORE_PICKER_ACCESSIBLE_NAME},
+ {"importPasswordsAlreadyActive",
+ IDS_SETTINGS_PASSWORDS_IMPORT_ALREADY_ACTIVE},
+ {"importPasswordsLimitExceeded",
+ IDS_SETTINGS_PASSWORDS_IMPORT_ERROR_LIMIT_EXCEEDED},
+ {"exportMenuItem", IDS_SETTINGS_PASSWORDS_EXPORT_MENU_ITEM},
+ {"exportPasswordsTitle", IDS_SETTINGS_PASSWORDS_EXPORT_TITLE},
+ {"exportPasswordsDescription", IDS_SETTINGS_PASSWORDS_EXPORT_DESCRIPTION},
+ {"exportPasswords", IDS_SETTINGS_PASSWORDS_EXPORT},
+ {"exportingPasswordsTitle", IDS_SETTINGS_PASSWORDS_EXPORTING_TITLE},
+ {"exportPasswordsTryAgain", IDS_SETTINGS_PASSWORDS_EXPORT_TRY_AGAIN},
+ {"exportPasswordsFailTitle",
+ IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TITLE},
+ {"exportPasswordsFailTips", IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIPS},
+ {"exportPasswordsFailTipsEnoughSpace",
+ IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ENOUGH_SPACE},
+ {"exportPasswordsFailTipsAnotherFolder",
+ IDS_SETTINGS_PASSWORDS_EXPORTING_FAILURE_TIP_ANOTHER_FOLDER},
+ {"managePasswordsPlaintext",
+ IDS_SETTINGS_PASSWORDS_MANAGE_PASSWORDS_PLAINTEXT},
+ {"savedToThisDeviceOnly", IDS_SETTINGS_PAYMENTS_SAVED_TO_THIS_DEVICE_ONLY},
+ {"trustedVaultBannerLabel", IDS_SETTINGS_TRUSTED_VAULT_BANNER_LABEL},
+ {"trustedVaultBannerSubLabelOfferOptIn",
+ IDS_SETTINGS_TRUSTED_VAULT_BANNER_SUB_LABEL_OFFER_OPT_IN},
+ {"trustedVaultBannerSubLabelOptedIn",
+ IDS_SETTINGS_TRUSTED_VAULT_BANNER_SUB_LABEL_OPTED_IN},
+ {"noSearchResults", IDS_SEARCH_NO_RESULTS},
+ {"searchResultsPlural", IDS_SEARCH_RESULTS_PLURAL},
+ {"searchResultsSingular", IDS_SEARCH_RESULTS_SINGULAR},
+ {"showPasswordLabel", IDS_SETTINGS_PASSWORD_SHOW_PASSWORD_A11Y},
+ {"hidePasswordLabel", IDS_SETTINGS_PASSWORD_HIDE_PASSWORD_A11Y},
+ {"addVirtualCard", IDS_AUTOFILL_ADD_VIRTUAL_CARD},
+ {"removeVirtualCard", IDS_AUTOFILL_REMOVE_VIRTUAL_CARD},
+ {"editServerCard", IDS_AUTOFILL_EDIT_SERVER_CREDIT_CARD},
+ {"virtualCardAvailable", IDS_AUTOFILL_VIRTUAL_CARD_AVAILABLE_LABEL},
+ {"virtualCardEnabled", IDS_AUTOFILL_VIRTUAL_CARD_ENABLED_LABEL},
+ {"virtualCardTurnedOn", IDS_AUTOFILL_VIRTUAL_CARD_TURNED_ON_LABEL},
+ {"unenrollVirtualCardDialogTitle",
+ IDS_AUTOFILL_VIRTUAL_CARD_UNENROLL_DIALOG_TITLE},
+ {"unenrollVirtualCardDialogConfirm",
+ IDS_AUTOFILL_VIRTUAL_CARD_UNENROLL_DIALOG_CONFIRM_BUTTON_LABEL},
+#if BUILDFLAG(IS_WIN)
+ {"managePasskeysLabel", IDS_AUTOFILL_MANAGE_PASSKEYS_LABEL},
+ {"managePasskeysTitle", IDS_AUTOFILL_MANAGE_PASSKEYS_TITLE},
+ {"managePasskeysSubTitle", IDS_AUTOFILL_MANAGE_PASSKEYS_SUB_TITLE},
+ {"managePasskeysSearch", IDS_AUTOFILL_MANAGE_PASSKEYS_SEARCH},
+ {"managePasskeysNoSupport", IDS_AUTOFILL_MANAGE_PASSKEYS_NO_SUPPORT},
+ {"managePasskeysCannotDeleteTitle",
+ IDS_AUTOFILL_MANAGE_PASSKEYS_CANNOT_DELETE_TITLE},
+ {"managePasskeysCannotDeleteBody",
+ IDS_AUTOFILL_MANAGE_PASSKEYS_CANNOT_DELETE_BODY},
+#endif
+ };
bool unifiedPasswordManagerEnabled = base::FeatureList::IsEnabled(
password_manager::features::kUnifiedPasswordManagerDesktop);
@@ -1244,11 +1267,6 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
autofill::features::kAutofillEnableSupportForHonorificPrefixes));
html_source->AddBoolean(
- "addPasswordsInSettingsEnabled",
- base::FeatureList::IsEnabled(
- password_manager::features::kSupportForAddPasswordsInSettings));
-
- html_source->AddBoolean(
"virtualCardEnrollmentEnabled",
base::FeatureList::IsEnabled(
autofill::features::kAutofillEnableUpdateVirtualCardEnrollment) &&
@@ -1263,18 +1281,16 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
autofill::payments::GetVirtualCardEnrollmentSupportUrl()
.spec())));
+ html_source->AddBoolean(
+ "virtualCardMetadataEnabled",
+ base::FeatureList::IsEnabled(
+ autofill::features::kAutofillEnableVirtualCardMetadata));
+
html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
Profile* profile) {
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- bool is_dice_enabled = false;
-#else
- bool is_dice_enabled =
- AccountConsistencyModeManager::IsDiceEnabledForProfile(profile);
-#endif
-
#if BUILDFLAG(IS_CHROMEOS_LACROS)
bool is_main_profile = profile->IsMainProfile();
#else
@@ -1287,19 +1303,13 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
{"syncDisconnectTitle", IDS_SETTINGS_TURN_OFF_SYNC_DIALOG_TITLE},
};
html_source->AddLocalizedStrings(kTurnOffStrings);
- } else if (is_dice_enabled) {
+ } else {
static constexpr webui::LocalizedString kTurnOffStrings[] = {
{"syncDisconnect", IDS_SETTINGS_PEOPLE_SYNC_TURN_OFF},
{"syncDisconnectTitle",
IDS_SETTINGS_TURN_OFF_SYNC_AND_SIGN_OUT_DIALOG_TITLE},
};
html_source->AddLocalizedStrings(kTurnOffStrings);
- } else {
- static constexpr webui::LocalizedString kSignOutStrings[] = {
- {"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT},
- {"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE},
- };
- html_source->AddLocalizedStrings(kSignOutStrings);
}
std::string sync_dashboard_url =
@@ -1318,7 +1328,7 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SYNC_DISCONNECT_MAIN_PROFILE_EXPLANATION},
};
html_source->AddLocalizedStrings(kSyncDisconnectStrings);
- } else if (is_dice_enabled) {
+ } else {
static constexpr webui::LocalizedString kSyncDisconnectStrings[] = {
{"syncDisconnectDeleteProfile",
IDS_SETTINGS_TURN_OFF_SYNC_DIALOG_CHECKBOX},
@@ -1328,18 +1338,6 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SYNC_DISCONNECT_AND_SIGN_OUT_EXPLANATION},
};
html_source->AddLocalizedStrings(kSyncDisconnectStrings);
- } else {
- static constexpr webui::LocalizedString kSyncDisconnectStrings[] = {
- {"syncDisconnectDeleteProfile",
- IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE},
- {"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM},
- };
- html_source->AddLocalizedStrings(kSyncDisconnectStrings);
-
- html_source->AddString(
- "syncDisconnectExplanation",
- l10n_util::GetStringFUTF8(IDS_SETTINGS_SYNC_DISCONNECT_EXPLANATION,
- base::ASCIIToUTF16(sync_dashboard_url)));
}
#if !BUILDFLAG(IS_CHROMEOS_ASH)
@@ -1384,6 +1382,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
// Color picker strings:
{"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
{"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL},
+ {"themesContainerLabel", IDS_SETTINGS_PICK_A_THEME_COLOR},
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
@@ -1554,6 +1553,14 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
{"openChromeOSSecureDnsSettingsLabel",
IDS_SETTINGS_SECURE_DNS_OPEN_CHROME_OS_SETTINGS_LABEL},
#endif
+#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED)
+ {"manageDeviceCertificates", IDS_SETTINGS_MANAGE_DEVICE_CERTIFICATES},
+ {"manageDeviceCertificatesDescription",
+ IDS_SETTINGS_MANAGE_DEVICE_CERTIFICATES_DESCRIPTION},
+ {"chromeCertificates", IDS_SETTINGS_CHROME_CERTIFICATES},
+ {"chromeCertificatesDescription",
+ IDS_SETTINGS_CHROME_CERTIFICATES_DESCRIPTION},
+#endif
};
html_source->AddLocalizedStrings(kLocalizedStrings);
@@ -1607,6 +1614,27 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
"showHttpsOnlyModeSetting",
base::FeatureList::IsEnabled(features::kHttpsOnlyMode));
+#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED)
+ bool chrome_root_store_used =
+ base::FeatureList::IsEnabled(net::features::kChromeRootStoreUsed);
+#if BUILDFLAG(CHROME_ROOT_STORE_POLICY_SUPPORTED)
+ const PrefService::Preference* chrome_root_store_enabled_pref =
+ g_browser_process->local_state()->FindPreference(
+ prefs::kChromeRootStoreEnabled);
+ if (chrome_root_store_enabled_pref &&
+ chrome_root_store_enabled_pref->IsManaged()) {
+ chrome_root_store_used =
+ chrome_root_store_enabled_pref->GetValue()->GetBool();
+ }
+#endif // BUILDFLAG(CHROME_ROOT_STORE_POLICY_SUPPORTED)
+
+ html_source->AddBoolean("showChromeRootStoreCertificates",
+ chrome_root_store_used);
+
+ html_source->AddString("chromeRootStoreHelpCenterURL",
+ chrome::kChromeRootStoreSettingsHelpCenterURL);
+#endif // BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED)
+
// The link to the Advanced Protection Program landing page, with a referrer
// from Chrome settings.
GURL advanced_protection_url(
@@ -1655,10 +1683,15 @@ void AddPrivacySandboxStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_FLOC_HEADING},
{"privacySandboxPageFlocStatus",
IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_FLOC_STATUS},
+ {"privacySandboxPageFlocStatusNotActive",
+ IDS_PRIVACY_SANDBOX_FLOC_STATUS_NOT_ACTIVE},
{"privacySandboxPageFlocCohort",
IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_FLOC_COHORT},
+ {"privacySandboxFlocInvalid", IDS_PRIVACY_SANDBOX_FLOC_INVALID},
{"privacySandboxPageFlocCohortNextUpdate",
IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_FLOC_COHORT_NEXT_UPDATE},
+ {"privacySandboxPageFlocTimeToNextComputeInvalid",
+ IDS_PRIVACY_SANDBOX_FLOC_TIME_TO_NEXT_COMPUTE_INVALID},
{"privacySandboxPageFlocResetCohort",
IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_FLOC_RESET_COHORT},
// The following strings are used for PrivacySandboxSettings3.
@@ -1773,8 +1806,8 @@ void AddPrivacySandboxStrings(content::WebUIDataSource* html_source,
// one provided by the Privacy Sandbox service, and one with a URL
// replacement based on a feature parameter.
std::u16string floc_explanation =
- PrivacySandboxServiceFactory::GetForProfile(profile)
- ->GetFlocDescriptionForDisplay() +
+ l10n_util::GetPluralStringFUTF16(IDS_PRIVACY_SANDBOX_FLOC_DESCRIPTION,
+ 7) +
u" " + // Whitespace is a valid separator w.r.t l10n.
l10n_util::GetStringFUTF16(IDS_SETTINGS_PRIVACY_SANDBOX_FLOC_TRIAL_ACTIVE,
u"https://privacysandbox.com/proposals/floc");
@@ -1784,8 +1817,8 @@ void AddPrivacySandboxStrings(content::WebUIDataSource* html_source,
// profile, and so the relevant string can be injected here, rather than
// fetched dynamically from JS.
html_source->AddString("privacySandboxPageFlocResetExplanation",
- PrivacySandboxServiceFactory::GetForProfile(profile)
- ->GetFlocResetExplanationForDisplay());
+ l10n_util::GetPluralStringFUTF16(
+ IDS_PRIVACY_SANDBOX_FLOC_RESET_EXPLANATION, 7));
html_source->AddBoolean(
"privacySandboxSettings3Enabled",
@@ -1925,7 +1958,11 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SAFETY_CHECK_ICON_INFO_ARIA_LABEL},
{"safetyCheckIconWarningAriaLabel",
IDS_SETTINGS_SAFETY_CHECK_ICON_WARNING_ARIA_LABEL},
+ {"safetyCheckNotificationPermissionsPrimaryLabel",
+ IDS_SETTINGS_SAFETY_CHECK_NOTIFICATION_PERMISSIONS_PRIMARY_LABEL},
{"safetyCheckReview", IDS_SETTINGS_SAFETY_CHECK_REVIEW},
+ {"safetyCheckUnusedSitePermissionsPrimaryLabel",
+ IDS_SETTINGS_SAFETY_CHECK_UNUSED_SITE_PERMISSIONS_PRIMARY_LABEL},
{"safetyCheckUpdatesPrimaryLabel",
IDS_SETTINGS_SAFETY_CHECK_UPDATES_PRIMARY_LABEL},
{"safetyCheckUpdatesButtonAriaLabel", IDS_UPDATE_RECOMMENDED_DIALOG_TITLE},
@@ -2005,7 +2042,6 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SEARCH_ENGINES_INACTIVE_SHORTCUTS},
{"searchEnginesNoInactiveShortcuts",
IDS_SETTINGS_SEARCH_ENGINES_NO_INACTIVE_SHORTCUTS},
- {"searchEnginesOther", IDS_SETTINGS_SEARCH_ENGINES_OTHER_ENGINES},
{"searchEnginesNoOtherEngines",
IDS_SETTINGS_SEARCH_ENGINES_NO_OTHER_ENGINES},
{"searchEnginesExtension", IDS_SETTINGS_SEARCH_ENGINES_EXTENSION_ENGINES},
@@ -2015,7 +2051,6 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
{"searchEnginesSearchEngine", IDS_SETTINGS_SEARCH_ENGINES_SEARCH_ENGINE},
{"searchEnginesSiteOrPage", IDS_SETTINGS_SEARCH_ENGINES_SITE_OR_PAGE},
{"searchEnginesInactiveSite", IDS_SETTINGS_SEARCH_ENGINES_INACTIVE_SITE},
- {"searchEnginesKeyword", IDS_SETTINGS_SEARCH_ENGINES_KEYWORD},
{"searchEnginesShortcut", IDS_SETTINGS_SEARCH_ENGINES_SHORTCUT},
{"searchEnginesQueryURL", IDS_SETTINGS_SEARCH_ENGINES_QUERY_URL},
{"searchEnginesQueryURLExplanation",
@@ -2043,9 +2078,6 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SEARCH_ENGINES_ADDITIONAL_EXTENSIONS},
};
html_source->AddLocalizedStrings(kLocalizedStrings);
- html_source->AddBoolean(
- "isActiveSearchEnginesFlagEnabled",
- base::FeatureList::IsEnabled(omnibox::kActiveSearchEngines));
}
void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
@@ -2061,9 +2093,9 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"cookieFileSystem", IDS_SETTINGS_COOKIES_FILE_SYSTEM},
{"cookieFlashLso", IDS_SETTINGS_COOKIES_FLASH_LSO},
{"cookieLocalStorage", IDS_SETTINGS_COOKIES_LOCAL_STORAGE},
- {"cookieMediaLicense", IDS_SETTINGS_COOKIES_MEDIA_LICENSE},
{"cookieServiceWorker", IDS_SETTINGS_COOKIES_SERVICE_WORKER},
{"cookieSharedWorker", IDS_SETTINGS_COOKIES_SHARED_WORKER},
+ {"cookieQuotaStorage", IDS_SETTINGS_COOKIES_QUOTA_STORAGE},
{"embeddedOnAnyHost", IDS_SETTINGS_EXCEPTIONS_EMBEDDED_ON_ANY_HOST},
{"embeddedOnHost", IDS_SETTINGS_EXCEPTIONS_EMBEDDED_ON_HOST},
{"editSiteTitle", IDS_SETTINGS_EDIT_SITE_TITLE},
@@ -2094,10 +2126,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL},
{"localStorageOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
{"localStorageSize", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL},
- {"mediaLicenseOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
- {"mediaLicenseSize", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL},
- {"mediaLicenseLastModified",
- IDS_SETTINGS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL},
+ {"quotaOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
+ {"quotaSize", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL},
{"noBluetoothDevicesFound", IDS_SETTINGS_NO_BLUETOOTH_DEVICES_FOUND},
{"noHidDevicesFound", IDS_SETTINGS_NO_HID_DEVICES_FOUND},
{"noSerialPortsFound", IDS_SETTINGS_NO_SERIAL_PORTS_FOUND},
@@ -2430,16 +2460,28 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsDelete", IDS_SETTINGS_SITE_SETTINGS_DELETE},
{"siteSettingsClearAllStorageDialogTitle",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_DIALOG_TITLE},
+ {"siteSettingsClearDisplayedStorageDialogTitle",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_DIALOG_TITLE},
{"siteSettingsClearAllStorageDescription",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_DESCRIPTION},
+ {"siteSettingsClearDisplayedStorageDescription",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_DESCRIPTION},
{"siteSettingsClearAllStorageLabel",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_LABEL},
+ {"siteSettingsClearDisplayedStorageLabel",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_LABEL},
{"siteSettingsClearAllStorageConfirmation",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_CONFIRMATION},
+ {"siteSettingsClearDisplayedStorageConfirmation",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_CONFIRMATION},
{"siteSettingsClearAllStorageConfirmationInstalled",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_CONFIRMATION_INSTALLED},
+ {"siteSettingsClearDisplayedStorageConfirmationInstalled",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_CONFIRMATION_INSTALLED},
{"siteSettingsClearAllStorageSignOut",
IDS_SETTINGS_SITE_SETTINGS_CLEAR_ALL_STORAGE_SIGN_OUT},
+ {"siteSettingsClearDisplayedStorageSignOut",
+ IDS_SETTINGS_SITE_SETTINGS_CLEAR_DISPLAYED_STORAGE_SIGN_OUT},
{"siteSettingsOriginDeleteConfirmation",
IDS_SETTINGS_SITE_SETTINGS_ORIGIN_DELETE_CONFIRMATION},
{"siteSettingsOriginDeleteConfirmationInstalled",
@@ -2807,19 +2849,19 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsVrMidSentence", IDS_SITE_SETTINGS_TYPE_VR_MID_SENTENCE},
{"siteSettingsVrAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_VR_ASK_RECOMMENDED},
- {"siteSettingsWindowPlacement", IDS_SITE_SETTINGS_TYPE_WINDOW_PLACEMENT},
+ {"siteSettingsWindowPlacement", IDS_SITE_SETTINGS_TYPE_WINDOW_MANAGEMENT},
{"siteSettingsWindowPlacementMidSentence",
- IDS_SITE_SETTINGS_TYPE_WINDOW_PLACEMENT_MID_SENTENCE},
+ IDS_SITE_SETTINGS_TYPE_WINDOW_MANAGEMENT_MID_SENTENCE},
{"siteSettingsWindowPlacementDescription",
- IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_DESCRIPTION},
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_MANAGEMENT_DESCRIPTION},
{"siteSettingsWindowPlacementAsk",
- IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_ASK},
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_MANAGEMENT_ASK},
{"siteSettingsWindowPlacementBlocked",
- IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_BLOCKED},
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_MANAGEMENT_BLOCKED},
{"siteSettingsWindowPlacementAskExceptions",
- IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_ASK_EXCEPTIONS},
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_MANAGEMENT_ASK_EXCEPTIONS},
{"siteSettingsWindowPlacementBlockedExceptions",
- IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_BLOCKED_EXCEPTIONS},
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_MANAGEMENT_BLOCKED_EXCEPTIONS},
{"siteSettingsFontAccessMidSentence",
IDS_SITE_SETTINGS_TYPE_FONT_ACCESS_MID_SENTENCE},
{"siteSettingsIdleDetection", IDS_SITE_SETTINGS_TYPE_IDLE_DETECTION},
@@ -3069,11 +3111,6 @@ void AddSecurityKeysStrings(content::WebUIDataSource* html_source) {
!win_native_api_available);
}
-void AddIPHStrings(content::WebUIDataSource* html_source) {
- html_source->AddBoolean("iphDemoEnabled", base::FeatureList::IsEnabled(
- features::kIPHInWebUIDemo));
-}
-
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source,
@@ -3093,7 +3130,6 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddCommonStrings(html_source, profile);
AddDownloadsStrings(html_source);
AddExtensionsStrings(html_source);
- AddIPHStrings(html_source);
AddLanguagesStrings(html_source, profile);
AddOnStartupStrings(html_source);
AddPeopleStrings(html_source, profile);
@@ -3107,9 +3143,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddSearchStrings(html_source);
AddSiteSettingsStrings(html_source, profile);
-#if BUILDFLAG(IS_CHROMEOS)
- AddChromeOSSettingsStrings(html_source);
-#else
+#if !BUILDFLAG(IS_CHROMEOS)
AddDefaultBrowserStrings(html_source);
AddImportDataStrings(html_source);
#endif
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 511e797aa28..8237994bcfc 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
@@ -103,8 +103,7 @@ void ManageProfileHandler::OnProfileHighResAvatarLoaded(
return;
// GAIA image is loaded asynchronously.
- FireWebUIListener("available-icons-changed",
- base::Value(GetAvailableIcons()));
+ FireWebUIListener("available-icons-changed", GetAvailableIcons());
}
void ManageProfileHandler::OnProfileAvatarChanged(
@@ -113,8 +112,7 @@ void ManageProfileHandler::OnProfileAvatarChanged(
return;
// This is necessary to send the potentially updated GAIA photo.
- FireWebUIListener("available-icons-changed",
- base::Value(GetAvailableIcons()));
+ FireWebUIListener("available-icons-changed", GetAvailableIcons());
}
void ManageProfileHandler::OnProfileThemeColorsChanged(
@@ -132,10 +130,10 @@ void ManageProfileHandler::HandleGetAvailableIcons(
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, base::Value(GetAvailableIcons()));
+ ResolveJavascriptCallback(callback_id, GetAvailableIcons());
}
-std::vector<base::Value> ManageProfileHandler::GetAvailableIcons() {
+base::Value::List ManageProfileHandler::GetAvailableIcons() {
ProfileAttributesEntry* entry =
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
@@ -144,7 +142,7 @@ std::vector<base::Value> ManageProfileHandler::GetAvailableIcons() {
if (!entry) {
LOG(ERROR) << "No profile attributes entry found for profile with path: "
<< profile_->GetPath();
- return std::vector<base::Value>();
+ return base::Value::List();
}
bool using_gaia = entry->IsUsingGAIAPicture();
@@ -152,7 +150,7 @@ std::vector<base::Value> ManageProfileHandler::GetAvailableIcons() {
using_gaia ? SIZE_MAX : entry->GetAvatarIconIndex();
// Obtain a list of the modern avatar icons.
- std::vector<base::Value> avatars(
+ base::Value::List avatars(
profiles::GetCustomProfileAvatarIconsAndLabels(selected_avatar_idx));
if (entry->GetSigninState() == SigninState::kNotSignedIn) {
@@ -160,7 +158,7 @@ std::vector<base::Value> ManageProfileHandler::GetAvailableIcons() {
auto generic_avatar_info = profiles::GetDefaultProfileAvatarIconAndLabel(
colors.default_avatar_fill_color, colors.default_avatar_stroke_color,
selected_avatar_idx == profiles::GetPlaceholderAvatarIndex());
- avatars.insert(avatars.begin(),
+ avatars.Insert(avatars.begin(),
base::Value(std::move(generic_avatar_info)));
return avatars;
}
@@ -174,7 +172,7 @@ std::vector<base::Value> ManageProfileHandler::GetAvailableIcons() {
/*label=*/
l10n_util::GetStringUTF16(IDS_SETTINGS_CHANGE_PICTURE_PROFILE_PHOTO),
/*index=*/0, using_gaia, /*is_gaia_avatar=*/true);
- avatars.insert(avatars.begin(), base::Value(std::move(gaia_picture_info)));
+ avatars.Insert(avatars.begin(), base::Value(std::move(gaia_picture_info)));
}
return avatars;
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
index 2741526fa12..d330a7ba1c7 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h
@@ -62,7 +62,7 @@ class ManageProfileHandler : public settings::SettingsPageUIHandler,
void HandleGetAvailableIcons(const base::Value::List& args);
// Get all the available profile icons to choose from.
- std::vector<base::Value> GetAvailableIcons();
+ base::Value::List GetAvailableIcons();
// Callback for the "setProfileIconToGaiaAvatar" message.
void HandleSetProfileIconToGaiaAvatar(const base::Value::List& args);
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
index 3c4be909bc9..2c646656392 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc
@@ -143,9 +143,8 @@ void MediaDevicesSelectionHandler::UpdateDevicesMenu(
base::Value default_value(default_id);
base::Value type_value(device_type);
- base::Value device_list_value(std::move(device_list));
- FireWebUIListener("updateDevicesMenu", type_value, device_list_value,
+ FireWebUIListener("updateDevicesMenu", type_value, device_list,
default_value);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc
index 3d33abf7223..ac1d41affee 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc
@@ -35,7 +35,7 @@ namespace settings {
namespace {
-base::Value CreateSecureDnsSettingDict() {
+base::Value::Dict CreateSecureDnsSettingDict() {
// Fetch the current host resolver configuration. It is not sufficient to read
// the secure DNS prefs directly since the host resolver configuration takes
// other factors into account such as whether a managed environment or
@@ -49,7 +49,7 @@ base::Value CreateSecureDnsSettingDict() {
dict.Set("mode", SecureDnsConfig::ModeToString(config.mode()));
dict.Set("config", config.doh_servers().ToString());
dict.Set("managementMode", static_cast<int>(config.management_mode()));
- return base::Value(std::move(dict));
+ return dict;
}
} // namespace
@@ -105,8 +105,16 @@ void SecureDnsHandler::OnJavascriptDisallowed() {
pref_registrar_.RemoveAll();
}
-base::Value SecureDnsHandler::GetSecureDnsResolverList() {
+base::Value::List SecureDnsHandler::GetSecureDnsResolverList() {
base::Value::List resolvers;
+
+ // Add a custom option to the front of the list
+ base::Value::Dict custom;
+ custom.Set("name", l10n_util::GetStringUTF8(IDS_SETTINGS_CUSTOM));
+ custom.Set("value", std::string()); // Empty value means custom.
+ custom.Set("policy", std::string());
+ resolvers.Append(std::move(custom));
+
for (const auto* entry : providers_) {
net::DnsOverHttpsConfig doh_config({entry->doh_server_config});
base::Value::Dict dict;
@@ -116,17 +124,10 @@ base::Value SecureDnsHandler::GetSecureDnsResolverList() {
resolvers.Append(std::move(dict));
}
- // Randomize the order of the resolvers.
- base::RandomShuffle(resolvers.begin(), resolvers.end());
-
- // Add a custom option to the front of the list
- base::Value::Dict custom;
- custom.Set("name", l10n_util::GetStringUTF8(IDS_SETTINGS_CUSTOM));
- custom.Set("value", std::string()); // Empty value means custom.
- custom.Set("policy", std::string());
- resolvers.Insert(resolvers.begin(), base::Value(std::move(custom)));
+ // Randomize the order of the resolvers, but keep custom in first place.
+ base::RandomShuffle(std::next(resolvers.begin()), resolvers.end());
- return base::Value(std::move(resolvers));
+ return resolvers;
}
void SecureDnsHandler::SetNetworkContextForTesting(
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.h
index b5d22f19653..0ef3d9732b1 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.h
@@ -39,7 +39,7 @@ class SecureDnsHandler : public SettingsPageUIHandler {
// as a dictionary with the following keys: "name" (the text to display in the
// UI), "value" (the DoH template for this provider), and "policy" (the URL of
// the provider's privacy policy).
- base::Value GetSecureDnsResolverList();
+ base::Value::List GetSecureDnsResolverList();
void SetNetworkContextForTesting(
network::mojom::NetworkContext* network_context);
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc
index c7d4cf56c2f..3d14e84796f 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc
@@ -92,18 +92,16 @@ net::DohProviderEntry::List GetDohProviderListForTesting() {
return {&global1, &no_display, &ee_fr, &fr, &global2};
}
-bool FindDropdownItem(const base::Value& resolvers,
+bool FindDropdownItem(const base::Value::List& resolvers,
const std::string& name,
const std::string& value,
const std::string& policy) {
- base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetKey("name", base::Value(name));
- dict.SetKey("value", base::Value(value));
- dict.SetKey("policy", base::Value(policy));
-
- return std::find(resolvers.GetListDeprecated().begin(),
- resolvers.GetListDeprecated().end(),
- dict) != resolvers.GetListDeprecated().end();
+ base::Value::Dict dict;
+ dict.Set("name", name);
+ dict.Set("value", value);
+ dict.Set("policy", policy);
+
+ return std::find(resolvers.begin(), resolvers.end(), dict) != resolvers.end();
}
} // namespace
@@ -305,33 +303,28 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, OtherPoliciesSet) {
// This test makes no assumptions about the country or underlying resolver list.
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, DropdownList) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kWebUiFunctionName);
- web_ui_.HandleReceivedMessage(kGetSecureDnsResolverList,
- &base::Value::AsListValue(args));
+ web_ui_.HandleReceivedMessage(kGetSecureDnsResolverList, args);
const content::TestWebUI::CallData& call_data = *web_ui_.call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
EXPECT_EQ(kWebUiFunctionName, call_data.arg1()->GetString());
ASSERT_TRUE(call_data.arg2()->GetBool());
// Check results.
- base::Value::ConstListView resolver_list =
- call_data.arg3()->GetListDeprecated();
+ const base::Value::List& resolver_list = call_data.arg3()->GetList();
ASSERT_GE(resolver_list.size(), 1U);
- EXPECT_TRUE(resolver_list[0].FindKey("value")->GetString().empty());
+ EXPECT_TRUE(resolver_list[0].GetDict().FindString("value")->empty());
}
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, DropdownListContents) {
const auto entries = GetDohProviderListForTesting();
handler_->SetProvidersForTesting(entries);
- const base::Value resolver_list = handler_->GetSecureDnsResolverList();
+ const base::Value::List resolver_list = handler_->GetSecureDnsResolverList();
- EXPECT_EQ(entries.size() + 1, resolver_list.GetListDeprecated().size());
- EXPECT_TRUE(resolver_list.GetListDeprecated()[0]
- .FindKey("value")
- ->GetString()
- .empty());
+ EXPECT_EQ(entries.size() + 1, resolver_list.size());
+ EXPECT_TRUE(resolver_list[0].GetDict().FindString("value")->empty());
for (const auto* entry : entries) {
EXPECT_TRUE(FindDropdownItem(resolver_list, entry->ui_name,
entry->doh_server_config.server_template(),
@@ -343,11 +336,10 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, DropdownListChange) {
handler_->SetProvidersForTesting(GetDohProviderListForTesting());
base::HistogramTester histograms;
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(std::string() /* old_provider */);
args.Append("https://global1.provider/dns-query{?dns}" /* new_provider */);
- web_ui_.HandleReceivedMessage(kRecordUserDropdownInteraction,
- &base::Value::AsListValue(args));
+ web_ui_.HandleReceivedMessage(kRecordUserDropdownInteraction, args);
const std::string kUmaBase = "Net.DNS.UI.DropdownSelectionEvent";
histograms.ExpectTotalCount(kUmaBase + ".Ignored", 4u);
@@ -390,13 +382,12 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, SecureDnsTemplates) {
}
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateValid) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kWebUiFunctionName);
args.Append("https://example.template/dns-query");
base::HistogramTester histograms;
- web_ui_.HandleReceivedMessage(kIsValidConfig,
- &base::Value::AsListValue(args));
+ web_ui_.HandleReceivedMessage(kIsValidConfig, args);
const content::TestWebUI::CallData& call_data = *web_ui_.call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
EXPECT_EQ(kWebUiFunctionName, call_data.arg1()->GetString());
@@ -409,13 +400,12 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateValid) {
}
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateInvalid) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kWebUiFunctionName);
args.Append("invalid_template");
base::HistogramTester histograms;
- web_ui_.HandleReceivedMessage(kIsValidConfig,
- &base::Value::AsListValue(args));
+ web_ui_.HandleReceivedMessage(kIsValidConfig, args);
const content::TestWebUI::CallData& call_data = *web_ui_.call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data.function_name());
EXPECT_EQ(kWebUiFunctionName, call_data.arg1()->GetString());
@@ -429,12 +419,11 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateInvalid) {
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, MultipleTemplates) {
base::HistogramTester histograms;
- base::Value args_valid(base::Value::Type::LIST);
+ base::Value::List args_valid;
args_valid.Append(kWebUiFunctionName);
args_valid.Append(
"https://example1.template/dns https://example2.template/dns-query");
- web_ui_.HandleReceivedMessage(kIsValidConfig,
- &base::Value::AsListValue(args_valid));
+ web_ui_.HandleReceivedMessage(kIsValidConfig, args_valid);
const content::TestWebUI::CallData& call_data_valid =
*web_ui_.call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data_valid.function_name());
@@ -446,11 +435,10 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, MultipleTemplates) {
histograms.ExpectBucketCount("Net.DNS.UI.ValidationAttemptSuccess", false, 0);
histograms.ExpectBucketCount("Net.DNS.UI.ValidationAttemptSuccess", true, 1);
- base::Value args_invalid(base::Value::Type::LIST);
+ base::Value::List args_invalid;
args_invalid.Append(kWebUiFunctionName);
args_invalid.Append("invalid_template https://example.template/dns");
- web_ui_.HandleReceivedMessage(kIsValidConfig,
- &base::Value::AsListValue(args_invalid));
+ web_ui_.HandleReceivedMessage(kIsValidConfig, args_invalid);
const content::TestWebUI::CallData& call_data_invalid =
*web_ui_.call_data().back();
EXPECT_EQ("cr.webUIResponse", call_data_invalid.function_name());
@@ -475,11 +463,10 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateProbeSuccess) {
SingleResult>() /* google_config_result_list */);
handler_->SetNetworkContextForTesting(network_context_.get());
base::HistogramTester histograms;
- base::Value args_valid(base::Value::Type::LIST);
+ base::Value::List args_valid;
args_valid.Append(kWebUiFunctionName);
args_valid.Append("https://example.template/dns-query https://example2/");
- web_ui_.HandleReceivedMessage(kProbeConfig,
- &base::Value::AsListValue(args_valid));
+ web_ui_.HandleReceivedMessage(kProbeConfig, args_valid);
base::RunLoop().RunUntilIdle();
const content::TestWebUI::CallData& call_data_valid =
@@ -507,11 +494,10 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateProbeFailure) {
SingleResult>() /* google_config_result_list */);
handler_->SetNetworkContextForTesting(network_context_.get());
base::HistogramTester histograms;
- base::Value args_valid(base::Value::Type::LIST);
+ base::Value::List args_valid;
args_valid.Append(kWebUiFunctionName);
args_valid.Append("https://example.template/dns-query");
- web_ui_.HandleReceivedMessage(kProbeConfig,
- &base::Value::AsListValue(args_valid));
+ web_ui_.HandleReceivedMessage(kProbeConfig, args_valid);
base::RunLoop().RunUntilIdle();
const content::TestWebUI::CallData& call_data_valid =
@@ -540,13 +526,12 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateProbeDebounce) {
std::vector<chrome_browser_net::FakeHostResolver::
SingleResult>() /* google_config_result_list */);
base::HistogramTester histograms;
- base::Value args_valid(base::Value::Type::LIST);
+ base::Value::List args_valid;
args_valid.Append(kWebUiFunctionName);
args_valid.Append("https://example.template/dns-query");
// Request a probe that will hang.
handler_->SetNetworkContextForTesting(network_context_hang.get());
- web_ui_.HandleReceivedMessage(kProbeConfig,
- &base::Value::AsListValue(args_valid));
+ web_ui_.HandleReceivedMessage(kProbeConfig, args_valid);
size_t responses = web_ui_.call_data().size();
base::RunLoop().RunUntilIdle();
// No response yet from the hanging probe.
@@ -554,8 +539,7 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, TemplateProbeDebounce) {
// Request a probe that will fail.
handler_->SetNetworkContextForTesting(network_context_fail.get());
- web_ui_.HandleReceivedMessage(kProbeConfig,
- &base::Value::AsListValue(args_valid));
+ web_ui_.HandleReceivedMessage(kProbeConfig, args_valid);
// The hanging response should now have arrived.
EXPECT_EQ(responses + 1, web_ui_.call_data().size());
const content::TestWebUI::CallData& first_response =
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc
index d1dac22ede5..8d296e6aff6 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc
@@ -14,10 +14,12 @@
#include "base/callback.h"
#include "base/containers/contains.h"
#include "base/strings/string_number_conversions.h"
+#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h"
#include "chrome/browser/webauthn/cablev2_devices.h"
+#include "chrome/browser/webauthn/local_credential_management.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
@@ -34,6 +36,10 @@
#include "third_party/icu/source/common/unicode/locid.h"
#include "ui/base/l10n/l10n_util.h"
+#if BUILDFLAG(IS_WIN)
+#include "device/fido/win/webauthn_api.h"
+#endif
+
using content::BrowserThread;
namespace {
@@ -154,8 +160,7 @@ void SecurityKeysPINHandler::OnGatherPIN(uint32_t current_min_pin_length,
response.Set("retries", base::Value());
}
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysPINHandler::OnSetPINComplete(
@@ -174,8 +179,7 @@ void SecurityKeysPINHandler::OnSetPINComplete(
base::Value::Dict response;
response.Set("done", true);
response.Set("error", static_cast<int>(code));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysPINHandler::HandleSetPIN(const base::Value::List& args) {
@@ -527,8 +531,7 @@ void SecurityKeysCredentialHandler::OnHaveCredentials(
}
}
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(credentials)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), credentials);
}
void SecurityKeysCredentialHandler::OnGatherPIN(
@@ -548,8 +551,7 @@ void SecurityKeysCredentialHandler::OnGatherPIN(
response.Set("supportsUpdateUserInformation",
authenticator_properties.supports_update_user_information);
state_ = State::kPIN;
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
return;
}
@@ -558,8 +560,7 @@ void SecurityKeysCredentialHandler::OnGatherPIN(
base::Value::List response;
response.Append(static_cast<int>(authenticator_properties.min_pin_length));
response.Append(static_cast<int>(authenticator_properties.pin_retries));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysCredentialHandler::OnCredentialsDeleted(
@@ -580,8 +581,7 @@ void SecurityKeysCredentialHandler::OnCredentialsDeleted(
status == device::CtapDeviceResponseCode::kSuccess
? IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_DELETE_SUCCESS
: IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_DELETE_FAILED));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysCredentialHandler::OnUserInformationUpdated(
@@ -602,8 +602,7 @@ void SecurityKeysCredentialHandler::OnUserInformationUpdated(
status == device::CtapDeviceResponseCode::kSuccess
? IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_UPDATE_SUCCESS
: IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_UPDATE_FAILED));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysCredentialHandler::OnFinished(
@@ -796,8 +795,7 @@ void SecurityKeysBioEnrollmentHandler::OnGatherPIN(
base::Value::List response;
response.Append(static_cast<int>(min_pin_length));
response.Append(static_cast<int>(retries));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(response)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), response);
}
void SecurityKeysBioEnrollmentHandler::HandleProvidePIN(
@@ -822,7 +820,7 @@ void SecurityKeysBioEnrollmentHandler::HandleGetSensorInfo(
response.Set("maxSamplesForEnroll", *sensor_info_.max_samples_for_enroll);
}
ResolveJavascriptCallback(base::Value(std::move(args[0].GetString())),
- base::Value(std::move(response)));
+ response);
}
void SecurityKeysBioEnrollmentHandler::HandleEnumerate(
@@ -852,8 +850,7 @@ void SecurityKeysBioEnrollmentHandler::OnHaveEnumeration(
}
state_ = State::kReady;
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(list)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), list);
}
void SecurityKeysBioEnrollmentHandler::HandleStartEnrolling(
@@ -878,8 +875,7 @@ void SecurityKeysBioEnrollmentHandler::OnEnrollingResponse(
base::Value::Dict d;
d.Set("status", static_cast<int>(status));
d.Set("remaining", static_cast<int>(remaining_samples));
- FireWebUIListener("security-keys-bio-enroll-status",
- base::Value(std::move(d)));
+ FireWebUIListener("security-keys-bio-enroll-status", d);
}
void SecurityKeysBioEnrollmentHandler::OnEnrollmentFinished(
@@ -893,8 +889,7 @@ void SecurityKeysBioEnrollmentHandler::OnEnrollmentFinished(
base::Value::Dict d;
d.Set("code", static_cast<int>(code));
d.Set("remaining", 0);
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(d)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), d);
return;
}
if (code != device::CtapDeviceResponseCode::kSuccess) {
@@ -924,8 +919,7 @@ void SecurityKeysBioEnrollmentHandler::OnHavePostEnrollmentEnumeration(
d.Set("remaining", 0);
d.Set("enrollment", EncodeEnrollment(enrolled_template_id,
(*enrollments)[enrolled_template_id]));
- ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(d)));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)), d);
}
void SecurityKeysBioEnrollmentHandler::HandleDelete(
@@ -1112,7 +1106,138 @@ void SecurityKeysPhonesHandler::DoEnumerate(const base::Value& callback_id) {
result.Append(std::move(synced));
result.Append(std::move(linked));
- ResolveJavascriptCallback(callback_id, base::Value(std::move(result)));
+ ResolveJavascriptCallback(callback_id, result);
+}
+
+#if BUILDFLAG(IS_WIN)
+
+PasskeysHandler::PasskeysHandler() = default;
+PasskeysHandler::~PasskeysHandler() = default;
+
+void PasskeysHandler::OnJavascriptAllowed() {}
+void PasskeysHandler::OnJavascriptDisallowed() {}
+
+void PasskeysHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "passkeysHasPasskeys",
+ base::BindRepeating(&PasskeysHandler::HandleHasPasskeys,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "passkeysEnumerate",
+ base::BindRepeating(&PasskeysHandler::HandleEnumerate,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "passkeysDelete", base::BindRepeating(&PasskeysHandler::HandleDelete,
+ base::Unretained(this)));
+}
+
+void PasskeysHandler::HandleHasPasskeys(const base::Value::List& args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(1u, args.size());
+
+ AllowJavascript();
+ auto local_cred_man = std::make_unique<LocalCredentialManagement>(
+ device::WinWebAuthnApi::GetDefault());
+ local_cred_man->HasCredentials(
+ Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext()),
+ base::BindOnce(&PasskeysHandler::OnHasPasskeysComplete,
+ weak_factory_.GetWeakPtr(), args[0].GetString(),
+ std::move(local_cred_man)));
+}
+
+void PasskeysHandler::OnHasPasskeysComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ bool has_passkeys) {
+ ResolveJavascriptCallback(base::Value(std::move(callback_id)),
+ base::Value(has_passkeys));
+}
+
+void PasskeysHandler::HandleEnumerate(const base::Value::List& args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(1u, args.size());
+
+ AllowJavascript();
+ DoEnumerate(args[0].GetString());
+}
+
+void PasskeysHandler::DoEnumerate(std::string callback_id) {
+ auto local_cred_man = std::make_unique<LocalCredentialManagement>(
+ device::WinWebAuthnApi::GetDefault());
+ local_cred_man->Enumerate(
+ Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext()),
+ base::BindOnce(&PasskeysHandler::OnEnumerateComplete,
+ weak_factory_.GetWeakPtr(), std::move(callback_id),
+ std::move(local_cred_man)));
+}
+
+void PasskeysHandler::OnEnumerateComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ absl::optional<std::vector<device::DiscoverableCredentialMetadata>>
+ credentials) {
+ base::Value result;
+
+ if (credentials.has_value()) {
+ base::Value::List passkeys;
+ for (const auto& cred : *credentials) {
+ // RP IDs with colons in them are assumed to be URLs and thus for
+ // protocols like SSH. In order to avoid confusing the UI, these are
+ // filtered out.
+ if (cred.rp_id.find(':') != std::string::npos) {
+ continue;
+ }
+
+ base::Value::Dict passkey;
+ passkey.Set("relyingPartyId", cred.rp_id);
+ passkey.Set("userName", cred.user.name.value_or(""));
+ passkey.Set("userDisplayName", cred.user.display_name.value_or(""));
+ passkey.Set("credentialId", base::HexEncode(cred.cred_id));
+ passkeys.Append(std::move(passkey));
+ }
+
+ result = base::Value(std::move(passkeys));
+ }
+
+ ResolveJavascriptCallback(base::Value(std::move(callback_id)), result);
}
+void PasskeysHandler::HandleDelete(const base::Value::List& args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(2u, args.size());
+
+ std::vector<uint8_t> credential_id;
+ const bool ok = base::HexStringToBytes(args[1].GetString(), &credential_id);
+ DCHECK(ok);
+
+ auto local_cred_man = std::make_unique<LocalCredentialManagement>(
+ device::WinWebAuthnApi::GetDefault());
+ local_cred_man->Delete(
+ Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext()),
+ credential_id,
+ base::BindOnce(&PasskeysHandler::OnDeleteComplete,
+ weak_factory_.GetWeakPtr(), args[0].GetString(),
+ std::move(local_cred_man)));
+}
+
+void PasskeysHandler::OnDeleteComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ bool ok) {
+ if (!ok) {
+ // Windows failed to delete the passkey. This can happen if API support is
+ // missing but no passkeys will be shown at all in that case so that should
+ // be impossible. It can also happen if the user attempts to delete a
+ // system-created credential. In this case the Javascript will notice that
+ // the credential didn't disappear and will show an error message.
+ }
+
+ DoEnumerate(std::move(callback_id));
+}
+
+#endif
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h
index ce33e5c355d..276f493a190 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h
@@ -10,6 +10,7 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "device/fido/bio/enrollment.h"
#include "device/fido/bio/enrollment_handler.h"
@@ -25,6 +26,8 @@ class SetPINRequestHandler;
class ResetRequestHandler;
} // namespace device
+class LocalCredentialManagement;
+
namespace settings {
// Base class for message handlers on the "Security Keys" settings subpage.
@@ -267,6 +270,44 @@ class SecurityKeysPhonesHandler : public SettingsPageUIHandler {
void DoEnumerate(const base::Value& callback_id);
};
+#if BUILDFLAG(IS_WIN)
+
+class PasskeysHandler : public SettingsPageUIHandler {
+ public:
+ PasskeysHandler();
+ ~PasskeysHandler() override;
+
+ protected:
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ void HandleHasPasskeys(const base::Value::List& args);
+ void OnHasPasskeysComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ bool has_passkeys);
+
+ void HandleEnumerate(const base::Value::List& args);
+ void DoEnumerate(std::string callback_id);
+ void OnEnumerateComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ absl::optional<std::vector<device::DiscoverableCredentialMetadata>>
+ credentials);
+
+ void HandleDelete(const base::Value::List& args);
+ void OnDeleteComplete(
+ std::string callback_id,
+ std::unique_ptr<LocalCredentialManagement> local_cred_man,
+ bool delete_ok);
+
+ base::WeakPtrFactory<PasskeysHandler> weak_factory_{this};
+};
+
+#endif
+
} // namespace settings
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_SECURITY_KEY_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
index ee56cf9d106..0fed80bfe3a 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc
@@ -77,14 +77,14 @@ void StartupPagesHandler::OnJavascriptDisallowed() {
void StartupPagesHandler::OnModelChanged() {
base::Value::List startup_pages;
- int page_count = startup_custom_pages_table_model_.RowCount();
+ size_t page_count = startup_custom_pages_table_model_.RowCount();
std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs();
- for (int i = 0; i < page_count; ++i) {
+ for (size_t i = 0; i < page_count; ++i) {
base::Value::Dict entry;
entry.Set("title", startup_custom_pages_table_model_.GetText(i, 0));
entry.Set("url", urls[i].spec());
entry.Set("tooltip", startup_custom_pages_table_model_.GetTooltip(i));
- entry.Set("modelIndex", i);
+ entry.Set("modelIndex", base::checked_cast<int>(i));
startup_pages.Append(std::move(entry));
}
@@ -92,15 +92,15 @@ void StartupPagesHandler::OnModelChanged() {
base::Value(std::move(startup_pages)));
}
-void StartupPagesHandler::OnItemsChanged(int start, int length) {
+void StartupPagesHandler::OnItemsChanged(size_t start, size_t length) {
OnModelChanged();
}
-void StartupPagesHandler::OnItemsAdded(int start, int length) {
+void StartupPagesHandler::OnItemsAdded(size_t start, size_t length) {
OnModelChanged();
}
-void StartupPagesHandler::OnItemsRemoved(int start, int length) {
+void StartupPagesHandler::OnItemsRemoved(size_t start, size_t length) {
OnModelChanged();
}
@@ -132,7 +132,8 @@ void StartupPagesHandler::HandleEditStartupPage(const base::Value::List& args) {
const base::Value& callback_id = args[0];
int index = args[1].GetInt();
- if (index < 0 || index >= startup_custom_pages_table_model_.RowCount()) {
+ if (index < 0 || static_cast<size_t>(index) >=
+ startup_custom_pages_table_model_.RowCount()) {
RejectJavascriptCallback(callback_id, base::Value());
NOTREACHED();
return;
@@ -166,8 +167,8 @@ void StartupPagesHandler::HandleRemoveStartupPage(
}
int selected_index = args[0].GetInt();
- if (selected_index < 0 ||
- selected_index >= startup_custom_pages_table_model_.RowCount()) {
+ if (selected_index < 0 || static_cast<size_t>(selected_index) >=
+ startup_custom_pages_table_model_.RowCount()) {
NOTREACHED();
return;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.h
index b5f30b53e44..2dd7343d74d 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.h
@@ -34,9 +34,9 @@ class StartupPagesHandler : public SettingsPageUIHandler,
// ui::TableModelObserver:
void OnModelChanged() override;
- void OnItemsChanged(int start, int length) override;
- void OnItemsAdded(int start, int length) override;
- void OnItemsRemoved(int start, int length) override;
+ void OnItemsChanged(size_t start, size_t length) override;
+ void OnItemsAdded(size_t start, size_t length) override;
+ void OnItemsRemoved(size_t start, size_t length) override;
private:
// Adds a startup page with the given URL after the given index.
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
index 13f66230dae..304c914ed57 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/ui/webui/settings/about_handler.h"
#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h"
#include "chrome/browser/ui/webui/settings/appearance_handler.h"
+#include "chrome/browser/ui/webui/settings/autofill_assistant_handler.h"
#include "chrome/browser/ui/webui/settings/browser_lifetime_handler.h"
#include "chrome/browser/ui/webui/settings/downloads_handler.h"
#include "chrome/browser/ui/webui/settings/extension_control_handler.h"
@@ -62,6 +63,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/settings_resources.h"
#include "chrome/grit/settings_resources_map.h"
@@ -72,7 +74,6 @@
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/signin/public/base/signin_pref_names.h"
-#include "components/signin/public/base/signin_switches.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -95,12 +96,11 @@
#include "chrome/browser/ui/webui/settings/languages_handler.h"
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
-#if !BUILDFLAG(IS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/language/core/common/language_experiments.h"
-#endif // !BUILDFLAG(IS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
-#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/components/arc/arc_util.h"
#include "ash/components/login/auth/password_visibility_utils.h"
#include "ash/components/phonehub/phone_hub_manager.h"
@@ -117,12 +117,12 @@
#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/ui/webui/certificate_provisioning_ui_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/browser_resources.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
#include "components/user_manager/user.h"
@@ -136,6 +136,10 @@
#include "chrome/browser/ui/webui/settings/system_handler.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
+#include "chrome/browser/ui/webui/certificate_provisioning_ui_handler.h"
+#endif // BUILDFLAG(IS_CHROMEOS)
+
#if BUILDFLAG(USE_NSS_CERTS)
#include "chrome/browser/ui/webui/certificates_handler.h"
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
@@ -179,11 +183,11 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
AddSettingsPageUIHandler(std::make_unique<NativeCertificatesHandler>());
#endif // BUILDFLAG(USE_NSS_CERTS)
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
AddSettingsPageUIHandler(
chromeos::cert_provisioning::CertificateProvisioningUiHandler::
CreateForProfile(profile));
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // BUILDFLAG(IS_CHROMEOS)
AddSettingsPageUIHandler(std::make_unique<AccessibilityMainHandler>());
AddSettingsPageUIHandler(std::make_unique<BrowserLifetimeHandler>());
@@ -225,6 +229,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
std::make_unique<SecurityKeysBioEnrollmentHandler>());
AddSettingsPageUIHandler(std::make_unique<SecurityKeysPhonesHandler>());
+#if BUILDFLAG(IS_WIN)
+ AddSettingsPageUIHandler(std::make_unique<PasskeysHandler>());
+#endif
+
#if BUILDFLAG(IS_CHROMEOS_ASH)
InitBrowserSettingsWebUIHandlers();
#else
@@ -235,9 +243,6 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(std::make_unique<SystemHandler>());
#if BUILDFLAG(IS_CHROMEOS_LACROS)
html_source->AddBoolean("isSecondaryUser", !profile->IsMainProfile());
- html_source->AddBoolean(
- "nonSyncingProfilesEnabled",
- base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles));
#endif
#endif
@@ -286,18 +291,23 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
"enableSendPasswords",
base::FeatureList::IsEnabled(password_manager::features::kSendPasswords));
- // Autofill Assistant on Desktop is currently used only by password change.
- // As soon as it becomes more widely used, this condition needs to be
- // adjusted.
+ // Indicates whether any automated password change entry point is enabled.
+ // This is currently used as a prerequisite for showing a settings toggle
+ // for Autofill Assistant.
html_source->AddBoolean(
- "enableAutofillAssistant",
+ "isAutomatedPasswordChangeEnabled",
password_manager::features::IsAutomatedPasswordChangeEnabled());
-#if !BUILDFLAG(IS_CHROMEOS)
+ html_source->AddBoolean(
+ "enableAutomaticPasswordChangeInSettings",
+ base::FeatureList::IsEnabled(
+ password_manager::features::kPasswordChangeInSettings));
+
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddBoolean(
"enableDesktopDetailedLanguageSettings",
base::FeatureList::IsEnabled(language::kDesktopDetailedLanguageSettings));
-#endif // !BUILDFLAG(IS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddBoolean(
@@ -323,16 +333,9 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("userCannotManuallyEnterPassword", false);
#endif // !BUILDFLAG(IS_CHROMEOS_LACROS)
- bool privacy_guide_enabled =
- !chrome::ShouldDisplayManagedUi(profile) && !profile->IsChild() &&
- base::FeatureList::IsEnabled(features::kPrivacyGuide);
- html_source->AddBoolean("privacyGuideEnabled", privacy_guide_enabled);
-
html_source->AddBoolean(
"privacyGuide2Enabled",
- // #privacy-guide-2 only has effect if #privacy-guide is enabled too.
- privacy_guide_enabled &&
- base::FeatureList::IsEnabled(features::kPrivacyGuide2));
+ base::FeatureList::IsEnabled(features::kPrivacyGuide2));
AddSettingsPageUIHandler(std::make_unique<AboutHandler>(profile));
AddSettingsPageUIHandler(std::make_unique<ResetSettingsHandler>(profile));
@@ -355,10 +358,21 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT_SHORT);
plural_string_handler->AddLocalizedString(
"safetyCheckPasswordsWeak", IDS_SETTINGS_WEAK_PASSWORDS_COUNT_SHORT);
+ plural_string_handler->AddLocalizedString(
+ "importPasswordsSuccessSummaryDevice",
+ IDS_SETTINGS_PASSWORDS_IMPORT_SUCCESS_SUMMARY_DEVICE);
+ plural_string_handler->AddLocalizedString(
+ "importPasswordsSuccessSummaryAccount",
+ IDS_SETTINGS_PASSWORDS_IMPORT_SUCCESS_SUMMARY_ACCOUNT);
web_ui->AddMessageHandler(std::move(plural_string_handler));
// Add the metrics handler to write uma stats.
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
+ // Add the handler for personalization options, e.g. Autofill Assistant
+ // consent.
+ web_ui->AddMessageHandler(std::make_unique<AutofillAssistantHandler>(
+ std::vector<int>{IDS_SETTINGS_AUTOFILL_ASSISTANT_PREF,
+ IDS_SETTINGS_AUTOFILL_ASSISTANT_PREF_DESC}));
webui::SetupWebUIDataSource(
html_source, base::make_span(kSettingsResources, kSettingsResourcesSize),
@@ -386,6 +400,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
"privacySandbox", IDR_SETTINGS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_HTML);
}
+ html_source->AddBoolean(
+ "safetyCheckPermissionsEnabled",
+ base::FeatureList::IsEnabled(features::kSafetyCheckPermissions));
+
TryShowHatsSurveyWithTimeout();
}
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_utils.cc b/chromium/chrome/browser/ui/webui/settings/settings_utils.cc
index 5e88ce140dd..6b39bf89570 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_utils.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils.cc
@@ -4,13 +4,11 @@
#include "chrome/browser/ui/webui/settings/settings_utils.h"
-#include "build/build_config.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/grit/theme_resources.h"
#include "components/grit/components_scaled_resources.h"
#include "components/url_formatter/url_fixer.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/font_list.h"
#include "url/gurl.h"
namespace settings_utils {
@@ -36,16 +34,4 @@ base::RefCountedMemory* GetPrivacySandboxFaviconResourceBytes(
IDR_FLAGS_FAVICON, scale_factor);
}
-std::string ResolveFontList(const std::string& font_name_or_list) {
- if (!font_name_or_list.empty() && font_name_or_list[0] == ',')
- return gfx::FontList::FirstAvailableOrFirst(font_name_or_list);
- return font_name_or_list;
-}
-
-#if !BUILDFLAG(IS_WIN)
-std::string MaybeGetLocalizedFontName(const std::string& font_name_or_list) {
- return ResolveFontList(font_name_or_list);
-}
-#endif
-
} // namespace settings_utils
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_utils.h b/chromium/chrome/browser/ui/webui/settings/settings_utils.h
index 4b4a930a3e4..fe9c668b74d 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_utils.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils.h
@@ -45,13 +45,6 @@ base::RefCountedMemory* GetPrivacySandboxFaviconResourceBytes(
void ValidateSavedFonts(PrefService* prefs);
#endif
-// When |font_name_or_list| starts with ",", it is a list of font names
-// separated by "," and this function returns the first available font name.
-// Otherwise returns |font_name_or_list| as is.
-// Unlike gfx::FontList, this function picks one font, and character-level
-// fallback is handled in CSS.
-std::string ResolveFontList(const std::string& font_name_or_list);
-
} // namespace settings_utils
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UTILS_H_
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 600283a3623..b129f4c7f5c 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
@@ -41,7 +41,7 @@
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
-#include "chromeos/startup/browser_init_params.h"
+#include "chromeos/startup/browser_params_proxy.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
@@ -78,8 +78,7 @@ bool ShouldShowLacrosSideBySideWarningInAsh() {
bool ShouldShowLacrosSideBySideWarningInLacros() {
return base::FeatureList::IsEnabled(
syncer::kSyncSettingsShowLacrosSideBySideWarning) &&
- !chromeos::BrowserInitParams::Get()
- ->standalone_browser_is_only_browser;
+ !chromeos::BrowserParamsProxy::Get()->StandaloneBrowserIsOnlyBrowser();
}
#endif
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 d315f397620..97b0829664b 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -11,6 +11,7 @@
#include "base/barrier_closure.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
@@ -29,6 +30,8 @@
#include "chrome/browser/hid/hid_chooser_context_factory.h"
#include "chrome/browser/media/unified_autoplay_config.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h"
#include "chrome/browser/serial/serial_chooser_context.h"
#include "chrome/browser/serial/serial_chooser_context_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -98,6 +101,7 @@ constexpr char kNumCookies[] = "numCookies";
constexpr char kHasPermissionSettings[] = "hasPermissionSettings";
constexpr char kHasInstalledPWA[] = "hasInstalledPWA";
constexpr char kIsInstalled[] = "isInstalled";
+constexpr char kFpsOwner[] = "fpsOwner";
constexpr char kZoom[] = "zoom";
// Placeholder value for ETLD+1 until a valid origin is added. If an ETLD+1
// only has placeholder, then create an ETLD+1 origin.
@@ -141,7 +145,7 @@ APIPermissionID APIPermissionFromGroupName(std::string type) {
// adds their web extent and launch URL to the |exceptions| list.
void AddExceptionsGrantedByHostedApps(content::BrowserContext* context,
APIPermissionID permission,
- base::ListValue* exceptions) {
+ base::Value::List* exceptions) {
const extensions::ExtensionSet& extensions =
extensions::ExtensionRegistry::Get(context)->enabled_extensions();
for (extensions::ExtensionSet::const_iterator extension = extensions.begin();
@@ -260,63 +264,70 @@ void UpdateDataForOrigin(const GURL& url,
}
// Converts |etld_plus1| into an origin representation by adding HTTP scheme.
-std::string ConvertEtldToOrigin(const std::string etld_plus1) {
- return std::string(url::kHttpScheme) + url::kStandardSchemeSeparator +
- etld_plus1 + "/";
+std::string ConvertEtldToOrigin(const std::string etld_plus1, bool secure) {
+ return std::string(secure ? url::kHttpsScheme : url::kHttpScheme) +
+ url::kStandardSchemeSeparator + etld_plus1 + "/";
}
-// Converts a given |site_group_map| to a list of base::DictionaryValues, adding
+// Converts a given |site_group_map| to a list of base::Value::Dicts, adding
// the site engagement score for each origin.
-void ConvertSiteGroupMapToListValue(
+void ConvertSiteGroupMapToList(
const std::map<std::string, std::set<std::pair<std::string, bool>>>&
site_group_map,
const std::set<std::string>& origin_permission_set,
- base::Value* list_value,
+ base::Value::List* list_value,
Profile* profile) {
- DCHECK_EQ(base::Value::Type::LIST, list_value->type());
DCHECK(profile);
+ auto* privacy_sandbox_service =
+ PrivacySandboxServiceFactory::GetForProfile(profile);
+ auto first_party_sets = privacy_sandbox_service->GetFirstPartySets();
base::flat_set<std::string> installed_origins =
GetInstalledAppOrigins(profile);
site_engagement::SiteEngagementService* engagement_service =
site_engagement::SiteEngagementService::Get(profile);
for (const auto& entry : site_group_map) {
// eTLD+1 is the effective top level domain + 1.
- base::Value site_group(base::Value::Type::DICTIONARY);
- site_group.SetKey(kEffectiveTopLevelDomainPlus1Name,
- base::Value(entry.first));
+ base::Value::Dict site_group;
+ site_group.Set(kEffectiveTopLevelDomainPlus1Name, entry.first);
bool has_installed_pwa = false;
- base::Value origin_list(base::Value::Type::LIST);
+ base::Value::List origin_list;
for (const auto& origin_is_partitioned : entry.second) {
const auto& origin = origin_is_partitioned.first;
bool is_partitioned = origin_is_partitioned.second;
- base::Value origin_object(base::Value::Type::DICTIONARY);
+ base::Value::Dict origin_object;
// If origin is placeholder, create a http ETLD+1 origin for it.
if (origin == kPlaceholder) {
- origin_object.SetKey("origin",
- base::Value(ConvertEtldToOrigin(entry.first)));
+ origin_object.Set("origin",
+ ConvertEtldToOrigin(entry.first, /*secure=*/false));
} else {
- origin_object.SetKey("origin", base::Value(origin));
+ origin_object.Set("origin", origin);
}
- origin_object.SetKey("isPartitioned", base::Value(is_partitioned));
- origin_object.SetKey(
- "engagement",
- base::Value(engagement_service->GetScore(GURL(origin))));
- origin_object.SetKey("usage", base::Value(0));
- origin_object.SetKey(kNumCookies, base::Value(0));
+ origin_object.Set("isPartitioned", is_partitioned);
+ origin_object.Set("engagement",
+ engagement_service->GetScore(GURL(origin)));
+ origin_object.Set("usage", 0);
+ origin_object.Set(kNumCookies, 0);
bool is_installed = installed_origins.contains(origin);
if (is_installed)
has_installed_pwa = true;
- origin_object.SetKey(kIsInstalled, base::Value(is_installed));
+ origin_object.Set(kIsInstalled, is_installed);
- origin_object.SetKey(
- kHasPermissionSettings,
- base::Value(base::Contains(origin_permission_set, origin)));
+ origin_object.Set(kHasPermissionSettings,
+ base::Contains(origin_permission_set, origin));
origin_list.Append(std::move(origin_object));
}
- site_group.SetKey(kHasInstalledPWA, base::Value(has_installed_pwa));
- site_group.SetKey(kNumCookies, base::Value(0));
- site_group.SetKey(kOriginList, std::move(origin_list));
+ site_group.Set(kHasInstalledPWA, has_installed_pwa);
+ site_group.Set(kNumCookies, 0);
+ site_group.Set(kOriginList, std::move(origin_list));
+ if (first_party_sets.size()) {
+ auto site = net::SchemefulSite(
+ GURL(ConvertEtldToOrigin(entry.first, /*secure=*/true)));
+
+ if (first_party_sets.count(site)) {
+ site_group.Set(kFpsOwner, (first_party_sets)[site].Serialize());
+ }
+ }
list_value->Append(std::move(site_group));
}
}
@@ -896,7 +907,7 @@ void SiteSettingsHandler::HandleGetDefaultValueForContentType(
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(profile_);
- base::DictionaryValue category;
+ base::Value::Dict category;
site_settings::GetContentCategorySetting(map, content_type, &category);
ResolveJavascriptCallback(callback_id, category);
}
@@ -956,11 +967,11 @@ void SiteSettingsHandler::HandleGetAllSites(const base::Value::List& args) {
cookies_tree_model_.reset();
EnsureCookiesTreeModelCreated();
- base::Value result(base::Value::Type::LIST);
+ base::Value::List result;
// Respond with currently available data.
- ConvertSiteGroupMapToListValue(all_sites_map_, origin_permission_set_,
- &result, profile);
+ ConvertSiteGroupMapToList(all_sites_map_, origin_permission_set_, &result,
+ profile);
LogAllSitesAction(AllSitesAction2::kLoadPage);
@@ -976,7 +987,7 @@ void SiteSettingsHandler::HandleGetCategoryList(const base::Value::List& args) {
std::string callback_id = args[0].GetString();
GURL origin(args[1].GetString());
- base::Value result(base::Value::Type::LIST);
+ base::Value::List result;
for (ContentSettingsType content_type :
site_settings::GetVisiblePermissionCategories()) {
result.Append(site_settings::ContentSettingsTypeToGroupName(content_type));
@@ -1008,56 +1019,56 @@ void SiteSettingsHandler::HandleGetRecentSitePermissions(
profile_, content_types, max_sources);
// Convert groups of TimestampedPermissions for consumption by JS
- base::Value result(base::Value::Type::LIST);
+ base::Value::List result;
for (const auto& site_permissions : recent_site_permissions) {
DCHECK(!site_permissions.settings.empty());
- base::Value recent_site(base::Value::Type::DICTIONARY);
- recent_site.SetKey(site_settings::kOrigin,
- base::Value(site_permissions.origin.spec()));
- recent_site.SetKey(site_settings::kIncognito,
- base::Value(site_permissions.incognito));
+ base::Value::Dict recent_site;
+ recent_site.Set(site_settings::kOrigin, site_permissions.origin.spec());
+ recent_site.Set(site_settings::kIncognito, site_permissions.incognito);
- base::Value permissions_list(base::Value::Type::LIST);
+ base::Value::List permissions_list;
for (const auto& p : site_permissions.settings) {
- base::Value recent_permission(base::Value::Type::DICTIONARY);
- recent_permission.SetKey(
+ base::Value::Dict recent_permission;
+ recent_permission.Set(
site_settings::kType,
- base::Value(
- site_settings::ContentSettingsTypeToGroupName(p.content_type)));
- recent_permission.SetKey(
+
+ site_settings::ContentSettingsTypeToGroupName(p.content_type));
+ recent_permission.Set(
site_settings::kSetting,
- base::Value(
- content_settings::ContentSettingToString(p.content_setting)));
- recent_permission.SetKey(
+
+ content_settings::ContentSettingToString(p.content_setting));
+ recent_permission.Set(
site_settings::kSource,
- base::Value(
- site_settings::SiteSettingSourceToString(p.setting_source)));
+
+ site_settings::SiteSettingSourceToString(p.setting_source));
permissions_list.Append(std::move(recent_permission));
}
- recent_site.SetKey(site_settings::kRecentPermissions,
- std::move(permissions_list));
+ recent_site.Set(site_settings::kRecentPermissions,
+ std::move(permissions_list));
result.Append(std::move(recent_site));
}
ResolveJavascriptCallback(base::Value(callback_id), result);
}
-base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
+base::Value::List SiteSettingsHandler::PopulateCookiesAndUsageData(
+ Profile* profile) {
std::map<std::string, int64_t> origin_size_map;
std::map<std::pair<std::string, absl::optional<std::string>>, int>
origin_cookie_map;
- base::Value list_value(base::Value::Type::LIST);
+ base::Value::List list_value;
GetOriginStorage(&all_sites_map_, &origin_size_map);
GetOriginCookies(&all_sites_map_, &origin_cookie_map);
- ConvertSiteGroupMapToListValue(all_sites_map_, origin_permission_set_,
- &list_value, profile);
+ ConvertSiteGroupMapToList(all_sites_map_, origin_permission_set_, &list_value,
+ profile);
// Merge the origin usage and cookies number into |list_value|.
- for (base::Value& site_group : list_value.GetListDeprecated()) {
- base::Value* origin_list = site_group.FindKey(kOriginList);
+ for (base::Value& item : list_value) {
+ base::Value::Dict& site_group = item.GetDict();
+ base::Value::List& origin_list = *site_group.FindList(kOriginList);
int cookie_num = 0;
const std::string& etld_plus1 =
- site_group.FindKey(kEffectiveTopLevelDomainPlus1Name)->GetString();
+ *site_group.FindString(kEffectiveTopLevelDomainPlus1Name);
const auto& etld_plus1_cookie_num_it =
origin_cookie_map.find({etld_plus1, absl::nullopt});
// Add the number of eTLD+1 scoped cookies.
@@ -1065,30 +1076,30 @@ base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
cookie_num = etld_plus1_cookie_num_it->second;
// Iterate over the origins for the ETLD+1, and set their usage and cookie
// numbers.
- for (base::Value& origin_info : origin_list->GetListDeprecated()) {
- const std::string& origin = origin_info.FindKey("origin")->GetString();
- bool is_partitioned = origin_info.FindKey("isPartitioned")->GetBool();
+ for (base::Value& value : origin_list) {
+ base::Value::Dict& origin_info = value.GetDict();
+ const std::string* origin = origin_info.FindString("origin");
+ bool is_partitioned =
+ origin_info.FindBool("isPartitioned").value_or(false);
if (!is_partitioned) {
// Only unpartitioned storage has a size.
- const auto& size_info_it = origin_size_map.find(origin);
+ const auto& size_info_it = origin_size_map.find(*origin);
if (size_info_it != origin_size_map.end())
- origin_info.SetKey(
- "usage", base::Value(static_cast<double>(size_info_it->second)));
+ origin_info.Set("usage", static_cast<double>(size_info_it->second));
}
- GURL origin_url(origin);
+ GURL origin_url(*origin);
const auto& origin_cookie_num_it = origin_cookie_map.find(
{origin_url.host(),
(is_partitioned ? absl::optional<std::string>(etld_plus1)
: absl::nullopt)});
if (origin_cookie_num_it != origin_cookie_map.end()) {
- origin_info.SetKey(kNumCookies,
- base::Value(origin_cookie_num_it->second));
+ origin_info.Set(kNumCookies, origin_cookie_num_it->second);
// Add cookies numbers for origins that isn't an eTLD+1.
if (origin_url.host() != etld_plus1 || is_partitioned)
cookie_num += origin_cookie_num_it->second;
}
}
- site_group.SetKey(kNumCookies, base::Value(cookie_num));
+ site_group.Set(kNumCookies, cookie_num);
}
return list_value;
}
@@ -1118,14 +1129,14 @@ void SiteSettingsHandler::HandleGetExceptionList(
ContentSettingsType content_type =
site_settings::ContentSettingsTypeFromGroupName(type);
- std::unique_ptr<base::ListValue> exceptions(new base::ListValue);
+ base::Value::List exceptions;
const auto* extension_registry = extensions::ExtensionRegistry::Get(profile_);
AddExceptionsGrantedByHostedApps(profile_, APIPermissionFromGroupName(type),
- exceptions.get());
- site_settings::GetExceptionsForContentType(
- content_type, profile_, extension_registry, web_ui(), /*incognito=*/false,
- exceptions.get());
+ &exceptions);
+ site_settings::GetExceptionsForContentType(content_type, profile_,
+ extension_registry, web_ui(),
+ /*incognito=*/false, &exceptions);
Profile* incognito =
profile_->HasPrimaryOTRProfile()
@@ -1135,12 +1146,12 @@ void SiteSettingsHandler::HandleGetExceptionList(
// so do not fetch an extra copy of the same exceptions.
if (incognito && incognito != profile_) {
extension_registry = extensions::ExtensionRegistry::Get(incognito);
- site_settings::GetExceptionsForContentType(
- content_type, incognito, extension_registry, web_ui(),
- /*incognito=*/true, exceptions.get());
+ site_settings::GetExceptionsForContentType(content_type, incognito,
+ extension_registry, web_ui(),
+ /*incognito=*/true, &exceptions);
}
- ResolveJavascriptCallback(callback_id, *exceptions.get());
+ ResolveJavascriptCallback(callback_id, exceptions);
}
void SiteSettingsHandler::HandleGetChooserExceptionList(
@@ -1154,9 +1165,10 @@ void SiteSettingsHandler::HandleGetChooserExceptionList(
site_settings::ChooserTypeFromGroupName(type);
CHECK(chooser_type);
- base::Value exceptions = site_settings::GetChooserExceptionListFromProfile(
- profile_, *chooser_type);
- ResolveJavascriptCallback(callback_id, std::move(exceptions));
+ base::Value::List exceptions =
+ site_settings::GetChooserExceptionListFromProfile(profile_,
+ *chooser_type);
+ ResolveJavascriptCallback(callback_id, exceptions);
}
void SiteSettingsHandler::HandleGetOriginPermissions(
@@ -1166,11 +1178,11 @@ void SiteSettingsHandler::HandleGetOriginPermissions(
CHECK_EQ(3U, args.size());
const base::Value& callback_id = args[0];
std::string origin = args[1].GetString();
- base::Value::ConstListView types = args[2].GetListDeprecated();
+ const base::Value::List& types = args[2].GetList();
// Note: Invalid URLs will just result in default settings being shown.
const GURL origin_url(origin);
- base::Value exceptions(base::Value::Type::LIST);
+ base::Value::List exceptions;
for (const auto& type_val : types) {
std::string type;
DCHECK(type_val.is_string());
@@ -1191,15 +1203,14 @@ void SiteSettingsHandler::HandleGetOriginPermissions(
std::string content_setting_string =
content_settings::ContentSettingToString(content_setting);
- base::Value raw_site_exception(base::Value::Type::DICTIONARY);
- raw_site_exception.SetStringKey(site_settings::kEmbeddingOrigin, origin);
- raw_site_exception.SetBoolKey(site_settings::kIncognito,
- profile_->IsOffTheRecord());
- raw_site_exception.SetStringKey(site_settings::kOrigin, origin);
- raw_site_exception.SetStringKey(site_settings::kDisplayName, display_name);
- raw_site_exception.SetStringKey(site_settings::kSetting,
- content_setting_string);
- raw_site_exception.SetStringKey(site_settings::kSource, source_string);
+ base::Value::Dict raw_site_exception;
+ raw_site_exception.Set(site_settings::kEmbeddingOrigin, origin);
+ raw_site_exception.Set(site_settings::kIncognito,
+ profile_->IsOffTheRecord());
+ raw_site_exception.Set(site_settings::kOrigin, origin);
+ raw_site_exception.Set(site_settings::kDisplayName, display_name);
+ raw_site_exception.Set(site_settings::kSetting, content_setting_string);
+ raw_site_exception.Set(site_settings::kSource, source_string);
exceptions.Append(std::move(raw_site_exception));
}
@@ -1345,17 +1356,17 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForPattern(
ContentSetting setting;
CHECK(content_settings::ContentSettingFromString(value, &setting));
- Profile* profile = nullptr;
+ Profile* target_profile = nullptr;
if (incognito) {
if (!profile_->HasPrimaryOTRProfile())
return;
- profile = profile_->GetPrimaryOTRProfile(/*create_if_needed=*/true);
+ target_profile = profile_->GetPrimaryOTRProfile(/*create_if_needed=*/true);
} else {
- profile = profile_;
+ target_profile = profile_;
}
HostContentSettingsMap* map =
- HostContentSettingsMapFactory::GetForProfile(profile);
+ HostContentSettingsMapFactory::GetForProfile(target_profile);
ContentSettingsPattern primary_pattern =
ContentSettingsPattern::FromString(primary_pattern_string);
@@ -1368,14 +1379,14 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForPattern(
if (setting != CONTENT_SETTING_BLOCK) {
GURL url(primary_pattern.ToString());
if (url.is_valid()) {
- PermissionDecisionAutoBlockerFactory::GetForProfile(profile_)
+ PermissionDecisionAutoBlockerFactory::GetForProfile(target_profile)
->RemoveEmbargoAndResetCounts(url, content_type);
}
}
permissions::PermissionUmaUtil::ScopedRevocationReporter
scoped_revocation_reporter(
- profile, primary_pattern, secondary_pattern, content_type,
+ target_profile, primary_pattern, secondary_pattern, content_type,
permissions::PermissionSourceUI::SITE_SETTINGS);
map->SetContentSettingCustomScope(primary_pattern, secondary_pattern,
@@ -1442,9 +1453,9 @@ void SiteSettingsHandler::HandleIsPatternValidForType(
bool is_valid =
IsPatternValidForType(pattern_string, type, profile_, &reason);
- base::Value return_value(base::Value::Type::DICTIONARY);
- return_value.SetKey(kIsValidKey, base::Value(is_valid));
- return_value.SetKey(kReasonKey, base::Value(std::move(reason)));
+ base::Value::Dict return_value;
+ return_value.Set(kIsValidKey, base::Value(is_valid));
+ return_value.Set(kReasonKey, base::Value(std::move(reason)));
ResolveJavascriptCallback(callback_id, return_value);
}
@@ -1534,8 +1545,7 @@ void SiteSettingsHandler::SendZoomLevels() {
zoom_levels_exceptions.Append(std::move(exception));
}
- FireWebUIListener("onZoomLevelsChanged",
- base::Value(std::move(zoom_levels_exceptions)));
+ FireWebUIListener("onZoomLevelsChanged", zoom_levels_exceptions);
}
void SiteSettingsHandler::HandleRemoveZoomLevel(const base::Value::List& args) {
@@ -1564,22 +1574,19 @@ void SiteSettingsHandler::SendBlockAutoplayStatus() {
if (!IsJavascriptAllowed())
return;
- base::DictionaryValue status;
+ base::Value::Dict status;
// Whether the block autoplay toggle should be checked.
- base::DictionaryValue pref;
- pref.SetKey(
- "value",
- base::Value(
- UnifiedAutoplayConfig::ShouldBlockAutoplay(profile_) &&
- UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_)));
- status.SetKey("pref", std::move(pref));
+ base::Value::Dict pref;
+ pref.Set("value",
+
+ UnifiedAutoplayConfig::ShouldBlockAutoplay(profile_) &&
+ UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_));
+ status.Set("pref", std::move(pref));
// Whether the block autoplay toggle should be enabled.
- status.SetKey(
- "enabled",
- base::Value(
- UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_)));
+ status.Set("enabled",
+ UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_));
FireWebUIListener("onBlockAutoplayStatusChanged", status);
}
@@ -1601,7 +1608,7 @@ void SiteSettingsHandler::HandleSetBlockAutoplayEnabled(
void SiteSettingsHandler::EnsureCookiesTreeModelCreated() {
if (cookies_tree_model_)
return;
- cookies_tree_model_ = CookiesTreeModel::CreateForProfile(profile_);
+ cookies_tree_model_ = CookiesTreeModel::CreateForProfileDeprecated(profile_);
cookies_tree_model_->AddCookiesTreeObserver(this);
}
@@ -1767,7 +1774,7 @@ void SiteSettingsHandler::HandleClearEtldPlus1DataAndCookies(
// eTLD+1 itself should be converted to an origin, the same as it would
// have been for display.
origin_is_partitioned.first == kPlaceholder
- ? GURL(ConvertEtldToOrigin(etld_plus1))
+ ? GURL(ConvertEtldToOrigin(etld_plus1, /*secure=*/false))
: GURL(origin_is_partitioned.first)));
}
@@ -1803,6 +1810,12 @@ void SiteSettingsHandler::RemoveNonTreeModelData(
->SetWebsiteSettingDefaultScope(origin.GetURL(), GURL(),
ContentSettingsType::CLIENT_HINTS,
base::Value());
+ // Once user clears site setting data for `origins`, all corresponding
+ // reduced accept language stored in the setting map should also be cleaned.
+ HostContentSettingsMapFactory::GetForProfile(profile_)
+ ->SetWebsiteSettingDefaultScope(
+ origin.GetURL(), GURL(),
+ ContentSettingsType::REDUCED_ACCEPT_LANGUAGE, base::Value());
}
// Remove Privacy Sandbox API data.
content::BrowsingDataRemover* remover = profile_->GetBrowsingDataRemover();
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 c9fc1a8046a..4e97fbecea3 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -127,6 +127,7 @@ class SiteSettingsHandler
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest,
HandleClearUnpartitionedUsage);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, ClearClientHints);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, ClearReducedAcceptLanguage);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest,
HandleClearPartitionedUsage);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, CookieSettingDescription);
@@ -138,6 +139,7 @@ class SiteSettingsHandler
IncludeWebUISchemesInGetOriginPermissions);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, HandleGetUsageInfo);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, NonTreeModelDeletion);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, FirstPartySetsMembership);
// Creates the CookiesTreeModel if necessary.
void EnsureCookiesTreeModelCreated();
@@ -204,7 +206,7 @@ class SiteSettingsHandler
// Returns a list of sites, grouped by their effective top level domain plus
// 1, with their cookies number and data usage information. This method will
// only be called after HandleGetAllSites is called.
- base::Value PopulateCookiesAndUsageData(Profile* profile);
+ base::Value::List PopulateCookiesAndUsageData(Profile* profile);
// Converts a given number of bytes into a human-readable format, with data
// units.
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 bc01976ce12..606284bc22f 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
@@ -30,6 +30,8 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h"
+#include "chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/settings/site_settings_helper.h"
@@ -58,11 +60,10 @@
#include "components/permissions/permission_decision_auto_blocker.h"
#include "components/permissions/permission_uma_util.h"
#include "components/permissions/test/object_permission_context_base_mock_permission_observer.h"
+#include "components/permissions/test/permission_test_util.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/app_update.h"
-#include "components/services/app_service/public/cpp/features.h"
-#include "components/services/app_service/public/mojom/types.mojom.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/browsing_data_remover.h"
@@ -92,6 +93,8 @@
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#endif
+using ::testing::Return;
+
namespace {
constexpr char kCallbackId[] = "test-callback-id";
@@ -120,6 +123,34 @@ const struct PatternContentTypeTestCase {
{{"http://127.0.0.1", "location"}, {true, ""}}, // Localhost is secure.
{{"http://[::1]", "location"}, {true, ""}}};
+// Converts |etld_plus1| into an HTTPS SchemefulSite.
+net::SchemefulSite ConvertEtldToSchemefulSite(const std::string etld_plus1) {
+ return net::SchemefulSite(GURL(std::string(url::kHttpsScheme) +
+ url::kStandardSchemeSeparator + etld_plus1 +
+ "/"));
+}
+
+// Validates that the list of sites are aligned with the first party sets
+// mapping.
+void ValidateSitesWithFps(
+ const base::Value::List& storage_and_cookie_list,
+ base::flat_map<net::SchemefulSite, net::SchemefulSite>& first_party_sets) {
+ for (const base::Value& site_group : storage_and_cookie_list) {
+ std::string etld_plus1 = *site_group.GetDict().FindString("etldPlus1");
+ auto schemeful_site = ConvertEtldToSchemefulSite(etld_plus1);
+
+ if (first_party_sets.count(schemeful_site)) {
+ // Ensure that the `fpsOwner` is set correctly and aligned with
+ // |first_party_sets| mapping of site group owners.
+ ASSERT_EQ(first_party_sets[schemeful_site].Serialize(),
+ *site_group.GetDict().FindString("fpsOwner"));
+ } else {
+ // The site doesn't have `fpsOwner` set, `FindString` should return null.
+ ASSERT_FALSE(site_group.GetDict().FindString("fpsOwner"));
+ }
+ }
+}
+
apps::AppPtr MakeApp(const std::string& app_id,
apps::AppType app_type,
const std::string& publisher_id,
@@ -140,15 +171,8 @@ void InstallWebApp(Profile* profile, const GURL& start_url) {
MakeApp(web_app::GenerateAppId(/*manifest_id=*/absl::nullopt, start_url),
apps::AppType::kWeb, start_url.spec(), apps::Readiness::kReady,
apps::InstallReason::kSync));
- if (base::FeatureList::IsEnabled(apps::kAppServiceOnAppUpdateWithoutMojom)) {
- cache.OnApps(std::move(deltas), apps::AppType::kWeb,
- /*should_notify_initialized=*/true);
- } else {
- std::vector<apps::mojom::AppPtr> mojom_deltas;
- mojom_deltas.push_back(apps::ConvertAppToMojomApp(deltas[0]));
- cache.OnApps(std::move(mojom_deltas), apps::mojom::AppType::kWeb,
- /*should_notify_initialized=*/true);
- }
+ cache.OnApps(std::move(deltas), apps::AppType::kWeb,
+ /*should_notify_initialized=*/true);
}
} // namespace
@@ -160,10 +184,7 @@ class ContentSettingSourceSetter {
public:
ContentSettingSourceSetter(TestingProfile* profile,
ContentSettingsType content_type)
- : prefs_(profile->GetTestingPrefService()),
- host_content_settings_map_(
- HostContentSettingsMapFactory::GetForProfile(profile)),
- content_type_(content_type) {}
+ : prefs_(profile->GetTestingPrefService()), content_type_(content_type) {}
ContentSettingSourceSetter(const ContentSettingSourceSetter&) = delete;
ContentSettingSourceSetter& operator=(const ContentSettingSourceSetter&) =
delete;
@@ -186,7 +207,6 @@ class ContentSettingSourceSetter {
private:
raw_ptr<sync_preferences::TestingPrefServiceSyncable> prefs_;
- raw_ptr<HostContentSettingsMap> host_content_settings_map_;
ContentSettingsType content_type_;
};
@@ -225,7 +245,14 @@ class SiteSettingsHandlerTest : public testing::Test,
return mock_browsing_topics_service;
}));
- handler_ = std::make_unique<SiteSettingsHandler>(profile_.get());
+ mock_privacy_sandbox_service_ = static_cast<MockPrivacySandboxService*>(
+ PrivacySandboxServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile(), base::BindRepeating(&BuildMockPrivacySandboxService)));
+
+ profile()->SetPermissionControllerDelegate(
+ permissions::GetPermissionControllerDelegate(profile()));
+
+ handler_ = std::make_unique<SiteSettingsHandler>(profile());
handler()->set_web_ui(web_ui());
handler()->AllowJavascript();
// AllowJavascript() adds a callback to create leveldb_env::ChromiumEnv
@@ -250,6 +277,9 @@ class SiteSettingsHandlerTest : public testing::Test,
browsing_topics::MockBrowsingTopicsService* mock_browsing_topics_service() {
return mock_browsing_topics_service_;
}
+ MockPrivacySandboxService* mock_privacy_sandbox_service() {
+ return mock_privacy_sandbox_service_.get();
+ }
void ValidateBlockAutoplay(bool expected_value, bool expected_enabled) {
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -324,9 +354,9 @@ class SiteSettingsHandlerTest : public testing::Test,
ASSERT_TRUE(data.arg2()->GetBool());
ASSERT_TRUE(data.arg3()->is_list());
- EXPECT_EQ(1U, data.arg3()->GetListDeprecated().size());
+ EXPECT_EQ(1U, data.arg3()->GetList().size());
- const base::Value& exception = data.arg3()->GetListDeprecated()[0];
+ const base::Value& exception = data.arg3()->GetList()[0];
ASSERT_TRUE(exception.is_dict());
const std::string* origin = exception.FindStringKey(site_settings::kOrigin);
@@ -369,7 +399,7 @@ class SiteSettingsHandlerTest : public testing::Test,
const base::Value& exceptions = *data.arg3();
ASSERT_TRUE(exceptions.is_list());
- EXPECT_EQ(0U, exceptions.GetListDeprecated().size());
+ EXPECT_TRUE(exceptions.GetList().empty());
}
void ValidatePattern(bool expected_validity,
@@ -424,7 +454,7 @@ class SiteSettingsHandlerTest : public testing::Test,
EXPECT_EQ("onZoomLevelsChanged", data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->is_list());
- base::Value::ConstListView exceptions = data.arg2()->GetListDeprecated();
+ const base::Value::List& exceptions = data.arg2()->GetList();
if (expected_host.empty()) {
EXPECT_EQ(0U, exceptions.size());
} else {
@@ -505,8 +535,7 @@ class SiteSettingsHandlerTest : public testing::Test,
/*quota_helper=*/nullptr,
/*service_worker_helper=*/nullptr,
/*data_shared_worker_helper=*/nullptr,
- /*cache_storage_helper=*/nullptr,
- /*media_license_helper=*/nullptr);
+ /*cache_storage_helper=*/nullptr);
auto mock_cookies_tree_model = std::make_unique<CookiesTreeModel>(
std::move(container), profile()->GetExtensionSpecialStoragePolicy());
@@ -565,11 +594,11 @@ class SiteSettingsHandlerTest : public testing::Test,
std::move(mock_cookies_tree_model));
}
- base::Value::ConstListView GetOnStorageFetchedSentListView() {
+ base::Value::List GetOnStorageFetchedSentList() {
handler()->ClearAllSitesMapForTesting();
handler()->OnStorageFetched();
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- return data.arg2()->GetListDeprecated();
+ return data.arg2()->GetList().Clone();
}
std::vector<CookieTreeNode*> GetHostNodes(GURL url) {
@@ -605,6 +634,7 @@ class SiteSettingsHandlerTest : public testing::Test,
#endif
raw_ptr<browsing_topics::MockBrowsingTopicsService>
mock_browsing_topics_service_;
+ raw_ptr<MockPrivacySandboxService> mock_privacy_sandbox_service_;
};
// True if testing for handle clear unpartitioned usage with HTTPS scheme URL.
@@ -614,35 +644,35 @@ INSTANTIATE_TEST_SUITE_P(All, SiteSettingsHandlerTest, testing::Bool());
TEST_F(SiteSettingsHandlerTest, GetAndSetDefault) {
// Test the JS -> C++ -> JS callback path for getting and setting defaults.
- base::Value get_args(base::Value::Type::LIST);
+ base::Value::List get_args;
get_args.Append(kCallbackId);
get_args.Append(kNotifications);
- handler()->HandleGetDefaultValueForContentType(get_args.GetList());
+ handler()->HandleGetDefaultValueForContentType(get_args);
ValidateDefault(CONTENT_SETTING_ASK,
site_settings::SiteSettingSource::kDefault, 1U);
// Set the default to 'Blocked'.
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(kNotifications);
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
- handler()->HandleSetDefaultValueForContentType(set_args.GetList());
+ handler()->HandleSetDefaultValueForContentType(set_args);
EXPECT_EQ(2U, web_ui()->call_data().size());
// Verify that the default has been set to 'Blocked'.
- handler()->HandleGetDefaultValueForContentType(get_args.GetList());
+ handler()->HandleGetDefaultValueForContentType(get_args);
ValidateDefault(CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kDefault, 3U);
}
// Flaky on CrOS and Linux. https://crbug.com/930481
TEST_F(SiteSettingsHandlerTest, GetAllSites) {
- base::Value get_all_sites_args(base::Value::Type::LIST);
+ base::Value::List get_all_sites_args;
get_all_sites_args.Append(kCallbackId);
// Test all sites is empty when there are no preferences.
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
EXPECT_EQ(1U, web_ui()->call_data().size());
{
@@ -651,8 +681,8 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
- EXPECT_EQ(0UL, site_groups.size());
+ const base::Value::List& site_groups = data.arg3()->GetList();
+ EXPECT_TRUE(site_groups.empty());
}
// Add a couple of exceptions and check they appear in all sites.
@@ -664,7 +694,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
url1, url1, ContentSettingsType::NOTIFICATIONS, CONTENT_SETTING_BLOCK);
map->SetContentSettingDefaultScope(
url2, url2, ContentSettingsType::NOTIFICATIONS, CONTENT_SETTING_ALLOW);
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -672,13 +702,13 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(1UL, site_groups.size());
for (const base::Value& site_group : site_groups) {
const std::string& etld_plus1_string =
site_group.FindKey("etldPlus1")->GetString();
- base::Value::ConstListView origin_list =
- site_group.FindKey("origins")->GetListDeprecated();
+ const base::Value::List& origin_list =
+ site_group.FindKey("origins")->GetList();
EXPECT_EQ("example.com", etld_plus1_string);
EXPECT_EQ(2UL, origin_list.size());
EXPECT_EQ(url1.spec(), origin_list[0].FindKey("origin")->GetString());
@@ -692,7 +722,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
const GURL url3("https://example2.net");
map->SetContentSettingDefaultScope(
url3, url3, ContentSettingsType::NOTIFICATIONS, CONTENT_SETTING_BLOCK);
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -701,13 +731,13 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(2UL, site_groups.size());
for (const base::Value& site_group : site_groups) {
const std::string& etld_plus1_string =
site_group.FindKey("etldPlus1")->GetString();
- base::Value::ConstListView origin_list =
- site_group.FindKey("origins")->GetListDeprecated();
+ const base::Value::List& origin_list =
+ site_group.FindKey("origins")->GetList();
if (etld_plus1_string == "example2.net") {
EXPECT_EQ(1UL, origin_list.size());
EXPECT_EQ(url3.spec(), origin_list[0].FindKey("origin")->GetString());
@@ -732,7 +762,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
CONTENT_SETTING_BLOCK,
auto_blocker->GetEmbargoResult(url4, ContentSettingsType::NOTIFICATIONS)
->content_setting);
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -740,13 +770,12 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
- EXPECT_EQ(3UL, site_groups.size());
+ EXPECT_EQ(3UL, data.arg3()->GetList().size());
}
// Check |url4| disappears from the list when its embargo expires.
clock.Advance(base::Days(8));
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -754,7 +783,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(2UL, site_groups.size());
EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
@@ -775,14 +804,14 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
auto_blocker->GetEmbargoResult(url3, ContentSettingsType::NOTIFICATIONS)
.has_value());
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(2UL, site_groups.size());
EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
@@ -803,14 +832,14 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
auto_blocker->GetEmbargoResult(url5, ContentSettingsType::NOTIFICATIONS)
.has_value());
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(2UL, site_groups.size());
EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
@@ -834,7 +863,7 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
std::string kPreference =
SiteSettingSourceToString(site_settings::SiteSettingSource::kPreference);
- base::Value get_recent_permissions_args(base::Value::Type::LIST);
+ base::Value::List get_recent_permissions_args;
get_recent_permissions_args.Append(kCallbackId);
get_recent_permissions_args.Append(3);
@@ -850,8 +879,7 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
clock.Advance(base::Hours(1));
// Test recent permissions is empty when there are no preferences.
- handler()->HandleGetRecentSitePermissions(
- get_recent_permissions_args.GetList());
+ handler()->HandleGetRecentSitePermissions(get_recent_permissions_args);
EXPECT_EQ(1U, web_ui()->call_data().size());
{
@@ -860,9 +888,8 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView recent_permissions =
- data.arg3()->GetListDeprecated();
- EXPECT_EQ(0UL, recent_permissions.size());
+ const base::Value::List& recent_permissions = data.arg3()->GetList();
+ EXPECT_TRUE(recent_permissions.empty());
}
// Add numerous permissions from different sources and confirm that the recent
@@ -888,16 +915,14 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
incognito_auto_blocker->RecordDismissAndEmbargo(
url1, ContentSettingsType::NOTIFICATIONS, false);
- handler()->HandleGetRecentSitePermissions(
- get_recent_permissions_args.GetList());
+ handler()->HandleGetRecentSitePermissions(get_recent_permissions_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
EXPECT_EQ(kCallbackId, data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->GetBool());
- base::Value::ConstListView recent_permissions =
- data.arg3()->GetListDeprecated();
+ const base::Value::List& recent_permissions = data.arg3()->GetList();
EXPECT_EQ(2UL, recent_permissions.size());
EXPECT_EQ(url1.spec(),
recent_permissions[1].FindKey("origin")->GetString());
@@ -907,10 +932,10 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
EXPECT_TRUE(recent_permissions[0].FindKey("incognito")->GetBool());
EXPECT_FALSE(recent_permissions[1].FindKey("incognito")->GetBool());
- base::Value::ConstListView incognito_url1_permissions =
- recent_permissions[0].FindKey("recentPermissions")->GetListDeprecated();
- base::Value::ConstListView url1_permissions =
- recent_permissions[1].FindKey("recentPermissions")->GetListDeprecated();
+ const base::Value::List& incognito_url1_permissions =
+ recent_permissions[0].FindKey("recentPermissions")->GetList();
+ const base::Value::List& url1_permissions =
+ recent_permissions[1].FindKey("recentPermissions")->GetList();
EXPECT_EQ(1UL, incognito_url1_permissions.size());
@@ -940,8 +965,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
EXPECT_EQ("onStorageListFetched", data.arg1()->GetString());
ASSERT_TRUE(data.arg2()->is_list());
- base::Value::ConstListView storage_and_cookie_list =
- data.arg2()->GetListDeprecated();
+ const base::Value::List& storage_and_cookie_list = data.arg2()->GetList();
EXPECT_EQ(4U, storage_and_cookie_list.size());
{
@@ -958,9 +982,9 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
// There will be 2 origins in this case. Cookie node with url
// http://www.example.com/ will be treat as https://www.example.com/ because
// this url existed in the storage nodes.
- EXPECT_EQ(2U, origin_list->GetListDeprecated().size());
+ EXPECT_EQ(2U, origin_list->GetList().size());
- const base::Value& origin_info_0 = origin_list->GetListDeprecated()[0];
+ const base::Value& origin_info_0 = origin_list->GetList()[0];
ASSERT_TRUE(origin_info_0.is_dict());
EXPECT_EQ("http://abc.example.com/",
@@ -969,7 +993,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
EXPECT_EQ(0, origin_info_0.FindKey("usage")->GetDouble());
EXPECT_EQ(1, origin_info_0.FindKey("numCookies")->GetDouble());
- const base::Value& origin_info_1 = origin_list->GetListDeprecated()[1];
+ const base::Value& origin_info_1 = origin_list->GetList()[1];
ASSERT_TRUE(origin_info_1.is_dict());
// Even though in the cookies the scheme is http, it still stored as https
@@ -993,10 +1017,9 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
const base::Value* origin_list = site_group.FindListKey("origins");
ASSERT_TRUE(origin_list && origin_list->is_list());
- EXPECT_EQ(2U, origin_list->GetListDeprecated().size());
+ EXPECT_EQ(2U, origin_list->GetList().size());
- const base::Value& partitioned_origin_info =
- origin_list->GetListDeprecated()[0];
+ const base::Value& partitioned_origin_info = origin_list->GetList()[0];
ASSERT_TRUE(partitioned_origin_info.is_dict());
EXPECT_EQ("https://www.example.com/",
@@ -1006,8 +1029,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
EXPECT_EQ(1, partitioned_origin_info.FindKey("numCookies")->GetDouble());
EXPECT_TRUE(partitioned_origin_info.FindKey("isPartitioned")->GetBool());
- const base::Value& unpartitioned_origin_info =
- origin_list->GetListDeprecated()[1];
+ const base::Value& unpartitioned_origin_info = origin_list->GetList()[1];
ASSERT_TRUE(unpartitioned_origin_info.is_dict());
EXPECT_EQ("https://www.google.com/",
@@ -1036,10 +1058,9 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
// exist for the unpartitioned storage. The partitioned cookie for
// google.com.au, partitioned by google.com.au should have also created an
// entry.
- EXPECT_EQ(3U, origin_list->GetListDeprecated().size());
+ EXPECT_EQ(3U, origin_list->GetList().size());
- const base::Value& partitioned_origin_one_info =
- origin_list->GetListDeprecated()[0];
+ const base::Value& partitioned_origin_one_info = origin_list->GetList()[0];
ASSERT_TRUE(partitioned_origin_one_info.is_dict());
EXPECT_EQ("https://google.com.au/",
@@ -1052,8 +1073,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
EXPECT_TRUE(
partitioned_origin_one_info.FindKey("isPartitioned")->GetBool());
- const base::Value& partitioned_origin_two_info =
- origin_list->GetListDeprecated()[1];
+ const base::Value& partitioned_origin_two_info = origin_list->GetList()[1];
EXPECT_EQ("https://www.another-example.com/",
partitioned_origin_two_info.FindKey("origin")->GetString());
EXPECT_EQ(0,
@@ -1065,7 +1085,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
partitioned_origin_two_info.FindKey("isPartitioned")->GetBool());
const base::Value& partitioned_origin_three_info =
- origin_list->GetListDeprecated()[2];
+ origin_list->GetList()[2];
ASSERT_TRUE(partitioned_origin_three_info.is_dict());
EXPECT_EQ("https://www.example.com/",
@@ -1090,9 +1110,9 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
const base::Value* origin_list = site_group.FindListKey("origins");
ASSERT_TRUE(origin_list && origin_list->is_list());
- EXPECT_EQ(1U, origin_list->GetListDeprecated().size());
+ EXPECT_EQ(1U, origin_list->GetList().size());
- const base::Value& origin_info = origin_list->GetListDeprecated()[0];
+ const base::Value& origin_info = origin_list->GetList()[0];
ASSERT_TRUE(origin_info.is_dict());
EXPECT_EQ("http://ungrouped.com/",
@@ -1108,8 +1128,7 @@ TEST_F(SiteSettingsHandlerTest, InstalledApps) {
SetUpCookiesTreeModel();
- base::Value::ConstListView storage_and_cookie_list =
- GetOnStorageFetchedSentListView();
+ base::Value::List storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(4U, storage_and_cookie_list.size());
{
@@ -1124,7 +1143,7 @@ TEST_F(SiteSettingsHandlerTest, InstalledApps) {
const base::Value* origin_list = site_group.FindListKey("origins");
ASSERT_TRUE(origin_list);
- const base::Value& origin_info = origin_list->GetListDeprecated()[0];
+ const base::Value& origin_info = origin_list->GetList()[0];
ASSERT_TRUE(origin_info.is_dict());
EXPECT_EQ("http://abc.example.com/",
@@ -1144,7 +1163,7 @@ TEST_F(SiteSettingsHandlerTest, InstalledApps) {
const base::Value* origin_list = site_group.FindListKey("origins");
ASSERT_TRUE(origin_list);
- for (const auto& origin_info : origin_list->GetListDeprecated()) {
+ for (const auto& origin_info : origin_list->GetList()) {
ASSERT_TRUE(origin_info.is_dict());
EXPECT_FALSE(origin_info.FindKey("isInstalled")->GetBool());
}
@@ -1164,7 +1183,7 @@ TEST_F(SiteSettingsHandlerTest, IncognitoExceptions) {
CreateIncognitoProfile();
{
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(kOriginToBlock); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kNotifications);
@@ -1172,24 +1191,24 @@ TEST_F(SiteSettingsHandlerTest, IncognitoExceptions) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_args.Append(true); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
- base::Value get_exception_list_args(base::Value::Type::LIST);
+ base::Value::List get_exception_list_args;
get_exception_list_args.Append(kCallbackId);
get_exception_list_args.Append(kNotifications);
- handler()->HandleGetExceptionList(get_exception_list_args.GetList());
+ handler()->HandleGetExceptionList(get_exception_list_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
ASSERT_TRUE(data.arg3()->is_list());
- base::Value::ConstListView exceptions = data.arg3()->GetListDeprecated();
+ const base::Value::List& exceptions = data.arg3()->GetList();
ASSERT_EQ(1U, exceptions.size());
validate_exception(exceptions[0]);
}
{
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(kOriginToBlock); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kNotifications);
@@ -1197,17 +1216,17 @@ TEST_F(SiteSettingsHandlerTest, IncognitoExceptions) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_args.Append(false); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
- base::Value get_exception_list_args(base::Value::Type::LIST);
+ base::Value::List get_exception_list_args;
get_exception_list_args.Append(kCallbackId);
get_exception_list_args.Append(kNotifications);
- handler()->HandleGetExceptionList(get_exception_list_args.GetList());
+ handler()->HandleGetExceptionList(get_exception_list_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
ASSERT_TRUE(data.arg3()->is_list());
- base::Value::ConstListView exceptions = data.arg3()->GetListDeprecated();
+ const base::Value::List& exceptions = data.arg3()->GetList();
ASSERT_EQ(2U, exceptions.size());
validate_exception(exceptions[0]);
@@ -1223,7 +1242,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
// Add and test 1 blocked origin
{
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(kOriginToBlock); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kNotifications);
@@ -1231,7 +1250,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_args.Append(false); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
ASSERT_EQ(1U, web_ui()->call_data().size());
}
@@ -1253,50 +1272,50 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
// Check there are 2 blocked origins.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kPermissionNotifications, profile(), /*extension_registry=*/nullptr,
web_ui(),
/*incognito=*/false, &exceptions);
// The size should be 2, 1st is blocked origin, 2nd is embargoed origin.
- ASSERT_EQ(2U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(2U, exceptions.size());
}
{
// Reset blocked origin.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(kOriginToBlock);
reset_args.Append(std::string());
reset_args.Append(kNotifications);
reset_args.Append(false); // Incognito.
- handler()->HandleResetCategoryPermissionForPattern(reset_args.GetList());
+ handler()->HandleResetCategoryPermissionForPattern(reset_args);
// Check there is 1 blocked origin.
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kPermissionNotifications, profile(), /*extension_registry=*/nullptr,
web_ui(),
/*incognito=*/false, &exceptions);
- ASSERT_EQ(1U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(1U, exceptions.size());
}
{
// Reset embargoed origin.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(kOriginToEmbargo);
reset_args.Append(std::string());
reset_args.Append(kNotifications);
reset_args.Append(false); // Incognito.
- handler()->HandleResetCategoryPermissionForPattern(reset_args.GetList());
+ handler()->HandleResetCategoryPermissionForPattern(reset_args);
// Check that there are no blocked or embargoed origins.
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kPermissionNotifications, profile(), /*extension_registry=*/nullptr,
web_ui(),
/*incognito=*/false, &exceptions);
- ASSERT_EQ(0U, exceptions.GetListDeprecated().size());
+ ASSERT_TRUE(exceptions.empty());
}
}
@@ -1306,7 +1325,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForInvalidOrigins) {
EXPECT_FALSE(url.is_valid());
EXPECT_TRUE(url.is_empty());
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(kInvalidOrigin); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kNotifications);
@@ -1314,17 +1333,17 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForInvalidOrigins) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_args.Append(false); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
ASSERT_EQ(1U, web_ui()->call_data().size());
// Reset blocked origin.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(kInvalidOrigin);
reset_args.Append(std::string());
reset_args.Append(kNotifications);
reset_args.Append(false); // Incognito.
// Check that this method is not crashing for an invalid origin.
- handler()->HandleResetCategoryPermissionForPattern(reset_args.GetList());
+ handler()->HandleResetCategoryPermissionForPattern(reset_args);
}
TEST_F(SiteSettingsHandlerTest, Origins) {
@@ -1332,37 +1351,37 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
{
// Test the JS -> C++ -> JS callback path for configuring origins, by
// setting Google.com to blocked.
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(google); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kNotifications);
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_args.Append(false); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
EXPECT_EQ(1U, web_ui()->call_data().size());
}
- base::Value get_exception_list_args(base::Value::Type::LIST);
+ base::Value::List get_exception_list_args;
get_exception_list_args.Append(kCallbackId);
get_exception_list_args.Append(kNotifications);
- handler()->HandleGetExceptionList(get_exception_list_args.GetList());
+ handler()->HandleGetExceptionList(get_exception_list_args);
ValidateOrigin(google, "", google, CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kPreference, 2U);
{
// Reset things back to how they were.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(google);
reset_args.Append(std::string());
reset_args.Append(kNotifications);
reset_args.Append(false); // Incognito.
- handler()->HandleResetCategoryPermissionForPattern(reset_args.GetList());
+ handler()->HandleResetCategoryPermissionForPattern(reset_args);
EXPECT_EQ(3U, web_ui()->call_data().size());
}
// Verify the reset was successful.
- handler()->HandleGetExceptionList(get_exception_list_args.GetList());
+ handler()->HandleGetExceptionList(get_exception_list_args);
ValidateNoOrigin(4U);
}
@@ -1378,7 +1397,7 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) {
origin_queried_waiter.QuitClosure());
{
- base::Value set_notification_origin_args(base::Value::Type::LIST);
+ base::Value::List set_notification_origin_args;
set_notification_origin_args.Append(google);
set_notification_origin_args.Append("");
set_notification_origin_args.Append(kNotifications);
@@ -1386,11 +1405,11 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) {
content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
set_notification_origin_args.Append(false /* incognito */);
handler()->HandleSetCategoryPermissionForPattern(
- set_notification_origin_args.GetList());
+ set_notification_origin_args);
}
{
- base::Value set_notification_origin_args(base::Value::Type::LIST);
+ base::Value::List set_notification_origin_args;
set_notification_origin_args.Append(google);
set_notification_origin_args.Append("");
set_notification_origin_args.Append(kNotifications);
@@ -1398,7 +1417,7 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_notification_origin_args.Append(false /* incognito */);
handler()->HandleSetCategoryPermissionForPattern(
- set_notification_origin_args.GetList());
+ set_notification_origin_args);
}
origin_queried_waiter.Run();
@@ -1434,29 +1453,29 @@ TEST_F(SiteSettingsHandlerTest, MAYBE_DefaultSettingSource) {
ContentSettingSourceSetter source_setter(profile(),
ContentSettingsType::NOTIFICATIONS);
- base::Value get_origin_permissions_args(base::Value::Type::LIST);
+ base::Value::List get_origin_permissions_args;
get_origin_permissions_args.Append(kCallbackId);
get_origin_permissions_args.Append(google);
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
get_origin_permissions_args.Append(std::move(category_list));
// Test Chrome built-in defaults are marked as default.
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(google, google, expected_display_name, CONTENT_SETTING_ASK,
site_settings::SiteSettingSource::kDefault, 1U);
- base::Value default_value_args(base::Value::Type::LIST);
+ base::Value::List default_value_args;
default_value_args.Append(kNotifications);
default_value_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
- handler()->HandleSetDefaultValueForContentType(default_value_args.GetList());
+ handler()->HandleSetDefaultValueForContentType(default_value_args);
// A user-set global default should also show up as default.
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(google, google, expected_display_name, CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kDefault, 3U);
- base::Value set_notification_pattern_args(base::Value::Type::LIST);
+ base::Value::List set_notification_pattern_args;
set_notification_pattern_args.Append("[*.]google.com");
set_notification_pattern_args.Append("");
set_notification_pattern_args.Append(kNotifications);
@@ -1464,13 +1483,13 @@ TEST_F(SiteSettingsHandlerTest, MAYBE_DefaultSettingSource) {
content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
set_notification_pattern_args.Append(false);
handler()->HandleSetCategoryPermissionForPattern(
- set_notification_pattern_args.GetList());
+ set_notification_pattern_args);
// A user-set pattern should not show up as default.
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(google, google, expected_display_name, CONTENT_SETTING_ALLOW,
site_settings::SiteSettingSource::kPreference, 5U);
- base::Value set_notification_origin_args(base::Value::Type::LIST);
+ base::Value::List set_notification_origin_args;
set_notification_origin_args.Append(google);
set_notification_origin_args.Append("");
set_notification_origin_args.Append(kNotifications);
@@ -1478,15 +1497,15 @@ TEST_F(SiteSettingsHandlerTest, MAYBE_DefaultSettingSource) {
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
set_notification_origin_args.Append(false);
handler()->HandleSetCategoryPermissionForPattern(
- set_notification_origin_args.GetList());
+ set_notification_origin_args);
// A user-set per-origin permission should not show up as default.
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(google, google, expected_display_name, CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kPreference, 7U);
// Enterprise-policy set defaults should not show up as default.
source_setter.SetPolicyDefault(CONTENT_SETTING_ALLOW);
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(google, google, expected_display_name, CONTENT_SETTING_ALLOW,
site_settings::SiteSettingSource::kPolicy, 8U);
}
@@ -1495,40 +1514,40 @@ TEST_F(SiteSettingsHandlerTest, GetAndSetOriginPermissions) {
const std::string origin_with_port("https://www.example.com:443");
// The display name won't show the port if it's default for that scheme.
const std::string origin("www.example.com");
- base::Value get_args(base::Value::Type::LIST);
+ base::Value::List get_args;
get_args.Append(kCallbackId);
get_args.Append(origin_with_port);
{
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
get_args.Append(std::move(category_list));
}
- handler()->HandleGetOriginPermissions(get_args.GetList());
+ handler()->HandleGetOriginPermissions(get_args);
ValidateOrigin(origin_with_port, origin_with_port, origin,
CONTENT_SETTING_ASK,
site_settings::SiteSettingSource::kDefault, 1U);
// Block notifications.
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(origin_with_port);
set_args.Append(kNotifications);
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
- handler()->HandleSetOriginPermissions(set_args.GetList());
+ handler()->HandleSetOriginPermissions(set_args);
EXPECT_EQ(2U, web_ui()->call_data().size());
// Reset things back to how they were.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(origin_with_port);
reset_args.Append(std::move(kNotifications));
reset_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT));
- handler()->HandleSetOriginPermissions(reset_args.GetList());
+ handler()->HandleSetOriginPermissions(reset_args);
EXPECT_EQ(3U, web_ui()->call_data().size());
// Verify the reset was successful.
- handler()->HandleGetOriginPermissions(get_args.GetList());
+ handler()->HandleGetOriginPermissions(get_args);
ValidateOrigin(origin_with_port, origin_with_port, origin,
CONTENT_SETTING_ASK,
site_settings::SiteSettingSource::kDefault, 4U);
@@ -1537,15 +1556,15 @@ TEST_F(SiteSettingsHandlerTest, GetAndSetOriginPermissions) {
TEST_F(SiteSettingsHandlerTest, GetAndSetForInvalidURLs) {
const std::string origin("arbitrary string");
EXPECT_FALSE(GURL(origin).is_valid());
- base::Value get_args(base::Value::Type::LIST);
+ base::Value::List get_args;
get_args.Append(kCallbackId);
get_args.Append(origin);
{
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
get_args.Append(std::move(category_list));
}
- handler()->HandleGetOriginPermissions(get_args.GetList());
+ handler()->HandleGetOriginPermissions(get_args);
// Verify that it'll return CONTENT_SETTING_BLOCK as |origin| is not a secure
// context, a requirement for notifications. Note that the display string
// will be blank since it's an invalid URL.
@@ -1553,19 +1572,19 @@ TEST_F(SiteSettingsHandlerTest, GetAndSetForInvalidURLs) {
site_settings::SiteSettingSource::kInsecureOrigin, 1U);
// Make sure setting a permission on an invalid origin doesn't crash.
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(origin);
{
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
set_args.Append(std::move(category_list));
}
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
- handler()->HandleSetOriginPermissions(set_args.GetList());
+ handler()->HandleSetOriginPermissions(set_args);
// Also make sure the content setting for |origin| wasn't actually changed.
- handler()->HandleGetOriginPermissions(get_args.GetList());
+ handler()->HandleGetOriginPermissions(get_args);
ValidateOrigin(origin, origin, "", CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kInsecureOrigin, 2U);
}
@@ -1573,31 +1592,30 @@ TEST_F(SiteSettingsHandlerTest, GetAndSetForInvalidURLs) {
TEST_F(SiteSettingsHandlerTest, ExceptionHelpers) {
ContentSettingsPattern pattern =
ContentSettingsPattern::FromString("[*.]google.com");
- std::unique_ptr<base::DictionaryValue> exception =
- site_settings::GetExceptionForPage(
- ContentSettingsType::NOTIFICATIONS, /*profile=*/nullptr, pattern,
- ContentSettingsPattern::Wildcard(), pattern.ToString(),
- CONTENT_SETTING_BLOCK,
- site_settings::SiteSettingSourceToString(
- site_settings::SiteSettingSource::kPreference),
- false);
-
- CHECK(exception->FindStringKey(site_settings::kOrigin));
- CHECK(exception->FindStringKey(site_settings::kDisplayName));
- CHECK(exception->FindStringKey(site_settings::kEmbeddingOrigin));
- CHECK(exception->FindStringKey(site_settings::kSetting));
- CHECK(exception->FindBoolKey(site_settings::kIncognito).has_value());
-
- base::Value args(base::Value::Type::LIST);
- args.Append(*exception->FindStringKey(site_settings::kOrigin));
- args.Append(*exception->FindStringKey(site_settings::kEmbeddingOrigin));
+ base::Value::Dict exception = site_settings::GetExceptionForPage(
+ ContentSettingsType::NOTIFICATIONS, /*profile=*/nullptr, pattern,
+ ContentSettingsPattern::Wildcard(), pattern.ToString(),
+ CONTENT_SETTING_BLOCK,
+ site_settings::SiteSettingSourceToString(
+ site_settings::SiteSettingSource::kPreference),
+ false);
+
+ CHECK(exception.FindString(site_settings::kOrigin));
+ CHECK(exception.FindString(site_settings::kDisplayName));
+ CHECK(exception.FindString(site_settings::kEmbeddingOrigin));
+ CHECK(exception.FindString(site_settings::kSetting));
+ CHECK(exception.FindBool(site_settings::kIncognito).has_value());
+
+ base::Value::List args;
+ args.Append(*exception.FindString(site_settings::kOrigin));
+ args.Append(*exception.FindString(site_settings::kEmbeddingOrigin));
args.Append(kNotifications); // Chosen arbitrarily.
- args.Append(*exception->FindStringKey(site_settings::kSetting));
- args.Append(*exception->FindBoolKey(site_settings::kIncognito));
+ args.Append(*exception.FindString(site_settings::kSetting));
+ args.Append(*exception.FindBool(site_settings::kIncognito));
// We don't need to check the results. This is just to make sure it doesn't
// crash on the input.
- handler()->HandleSetCategoryPermissionForPattern(args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(args);
scoped_refptr<const extensions::Extension> extension;
extension = extensions::ExtensionBuilder()
@@ -1609,11 +1627,11 @@ TEST_F(SiteSettingsHandlerTest, ExceptionHelpers) {
.SetID("ahfgeienlihckogmohjhadlkjgocpleb")
.Build();
- std::unique_ptr<base::ListValue> exceptions(new base::ListValue);
+ base::Value::List exceptions;
site_settings::AddExceptionForHostedApp("[*.]google.com", *extension.get(),
- exceptions.get());
+ &exceptions);
- const base::Value& dictionary = exceptions->GetListDeprecated()[0];
+ const base::Value& dictionary = exceptions[0];
CHECK(dictionary.is_dict());
CHECK(dictionary.FindStringKey(site_settings::kOrigin));
CHECK(dictionary.FindStringKey(site_settings::kDisplayName));
@@ -1622,7 +1640,7 @@ TEST_F(SiteSettingsHandlerTest, ExceptionHelpers) {
CHECK(dictionary.FindBoolKey(site_settings::kIncognito).has_value());
// Again, don't need to check the results.
- handler()->HandleSetCategoryPermissionForPattern(args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(args);
}
TEST_F(SiteSettingsHandlerTest, ExtensionDisplayName) {
@@ -1640,15 +1658,15 @@ TEST_F(SiteSettingsHandlerTest, ExtensionDisplayName) {
.Build();
extension_registry->AddEnabled(extension);
- base::Value get_origin_permissions_args(base::Value::Type::LIST);
+ base::Value::List get_origin_permissions_args;
get_origin_permissions_args.Append(kCallbackId);
get_origin_permissions_args.Append(test_extension_url);
{
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
get_origin_permissions_args.Append(std::move(category_list));
}
- handler()->HandleGetOriginPermissions(get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
ValidateOrigin(test_extension_url, test_extension_url, kExtensionName,
CONTENT_SETTING_ASK,
site_settings::SiteSettingSource::kDefault, 1U);
@@ -1657,11 +1675,11 @@ TEST_F(SiteSettingsHandlerTest, ExtensionDisplayName) {
TEST_F(SiteSettingsHandlerTest, PatternsAndContentType) {
unsigned counter = 1;
for (const auto& test_case : kPatternsAndContentTypeTestCases) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kCallbackId);
args.Append(test_case.arguments.pattern);
args.Append(test_case.arguments.content_type);
- handler()->HandleIsPatternValidForType(args.GetList());
+ handler()->HandleIsPatternValidForType(args);
ValidatePattern(test_case.expected.validity, counter,
test_case.expected.reason);
++counter;
@@ -1669,8 +1687,8 @@ TEST_F(SiteSettingsHandlerTest, PatternsAndContentType) {
}
TEST_F(SiteSettingsHandlerTest, Incognito) {
- base::Value args(base::Value::Type::LIST);
- handler()->HandleUpdateIncognitoStatus(args.GetList());
+ base::Value::List args;
+ handler()->HandleUpdateIncognitoStatus(args);
ValidateIncognitoExists(false, 1U);
CreateIncognitoProfile();
@@ -1689,12 +1707,12 @@ TEST_F(SiteSettingsHandlerTest, ZoomLevels) {
host_zoom_map->SetZoomLevelForHost(host, zoom_level);
ValidateZoom(host, "122%", 1U);
- base::Value args(base::Value::Type::LIST);
- handler()->HandleFetchZoomLevels(args.GetList());
+ base::Value::List args;
+ handler()->HandleFetchZoomLevels(args);
ValidateZoom(host, "122%", 2U);
args.Append("http://www.google.com");
- handler()->HandleRemoveZoomLevel(args.GetList());
+ handler()->HandleRemoveZoomLevel(args);
ValidateZoom("", "", 3U);
double default_level = host_zoom_map->GetDefaultZoomLevel();
@@ -1820,12 +1838,12 @@ TEST_F(SiteSettingsHandlerInfobarTest, SettingPermissionsTriggersInfobar) {
}
// Block notifications.
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(origin_anchor_string);
set_args.Append(kNotifications);
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
- handler()->HandleSetOriginPermissions(set_args.GetList());
+ handler()->HandleSetOriginPermissions(set_args);
// Make sure all tabs belonging to the same origin as |origin_anchor| have an
// infobar shown.
@@ -1868,14 +1886,14 @@ TEST_F(SiteSettingsHandlerInfobarTest, SettingPermissionsTriggersInfobar) {
NavigateAndCommit(origin_query_contents, example_without_www);
// Reset all permissions.
- base::Value reset_args(base::Value::Type::LIST);
+ base::Value::List reset_args;
reset_args.Append(origin_anchor_string);
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
reset_args.Append(std::move(category_list));
reset_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT));
- handler()->HandleSetOriginPermissions(reset_args.GetList());
+ handler()->HandleSetOriginPermissions(reset_args);
// Check the same tabs (plus the tab navigated to |origin_path|) still have
// infobars showing.
@@ -1910,21 +1928,21 @@ TEST_F(SiteSettingsHandlerInfobarTest, SettingPermissionsTriggersInfobar) {
TEST_F(SiteSettingsHandlerTest, SessionOnlyException) {
const std::string google_with_port("https://www.google.com:443");
- base::Value set_args(base::Value::Type::LIST);
+ base::Value::List set_args;
set_args.Append(google_with_port); // Primary pattern.
set_args.Append(std::string()); // Secondary pattern.
set_args.Append(kCookies);
set_args.Append(
content_settings::ContentSettingToString(CONTENT_SETTING_SESSION_ONLY));
set_args.Append(false); // Incognito.
- handler()->HandleSetCategoryPermissionForPattern(set_args.GetList());
+ handler()->HandleSetCategoryPermissionForPattern(set_args);
EXPECT_EQ(kNumberContentSettingListeners, web_ui()->call_data().size());
}
TEST_F(SiteSettingsHandlerTest, BlockAutoplay_SendOnRequest) {
- base::Value args(base::Value::Type::LIST);
- handler()->HandleFetchBlockAutoplayStatus(args.GetList());
+ base::Value::List args;
+ handler()->HandleFetchBlockAutoplayStatus(args);
// Check that we are checked and enabled.
ValidateBlockAutoplay(true, true);
@@ -1961,10 +1979,10 @@ TEST_F(SiteSettingsHandlerTest, BlockAutoplay_PrefUpdate) {
TEST_F(SiteSettingsHandlerTest, BlockAutoplay_Update) {
EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled));
- base::Value data(base::Value::Type::LIST);
+ base::Value::List data;
data.Append(false);
- handler()->HandleSetBlockAutoplayEnabled(data.GetList());
+ handler()->HandleSetBlockAutoplayEnabled(data);
EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled));
}
@@ -2002,35 +2020,34 @@ TEST_F(SiteSettingsHandlerTest, ExcludeWebUISchemesInLists) {
// GetAllSites() only returns website exceptions.
{
- base::Value get_all_sites_args(base::Value::Type::LIST);
+ base::Value::List get_all_sites_args;
get_all_sites_args.Append(kCallbackId);
- handler()->HandleGetAllSites(get_all_sites_args.GetList());
+ handler()->HandleGetAllSites(get_all_sites_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- base::Value::ConstListView site_groups = data.arg3()->GetListDeprecated();
+ const base::Value::List& site_groups = data.arg3()->GetList();
EXPECT_EQ(1UL, site_groups.size());
const std::string etld_plus1_string =
site_groups[0].FindKey("etldPlus1")->GetString();
EXPECT_EQ("example.com", etld_plus1_string);
- base::Value::ConstListView origin_list =
- site_groups[0].FindKey("origins")->GetListDeprecated();
+ const base::Value::List& origin_list =
+ site_groups[0].FindKey("origins")->GetList();
EXPECT_EQ(1UL, origin_list.size());
EXPECT_EQ(kWebUrl.spec(), origin_list[0].FindKey("origin")->GetString());
}
// GetExceptionList() only returns website exceptions.
{
- base::Value get_exception_list_args(base::Value::Type::LIST);
+ base::Value::List get_exception_list_args;
get_exception_list_args.Append(kCallbackId);
get_exception_list_args.Append(kNotifications);
- handler()->HandleGetExceptionList(get_exception_list_args.GetList());
+ handler()->HandleGetExceptionList(get_exception_list_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- base::Value::ConstListView exception_list =
- data.arg3()->GetListDeprecated();
+ const base::Value::List& exception_list = data.arg3()->GetList();
EXPECT_EQ(1UL, exception_list.size());
EXPECT_EQ("https://example.com:443",
exception_list[0].FindKey("origin")->GetString());
@@ -2038,16 +2055,14 @@ TEST_F(SiteSettingsHandlerTest, ExcludeWebUISchemesInLists) {
// GetRecentSitePermissions() only returns website exceptions.
{
- base::Value get_recent_permissions_args(base::Value::Type::LIST);
+ base::Value::List get_recent_permissions_args;
get_recent_permissions_args.Append(kCallbackId);
get_recent_permissions_args.Append(3);
- handler()->HandleGetRecentSitePermissions(
- get_recent_permissions_args.GetList());
+ handler()->HandleGetRecentSitePermissions(get_recent_permissions_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- base::Value::ConstListView recent_permission_list =
- data.arg3()->GetListDeprecated();
+ const base::Value::List& recent_permission_list = data.arg3()->GetList();
EXPECT_EQ(1UL, recent_permission_list.size());
EXPECT_EQ(kWebUrl.spec(),
recent_permission_list[0].FindKey("origin")->GetString());
@@ -2073,18 +2088,16 @@ TEST_F(SiteSettingsHandlerTest, IncludeWebUISchemesInGetOriginPermissions) {
allowlist->RegisterAutoGrantedPermission(origin, content_settings_type);
for (const url::Origin& origin : kWebUIOrigins) {
- base::Value get_origin_permissions_args(base::Value::Type::LIST);
+ base::Value::List get_origin_permissions_args;
get_origin_permissions_args.Append(kCallbackId);
get_origin_permissions_args.Append(origin.GetURL().spec());
- base::Value category_list(base::Value::Type::LIST);
+ base::Value::List category_list;
category_list.Append(kNotifications);
get_origin_permissions_args.Append(std::move(category_list));
- handler()->HandleGetOriginPermissions(
- get_origin_permissions_args.GetList());
+ handler()->HandleGetOriginPermissions(get_origin_permissions_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
- const base::Value::ConstListView exception_list =
- data.arg3()->GetListDeprecated();
+ const base::Value::List& exception_list = data.arg3()->GetList();
EXPECT_EQ(1UL, exception_list.size());
EXPECT_EQ(origin.GetURL().spec(),
@@ -2225,11 +2238,11 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
// and return the exception list received by the WebUI.
void ValidateChooserExceptionList(const std::string& chooser_type,
size_t expected_total_calls) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kCallbackId);
args.Append(chooser_type);
- handler()->HandleGetChooserExceptionList(args.GetList());
+ handler()->HandleGetChooserExceptionList(args);
EXPECT_EQ(web_ui()->call_data().size(), expected_total_calls);
@@ -2263,7 +2276,7 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
if (!sites)
return false;
- for (const auto& site : sites->GetListDeprecated()) {
+ for (const auto& site : sites->GetList()) {
const std::string* exception_origin =
site.FindStringKey(site_settings::kOrigin);
if (!exception_origin)
@@ -2283,7 +2296,7 @@ class SiteSettingsHandlerChooserExceptionTest : public SiteSettingsHandlerTest {
if (!exceptions.is_list())
return false;
- for (const auto& exception : exceptions.GetListDeprecated()) {
+ for (const auto& exception : exceptions.GetList()) {
const std::string* exception_display_name =
exception.FindStringKey(site_settings::kDisplayName);
if (!exception_display_name)
@@ -2315,7 +2328,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/1u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
// Don't include WebUI schemes.
const std::string kWebUIOriginStr =
@@ -2341,8 +2354,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/1u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 7u);
- for (const auto& exception : exceptions.GetListDeprecated()) {
+ EXPECT_EQ(exceptions.GetList().size(), 7u);
+ for (const auto& exception : exceptions.GetList()) {
LOG(INFO) << exception.FindKey(site_settings::kDisplayName)->GetString();
}
}
@@ -2356,7 +2369,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/3u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
}
}
@@ -2378,13 +2391,13 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/1u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
}
// User granted USB permissions for devices also containing policy permissions
// should be able to be reset without removing the chooser exception object
// from the list.
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kUsbChooserGroupName);
args.Append("https://unused.com");
args.Append(kGoogleOriginStr);
@@ -2395,7 +2408,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
ContentSettingsType::USB_GUARD),
ContentSettingsType::USB_CHOOSER_DATA));
EXPECT_CALL(observer_, OnPermissionRevoked(kGoogleOrigin));
- handler()->HandleResetChooserExceptionForSite(args.GetList());
+ handler()->HandleResetChooserExceptionForSite(args);
auto* chooser_context = UsbChooserContextFactory::GetForProfile(profile());
chooser_context->FlushScheduledSaveSettingsCalls();
@@ -2408,7 +2421,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
// a policy granted permission for the "Gizmo" device.
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/4u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
// Ensure that the sites list does not contain the URLs of the removed
// permission.
@@ -2418,7 +2431,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
// User granted USB permissions that are also granted by policy should not
// be able to be reset.
- args.ClearList();
+ args.clear();
args.Append(kUsbChooserGroupName);
args.Append("https://unused.com");
args.Append(kChromiumOriginStr);
@@ -2427,7 +2440,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions =
GetChooserExceptionListFromWebUiCallData(kUsbChooserGroupName, 5u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ 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 the
@@ -2443,7 +2456,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
ContentSettingsType::USB_GUARD),
ContentSettingsType::USB_CHOOSER_DATA));
EXPECT_CALL(observer_, OnPermissionRevoked(kChromiumOrigin));
- handler()->HandleResetChooserExceptionForSite(args.GetList());
+ handler()->HandleResetChooserExceptionForSite(args);
chooser_context->FlushScheduledSaveSettingsCalls();
// The HandleResetChooserExceptionForSite() method should have also caused the
@@ -2453,7 +2466,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/8u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
// Ensure that the sites list still displays a site exception entry for an
// origin of kGoogleOriginStr. Since now the device has had its
@@ -2470,7 +2483,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
// User granted USB permissions that are not covered by policy should be able
// to be reset and the chooser exception entry should be removed from the list
// when the exception only has one site exception granted to it..
- args.ClearList();
+ args.clear();
args.Append(kUsbChooserGroupName);
args.Append("https://unused.com");
args.Append(kAndroidOriginStr);
@@ -2479,7 +2492,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions =
GetChooserExceptionListFromWebUiCallData(kUsbChooserGroupName, 9u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 5u);
+ EXPECT_EQ(exceptions.GetList().size(), 5u);
EXPECT_TRUE(ChooserExceptionContainsSiteException(exceptions, "Widget",
kAndroidOriginStr));
}
@@ -2489,7 +2502,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
ContentSettingsType::USB_GUARD),
ContentSettingsType::USB_CHOOSER_DATA));
EXPECT_CALL(observer_, OnPermissionRevoked(kAndroidOrigin));
- handler()->HandleResetChooserExceptionForSite(args.GetList());
+ handler()->HandleResetChooserExceptionForSite(args);
chooser_context->FlushScheduledSaveSettingsCalls();
// The HandleResetChooserExceptionForSite() method should have also caused the
@@ -2499,7 +2512,7 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
{
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/12u);
- EXPECT_EQ(exceptions.GetListDeprecated().size(), 4u);
+ EXPECT_EQ(exceptions.GetList().size(), 4u);
EXPECT_FALSE(ChooserExceptionContainsSiteException(exceptions, "Widget",
kAndroidOriginStr));
}
@@ -2508,7 +2521,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
TEST_F(SiteSettingsHandlerTest, HandleClearEtldPlus1DataAndCookies) {
SetUpCookiesTreeModel();
- EXPECT_EQ(31, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(31u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
auto verify_site_group = [](const base::Value& site_group,
std::string expected_etld_plus1) {
@@ -2518,14 +2532,13 @@ TEST_F(SiteSettingsHandlerTest, HandleClearEtldPlus1DataAndCookies) {
ASSERT_EQ(expected_etld_plus1, *etld_plus1);
};
- base::ListValue::ConstListView storage_and_cookie_list =
- GetOnStorageFetchedSentListView();
+ base::Value::List storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(4U, storage_and_cookie_list.size());
verify_site_group(storage_and_cookie_list[0], "example.com");
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("example.com");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
// All host nodes for non-secure example.com, and abc.example.com, which do
// not have any unpartitioned storage, should have been removed.
@@ -2548,27 +2561,29 @@ TEST_F(SiteSettingsHandlerTest, HandleClearEtldPlus1DataAndCookies) {
EXPECT_TRUE(cookie->IsPartitioned());
}
- EXPECT_EQ(22, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(22u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
- storage_and_cookie_list = GetOnStorageFetchedSentListView();
+ storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(3U, storage_and_cookie_list.size());
verify_site_group(storage_and_cookie_list[0], "google.com");
- args.ClearList();
+ args.clear();
args.Append("google.com");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
- EXPECT_EQ(14, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(14u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
- storage_and_cookie_list = GetOnStorageFetchedSentListView();
+ storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(2U, storage_and_cookie_list.size());
verify_site_group(storage_and_cookie_list[0], "google.com.au");
- args.ClearList();
+ args.clear();
args.Append("google.com.au");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
// No nodes representing storage partitioned on google.com.au should be
// present.
for (const auto& host_node :
@@ -2588,28 +2603,29 @@ TEST_F(SiteSettingsHandlerTest, HandleClearEtldPlus1DataAndCookies) {
}
}
- storage_and_cookie_list = GetOnStorageFetchedSentListView();
+ storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(1U, storage_and_cookie_list.size());
verify_site_group(storage_and_cookie_list[0], "ungrouped.com");
- args.ClearList();
+ args.clear();
args.Append("ungrouped.com");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
- storage_and_cookie_list = GetOnStorageFetchedSentListView();
+ storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(0U, storage_and_cookie_list.size());
}
TEST_P(SiteSettingsHandlerTest, HandleClearUnpartitionedUsage) {
SetUpCookiesTreeModel();
- EXPECT_EQ(31, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(31u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(GetParam() ? "https://www.example.com/"
: "http://www.example.com/");
- handler()->HandleClearUnpartitionedUsage(args.GetList());
+ handler()->HandleClearUnpartitionedUsage(args);
// Confirm that only the unpartitioned items for example.com have been
// cleared.
@@ -2630,9 +2646,9 @@ TEST_P(SiteSettingsHandlerTest, HandleClearUnpartitionedUsage) {
// Partitioned storage, even when keyed on the cookie domain site, should
// not be cleared.
- args = base::Value(base::Value::Type::LIST);
+ args = base::Value::List();
args.Append("https://google.com.au/");
- handler()->HandleClearUnpartitionedUsage(args.GetList());
+ handler()->HandleClearUnpartitionedUsage(args);
remaining_host_nodes = GetHostNodes(GURL("https://google.com.au"));
@@ -2663,25 +2679,25 @@ TEST_F(SiteSettingsHandlerTest, ClearClientHints) {
base::Value client_hint_platform_version(14);
base::Value client_hint_bitness(16);
- base::Value client_hints_list(base::Value::Type::LIST);
+ base::Value::List client_hints_list;
client_hints_list.Append(std::move(client_hint_platform_version));
client_hints_list.Append(std::move(client_hint_bitness));
- base::Value client_hints_dictionary(base::Value::Type::DICTIONARY);
- client_hints_dictionary.SetKey(client_hints::kClientHintsSettingKey,
- std::move(client_hints_list));
+ base::Value::Dict client_hints_dictionary;
+ client_hints_dictionary.Set(client_hints::kClientHintsSettingKey,
+ std::move(client_hints_list));
// Add setting for the hosts.
for (const auto& host : hosts) {
host_content_settings_map->SetWebsiteSettingDefaultScope(
host, GURL(), ContentSettingsType::CLIENT_HINTS,
- client_hints_dictionary.Clone());
+ base::Value(client_hints_dictionary.Clone()));
}
// Clear at the eTLD+1 level and ensure affected origins are cleared.
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("example.com");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
host_content_settings_map->GetSettingsForOneType(
ContentSettingsType::CLIENT_HINTS, &client_hints_settings);
EXPECT_EQ(2U, client_hints_settings.size());
@@ -2700,9 +2716,9 @@ TEST_F(SiteSettingsHandlerTest, ClearClientHints) {
// Clear unpartitioned usage data, which should only affect the specific
// origin.
- args.ClearList();
+ args.clear();
args.Append("https://google.com/");
- handler()->HandleClearUnpartitionedUsage(args.GetList());
+ handler()->HandleClearUnpartitionedUsage(args);
// Validate the client hint has been cleared.
host_content_settings_map->GetSettingsForOneType(
@@ -2719,9 +2735,9 @@ TEST_F(SiteSettingsHandlerTest, ClearClientHints) {
// Clear unpartitioned usage data through HTTPS scheme, make sure https site
// client hints have been cleared when the specific origin HTTPS scheme
// exist.
- args.ClearList();
+ args.clear();
args.Append("http://www.google.com/");
- handler()->HandleClearUnpartitionedUsage(args.GetList());
+ handler()->HandleClearUnpartitionedUsage(args);
// Validate the client hint has been cleared.
host_content_settings_map->GetSettingsForOneType(
@@ -2729,16 +2745,96 @@ TEST_F(SiteSettingsHandlerTest, ClearClientHints) {
EXPECT_EQ(0U, client_hints_settings.size());
}
+TEST_F(SiteSettingsHandlerTest, ClearReducedAcceptLanguage) {
+ // Confirm that when the user clears unpartitioned storage, or the eTLD+1
+ // group, reduce accept language are also cleared.
+ SetUpCookiesTreeModel();
+ handler()->OnStorageFetched();
+
+ GURL hosts[] = {GURL("https://example.com/"), GURL("https://www.example.com"),
+ GURL("https://google.com/"), GURL("https://www.google.com/")};
+
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(profile());
+ ContentSettingsForOneType accept_language_settings;
+
+ std::string language = "en-us";
+ base::Value accept_language_dictionary(base::Value::Type::DICTIONARY);
+ accept_language_dictionary.SetKey("reduce-accept-language",
+ base::Value(language));
+
+ // Add setting for the hosts.
+ for (const auto& host : hosts) {
+ host_content_settings_map->SetWebsiteSettingDefaultScope(
+ host, GURL(), ContentSettingsType::REDUCED_ACCEPT_LANGUAGE,
+ accept_language_dictionary.Clone());
+ }
+
+ // Clear at the eTLD+1 level and ensure affected origins are cleared.
+ base::Value args(base::Value::Type::LIST);
+ args.Append("example.com");
+ handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ host_content_settings_map->GetSettingsForOneType(
+ ContentSettingsType::REDUCED_ACCEPT_LANGUAGE, &accept_language_settings);
+ EXPECT_EQ(2U, accept_language_settings.size());
+
+ EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(hosts[2]),
+ accept_language_settings.at(0).primary_pattern);
+ EXPECT_EQ(ContentSettingsPattern::Wildcard(),
+ accept_language_settings.at(0).secondary_pattern);
+ EXPECT_EQ(accept_language_dictionary,
+ accept_language_settings.at(0).setting_value);
+
+ EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(hosts[3]),
+ accept_language_settings.at(1).primary_pattern);
+ EXPECT_EQ(ContentSettingsPattern::Wildcard(),
+ accept_language_settings.at(1).secondary_pattern);
+ EXPECT_EQ(accept_language_dictionary,
+ accept_language_settings.at(1).setting_value);
+
+ // Clear unpartitioned usage data, which should only affect the specific
+ // origin.
+ args.ClearList();
+ args.Append("https://google.com/");
+ handler()->HandleClearUnpartitionedUsage(args.GetList());
+
+ // Validate the reduce accept language has been cleared.
+ host_content_settings_map->GetSettingsForOneType(
+ ContentSettingsType::REDUCED_ACCEPT_LANGUAGE, &accept_language_settings);
+ EXPECT_EQ(1U, accept_language_settings.size());
+
+ // www.google.com should be the only remainining entry.
+ EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(hosts[3]),
+ accept_language_settings.at(0).primary_pattern);
+ EXPECT_EQ(ContentSettingsPattern::Wildcard(),
+ accept_language_settings.at(0).secondary_pattern);
+ EXPECT_EQ(accept_language_dictionary,
+ accept_language_settings.at(0).setting_value);
+
+ // Clear unpartitioned usage data through HTTPS scheme, make sure https site
+ // reduced accept language have been cleared when the specific origin HTTPS
+ // scheme exist.
+ args.ClearList();
+ args.Append("http://www.google.com/");
+ handler()->HandleClearUnpartitionedUsage(args.GetList());
+
+ // Validate the reduced accept language has been cleared.
+ host_content_settings_map->GetSettingsForOneType(
+ ContentSettingsType::REDUCED_ACCEPT_LANGUAGE, &accept_language_settings);
+ EXPECT_EQ(0U, accept_language_settings.size());
+}
+
TEST_F(SiteSettingsHandlerTest, HandleClearPartitionedUsage) {
// Confirm that removing unpartitioned storage correctly removes the
// appropriate nodes.
SetUpCookiesTreeModel();
- EXPECT_EQ(31, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(31u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("https://www.example.com/");
args.Append("google.com");
- handler()->HandleClearPartitionedUsage(args.GetList());
+ handler()->HandleClearPartitionedUsage(args);
// This should have only removed cookies for embedded.com partitioned on
// google.com, leaving other cookies and storage untouched.
@@ -2792,9 +2888,9 @@ TEST_F(SiteSettingsHandlerTest, CookieSettingDescription) {
web_ui()->ClearTrackedCalls();
// Validate get method works.
- base::Value get_args(base::Value::Type::LIST);
+ base::Value::List get_args;
get_args.Append(kCallbackId);
- handler()->HandleGetCookieSettingDescription(get_args.GetList());
+ handler()->HandleGetCookieSettingDescription(get_args);
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
@@ -2863,10 +2959,10 @@ TEST_F(SiteSettingsHandlerTest, CookieSettingDescription) {
TEST_F(SiteSettingsHandlerTest, HandleGetFormattedBytes) {
const double size = 120000000000;
- base::Value get_args(base::Value::Type::LIST);
+ base::Value::List get_args;
get_args.Append(kCallbackId);
get_args.Append(size);
- handler()->HandleGetFormattedBytes(get_args.GetList());
+ handler()->HandleGetFormattedBytes(get_args);
// Validate that this method can handle large data.
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
@@ -2881,17 +2977,18 @@ TEST_F(SiteSettingsHandlerTest, HandleGetUsageInfo) {
// Confirm that usage info only returns unpartitioned storage.
SetUpCookiesTreeModel();
- EXPECT_EQ(31, handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
+ EXPECT_EQ(31u,
+ handler()->cookies_tree_model_->GetRoot()->GetTotalNodeCount());
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("www.example.com");
- handler()->HandleFetchUsageTotal(args.GetList());
+ handler()->HandleFetchUsageTotal(args);
handler()->OnGetUsageInfo();
ValidateUsageInfo("www.example.com", "2 B", "1 cookie");
- args.ClearList();
+ args.clear();
args.Append("example.com");
- handler()->HandleFetchUsageTotal(args.GetList());
+ handler()->HandleFetchUsageTotal(args);
handler()->OnGetUsageInfo();
ValidateUsageInfo("example.com", "", "1 cookie");
}
@@ -2901,8 +2998,7 @@ TEST_F(SiteSettingsHandlerTest, NonTreeModelDeletion) {
// Sandbox APIs that are not integrated with the tree model.
SetUpCookiesTreeModel();
- base::ListValue::ConstListView storage_and_cookie_list =
- GetOnStorageFetchedSentListView();
+ base::Value::List storage_and_cookie_list = GetOnStorageFetchedSentList();
EXPECT_EQ(4U, storage_and_cookie_list.size());
EXPECT_CALL(*mock_browsing_topics_service(),
ClearTopicsDataForOrigin(
@@ -2911,9 +3007,9 @@ TEST_F(SiteSettingsHandlerTest, NonTreeModelDeletion) {
ClearTopicsDataForOrigin(
url::Origin::Create(GURL("https://google.com"))));
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("google.com");
- handler()->HandleClearEtldPlus1DataAndCookies(args.GetList());
+ handler()->HandleClearEtldPlus1DataAndCookies(args);
auto* browsing_data_remover = profile()->GetBrowsingDataRemover();
EXPECT_EQ(content::BrowsingDataRemover::DATA_TYPE_PRIVACY_SANDBOX,
@@ -2924,4 +3020,31 @@ TEST_F(SiteSettingsHandlerTest, NonTreeModelDeletion) {
browsing_data_remover->GetLastUsedOriginTypeMaskForTesting());
}
+TEST_F(SiteSettingsHandlerTest, FirstPartySetsMembership) {
+ base::flat_map<net::SchemefulSite, net::SchemefulSite> first_party_sets = {
+ {ConvertEtldToSchemefulSite("google.com"),
+ ConvertEtldToSchemefulSite("google.com")},
+ {ConvertEtldToSchemefulSite("google.com.au"),
+ ConvertEtldToSchemefulSite("google.com")},
+ };
+ EXPECT_CALL(*mock_privacy_sandbox_service(), GetFirstPartySets())
+ .WillOnce(Return(first_party_sets));
+
+ SetUpCookiesTreeModel();
+
+ handler()->ClearAllSitesMapForTesting();
+
+ handler()->OnStorageFetched();
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+
+ ASSERT_TRUE(data.arg1()->is_string());
+ EXPECT_EQ("onStorageListFetched", data.arg1()->GetString());
+
+ ASSERT_TRUE(data.arg2()->is_list());
+ const base::Value::List& storage_and_cookie_list = data.arg2()->GetList();
+ EXPECT_EQ(4U, storage_and_cookie_list.size());
+
+ ValidateSitesWithFps(storage_and_cookie_list, first_party_sets);
+}
} // namespace settings
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 45585986dcc..ddc961b87e4 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/hid/hid_chooser_context.h"
#include "chrome/browser/hid/hid_chooser_context_factory.h"
-#include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/serial/serial_chooser_context.h"
#include "chrome/browser/serial/serial_chooser_context_factory.h"
@@ -40,7 +39,6 @@
#include "components/permissions/contexts/bluetooth_chooser_context.h"
#include "components/permissions/object_permission_context_base.h"
#include "components/permissions/permission_decision_auto_blocker.h"
-#include "components/permissions/permission_manager.h"
#include "components/permissions/permission_result.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/permissions_client.h"
@@ -49,11 +47,14 @@
#include "components/subresource_filter/content/browser/subresource_filter_profile_context.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "components/url_formatter/url_formatter.h"
+#include "content/public/browser/permission_controller.h"
+#include "content/public/browser/permission_result.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_utils.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
+#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "url/origin.h"
namespace site_settings {
@@ -63,17 +64,6 @@ constexpr char kAppId[] = "appId";
namespace {
-// Maps from the UI string to the object it represents (for sorting purposes).
-typedef std::multimap<std::string, const base::DictionaryValue*> SortedObjects;
-
-// Maps from a secondary URL to the set of objects it has permission to access.
-typedef std::map<GURL, SortedObjects> OneOriginObjects;
-
-// Maps from a primary URL/source pair to a OneOriginObjects. All the mappings
-// in OneOriginObjects share the given primary URL and source.
-typedef std::map<std::pair<GURL, std::string>, OneOriginObjects>
- AllOriginObjects;
-
// Chooser data group names.
const char kUsbChooserDataGroupType[] = "usb-devices-data";
const char kSerialChooserDataGroupType[] = "serial-ports-data";
@@ -171,6 +161,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{ContentSettingsType::REQUEST_DESKTOP_SITE, nullptr},
{ContentSettingsType::GET_DISPLAY_MEDIA_SET_SELECT_ALL_SCREENS, nullptr},
{ContentSettingsType::NOTIFICATION_INTERACTIONS, nullptr},
+ {ContentSettingsType::REDUCED_ACCEPT_LANGUAGE, nullptr},
};
static_assert(std::size(kContentSettingsTypeGroupNames) ==
@@ -201,28 +192,6 @@ static_assert(std::size(kSiteSettingSourceStringMapping) ==
"kSiteSettingSourceStringMapping should have "
"SiteSettingSource::kNumSources elements");
-struct PolicyIndicatorTypeStringMapping {
- PolicyIndicatorType source;
- const char* indicator_str;
-};
-
-// Converts a policy indicator type to its JS usable string representation.
-const PolicyIndicatorTypeStringMapping kPolicyIndicatorTypeStringMapping[] = {
- {PolicyIndicatorType::kDevicePolicy, "devicePolicy"},
- {PolicyIndicatorType::kExtension, "extension"},
- {PolicyIndicatorType::kNone, "none"},
- {PolicyIndicatorType::kOwner, "owner"},
- {PolicyIndicatorType::kPrimaryUser, "primary_user"},
- {PolicyIndicatorType::kRecommended, "recommended"},
- {PolicyIndicatorType::kUserPolicy, "userPolicy"},
- {PolicyIndicatorType::kParent, "parent"},
- {PolicyIndicatorType::kChildRestriction, "childRestriction"},
-};
-static_assert(std::size(kPolicyIndicatorTypeStringMapping) ==
- static_cast<int>(PolicyIndicatorType::kNumIndicators),
- "kPolicyIndicatorStringMapping should have "
- "PolicyIndicatorType::kNumIndicators elements");
-
// Retrieves the corresponding string, according to the following precedence
// order from highest to lowest priority:
// 1. Allowlisted WebUI content setting.
@@ -487,20 +456,11 @@ std::string SiteSettingSourceToString(const SiteSettingSource source) {
return kSiteSettingSourceStringMapping[static_cast<int>(source)].source_str;
}
-base::Value GetValueForManagedState(const site_settings::ManagedState& state) {
- base::Value value(base::Value::Type::DICTIONARY);
- value.SetKey(site_settings::kDisabled, base::Value(state.disabled));
- value.SetKey(
- site_settings::kPolicyIndicator,
- base::Value(site_settings::PolicyIndicatorTypeToString(state.indicator)));
- return value;
-}
-
// Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from
// the web extent of a hosted |app|.
void AddExceptionForHostedApp(const std::string& url_pattern,
const extensions::Extension& app,
- base::ListValue* exceptions) {
+ base::Value::List* exceptions) {
base::Value::Dict exception;
std::string setting_string =
@@ -516,12 +476,12 @@ void AddExceptionForHostedApp(const std::string& url_pattern,
exception.Set(kIncognito, false);
exception.Set(kAppName, app.name());
exception.Set(kAppId, app.id());
- exceptions->Append(base::Value(std::move(exception)));
+ exceptions->Append(std::move(exception));
}
-// Create a DictionaryValue* that will act as a data source for a single row
+// Create a base::Value::Dict that will act as a data source for a single row
// in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
-std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
+base::Value::Dict GetExceptionForPage(
ContentSettingsType content_type,
Profile* profile,
const ContentSettingsPattern& pattern,
@@ -531,22 +491,22 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
const std::string& provider_name,
bool incognito,
bool is_embargoed) {
- auto exception = std::make_unique<base::DictionaryValue>();
- exception->SetStringKey(kOrigin, pattern.ToString());
- exception->SetStringKey(kDisplayName, display_name);
- exception->SetStringKey(
- kEmbeddingOrigin, secondary_pattern == ContentSettingsPattern::Wildcard()
- ? std::string()
- : secondary_pattern.ToString());
+ base::Value::Dict exception;
+ exception.Set(kOrigin, pattern.ToString());
+ exception.Set(kDisplayName, display_name);
+ exception.Set(kEmbeddingOrigin,
+ secondary_pattern == ContentSettingsPattern::Wildcard()
+ ? std::string()
+ : secondary_pattern.ToString());
std::string setting_string =
content_settings::ContentSettingToString(setting);
DCHECK(!setting_string.empty());
- exception->SetStringKey(kSetting, setting_string);
+ exception.Set(kSetting, setting_string);
- exception->SetStringKey(kSource, provider_name);
- exception->SetBoolKey(kIncognito, incognito);
- exception->SetBoolKey(kIsEmbargoed, is_embargoed);
+ exception.Set(kSource, provider_name);
+ exception.Set(kIncognito, incognito);
+ exception.Set(kIsEmbargoed, is_embargoed);
return exception;
}
@@ -608,7 +568,7 @@ void GetExceptionsForContentType(
const extensions::ExtensionRegistry* extension_registry,
content::WebUI* web_ui,
bool incognito,
- base::ListValue* exceptions) {
+ base::Value::List* exceptions) {
ContentSettingsForOneType all_settings;
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(profile);
@@ -675,7 +635,7 @@ void GetExceptionsForContentType(
// Keep the exceptions sorted by provider so they will be displayed in
// precedence order.
- std::vector<std::unique_ptr<base::DictionaryValue>>
+ std::vector<base::Value::Dict>
all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES];
// |all_patterns_settings| is sorted from the lowest precedence pattern to
@@ -736,21 +696,21 @@ void GetExceptionsForContentType(
for (auto& one_provider_exceptions : all_provider_exceptions) {
for (auto& exception : one_provider_exceptions)
- exceptions->Append(base::Value::FromUniquePtrValue(std::move(exception)));
+ exceptions->Append(std::move(exception));
}
}
void GetContentCategorySetting(const HostContentSettingsMap* map,
ContentSettingsType content_type,
- base::DictionaryValue* object) {
+ base::Value::Dict* object) {
std::string provider;
std::string setting = content_settings::ContentSettingToString(
map->GetDefaultContentSetting(content_type, &provider));
DCHECK(!setting.empty());
- object->SetStringKey(kSetting, setting);
+ object->Set(kSetting, setting);
if (provider != SiteSettingSourceToString(SiteSettingSource::kDefault))
- object->SetStringKey(kSource, provider);
+ object->Set(kSource, provider);
}
ContentSetting GetContentSettingForOrigin(
@@ -775,9 +735,14 @@ ContentSetting GetContentSettingForOrigin(
if (permissions::PermissionDecisionAutoBlocker::IsEnabledForContentSetting(
content_type)) {
if (permissions::PermissionUtil::IsPermission(content_type)) {
+ content::PermissionResult permission_result =
+ profile->GetPermissionController()
+ ->GetPermissionResultForOriginWithoutContext(
+ permissions::PermissionUtil::
+ ContentSettingTypeToPermissionType(content_type),
+ url::Origin::Create(origin));
result =
- PermissionManagerFactory::GetForProfile(profile)
- ->GetPermissionStatusForDisplayOnSettingsUI(content_type, origin);
+ permissions::PermissionUtil::ToPermissionResult(permission_result);
} else {
permissions::PermissionDecisionAutoBlocker* auto_blocker =
permissions::PermissionsClient::Get()
@@ -818,7 +783,7 @@ std::vector<ContentSettingPatternSource> GetSiteExceptionsForContentType(
void GetPolicyAllowedUrls(
ContentSettingsType type,
- std::vector<std::unique_ptr<base::DictionaryValue>>* exceptions,
+ std::vector<base::Value::Dict>* exceptions,
const extensions::ExtensionRegistry* extension_registry,
content::WebUI* web_ui,
bool incognito) {
@@ -827,14 +792,14 @@ void GetPolicyAllowedUrls(
Profile* profile = Profile::FromWebUI(web_ui);
PrefService* prefs = profile->GetPrefs();
- const base::Value* policy_urls =
- prefs->GetList(type == ContentSettingsType::MEDIASTREAM_MIC
- ? prefs::kAudioCaptureAllowedUrls
- : prefs::kVideoCaptureAllowedUrls);
+ const base::Value::List& policy_urls =
+ prefs->GetValueList(type == ContentSettingsType::MEDIASTREAM_MIC
+ ? prefs::kAudioCaptureAllowedUrls
+ : prefs::kVideoCaptureAllowedUrls);
// Convert the URLs to |ContentSettingsPattern|s. Ignore any invalid ones.
std::vector<ContentSettingsPattern> patterns;
- for (const auto& entry : policy_urls->GetListDeprecated()) {
+ for (const auto& entry : policy_urls) {
const std::string* url = entry.GetIfString();
if (!url)
continue;
@@ -869,26 +834,26 @@ const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name) {
return nullptr;
}
-// Create a DictionaryValue* that will act as a data source for a single row
+// Create a base::Value::Dict that will act as a data source for a single row
// in a chooser permission exceptions table. The chooser permission will contain
// a list of site exceptions that correspond to the exception.
-base::Value CreateChooserExceptionObject(
+base::Value::Dict CreateChooserExceptionObject(
const std::u16string& display_name,
const base::Value& object,
const std::string& chooser_type,
const ChooserExceptionDetails& chooser_exception_details) {
- base::Value exception(base::Value::Type::DICTIONARY);
+ base::Value::Dict exception;
std::string setting_string =
content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT);
DCHECK(!setting_string.empty());
- exception.SetStringKey(kDisplayName, display_name);
- exception.SetKey(kObject, object.Clone());
- exception.SetStringKey(kChooserType, chooser_type);
+ exception.Set(kDisplayName, display_name);
+ exception.Set(kObject, object.Clone());
+ exception.Set(kChooserType, chooser_type);
// Order the sites by the provider precedence order.
- std::vector<base::Value>
+ std::vector<base::Value::Dict>
all_provider_sites[HostContentSettingsMap::NUM_PROVIDER_TYPES];
for (const auto& details : chooser_exception_details) {
const GURL& requesting_origin = details.first.first;
@@ -901,35 +866,35 @@ base::Value CreateChooserExceptionObject(
for (const auto& embedding_origin_incognito_pair : details.second) {
const GURL& embedding_origin = embedding_origin_incognito_pair.first;
const bool incognito = embedding_origin_incognito_pair.second;
- base::Value site(base::Value::Type::DICTIONARY);
-
- site.SetStringKey(kOrigin, requesting_origin.spec());
- site.SetStringKey(kDisplayName, requesting_origin.spec());
- site.SetStringKey(kEmbeddingOrigin, embedding_origin.is_empty()
- ? std::string()
- : embedding_origin.spec());
- site.SetStringKey(kSetting, setting_string);
- site.SetStringKey(kSource, source);
- site.SetBoolKey(kIncognito, incognito);
+ base::Value::Dict site;
+
+ site.Set(kOrigin, requesting_origin.spec());
+ site.Set(kDisplayName, requesting_origin.spec());
+ site.Set(kEmbeddingOrigin, embedding_origin.is_empty()
+ ? std::string()
+ : embedding_origin.spec());
+ site.Set(kSetting, setting_string);
+ site.Set(kSource, source);
+ site.Set(kIncognito, incognito);
this_provider_sites.push_back(std::move(site));
}
}
- base::Value sites(base::Value::Type::LIST);
+ base::Value::List sites;
for (auto& one_provider_sites : all_provider_sites) {
for (auto& site : one_provider_sites) {
sites.Append(std::move(site));
}
}
- exception.SetKey(kSites, std::move(sites));
+ exception.Set(kSites, std::move(sites));
return exception;
}
-base::Value GetChooserExceptionListFromProfile(
+base::Value::List GetChooserExceptionListFromProfile(
Profile* profile,
const ChooserTypeNameEntry& chooser_type) {
- base::Value exceptions(base::Value::Type::LIST);
+ base::Value::List exceptions;
ContentSettingsType content_type =
ContentSettingsTypeFromGroupName(std::string(chooser_type.name));
@@ -996,29 +961,4 @@ base::Value GetChooserExceptionListFromProfile(
return exceptions;
}
-std::string PolicyIndicatorTypeToString(const PolicyIndicatorType type) {
- return kPolicyIndicatorTypeStringMapping[static_cast<int>(type)]
- .indicator_str;
-}
-
-PolicyIndicatorType GetPolicyIndicatorFromPref(
- const PrefService::Preference* pref) {
- if (!pref) {
- return PolicyIndicatorType::kNone;
- }
- if (pref->IsExtensionControlled()) {
- return PolicyIndicatorType::kExtension;
- }
- if (pref->IsManagedByCustodian()) {
- return PolicyIndicatorType::kParent;
- }
- if (pref->IsManaged()) {
- return PolicyIndicatorType::kDevicePolicy;
- }
- if (pref->GetRecommendedValue()) {
- return PolicyIndicatorType::kRecommended;
- }
- return PolicyIndicatorType::kNone;
-}
-
} // namespace site_settings
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 a5b5c9017c1..8ee2fabdb25 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h
@@ -83,28 +83,6 @@ enum class SiteSettingSource {
kNumSources,
};
-// Possible policy indicators that can be shown in settings.
-// Must be kept in sync with the CrPolicyIndicatorType enum located in
-// src/ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.js
-enum class PolicyIndicatorType {
- kDevicePolicy,
- kExtension,
- kNone,
- kOwner,
- kPrimaryUser,
- kRecommended,
- kUserPolicy,
- kParent,
- kChildRestriction,
- kNumIndicators,
-};
-
-// Represents the managed state for a single settings control.
-struct ManagedState {
- bool disabled = false;
- PolicyIndicatorType indicator = PolicyIndicatorType::kNone;
-};
-
// Returns whether a group name has been registered for the given type.
bool HasRegisteredGroupName(ContentSettingsType type);
@@ -120,11 +98,8 @@ const std::vector<ContentSettingsType>& GetVisiblePermissionCategories();
// Converts a SiteSettingSource to its string identifier.
std::string SiteSettingSourceToString(const SiteSettingSource source);
-// Converts a ManagedState to a base::Value suitable for sending to JavaScript.
-base::Value GetValueForManagedState(const ManagedState& state);
-
// Helper function to construct a dictionary for an exception.
-std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
+base::Value::Dict GetExceptionForPage(
ContentSettingsType content_type,
Profile* profile,
const ContentSettingsPattern& pattern,
@@ -138,7 +113,7 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
// Helper function to construct a dictionary for a hosted app exception.
void AddExceptionForHostedApp(const std::string& url_pattern,
const extensions::Extension& app,
- base::ListValue* exceptions);
+ base::Value::List* exceptions);
// Fills in |exceptions| with Values for the given |type| from |profile|.
void GetExceptionsForContentType(
@@ -147,14 +122,14 @@ void GetExceptionsForContentType(
const extensions::ExtensionRegistry* extension_registry,
content::WebUI* web_ui,
bool incognito,
- base::ListValue* exceptions);
+ base::Value::List* exceptions);
// Fills in object saying what the current settings is for the category (such as
// enabled or blocked) and the source of that setting (such preference, policy,
// or extension).
void GetContentCategorySetting(const HostContentSettingsMap* map,
ContentSettingsType content_type,
- base::DictionaryValue* object);
+ base::Value::Dict* object);
// Retrieves the current setting for a given origin, category pair, the source
// of that setting, and its display name, which will be different if it's an
@@ -173,7 +148,7 @@ ContentSetting GetContentSettingForOrigin(
// for the content settings |type| mic or camera.
void GetPolicyAllowedUrls(
ContentSettingsType type,
- std::vector<std::unique_ptr<base::DictionaryValue>>* exceptions,
+ std::vector<base::Value::Dict>* exceptions,
const extensions::ExtensionRegistry* extension_registry,
content::WebUI* web_ui,
bool incognito);
@@ -206,24 +181,17 @@ const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name);
// * sites: Array<SiteException>
// The structure of the SiteException objects is the same as the objects
// returned by GetExceptionForPage().
-base::Value CreateChooserExceptionObject(
+base::Value::Dict CreateChooserExceptionObject(
const std::u16string& display_name,
const base::Value& object,
const std::string& chooser_type,
const ChooserExceptionDetails& chooser_exception_details);
// Returns an array of chooser exception objects.
-base::Value GetChooserExceptionListFromProfile(
+base::Value::List GetChooserExceptionListFromProfile(
Profile* profile,
const ChooserTypeNameEntry& chooser_type);
-// Concerts a PolicyIndicatorType to its string identifier.
-std::string PolicyIndicatorTypeToString(const PolicyIndicatorType type);
-
-// Returns the appropriate indicator for the source of a preference.
-PolicyIndicatorType GetPolicyIndicatorFromPref(
- const PrefService::Preference* pref);
-
} // namespace site_settings
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SITE_SETTINGS_HELPER_H_
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 2833d53740f..e856371de6d 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
@@ -26,6 +26,7 @@
#include "components/permissions/object_permission_context_base.h"
#include "components/permissions/permission_decision_auto_blocker.h"
#include "components/permissions/permissions_client.h"
+#include "components/permissions/test/permission_test_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/extension_registry.h"
@@ -46,21 +47,21 @@ constexpr ContentSettingsType kContentTypeCookies =
class SiteSettingsHelperTest : public testing::Test {
public:
- void VerifySetting(const base::ListValue& exceptions,
+ void VerifySetting(const base::Value::List& exceptions,
int index,
const std::string& pattern,
const std::string& pattern_display_name,
const ContentSetting setting) {
- const base::Value& value = exceptions.GetListDeprecated()[index];
+ const base::Value& value = exceptions[index];
EXPECT_TRUE(value.is_dict());
- const base::DictionaryValue& dict = base::Value::AsDictionaryValue(value);
- const std::string* actual_pattern = dict.FindStringKey("origin");
+ const base::Value::Dict& dict = value.GetDict();
+ const std::string* actual_pattern = dict.FindString("origin");
ASSERT_TRUE(actual_pattern);
EXPECT_EQ(pattern, *actual_pattern);
- const std::string* actual_display_name = dict.FindStringKey(kDisplayName);
+ const std::string* actual_display_name = dict.FindString(kDisplayName);
ASSERT_TRUE(actual_display_name);
EXPECT_EQ(pattern_display_name, *actual_display_name);
- const std::string* actual_setting = dict.FindStringKey(kSetting);
+ const std::string* actual_setting = dict.FindString(kSetting);
ASSERT_TRUE(actual_setting);
EXPECT_EQ(content_settings::ContentSettingToString(setting),
*actual_setting);
@@ -95,7 +96,7 @@ TEST_F(SiteSettingsHelperTest, ExceptionListWithEmbargoedAndBlockedOrigins) {
kContentTypeNotifications,
CONTENT_SETTING_BLOCK);
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(kContentTypeNotifications,
&profile,
/*extension_registry=*/nullptr,
@@ -103,17 +104,17 @@ TEST_F(SiteSettingsHelperTest, ExceptionListWithEmbargoedAndBlockedOrigins) {
/*incognito=*/false, &exceptions);
// |exceptions| size should be 2. One blocked and one embargoed origins.
- const auto& list = exceptions.GetListDeprecated();
- ASSERT_EQ(2U, list.size());
+ ASSERT_EQ(2U, exceptions.size());
// Get last added origin.
- base::Value* is_embargoed = list[0].FindKey(site_settings::kIsEmbargoed);
+ base::Value* is_embargoed =
+ exceptions[0].FindKey(site_settings::kIsEmbargoed);
ASSERT_NE(nullptr, is_embargoed);
// Last added origin is blocked, |embargo| key should be false.
EXPECT_FALSE(is_embargoed->GetBool());
// Get embargoed origin.
- is_embargoed = list[1].FindKey(site_settings::kIsEmbargoed);
+ is_embargoed = exceptions[1].FindKey(site_settings::kIsEmbargoed);
ASSERT_NE(nullptr, is_embargoed);
EXPECT_TRUE(is_embargoed->GetBool());
}
@@ -144,12 +145,12 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsIncognitoEmbargoed) {
// Check there is 1 embargoed origin for a non-incognito profile.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kContentTypeNotifications, &profile, /*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- ASSERT_EQ(1U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(1U, exceptions.size());
}
TestingProfile* incognito_profile =
@@ -157,13 +158,13 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsIncognitoEmbargoed) {
// Check there are no blocked origins for an incognito profile.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(kContentTypeNotifications,
incognito_profile,
/*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/true, &exceptions);
- ASSERT_EQ(0U, exceptions.GetListDeprecated().size());
+ ASSERT_TRUE(exceptions.empty());
}
{
@@ -176,7 +177,7 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsIncognitoEmbargoed) {
// Check there is only 1 blocked origin for an incognito profile.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(kContentTypeNotifications,
incognito_profile,
/*extension_registry=*/nullptr,
@@ -184,7 +185,7 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsIncognitoEmbargoed) {
/*incognito=*/true, &exceptions);
// The exceptions size should be 1 because previously embargoed origin
// was for a non-incognito profile.
- ASSERT_EQ(1U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(1U, exceptions.size());
}
// Add an origin under embargo for incognito profile.
@@ -204,13 +205,13 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsIncognitoEmbargoed) {
// Check there are 2 blocked or embargoed origins for an incognito profile.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(kContentTypeNotifications,
incognito_profile,
/*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/true, &exceptions);
- ASSERT_EQ(2U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(2U, exceptions.size());
}
}
@@ -221,12 +222,12 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsEmbargoed) {
// Check there is no blocked origins.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kContentTypeNotifications, &profile, /*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- ASSERT_EQ(0U, exceptions.GetListDeprecated().size());
+ ASSERT_TRUE(exceptions.empty());
}
auto* map = HostContentSettingsMapFactory::GetForProfile(&profile);
@@ -235,12 +236,12 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsEmbargoed) {
CONTENT_SETTING_BLOCK);
{
// Check there is 1 blocked origin.
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kContentTypeNotifications, &profile, /*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- ASSERT_EQ(1U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(1U, exceptions.size());
}
// Add an origin under embargo.
@@ -260,37 +261,36 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsEmbargoed) {
// Check there are 2 blocked origins.
{
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kContentTypeNotifications, &profile, /*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
// The size should be 2, 1st is blocked origin, 2nd is embargoed origin.
- ASSERT_EQ(2U, exceptions.GetListDeprecated().size());
+ ASSERT_EQ(2U, exceptions.size());
// Fetch and check the first origin.
- const base::DictionaryValue* dictionary;
- const base::Value* value = &exceptions.GetListDeprecated()[0];
+ const base::Value* value = &exceptions[0];
ASSERT_TRUE(value->is_dict());
- dictionary = &base::Value::AsDictionaryValue(*value);
+ const base::Value::Dict* dictionary = &value->GetDict();
const std::string* primary_pattern =
- dictionary->FindStringKey(site_settings::kOrigin);
+ dictionary->FindString(site_settings::kOrigin);
ASSERT_TRUE(primary_pattern);
const std::string* display_name =
- dictionary->FindStringKey(site_settings::kDisplayName);
+ dictionary->FindString(site_settings::kDisplayName);
ASSERT_TRUE(display_name);
EXPECT_EQ(kOriginToBlock, *primary_pattern);
EXPECT_EQ(kOriginToBlock, *display_name);
// Fetch and check the second origin.
- value = &exceptions.GetListDeprecated()[1];
+ value = &exceptions[1];
ASSERT_TRUE(value->is_dict());
- dictionary = &base::Value::AsDictionaryValue(*value);
+ dictionary = &value->GetDict();
- primary_pattern = dictionary->FindStringKey(site_settings::kOrigin);
+ primary_pattern = dictionary->FindString(site_settings::kOrigin);
ASSERT_TRUE(primary_pattern);
- display_name = dictionary->FindStringKey(site_settings::kDisplayName);
+ display_name = dictionary->FindString(site_settings::kDisplayName);
ASSERT_TRUE(display_name);
EXPECT_EQ(kOriginToEmbargo, *primary_pattern);
@@ -300,12 +300,12 @@ TEST_F(SiteSettingsHelperTest, ExceptionListShowsEmbargoed) {
{
// Non-permission types should not DCHECK when there is autoblocker data
// present.
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
kContentTypeCookies, &profile, /*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- ASSERT_EQ(0U, exceptions.GetListDeprecated().size());
+ ASSERT_TRUE(exceptions.empty());
}
}
@@ -322,7 +322,7 @@ TEST_F(SiteSettingsHelperTest, ExceptionListFedCmEmbargo) {
GURL(kOriginToEmbargo), ContentSettingsType::FEDERATED_IDENTITY_API,
/*dismissed_prompt_was_quiet=*/false);
- base::ListValue exceptions;
+ base::Value::List exceptions;
site_settings::GetExceptionsForContentType(
ContentSettingsType::FEDERATED_IDENTITY_API, &profile,
/*extension_registry=*/nullptr,
@@ -330,15 +330,14 @@ TEST_F(SiteSettingsHelperTest, ExceptionListFedCmEmbargo) {
/*incognito=*/false, &exceptions);
// |exceptions| should have an exception for the embargoed origin.
- const base::Value::List& list = exceptions.GetList();
- ASSERT_EQ(1U, list.size());
+ ASSERT_EQ(1U, exceptions.size());
absl::optional<bool> is_embargoed =
- list[0].GetDict().FindBool(site_settings::kIsEmbargoed);
+ exceptions[0].GetDict().FindBool(site_settings::kIsEmbargoed);
ASSERT_TRUE(is_embargoed.has_value());
EXPECT_TRUE(*is_embargoed);
const std::string* primary_pattern =
- list[0].GetDict().FindString(site_settings::kOrigin);
+ exceptions[0].GetDict().FindString(site_settings::kOrigin);
ASSERT_TRUE(primary_pattern);
EXPECT_EQ(kOriginToEmbargo, *primary_pattern);
}
@@ -348,13 +347,13 @@ TEST_F(SiteSettingsHelperTest, CheckExceptionOrder) {
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(&profile);
- base::ListValue exceptions;
+ base::Value::List exceptions;
// Check that the initial state of the map is empty.
GetExceptionsForContentType(kContentType, &profile,
/*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- EXPECT_EQ(0u, exceptions.GetListDeprecated().size());
+ EXPECT_TRUE(exceptions.empty());
map->SetDefaultContentSetting(kContentType, CONTENT_SETTING_ALLOW);
@@ -388,13 +387,13 @@ TEST_F(SiteSettingsHelperTest, CheckExceptionOrder) {
map, std::move(extension_provider),
HostContentSettingsMap::CUSTOM_EXTENSION_PROVIDER);
- exceptions.ClearList();
+ exceptions.clear();
GetExceptionsForContentType(kContentType, &profile,
/*extension_registry=*/nullptr,
/*web_ui=*/nullptr,
/*incognito=*/false, &exceptions);
- EXPECT_EQ(5u, exceptions.GetListDeprecated().size());
+ EXPECT_EQ(5u, exceptions.size());
// The policy exception should be returned first, the extension exception
// second and pref exceptions afterwards.
@@ -418,6 +417,8 @@ TEST_F(SiteSettingsHelperTest, CheckExceptionOrder) {
// default, user-set pattern, user-set origin setting, extension, and policy.
TEST_F(SiteSettingsHelperTest, ContentSettingSource) {
TestingProfile profile;
+ profile.SetPermissionControllerDelegate(
+ permissions::GetPermissionControllerDelegate(&profile));
HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(&profile);
@@ -502,28 +503,28 @@ TEST_F(SiteSettingsHelperTest, ContentSettingSource) {
namespace {
void ExpectValidChooserExceptionObject(
- const base::Value& actual_exception_object,
- const std::string& chooser_type,
- 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);
- ASSERT_TRUE(chooser_type_value);
- EXPECT_EQ(chooser_type_value->GetString(), chooser_type);
-
- const base::Value* display_name_value = actual_exception_object.FindKeyOfType(
- kDisplayName, base::Value::Type::STRING);
- ASSERT_TRUE(display_name_value);
- EXPECT_EQ(base::UTF8ToUTF16(display_name_value->GetString()), display_name);
+ const base::Value::Dict& actual_exception_object,
+ const std::string& expected_chooser_type,
+ const std::u16string& expected_display_name,
+ const base::Value::Dict& expected_chooser_object) {
+ const std::string* actual_chooser_type =
+ actual_exception_object.FindString(kChooserType);
+ ASSERT_TRUE(actual_chooser_type);
+ EXPECT_EQ(*actual_chooser_type, expected_chooser_type);
+
+ const std::string* actual_display_name =
+ actual_exception_object.FindString(kDisplayName);
+ ASSERT_TRUE(actual_display_name);
+ EXPECT_EQ(base::UTF8ToUTF16(*actual_display_name), expected_display_name);
- const base::Value* object_value = actual_exception_object.FindKeyOfType(
- kObject, base::Value::Type::DICTIONARY);
- ASSERT_TRUE(object_value);
- EXPECT_EQ(*object_value, chooser_object);
+ const base::Value::Dict* actual_chooser_object =
+ actual_exception_object.FindDict(kObject);
+ ASSERT_TRUE(actual_chooser_object);
+ EXPECT_EQ(*actual_chooser_object, expected_chooser_object);
- const base::Value* sites_value =
- actual_exception_object.FindKeyOfType(kSites, base::Value::Type::LIST);
- ASSERT_TRUE(sites_value);
+ const base::Value::List* sites_list =
+ actual_exception_object.FindList(kSites);
+ ASSERT_TRUE(sites_list);
}
void ExpectValidSiteExceptionObject(const base::Value& actual_site_object,
@@ -574,8 +575,8 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) {
ChooserExceptionDetails exception_details;
// Create a chooser object for testing.
- auto chooser_object = std::make_unique<base::DictionaryValue>();
- chooser_object->SetKey("name", base::Value(kObjectName));
+ base::Value::Dict chooser_object;
+ chooser_object.Set("name", base::Value(kObjectName));
// Add a user permission for a requesting origin of |kGoogleUrl| and an
// embedding origin of chromium.org.
@@ -589,14 +590,14 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) {
{
auto exception = CreateChooserExceptionObject(
/*display_name=*/kObjectName,
- /*object=*/*chooser_object,
+ /*object=*/base::Value(chooser_object.Clone()),
/*chooser_type=*/kUsbChooserGroupName,
/*chooser_exception_details=*/exception_details);
ExpectValidChooserExceptionObject(
exception, /*chooser_type=*/kUsbChooserGroupName,
- /*display_name=*/kObjectName, *chooser_object);
+ /*display_name=*/kObjectName, chooser_object);
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.Find(kSites)->GetList();
ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0],
/*origin=*/kGoogleUrl,
/*source=*/kPreferenceSource,
@@ -614,17 +615,17 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) {
{
auto exception = CreateChooserExceptionObject(
/*display_name=*/kObjectName,
- /*object=*/*chooser_object,
+ /*object=*/base::Value(chooser_object.Clone()),
/*chooser_type=*/kUsbChooserGroupName,
/*chooser_exception_details=*/exception_details);
ExpectValidChooserExceptionObject(exception,
/*chooser_type=*/kUsbChooserGroupName,
/*display_name=*/kObjectName,
- *chooser_object);
+ chooser_object);
// The map sorts the sites by requesting origin, so |kAndroidUrl| should
// be first, followed by the origin pair (kGoogleOrigin, kChromiumOrigin).
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.Find(kSites)->GetList();
ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0],
/*origin=*/kAndroidUrl,
/*source=*/kPreferenceSource,
@@ -643,19 +644,19 @@ TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) {
{
auto exception = CreateChooserExceptionObject(
/*display_name=*/kObjectName,
- /*object=*/*chooser_object,
+ /*object=*/base::Value(chooser_object.Clone()),
/*chooser_type=*/kUsbChooserGroupName,
/*chooser_exception_details=*/exception_details);
ExpectValidChooserExceptionObject(exception,
/*chooser_type=*/kUsbChooserGroupName,
/*display_name=*/kObjectName,
- *chooser_object);
+ chooser_object);
// The map sorts the sites by requesting origin, but the
// CreateChooserExceptionObject method sorts the sites further by the
// source. Therefore, policy granted sites are listed before user granted
// sites.
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.Find(kSites)->GetList();
ExpectValidSiteExceptionObject(/*actual_site_object=*/sites_list[0],
/*origin=*/kGoogleUrl,
/*source=*/kPolicySource,
@@ -774,9 +775,8 @@ TEST_F(SiteSettingsHelperChooserExceptionTest,
// origin and the embedding origin. User granted permissions that are also
// granted by policy are combined with the policy so that duplicate
// permissions are not displayed.
- base::Value exceptions =
+ base::Value::List exceptions_list =
GetChooserExceptionListFromProfile(profile(), *chooser_type);
- base::Value::ConstListView exceptions_list = exceptions.GetListDeprecated();
ASSERT_EQ(exceptions_list.size(), 4u);
// This exception should describe the permissions for any device with the
@@ -788,7 +788,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest,
ExpectDisplayNameEq(exception,
/*display_name=*/"Devices from Google Inc.");
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.FindKey(kSites)->GetList();
ASSERT_EQ(sites_list.size(), 1u);
ExpectValidSiteExceptionObject(sites_list[0],
/*origin=*/kAndroidUrl,
@@ -805,7 +805,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest,
ExpectDisplayNameEq(exception,
/*display_name=*/"Devices from any vendor");
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.FindKey(kSites)->GetList();
ASSERT_EQ(sites_list.size(), 1u);
ExpectValidSiteExceptionObject(sites_list[0],
/*origin=*/kGoogleUrl,
@@ -822,7 +822,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest,
ExpectDisplayNameEq(exception,
/*display_name=*/"Devices from vendor 0x18D2");
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.FindKey(kSites)->GetList();
ASSERT_EQ(sites_list.size(), 1u);
ExpectValidSiteExceptionObject(sites_list[0],
/*origin=*/kAndroidUrl,
@@ -843,7 +843,7 @@ TEST_F(SiteSettingsHelperChooserExceptionTest,
const auto& exception = exceptions_list[3];
ExpectDisplayNameEq(exception, /*display_name=*/"Gizmo");
- const auto& sites_list = exception.FindKey(kSites)->GetListDeprecated();
+ const auto& sites_list = exception.FindKey(kSites)->GetList();
ASSERT_EQ(sites_list.size(), 2u);
ExpectValidSiteExceptionObject(sites_list[0],
/*origin=*/kChromiumUrl,
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/BUILD.gn b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/BUILD.gn
index 5bc70f4253b..f3066da46d9 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(!is_android)
+
mojom("mojo_bindings") {
sources = [ "bookmarks.mojom" ]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom
index d7ec968cc22..19360565f56 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom
@@ -8,6 +8,12 @@ import "ui/base/mojom/window_open_disposition.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
+// Used to indicate the source item from which the action is triggered.
+enum ActionSource {
+ kBookmark,
+ kPriceTracking,
+};
+
// Used by the Read Later WebUI page (for the side panel) to bootstrap
// bidirectional communication.
interface BookmarksPageHandlerFactory {
@@ -17,15 +23,19 @@ interface BookmarksPageHandlerFactory {
// Browser-side handler for requests from WebUI page.
interface BookmarksPageHandler {
- // Opens the bookmark specified by node_id and passes the parent folder
- // depth for metrics collection.
+ // Opens the bookmark specified by node_id. Passes the parent folder
+ // depth for metrics collection and the action source to identify
+ // from which surface this request is made.
OpenBookmark(int64 node_id, int32 parent_folder_depth,
- ui.mojom.ClickModifiers click_modifiers);
+ ui.mojom.ClickModifiers click_modifiers,
+ ActionSource source);
// Opens a context menu for a bookmark node. The id parameter is internally
// an int64 but gets passed as a string from the chrome.bookmarks Extension
- // API.
- ShowContextMenu(string id, gfx.mojom.Point point);
+ // API. The point parameter is the location where the context menu is
+ // triggered. The source parameter is the type of source item from which
+ // the context menu is triggered.
+ ShowContextMenu(string id, gfx.mojom.Point point, ActionSource source);
// Notify the backend that the UI is ready to be shown.
ShowUI();
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.cc b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.cc
index 91c9fda6842..bff9f724239 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h"
#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
+#include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -42,7 +43,8 @@ class BookmarkContextMenu : public ui::SimpleMenuModel,
explicit BookmarkContextMenu(
Browser* browser,
base::WeakPtr<ui::MojoBubbleWebUIController::Embedder> embedder,
- const bookmarks::BookmarkNode* bookmark)
+ const bookmarks::BookmarkNode* bookmark,
+ const side_panel::mojom::ActionSource& source)
: ui::SimpleMenuModel(this),
embedder_(embedder),
controller_(base::WrapUnique(new BookmarkContextMenuController(
@@ -50,12 +52,18 @@ class BookmarkContextMenu : public ui::SimpleMenuModel,
this,
browser,
browser->profile(),
- base::BindRepeating(
- [](content::PageNavigator* navigator) { return navigator; },
- browser),
- BOOKMARK_LAUNCH_LOCATION_SIDE_PANEL_CONTEXT_MENU,
+ BookmarkLaunchLocation::kSidePanelContextMenu,
bookmark->parent(),
{bookmark}))) {
+ if (source == side_panel::mojom::ActionSource::kPriceTracking) {
+ AddItem(IDC_BOOKMARK_BAR_OPEN_ALL);
+ AddItem(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW);
+ AddItem(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO);
+ AddSeparator(ui::NORMAL_SEPARATOR);
+ AddItem(IDC_BOOKMARK_MANAGER);
+ return;
+ }
+
AddItem(IDC_BOOKMARK_BAR_OPEN_ALL);
AddItem(IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW);
AddItem(IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO);
@@ -98,10 +106,11 @@ class BookmarkContextMenu : public ui::SimpleMenuModel,
private:
void AddItem(int command_id) {
- ui::SimpleMenuModel::AddItem(
- command_id,
- controller_->menu_model()->GetLabelAt(
- controller_->menu_model()->GetIndexOfCommandId(command_id)));
+ ui::SimpleMenuModel::AddItem(command_id,
+ controller_->menu_model()->GetLabelAt(
+ controller_->menu_model()
+ ->GetIndexOfCommandId(command_id)
+ .value()));
}
base::WeakPtr<ui::MojoBubbleWebUIController::Embedder> embedder_;
std::unique_ptr<BookmarkContextMenuController> controller_;
@@ -124,7 +133,8 @@ BookmarksPageHandler::~BookmarksPageHandler() = default;
void BookmarksPageHandler::OpenBookmark(
int64_t node_id,
int32_t parent_folder_depth,
- ui::mojom::ClickModifiersPtr click_modifiers) {
+ ui::mojom::ClickModifiersPtr click_modifiers,
+ side_panel::mojom::ActionSource source) {
Browser* browser = chrome::FindLastActive();
if (!browser)
return;
@@ -140,19 +150,20 @@ void BookmarksPageHandler::OpenBookmark(
click_modifiers->middle_button, click_modifiers->alt_key,
click_modifiers->ctrl_key, click_modifiers->meta_key,
click_modifiers->shift_key);
- content::OpenURLParams params(bookmark_node->url(), content::Referrer(),
- open_location,
- ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
- browser->OpenURL(params);
+ chrome::OpenAllIfAllowed(browser, {bookmark_node}, open_location, false);
+ if (source == side_panel::mojom::ActionSource::kPriceTracking)
+ return;
base::RecordAction(base::UserMetricsAction("SidePanel.Bookmarks.Navigation"));
RecordBookmarkLaunch(
- parent_folder_depth > 0 ? BOOKMARK_LAUNCH_LOCATION_SIDE_PANEL_SUBFOLDER
- : BOOKMARK_LAUNCH_LOCATION_SIDE_PANEL_FOLDER,
+ parent_folder_depth > 0 ? BookmarkLaunchLocation::kSidePanelSubfolder
+ : BookmarkLaunchLocation::kSidePanelFolder,
profile_metrics::GetBrowserProfileType(browser->profile()));
}
-void BookmarksPageHandler::ShowContextMenu(const std::string& id_string,
- const gfx::Point& point) {
+void BookmarksPageHandler::ShowContextMenu(
+ const std::string& id_string,
+ const gfx::Point& point,
+ side_panel::mojom::ActionSource source) {
int64_t id;
if (!base::StringToInt64(id_string, &id))
return;
@@ -172,7 +183,7 @@ void BookmarksPageHandler::ShowContextMenu(const std::string& id_string,
bookmarks_ui_ ? bookmarks_ui_->embedder() : reading_list_ui_->embedder();
if (embedder) {
embedder->ShowContextMenu(point, std::make_unique<BookmarkContextMenu>(
- browser, embedder, bookmark));
+ browser, embedder, bookmark, source));
}
}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.h b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.h
index 9587ea85cd5..64ce2bfe70e 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_page_handler.h
@@ -28,8 +28,11 @@ class BookmarksPageHandler : public side_panel::mojom::BookmarksPageHandler {
// side_panel::mojom::BookmarksPageHandler:
void OpenBookmark(int64_t node_id,
int32_t parent_folder_depth,
- ui::mojom::ClickModifiersPtr click_modifiers) override;
- void ShowContextMenu(const std::string& id, const gfx::Point& point) override;
+ ui::mojom::ClickModifiersPtr click_modifiers,
+ side_panel::mojom::ActionSource source) override;
+ void ShowContextMenu(const std::string& id,
+ const gfx::Point& point,
+ side_panel::mojom::ActionSource source) override;
void ShowUI() override;
private:
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc
index 81e2acf7cee..2627b8016a6 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.cc
@@ -17,6 +17,7 @@
#include "chrome/grit/side_panel_resources.h"
#include "chrome/grit/side_panel_resources_map.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/commerce/core/webui/shopping_list_handler.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
@@ -41,6 +42,7 @@ BookmarksSidePanelUI::BookmarksSidePanelUI(content::WebUI* web_ui)
{"sidePanelTitle", IDS_SIDE_PANEL_TITLE},
{"tooltipClose", IDS_CLOSE},
{"tooltipDelete", IDS_DELETE},
+ {"shoppingListFolderTitle", IDS_SIDE_PANEL_TRACKED_PRODUCTS},
};
for (const auto& str : kLocalizedStrings)
webui::AddLocalizedString(source, str.name, str.id);
@@ -78,8 +80,21 @@ void BookmarksSidePanelUI::BindInterface(
bookmarks_page_factory_receiver_.Bind(std::move(receiver));
}
+void BookmarksSidePanelUI::BindInterface(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ receiver) {
+ shopping_list_factory_receiver_.reset();
+ shopping_list_factory_receiver_.Bind(std::move(receiver));
+}
+
void BookmarksSidePanelUI::CreateBookmarksPageHandler(
mojo::PendingReceiver<side_panel::mojom::BookmarksPageHandler> receiver) {
bookmarks_page_handler_ =
std::make_unique<BookmarksPageHandler>(std::move(receiver), this);
}
+
+void BookmarksSidePanelUI::CreateShoppingListHandler(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandler> receiver) {
+ shopping_list_handler_ =
+ std::make_unique<commerce::ShoppingListHandler>(std::move(receiver));
+}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h
index 0092c0d5c56..e377e478bcd 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h
+++ b/chromium/chrome/browser/ui/webui/side_panel/bookmarks/bookmarks_side_panel_ui.h
@@ -9,6 +9,7 @@
#include "chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
+#include "components/commerce/core/mojom/shopping_list.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -16,9 +17,14 @@
class BookmarksPageHandler;
+namespace commerce {
+class ShoppingListHandler;
+}
+
class BookmarksSidePanelUI
: public ui::MojoBubbleWebUIController,
- public side_panel::mojom::BookmarksPageHandlerFactory {
+ public side_panel::mojom::BookmarksPageHandlerFactory,
+ public shopping_list::mojom::ShoppingListHandlerFactory {
public:
explicit BookmarksSidePanelUI(content::WebUI* web_ui);
BookmarksSidePanelUI(const BookmarksSidePanelUI&) = delete;
@@ -31,15 +37,27 @@ class BookmarksSidePanelUI
mojo::PendingReceiver<side_panel::mojom::BookmarksPageHandlerFactory>
receiver);
+ void BindInterface(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ receiver);
+
private:
- // side_panel::mojom::BookmarksPageHandlerFactory
+ // side_panel::mojom::BookmarksPageHandlerFactory:
void CreateBookmarksPageHandler(
mojo::PendingReceiver<side_panel::mojom::BookmarksPageHandler> receiver)
override;
+ // shopping_list::mojom::ShoppingListHandlerFactory:
+ void CreateShoppingListHandler(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandler> receiver)
+ override;
+
std::unique_ptr<BookmarksPageHandler> bookmarks_page_handler_;
mojo::Receiver<side_panel::mojom::BookmarksPageHandlerFactory>
bookmarks_page_factory_receiver_{this};
+ std::unique_ptr<commerce::ShoppingListHandler> shopping_list_handler_;
+ mojo::Receiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ shopping_list_factory_receiver_{this};
WEB_UI_CONTROLLER_TYPE_DECL();
};
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/BUILD.gn b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/BUILD.gn
new file mode 100644
index 00000000000..cb2f6f81935
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/BUILD.gn
@@ -0,0 +1,13 @@
+# Copyright 2022 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//mojo/public/tools/bindings/mojom.gni")
+
+assert(!is_android)
+
+mojom("mojo_bindings") {
+ sources = [ "customize_chrome.mojom" ]
+ webui_module_path = "/"
+ public_deps = [ "//mojo/public/mojom/base" ]
+}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/DIR_METADATA b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/DIR_METADATA
new file mode 100644
index 00000000000..b22028a9c6e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>NewTabPage"
+} \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/OWNERS b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/OWNERS
new file mode 100644
index 00000000000..611a17fda5f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/OWNERS
@@ -0,0 +1,4 @@
+file://chrome/browser/resources/new_tab_page/OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom
new file mode 100644
index 00000000000..b5474c302a8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom
@@ -0,0 +1,15 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module side_panel.mojom;
+
+// Browser-side handler for requests from WebUI page.
+interface CustomizeChromePageHandler {
+ // Sets the visibility of NTP tiles and whether custom links are enabled.
+ SetMostVisitedSettings(bool custom_links_enabled, bool shortcuts_visible);
+
+ // Returns the visibility of NTP tiles and whether custom links are enabled.
+ GetMostVisitedSettings() => (bool custom_links_enabled,
+ bool shortcuts_visible);
+}; \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_browsertest.cc b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_browsertest.cc
new file mode 100644
index 00000000000..cce5c8cf272
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_browsertest.cc
@@ -0,0 +1,106 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/feature_list.h"
+#include "base/test/scoped_feature_list.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/side_panel/customize_chrome/customize_chrome_tab_helper.h"
+#include "chrome/browser/ui/ui_features.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "components/search/ntp_features.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test.h"
+
+class CustomizeChromeSidePanelBrowserTest : public InProcessBrowserTest {
+ protected:
+ // InProcessBrowserTest:
+ void SetUp() override {
+ scoped_feature_list_.InitWithFeatures(
+ {ntp_features::kCustomizeChromeSidePanel, features::kUnifiedSidePanel},
+ {});
+ InProcessBrowserTest::SetUp();
+ }
+ // Activates the browser tab at `index`.
+ void ActivateTabAt(Browser* browser, int index);
+
+ // Appends a new tab with `url` to the end of the tabstrip.
+ void AppendTab(Browser* browser, const GURL& url);
+
+ // Returns the CustomizeChromeTabHelper associated with the tab
+ CustomizeChromeTabHelper* GetTabHelper(Browser* browser);
+
+ private:
+ base::test::ScopedFeatureList scoped_feature_list_;
+};
+
+void CustomizeChromeSidePanelBrowserTest::ActivateTabAt(Browser* browser,
+ int index) {
+ browser->tab_strip_model()->ActivateTabAt(index);
+}
+
+void CustomizeChromeSidePanelBrowserTest::AppendTab(Browser* browser,
+ const GURL& url) {
+ chrome::AddTabAt(browser, url, -1, true);
+}
+
+CustomizeChromeTabHelper* CustomizeChromeSidePanelBrowserTest::GetTabHelper(
+ Browser* browser) {
+ auto* web_contents = browser->tab_strip_model()->GetActiveWebContents();
+ return CustomizeChromeTabHelper::FromWebContents(web_contents);
+}
+
+IN_PROC_BROWSER_TEST_F(CustomizeChromeSidePanelBrowserTest,
+ RegisterCustomizeChromeSidePanel) {
+ auto* customize_chrome_tab_helper = GetTabHelper(browser());
+
+ // When navigating to the New Tab Page, the Customize Chrome entry should be
+ // available
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(),
+ GURL(chrome::kChromeUINewTabURL)));
+ EXPECT_TRUE(customize_chrome_tab_helper->IsCustomizeChromeEntryAvailable());
+
+ // After calling show, the customize chrome entry should be shown in the side
+ // panel
+ customize_chrome_tab_helper->ShowCustomizeChromeSidePanel();
+ EXPECT_TRUE(customize_chrome_tab_helper->IsCustomizeChromeEntryShowing());
+}
+
+IN_PROC_BROWSER_TEST_F(CustomizeChromeSidePanelBrowserTest,
+ DeregisterCustomizeChromeSidePanel) {
+ // If the Customize Chrome side panel is open and you navigate away from the
+ // NTP the side panel entry should not be in the tabs' registry and the side
+ // panel should not show the customize chrome entry
+ auto* customize_chrome_tab_helper = GetTabHelper(browser());
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(),
+ GURL(chrome::kChromeUINewTabURL)));
+ customize_chrome_tab_helper->ShowCustomizeChromeSidePanel();
+ EXPECT_TRUE(customize_chrome_tab_helper->IsCustomizeChromeEntryShowing());
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(),
+ GURL(chrome::kChromeUISettingsURL)));
+ EXPECT_FALSE(customize_chrome_tab_helper->IsCustomizeChromeEntryAvailable());
+ EXPECT_FALSE(customize_chrome_tab_helper->IsCustomizeChromeEntryShowing());
+}
+
+IN_PROC_BROWSER_TEST_F(CustomizeChromeSidePanelBrowserTest,
+ ContextualCustomizeChromeSidePanel) {
+ // The Customize Chrome side panel should be contextual, opening on one tab
+ // should not open it on other tabs.
+ AppendTab(browser(), GURL(chrome::kChromeUINewTabURL));
+ AppendTab(browser(), GURL(chrome::kChromeUINewTabURL));
+ ActivateTabAt(browser(), 1);
+ // Navigate to URL to allow WebUI to load, if not then callback that is set
+ // in the New Tab Page constructor and run when ShowCustomizeChromeSidePanel()
+ // is called will not be set.
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(),
+ GURL(chrome::kChromeUINewTabURL)));
+ auto* customize_chrome_tab_helper1 = GetTabHelper(browser());
+ EXPECT_FALSE(customize_chrome_tab_helper1->IsCustomizeChromeEntryShowing());
+ customize_chrome_tab_helper1->ShowCustomizeChromeSidePanel();
+ ActivateTabAt(browser(), 2);
+ auto* customize_chrome_tab_helper2 = GetTabHelper(browser());
+ EXPECT_FALSE(customize_chrome_tab_helper2->IsCustomizeChromeEntryShowing());
+}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.cc b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.cc
new file mode 100644
index 00000000000..32f7bc96a13
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.cc
@@ -0,0 +1,42 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/new_tab_page/ntp_pref_names.h"
+#include "components/prefs/pref_service.h"
+
+CustomizeChromePageHandler::CustomizeChromePageHandler(
+ mojo::PendingReceiver<side_panel::mojom::CustomizeChromePageHandler>
+ receiver,
+ Profile* profile)
+ : receiver_(this, std::move(receiver)), profile_(profile) {}
+
+CustomizeChromePageHandler::~CustomizeChromePageHandler() = default;
+
+void CustomizeChromePageHandler::SetMostVisitedSettings(
+ bool custom_links_enabled,
+ bool visible) {
+ if (IsShortcutsVisible() != visible)
+ profile_->GetPrefs()->SetBoolean(ntp_prefs::kNtpShortcutsVisible, visible);
+
+ if (IsCustomLinksEnabled() != custom_links_enabled) {
+ profile_->GetPrefs()->SetBoolean(ntp_prefs::kNtpUseMostVisitedTiles,
+ !custom_links_enabled);
+ }
+}
+
+void CustomizeChromePageHandler::GetMostVisitedSettings(
+ GetMostVisitedSettingsCallback callback) {
+ std::move(callback).Run(IsCustomLinksEnabled(), IsShortcutsVisible());
+}
+
+bool CustomizeChromePageHandler::IsCustomLinksEnabled() const {
+ return !profile_->GetPrefs()->GetBoolean(ntp_prefs::kNtpUseMostVisitedTiles);
+}
+
+bool CustomizeChromePageHandler::IsShortcutsVisible() const {
+ return profile_->GetPrefs()->GetBoolean(ntp_prefs::kNtpShortcutsVisible);
+}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h
new file mode 100644
index 00000000000..9cc06a1dc0e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h
@@ -0,0 +1,41 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_PAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_PAGE_HANDLER_H_
+
+#include "base/memory/raw_ptr.h"
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+
+class Profile;
+
+class CustomizeChromePageHandler
+ : public side_panel::mojom::CustomizeChromePageHandler {
+ public:
+ CustomizeChromePageHandler(
+ mojo::PendingReceiver<side_panel::mojom::CustomizeChromePageHandler>
+ receiver,
+ Profile* profile);
+
+ CustomizeChromePageHandler(const CustomizeChromePageHandler&) = delete;
+ CustomizeChromePageHandler& operator=(const CustomizeChromePageHandler&) =
+ delete;
+
+ ~CustomizeChromePageHandler() override;
+
+ // side_panel::mojom::CustomizeChromePageHandler:
+ void SetMostVisitedSettings(bool custom_links_enabled, bool visible) override;
+ void GetMostVisitedSettings(GetMostVisitedSettingsCallback callback) override;
+
+ private:
+ bool IsCustomLinksEnabled() const;
+ bool IsShortcutsVisible() const;
+
+ mojo::Receiver<side_panel::mojom::CustomizeChromePageHandler> receiver_;
+ raw_ptr<Profile> profile_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc
new file mode 100644
index 00000000000..990d469ae18
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.cc
@@ -0,0 +1,50 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h"
+
+#include <string>
+#include <utility>
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_page_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/side_panel_customize_chrome_resources.h"
+#include "chrome/grit/side_panel_customize_chrome_resources_map.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/web_ui_util.h"
+
+CustomizeChromeUI::CustomizeChromeUI(content::WebUI* web_ui)
+ : ui::MojoBubbleWebUIController(web_ui),
+ profile_(Profile::FromWebUI(web_ui)) {
+ content::WebUIDataSource* source = content::WebUIDataSource::Create(
+ chrome::kChromeUICustomizeChromeSidePanelHost);
+
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"title", IDS_SIDE_PANEL_CUSTOMIZE_CHROME_TITLE},
+ };
+ source->AddLocalizedStrings(kLocalizedStrings);
+
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kSidePanelCustomizeChromeResources,
+ kSidePanelCustomizeChromeResourcesSize),
+ IDR_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_HTML);
+
+ content::WebUIDataSource::Add(profile_, source);
+}
+
+CustomizeChromeUI::~CustomizeChromeUI() = default;
+
+WEB_UI_CONTROLLER_TYPE_IMPL(CustomizeChromeUI)
+
+void CustomizeChromeUI::BindInterface(
+ mojo::PendingReceiver<side_panel::mojom::CustomizeChromePageHandler>
+ receiver) {
+ customize_chrome_page_handler_ = std::make_unique<CustomizeChromePageHandler>(
+ std::move(receiver), profile_);
+}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h
new file mode 100644
index 00000000000..20aeeeade82
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome_ui.h
@@ -0,0 +1,42 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_UI_H_
+
+#include <memory>
+
+#include "chrome/browser/ui/webui/side_panel/customize_chrome/customize_chrome.mojom.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "ui/webui/mojo_bubble_web_ui_controller.h"
+
+class Profile;
+class CustomizeChromePageHandler;
+
+// WebUI controller for chrome://customize-chrome-side-panel.top-chrome
+class CustomizeChromeUI : public ui::MojoBubbleWebUIController {
+ public:
+ explicit CustomizeChromeUI(content::WebUI* web_ui);
+ CustomizeChromeUI(const CustomizeChromeUI&) = delete;
+ CustomizeChromeUI& operator=(const CustomizeChromeUI&) = delete;
+ ~CustomizeChromeUI() override;
+
+ // Instantiates the implementor of the
+ // mojom::CustomizeChromePageHandlerFactory mojo interface passing the pending
+ // receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<side_panel::mojom::CustomizeChromePageHandler>
+ receiver);
+
+ private:
+ std::unique_ptr<CustomizeChromePageHandler> customize_chrome_page_handler_;
+ raw_ptr<Profile> profile_;
+
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_CUSTOMIZE_CHROME_CUSTOMIZE_CHROME_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc b/chromium/chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc
index 87bd9107335..f0191944385 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.cc
@@ -27,14 +27,22 @@ HistoryClustersSidePanelUI::HistoryClustersSidePanelUI(content::WebUI* web_ui)
Profile* const profile = Profile::FromWebUI(web_ui);
- HistoryClustersUtil::PopulateSource(source, profile);
+ HistoryClustersUtil::PopulateSource(source, profile, /*in_side_panel=*/true);
content::URLDataSource::Add(
profile, std::make_unique<FaviconSource>(
profile, chrome::FaviconUrlFormat::kFavicon2));
+ const webui::ResourcePath kHistoryClustersResources[] = {
+ {"history_clusters/history_clusters.html",
+ IDR_SIDE_PANEL_HISTORY_CLUSTERS_HISTORY_CLUSTERS_HTML},
+ {"history_clusters/app.js", IDR_SIDE_PANEL_HISTORY_CLUSTERS_APP_JS},
+ {"history_clusters/app.html.js",
+ IDR_SIDE_PANEL_HISTORY_CLUSTERS_APP_HTML_JS},
+ };
+
webui::SetupWebUIDataSource(
- source, base::span<const webui::ResourcePath>(),
+ source, kHistoryClustersResources,
IDR_SIDE_PANEL_HISTORY_CLUSTERS_HISTORY_CLUSTERS_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source);
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/DEPS b/chromium/chrome/browser/ui/webui/side_panel/read_anything/DEPS
index 18ecc211e0f..4883ab91e83 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/DEPS
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/DEPS
@@ -1,4 +1,5 @@
include_rules = [
"+chrome/browser/ui/views/side_panel/read_anything",
- "+chrome/browser/ui/views/frame/browser_view.h"
-] \ No newline at end of file
+ "+chrome/browser/ui/views/frame/browser_view.h",
+ "+chrome/common/accessibility",
+]
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom
deleted file mode 100644
index 5337d5f7714..00000000000
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2021 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// A module for a prototype of the Read Anything feature.
-module read_anything.mojom;
-
-import "url/mojom/url.mojom";
-
-// Used by the WebUI page to bootstrap bidirectional communication.
-interface PageHandlerFactory {
- // The WebUI calls this method when the page is first initialized.
- CreatePageHandler(pending_remote<Page> page,
- pending_receiver<PageHandler> handler);
-};
-
-// The type of content node.
-enum ContentType {
- kHeading,
- kLink,
- kParagraph,
- kStaticText,
-};
-
-// A node that contains distilled content. All nodes have type ContentType.
-// Some node types have additional values, which are verified in WebUI:
-// ContentNode with type kHeading must have a heading_level.
-// ContentNode with type kStaticText must have text.
-// ContentNode with type kUrl must have a url.
-struct ContentNode {
- array<ContentNode> children;
- uint32 heading_level;
- string text;
- ContentType type;
- url.mojom.Url url;
-};
-
-// Browser-side handler for requests from WebUI page.
-interface PageHandler {
- // Notify the backend that the WebUI is ready.
- OnUIReady();
-};
-
-// WebUI-side handler for requests from the browser.
-interface Page {
- // Trigger the frontend to update the current read anything display. Content
- // nodes is a list of content nodes from a web page, where each node is part
- // of the main article for that web page.
- ShowContent(array<ContentNode> content_nodes);
-
- // Send an updated font name to front end.
- OnFontNameChange(string new_font_name);
-};
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.cc b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.cc
index 3e046820722..3ea7ec74ec7 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.cc
@@ -11,6 +11,11 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/side_panel/read_anything/read_anything_controller.h"
+#include "ui/accessibility/ax_tree_update.h"
+
+using read_anything::mojom::Page;
+using read_anything::mojom::PageHandler;
+using read_anything::mojom::ReadAnythingThemePtr;
ReadAnythingPageHandler::ReadAnythingPageHandler(
mojo::PendingRemote<Page> page,
@@ -24,46 +29,44 @@ ReadAnythingPageHandler::ReadAnythingPageHandler(
return;
coordinator_ = ReadAnythingCoordinator::FromBrowser(browser_);
- coordinator_->AddObserver(this);
- model_ = coordinator_->GetModel();
- model_->AddObserver(this);
+ if (coordinator_) {
+ coordinator_->AddObserver(this);
+ coordinator_->AddModelObserver(this);
+ }
+
delegate_ = static_cast<ReadAnythingPageHandler::Delegate*>(
coordinator_->GetController());
+ if (delegate_)
+ delegate_->OnUIReady();
}
ReadAnythingPageHandler::~ReadAnythingPageHandler() {
+ delegate_ = static_cast<ReadAnythingPageHandler::Delegate*>(
+ coordinator_->GetController());
+ if (delegate_)
+ delegate_->OnUIDestroyed();
+
// If |this| is destroyed before the |ReadAnythingCoordinator|, then remove
// |this| from the observer lists. In the cases where the coordinator is
// destroyed first, these will have been destroyed before this call.
- if (model_)
- model_->RemoveObserver(this);
-
- if (coordinator_)
+ if (coordinator_) {
coordinator_->RemoveObserver(this);
-}
-
-void ReadAnythingPageHandler::OnUIReady() {
- if (delegate_)
- delegate_->OnUIReady();
+ coordinator_->RemoveModelObserver(this);
+ }
}
void ReadAnythingPageHandler::OnCoordinatorDestroyed() {
coordinator_ = nullptr;
- model_ = nullptr;
delegate_ = nullptr;
}
-void ReadAnythingPageHandler::OnContentUpdated(
- const std::vector<ContentNodePtr>& content_nodes) {
- // Make a copy of |content_nodes|, which is stored in the model, before moving
- // across IPC to the WebUI.
- std::vector<ContentNodePtr> content_nodes_copy;
- for (auto it = content_nodes.begin(); it != content_nodes.end(); ++it)
- content_nodes_copy.push_back(it->Clone());
- page_->ShowContent(std::move(content_nodes_copy));
+void ReadAnythingPageHandler::OnAXTreeDistilled(
+ const ui::AXTreeUpdate& snapshot,
+ const std::vector<ui::AXNodeID>& content_node_ids) {
+ page_->OnAXTreeDistilled(snapshot, content_node_ids);
}
-void ReadAnythingPageHandler::OnFontNameUpdated(
- const std::string& new_font_name) {
- page_->OnFontNameChange(new_font_name);
+void ReadAnythingPageHandler::OnReadAnythingThemeChanged(
+ ReadAnythingThemePtr new_theme_ptr) {
+ page_->OnThemeChanged(std::move(new_theme_ptr));
}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.h b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.h
index 7b0d97c6d0a..376d3cdeefc 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_page_handler.h
@@ -9,19 +9,16 @@
#include <vector>
#include "base/memory/raw_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/side_panel/read_anything/read_anything_coordinator.h"
#include "chrome/browser/ui/views/side_panel/read_anything/read_anything_model.h"
-#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom.h"
+#include "chrome/common/accessibility/read_anything.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
-
-using read_anything::mojom::ContentNodePtr;
-using read_anything::mojom::Page;
-using read_anything::mojom::PageHandler;
+#include "ui/accessibility/ax_node_id_forward.h"
+#include "ui/accessibility/ax_tree_update_forward.h"
///////////////////////////////////////////////////////////////////////////////
// ReadAnythingPageHandler
@@ -31,42 +28,41 @@ using read_anything::mojom::PageHandler;
// This class is created and owned by ReadAnythingUI and has the same lifetime
// as the Side Panel view.
//
-class ReadAnythingPageHandler : public PageHandler,
+class ReadAnythingPageHandler : public read_anything::mojom::PageHandler,
public ReadAnythingModel::Observer,
public ReadAnythingCoordinator::Observer {
public:
class Delegate {
public:
virtual void OnUIReady() = 0;
+ virtual void OnUIDestroyed() = 0;
};
- ReadAnythingPageHandler(mojo::PendingRemote<Page> page,
- mojo::PendingReceiver<PageHandler> receiver);
+ ReadAnythingPageHandler(
+ mojo::PendingRemote<read_anything::mojom::Page> page,
+ mojo::PendingReceiver<read_anything::mojom::PageHandler> receiver);
ReadAnythingPageHandler(const ReadAnythingPageHandler&) = delete;
ReadAnythingPageHandler& operator=(const ReadAnythingPageHandler&) = delete;
~ReadAnythingPageHandler() override;
- // PageHandler:
- void OnUIReady() override;
-
// ReadAnythingModel::Observer:
- void OnFontNameUpdated(const std::string& new_font_name) override;
- void OnContentUpdated(
- const std::vector<ContentNodePtr>& content_nodes) override;
+ void OnAXTreeDistilled(
+ const ui::AXTreeUpdate& snapshot,
+ const std::vector<ui::AXNodeID>& content_node_ids) override;
+ void OnReadAnythingThemeChanged(
+ read_anything::mojom::ReadAnythingThemePtr new_theme) override;
// ReadAnythingCoordinator::Observer:
void OnCoordinatorDestroyed() override;
private:
raw_ptr<ReadAnythingCoordinator> coordinator_;
- raw_ptr<ReadAnythingModel> model_;
raw_ptr<ReadAnythingPageHandler::Delegate> delegate_;
raw_ptr<Browser> browser_;
- mojo::Receiver<PageHandler> receiver_;
- mojo::Remote<Page> page_;
- base::WeakPtrFactory<ReadAnythingPageHandler> weak_pointer_factory_{this};
+ mojo::Receiver<read_anything::mojom::PageHandler> receiver_;
+ mojo::Remote<read_anything::mojom::Page> page_;
};
#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_READ_ANYTHING_READ_ANYTHING_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.cc b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.cc
new file mode 100644
index 00000000000..9f310ac46ec
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.cc
@@ -0,0 +1,42 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h"
+
+#include "chrome/browser/ui/views/side_panel/read_anything/read_anything_constants.h"
+#include "chrome/common/accessibility/read_anything.mojom.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+
+namespace prefs {
+
+#if !BUILDFLAG(IS_ANDROID)
+// String to represent the user's preferred font name for the read anything UI.
+const char kAccessibilityReadAnythingFontName[] =
+ "settings.a11y.read_anything.font_name";
+
+// Double to represent the user's preferred font size scaling factor.
+const char kAccessibilityReadAnythingFontScale[] =
+ "settings.a11y.read_anything.font_scale";
+
+// Int value to represent the user's preferred color settings.
+const char kAccessibilityReadAnythingColorInfo[] =
+ "settings.a11y.read_anything.color_info";
+
+} // namespace prefs
+
+void RegisterReadAnythingProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterStringPref(prefs::kAccessibilityReadAnythingFontName,
+ kReadAnythingDefaultFontName,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ registry->RegisterDoublePref(prefs::kAccessibilityReadAnythingFontScale,
+ kReadAnythingDefaultFontScale,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ registry->RegisterIntegerPref(
+ prefs::kAccessibilityReadAnythingColorInfo,
+ (int)read_anything::mojom::Colors::kDefaultValue,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+}
+
+#endif // !BUILDFLAG(IS_ANDROID)
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h
new file mode 100644
index 00000000000..4c0e067c59e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_prefs.h
@@ -0,0 +1,30 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_READ_ANYTHING_READ_ANYTHING_PREFS_H_
+#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_READ_ANYTHING_READ_ANYTHING_PREFS_H_
+
+#include "build/build_config.h"
+#include "chrome/common/buildflags.h"
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace prefs {
+
+#if !BUILDFLAG(IS_ANDROID)
+
+extern const char kAccessibilityReadAnythingFontName[];
+extern const char kAccessibilityReadAnythingFontScale[];
+extern const char kAccessibilityReadAnythingColorInfo[];
+
+} // namespace prefs
+
+void RegisterReadAnythingProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry);
+
+#endif // !BUILDFLAG(IS_ANDROID)
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_READ_ANYTHING_READ_ANYTHING_PREFS_H_
diff --git a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h
index 93757429041..a13425abfc2 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h
+++ b/chromium/chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h
@@ -7,7 +7,7 @@
#include <memory>
-#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom.h"
+#include "chrome/common/accessibility/read_anything.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chromium/chrome/browser/ui/webui/side_panel/reading_list/BUILD.gn b/chromium/chrome/browser/ui/webui/side_panel/reading_list/BUILD.gn
index 465afff0603..81afc59bbe0 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/reading_list/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/side_panel/reading_list/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(!is_android)
+
mojom("mojo_bindings") {
sources = [ "reading_list.mojom" ]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/side_panel/reading_list/DEPS b/chromium/chrome/browser/ui/webui/side_panel/reading_list/DEPS
new file mode 100644
index 00000000000..e20eb35ffe1
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/side_panel/reading_list/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+chrome/common/accessibility",
+]
diff --git a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
index 528bd03ef25..d143e28ffea 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.cc
@@ -191,7 +191,7 @@ void ReadingListPageHandler::OpenURL(
base::RecordAction(
base::UserMetricsAction("SidePanel.ReadingList.Navigation"));
RecordBookmarkLaunch(
- BOOKMARK_LAUNCH_LOCATION_SIDE_PANEL_READING_LIST,
+ BookmarkLaunchLocation::kSidePanelPendingList,
profile_metrics::GetBrowserProfileType(Profile::FromWebUI(web_ui_)));
}
diff --git a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.cc b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.cc
index e7a16f81c3c..45022891ca7 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.cc
+++ b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.cc
@@ -20,6 +20,7 @@
#include "chrome/grit/side_panel_resources.h"
#include "chrome/grit/side_panel_resources_map.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/commerce/core/webui/shopping_list_handler.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/prefs/pref_service.h"
#include "components/reading_list/core/reading_list_model.h"
@@ -59,6 +60,7 @@ ReadingListUI::ReadingListUI(content::WebUI* web_ui)
{"tooltipMarkAsRead", IDS_READ_LATER_MENU_TOOLTIP_MARK_AS_READ},
{"tooltipMarkAsUnread", IDS_READ_LATER_MENU_TOOLTIP_MARK_AS_UNREAD},
{"unreadHeader", IDS_READ_LATER_MENU_UNREAD_HEADER},
+ {"shoppingListFolderTitle", IDS_SIDE_PANEL_TRACKED_PRODUCTS},
};
for (const auto& str : kLocalizedStrings)
webui::AddLocalizedString(source, str.name, str.id);
@@ -140,6 +142,19 @@ void ReadingListUI::CreatePageHandler(
std::move(page), std::move(receiver));
}
+void ReadingListUI::BindInterface(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ receiver) {
+ shopping_list_factory_receiver_.reset();
+ shopping_list_factory_receiver_.Bind(std::move(receiver));
+}
+
+void ReadingListUI::CreateShoppingListHandler(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandler> receiver) {
+ shopping_list_handler_ =
+ std::make_unique<commerce::ShoppingListHandler>(std::move(receiver));
+}
+
void ReadingListUI::SetActiveTabURL(const GURL& url) {
if (page_handler_)
page_handler_->SetActiveTabURL(url);
diff --git a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h
index 3dd23b0dc98..a55dda8d279 100644
--- a/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h
+++ b/chromium/chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h
@@ -8,9 +8,10 @@
#include <memory>
#include "chrome/browser/ui/webui/side_panel/bookmarks/bookmarks.mojom.h"
-#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything.mojom.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list.mojom.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
+#include "chrome/common/accessibility/read_anything.mojom.h"
+#include "components/commerce/core/mojom/shopping_list.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -20,10 +21,15 @@ class BookmarksPageHandler;
class ReadAnythingPageHandler;
class ReadingListPageHandler;
+namespace commerce {
+class ShoppingListHandler;
+}
+
class ReadingListUI : public ui::MojoBubbleWebUIController,
public reading_list::mojom::PageHandlerFactory,
public side_panel::mojom::BookmarksPageHandlerFactory,
- public read_anything::mojom::PageHandlerFactory {
+ public read_anything::mojom::PageHandlerFactory,
+ public shopping_list::mojom::ShoppingListHandlerFactory {
public:
explicit ReadingListUI(content::WebUI* web_ui);
ReadingListUI(const ReadingListUI&) = delete;
@@ -42,6 +48,10 @@ class ReadingListUI : public ui::MojoBubbleWebUIController,
void BindInterface(
mojo::PendingReceiver<read_anything::mojom::PageHandlerFactory> receiver);
+ void BindInterface(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ receiver);
+
void SetActiveTabURL(const GURL& url);
private:
@@ -50,7 +60,7 @@ class ReadingListUI : public ui::MojoBubbleWebUIController,
mojo::PendingReceiver<reading_list::mojom::PageHandler>
receiver) override;
- // side_panel::mojom::BookmarksPageHandlerFactory
+ // side_panel::mojom::BookmarksPageHandlerFactory:
void CreateBookmarksPageHandler(
mojo::PendingReceiver<side_panel::mojom::BookmarksPageHandler> receiver)
override;
@@ -61,6 +71,11 @@ class ReadingListUI : public ui::MojoBubbleWebUIController,
mojo::PendingReceiver<read_anything::mojom::PageHandler> receiver)
override;
+ // shopping_list::mojom::ShoppingListHandlerFactory:
+ void CreateShoppingListHandler(
+ mojo::PendingReceiver<shopping_list::mojom::ShoppingListHandler> receiver)
+ override;
+
std::unique_ptr<ReadingListPageHandler> page_handler_;
mojo::Receiver<reading_list::mojom::PageHandlerFactory>
page_factory_receiver_{this};
@@ -73,6 +88,10 @@ class ReadingListUI : public ui::MojoBubbleWebUIController,
mojo::Receiver<read_anything::mojom::PageHandlerFactory>
read_anything_page_factory_receiver_{this};
+ std::unique_ptr<commerce::ShoppingListHandler> shopping_list_handler_;
+ mojo::Receiver<shopping_list::mojom::ShoppingListHandlerFactory>
+ shopping_list_factory_receiver_{this};
+
WebuiLoadTimer webui_load_timer_;
WEB_UI_CONTROLLER_TYPE_DECL();
diff --git a/chromium/chrome/browser/ui/webui/signin/OWNERS b/chromium/chrome/browser/ui/webui/signin/OWNERS
index dcf4b25d339..bd7918d7ae1 100644
--- a/chromium/chrome/browser/ui/webui/signin/OWNERS
+++ b/chromium/chrome/browser/ui/webui/signin/OWNERS
@@ -10,5 +10,5 @@ xiyuan@chromium.org
per-file inline_login_handler_impl*=file://chrome/credential_provider/OWNERS
per-file inline_login_handler.*=file://chrome/credential_provider/OWNERS
-per-file inline_login_*_chromeos*=file://ash/components/account_manager/OWNERS
-per-file signin_helper_chromeos.*=file://ash/components/account_manager/OWNERS
+per-file inline_login_*_chromeos*=file://chromeos/ash/components/account_manager/OWNERS
+per-file signin_helper_chromeos.*=file://chromeos/ash/components/account_manager/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
index 141fbe8b187..5c7e1c04648 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"
+#include <string>
+
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
@@ -17,10 +19,14 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_features.h"
+#include "chrome/browser/ui/managed_ui.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
+#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
+#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/management/management_service.h"
+#include "components/signin/public/identity_manager/account_info.h"
#include "content/public/browser/web_ui.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -179,6 +185,7 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
parameters.SetStringKey("bodyText", GetBodyText());
parameters.SetStringKey("confirmButtonLabel", GetConfirmButtonLabel());
parameters.SetStringKey("cancelButtonLabel", GetCancelButtonLabel());
+ parameters.SetStringKey("managedDisclaimerText", GetManagedDisclaimerText());
parameters.SetBoolKey("showGuestOption",
bubble_parameters_.show_guest_option);
parameters.SetKey("interceptedAccount",
@@ -192,6 +199,8 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
color_utils::SkColorToRgbaString(
GetProfileHighlightColor(Profile::FromWebUI(web_ui()))));
parameters.SetBoolKey("useV2Design", GetShouldUseV2Design());
+ parameters.SetBoolKey("showManagedDisclaimer",
+ bubble_parameters_.show_managed_disclaimer);
parameters.SetStringKey(
"headerTextColor",
@@ -313,6 +322,29 @@ std::string DiceWebSigninInterceptHandler::GetCancelButtonLabel() {
: IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL);
}
+std::string DiceWebSigninInterceptHandler::GetManagedDisclaimerText() {
+ std::string learn_more_url =
+ google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kSigninInterceptManagedDisclaimerLearnMoreURL),
+ g_browser_process->GetApplicationLocale())
+ .spec();
+ std::string manager_domain = intercepted_account().IsManaged()
+ ? intercepted_account().hosted_domain
+ : std::string();
+ if (manager_domain.empty())
+ manager_domain = chrome::GetDeviceManagerIdentity().value_or(std::string());
+
+ if (manager_domain.empty()) {
+ return l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_DISCLAIMER,
+ base::ASCIIToUTF16(learn_more_url));
+ }
+
+ return l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_MANAGED_BY_DISCLAIMER,
+ base::ASCIIToUTF16(manager_domain), base::ASCIIToUTF16(learn_more_url));
+}
+
bool DiceWebSigninInterceptHandler::GetShouldUseV2Design() {
if (bubble_parameters_.interception_type ==
DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch)
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
index 45f1d5434a6..f9526a3ae03 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h
@@ -64,6 +64,7 @@ class DiceWebSigninInterceptHandler : public content::WebUIMessageHandler,
std::string GetBodyText();
std::string GetConfirmButtonLabel();
std::string GetCancelButtonLabel();
+ std::string GetManagedDisclaimerText();
bool GetShouldUseV2Design();
base::ScopedObservation<signin::IdentityManager,
diff --git a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.cc b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.cc
index 3b0c8649f33..6bc3be09ae5 100644
--- a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.cc
@@ -24,9 +24,11 @@
#include "chrome/browser/ui/webui/management/management_ui_handler.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/google_chrome_strings.h"
+#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
@@ -113,12 +115,16 @@ EnterpriseProfileWelcomeHandler::EnterpriseProfileWelcomeHandler(
Browser* browser,
EnterpriseProfileWelcomeUI::ScreenType type,
bool profile_creation_required_by_policy,
+ bool show_link_data_option,
const AccountInfo& account_info,
absl::optional<SkColor> profile_color,
signin::SigninChoiceCallback proceed_callback)
: browser_(browser),
type_(type),
profile_creation_required_by_policy_(profile_creation_required_by_policy),
+#if !BUILDFLAG(IS_CHROMEOS)
+ show_link_data_option_(show_link_data_option),
+#endif
email_(base::UTF8ToUTF16(account_info.email)),
domain_name_(gaia::ExtractDomainName(account_info.email)),
account_id_(account_info.account_id),
@@ -302,6 +308,13 @@ base::Value EnterpriseProfileWelcomeHandler::GetProfileInfoValue() {
profile_creation_required_by_policy_
? IDS_ENTERPRISE_PROFILE_WELCOME_CREATE_PROFILE_BUTTON
: IDS_WELCOME_SIGNIN_VIEW_SIGNIN));
+#if !BUILDFLAG(IS_CHROMEOS)
+ dict.SetBoolKey(
+ "checkLinkDataCheckboxByDefault",
+ show_link_data_option_ &&
+ g_browser_process->local_state()->GetBoolean(
+ prefs::kEnterpriseProfileCreationKeepBrowsingData));
+#endif
break;
#if BUILDFLAG(IS_CHROMEOS_LACROS)
case EnterpriseProfileWelcomeUI::ScreenType::kLacrosEnterpriseWelcome:
diff --git a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.h b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.h
index 23e0d0a22a4..6517ea43b10 100644
--- a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler.h
@@ -42,6 +42,7 @@ class EnterpriseProfileWelcomeHandler
Browser* browser,
EnterpriseProfileWelcomeUI::ScreenType type,
bool profile_creation_required_by_policy,
+ bool show_link_data_option,
const AccountInfo& account_info,
absl::optional<SkColor> profile_color,
signin::SigninChoiceCallback proceed_callback);
@@ -114,6 +115,9 @@ class EnterpriseProfileWelcomeHandler
raw_ptr<Browser> browser_ = nullptr;
const EnterpriseProfileWelcomeUI::ScreenType type_;
const bool profile_creation_required_by_policy_;
+#if !BUILDFLAG(IS_CHROMEOS)
+ const bool show_link_data_option_;
+#endif
const std::u16string email_;
const std::string domain_name_;
const CoreAccountId account_id_;
diff --git a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler_unittest.cc
index c9fb3cde179..86062035bb9 100644
--- a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_handler_unittest.cc
@@ -48,12 +48,14 @@ class EnterpriseProfileWelcomeHandlerTestBase
void InitializeHandler(EnterpriseProfileWelcomeUI::ScreenType screen_type,
bool profile_creation_required_by_policy,
+ bool show_link_data_option,
signin::SigninChoiceCallback proceed_callback) {
message_handler_.reset();
message_handler_ = std::make_unique<EnterpriseProfileWelcomeHandler>(
/*browser=*/nullptr, screen_type, profile_creation_required_by_policy,
- account_info_, absl::optional<SkColor>(), std::move(proceed_callback));
+ show_link_data_option, account_info_, absl::optional<SkColor>(),
+ std::move(proceed_callback));
message_handler_->set_web_ui_for_test(web_ui());
message_handler_->RegisterMessages();
}
@@ -96,12 +98,12 @@ TEST_P(EnterpriseProfileWelcomeHandleProceedTest, HandleProceed) {
InitializeHandler(
EnterpriseProfileWelcomeUI::ScreenType::kEntepriseAccountSyncEnabled,
GetParam().profile_creation_required_by_policy,
- mock_proceed_callback.Get());
+ /*show_link_data_option=*/true, mock_proceed_callback.Get());
- base::ListValue args;
+ base::Value::List args;
args.Append(GetParam().should_link_data);
EXPECT_CALL(mock_proceed_callback, Run(GetParam().expected_choice));
- web_ui()->HandleReceivedMessage("proceed", &args);
+ web_ui()->HandleReceivedMessage("proceed", args);
}
INSTANTIATE_TEST_SUITE_P(All,
diff --git a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_ui.cc b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_ui.cc
index a163b8f7061..0baef3bc6e2 100644
--- a/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/enterprise_profile_welcome_ui.cc
@@ -78,8 +78,8 @@ void EnterpriseProfileWelcomeUI::Initialize(
absl::optional<SkColor> profile_color,
signin::SigninChoiceCallback proceed_callback) {
auto handler = std::make_unique<EnterpriseProfileWelcomeHandler>(
- browser, type, profile_creation_required_by_policy, account_info,
- profile_color, std::move(proceed_callback));
+ browser, type, profile_creation_required_by_policy, show_link_data_option,
+ account_info, profile_color, std::move(proceed_callback));
handler_ = handler.get();
if (type ==
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc
index 0a2e5f0a693..396cd530a07 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc
@@ -36,7 +36,9 @@ class ChildModalDialogDelegate : public views::DialogDelegateView {
DCHECK(owned_by_widget());
SetModalType(ui::MODAL_TYPE_CHILD);
SetFocusBehavior(FocusBehavior::ALWAYS);
- // Dialogs that take focus must have a name to pass accessibility checks.
+ // Dialogs that take focus must have a name and role to pass accessibility
+ // checks.
+ GetViewAccessibility().OverrideRole(ax::mojom::Role::kDialog);
GetViewAccessibility().OverrideName("Test dialog");
}
ChildModalDialogDelegate(const ChildModalDialogDelegate&) = delete;
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
index ee94de523d0..8a7d4e04e43 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
@@ -34,6 +34,7 @@
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/url_util.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
+#include "third_party/blink/public/common/storage_key/storage_key.h"
const char kSignInPromoQueryKeyShowAccountManagement[] =
"showAccountManagement";
@@ -54,23 +55,23 @@ InlineLoginHandler::CompleteLoginParams::operator=(
InlineLoginHandler::CompleteLoginParams::~CompleteLoginParams() = default;
void InlineLoginHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"initialize",
base::BindRepeating(&InlineLoginHandler::HandleInitializeMessage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"authExtensionReady",
base::BindRepeating(&InlineLoginHandler::HandleAuthExtensionReadyMessage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"completeLogin",
base::BindRepeating(&InlineLoginHandler::HandleCompleteLoginMessage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"switchToFullTab",
base::BindRepeating(&InlineLoginHandler::HandleSwitchToFullTabMessage,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"dialogClose", base::BindRepeating(&InlineLoginHandler::HandleDialogClose,
base::Unretained(this)));
}
@@ -79,7 +80,8 @@ void InlineLoginHandler::OnJavascriptDisallowed() {
weak_ptr_factory_.InvalidateWeakPtrs();
}
-void InlineLoginHandler::HandleInitializeMessage(const base::ListValue* args) {
+void InlineLoginHandler::HandleInitializeMessage(
+ const base::Value::List& args) {
AllowJavascript();
content::WebContents* contents = web_ui()->GetWebContents();
content::StoragePartition* partition =
@@ -97,8 +99,8 @@ void InlineLoginHandler::HandleInitializeMessage(const base::ListValue* args) {
value == "0") {
partition->ClearData(
content::StoragePartition::REMOVE_DATA_MASK_ALL,
- content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(),
- base::Time(), base::Time::Max(),
+ content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
+ blink::StorageKey(), base::Time(), base::Time::Max(),
base::BindOnce(&InlineLoginHandler::ContinueHandleInitializeMessage,
weak_ptr_factory_.GetWeakPtr()));
} else {
@@ -127,9 +129,7 @@ void InlineLoginHandler::ContinueHandleInitializeMessage() {
signin_metrics::LogSigninAccessPointStarted(
access_point,
signin_metrics::PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO);
- signin_metrics::RecordSigninUserActionForAccessPoint(
- access_point,
- signin_metrics::PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO);
+ signin_metrics::RecordSigninUserActionForAccessPoint(access_point);
base::RecordAction(base::UserMetricsAction("Signin_SigninPage_Loading"));
params.Set("isLoginPrimaryAccount", true);
}
@@ -162,7 +162,7 @@ void InlineLoginHandler::ContinueHandleInitializeMessage() {
}
void InlineLoginHandler::HandleCompleteLoginMessage(
- const base::ListValue* args) {
+ const base::Value::List& args) {
// When the network service is enabled, the webRequest API doesn't expose
// cookie headers. So manually fetch the cookies for the GAIA URL from the
// CookieManager.
@@ -175,15 +175,14 @@ void InlineLoginHandler::HandleCompleteLoginMessage(
net::CookieOptions::MakeAllInclusive(),
net::CookiePartitionKeyCollection::Todo(),
base::BindOnce(&InlineLoginHandler::HandleCompleteLoginMessageWithCookies,
- weak_ptr_factory_.GetWeakPtr(),
- base::ListValue(args->GetListDeprecated())));
+ weak_ptr_factory_.GetWeakPtr(), args.Clone()));
}
void InlineLoginHandler::HandleCompleteLoginMessageWithCookies(
- const base::ListValue& args,
+ const base::Value::List& args,
const net::CookieAccessResultList& cookies,
const net::CookieAccessResultList& excluded_cookies) {
- const base::Value& dict = args.GetListDeprecated()[0];
+ const base::Value& dict = args[0];
CompleteLoginParams params;
params.email = dict.FindKey("email")->GetString();
@@ -209,7 +208,7 @@ void InlineLoginHandler::HandleCompleteLoginMessageWithCookies(
}
void InlineLoginHandler::HandleSwitchToFullTabMessage(
- const base::ListValue* args) {
+ const base::Value::List& args) {
Browser* browser =
chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
if (browser) {
@@ -219,7 +218,7 @@ void InlineLoginHandler::HandleSwitchToFullTabMessage(
// Note: URL string is expected to be in the first argument,
// but it is not used.
- CHECK(args->GetListDeprecated()[0].is_string());
+ CHECK(args[0].is_string());
Profile* profile = Profile::FromWebUI(web_ui());
GURL main_frame_url(web_ui()->GetWebContents()->GetLastCommittedURL());
@@ -240,7 +239,7 @@ void InlineLoginHandler::HandleSwitchToFullTabMessage(
CloseDialogFromJavascript();
}
-void InlineLoginHandler::HandleDialogClose(const base::ListValue* args) {
+void InlineLoginHandler::HandleDialogClose(const base::Value::List& args) {
#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Does nothing if profile picker is not showing.
ProfilePickerForceSigninDialog::HideDialog();
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
index 1a9cdf93894..b7022bc7348 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
@@ -69,31 +69,31 @@ class InlineLoginHandler : public content::WebUIMessageHandler {
private:
// JS callback to prepare for starting auth.
- void HandleInitializeMessage(const base::ListValue* args);
+ void HandleInitializeMessage(const base::Value::List& args);
// Continue to initialize the gaia auth extension. It calls
// |SetExtraInitParams| to set extra init params.
void ContinueHandleInitializeMessage();
// JS callback to handle tasks after auth extension loads.
- virtual void HandleAuthExtensionReadyMessage(const base::ListValue* args) {}
+ virtual void HandleAuthExtensionReadyMessage(const base::Value::List& args) {}
// JS callback to complete login. It calls |CompleteLogin| to do the real
// work.
- void HandleCompleteLoginMessage(const base::ListValue* args);
+ void HandleCompleteLoginMessage(const base::Value::List& args);
// Called by HandleCompleteLoginMessage after it gets the GAIA URL's cookies
// from the CookieManager.
void HandleCompleteLoginMessageWithCookies(
- const base::ListValue& args,
+ const base::Value::List& args,
const net::CookieAccessResultList& cookies,
const net::CookieAccessResultList& excluded_cookies);
// JS callback to switch the UI from a constrainted dialog to a full tab.
- void HandleSwitchToFullTabMessage(const base::ListValue* args);
+ void HandleSwitchToFullTabMessage(const base::Value::List& args);
// Handles the web ui message sent when the window is closed from javascript.
- virtual void HandleDialogClose(const base::ListValue* args);
+ virtual void HandleDialogClose(const base::Value::List& args);
virtual void SetExtraInitParams(base::Value::Dict& params) {}
virtual void CompleteLogin(const CompleteLoginParams& params) = 0;
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc
index b60ceadd21d..413d67288f9 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc
@@ -7,7 +7,6 @@
#include <memory>
#include <string>
-#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/constants/ash_pref_names.h"
#include "base/base64.h"
#include "base/callback_helpers.h"
@@ -28,7 +27,8 @@
#include "chrome/browser/ui/webui/signin/inline_login_handler.h"
#include "chrome/browser/ui/webui/signin/signin_helper_chromeos.h"
#include "chrome/common/pref_names.h"
-#include "chromeos/dbus/util/version_loader.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
+#include "chromeos/version/version_loader.h"
#include "components/account_manager_core/account.h"
#include "components/account_manager_core/account_manager_facade.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
@@ -310,7 +310,7 @@ void InlineLoginHandlerChromeOS::CompleteLogin(
}
void InlineLoginHandlerChromeOS::HandleDialogClose(
- const base::ListValue* args) {
+ const base::Value::List& args) {
close_dialog_closure_.Run();
}
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
index 8a007744074..9f7bb461fdf 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
@@ -37,7 +37,7 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
void RegisterMessages() override;
void SetExtraInitParams(base::Value::Dict& params) override;
void CompleteLogin(const CompleteLoginParams& params) override;
- void HandleDialogClose(const base::ListValue* args) override;
+ void HandleDialogClose(const base::Value::List& args) override;
private:
// A callback for `GetAccounts` invoked from `CompleteLogin`.
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos_browsertest.cc
index af7612e59e9..abe7b0fcb54 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos_browsertest.cc
@@ -272,15 +272,15 @@ class InlineLoginHandlerChromeOSTest
}
void CompleteConsentLogForChildUser(const std::string& secondary_email) {
- base::ListValue call_args;
+ base::Value::List call_args;
call_args.Append(secondary_email);
call_args.Append(kToSVersion);
- base::ListValue list_args;
+ base::Value::List list_args;
list_args.Append(kConsentLoggedCallback);
list_args.Append(std::move(call_args));
- web_ui()->HandleReceivedMessage("consentLogged", &list_args);
+ web_ui()->HandleReceivedMessage("consentLogged", list_args);
}
ash::FakeChromeUserManager* GetFakeUserManager() const {
@@ -322,9 +322,9 @@ IN_PROC_BROWSER_TEST_P(InlineLoginHandlerChromeOSTest,
->AddObserver(&observer);
// Call "completeLogin".
- base::ListValue args;
+ base::Value::List args;
args.Append(GetCompleteLoginArgs(kSecondaryAccount1Email));
- web_ui()->HandleReceivedMessage(kCompleteLoginMessage, &args);
+ web_ui()->HandleReceivedMessage(kCompleteLoginMessage, args);
if (GetDeviceAccountInfo().user_type ==
user_manager::UserType::USER_TYPE_CHILD) {
@@ -350,9 +350,9 @@ IN_PROC_BROWSER_TEST_P(InlineLoginHandlerChromeOSTest,
->AddObserver(&observer);
// Call "completeLogin".
- base::ListValue args;
+ base::Value::List args;
args.Append(GetCompleteLoginArgs(GetDeviceAccountInfo().email));
- web_ui()->HandleReceivedMessage(kCompleteLoginMessage, &args);
+ web_ui()->HandleReceivedMessage(kCompleteLoginMessage, args);
// Wait until account is added.
base::RunLoop run_loop;
@@ -374,10 +374,7 @@ class InlineLoginHandlerChromeOSTestWithArcRestrictions
: public InlineLoginHandlerChromeOSTest {
public:
InlineLoginHandlerChromeOSTestWithArcRestrictions() {
- feature_list_.InitWithFeatures(
- /*enabled_features=*/{chromeos::features::kArcAccountRestrictions,
- chromeos::features::kLacrosSupport},
- /*disabled_features=*/{});
+ feature_list_.InitAndEnableFeature(chromeos::features::kLacrosSupport);
}
~InlineLoginHandlerChromeOSTestWithArcRestrictions() override = default;
@@ -431,10 +428,9 @@ class InlineLoginHandlerChromeOSTestWithArcRestrictions
const base::span<const base::Value> CallGetAccountsNotAvailableInArc() {
// Call "getAccountsNotAvailableInArc".
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append(kHandleFunctionName);
- web_ui()->HandleReceivedMessage(kGetAccountsNotAvailableInArcMessage,
- &base::Value::AsListValue(args));
+ web_ui()->HandleReceivedMessage(kGetAccountsNotAvailableInArcMessage, args);
base::RunLoop().RunUntilIdle();
const content::TestWebUI::CallData& call_data =
@@ -462,9 +458,9 @@ IN_PROC_BROWSER_TEST_P(InlineLoginHandlerChromeOSTestWithArcRestrictions,
&apps_availability_observer);
// Call "completeLogin".
- base::ListValue args;
+ base::Value::List args;
args.Append(GetCompleteLoginArgs(kSecondaryAccount1Email));
- web_ui()->HandleReceivedMessage(kCompleteLoginMessage, &args);
+ web_ui()->HandleReceivedMessage(kCompleteLoginMessage, args);
if (GetDeviceAccountInfo().user_type ==
user_manager::UserType::USER_TYPE_CHILD) {
@@ -503,9 +499,9 @@ IN_PROC_BROWSER_TEST_P(InlineLoginHandlerChromeOSTestWithArcRestrictions,
&apps_availability_observer);
// Call "completeLogin".
- base::ListValue args;
+ base::Value::List args;
args.Append(GetCompleteLoginArgs(GetDeviceAccountInfo().email));
- web_ui()->HandleReceivedMessage(kCompleteLoginMessage, &args);
+ web_ui()->HandleReceivedMessage(kCompleteLoginMessage, args);
// Wait until account is added.
base::RunLoop run_loop;
@@ -554,10 +550,9 @@ IN_PROC_BROWSER_TEST_P(InlineLoginHandlerChromeOSTestWithArcRestrictions,
EXPECT_TRUE(ValuesListContainAccount(result, kSecondaryAccount2Email));
// Call "makeAvailableInArc".
- base::Value args_1(base::Value::Type::LIST);
+ base::Value::List args_1;
args_1.Append(ValuesListGetAccount(result, kSecondaryAccount2Email).value());
- web_ui()->HandleReceivedMessage(kMakeAvailableInArcMessage,
- &base::Value::AsListValue(args_1));
+ web_ui()->HandleReceivedMessage(kMakeAvailableInArcMessage, args_1);
// Call "getAccountsNotAvailableInArc".
const base::span<const base::Value> result_1 =
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
index bff690561cb..db5f286a87e 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -47,6 +47,8 @@
#include "chrome/grit/arc_account_picker_resources.h"
#include "chrome/grit/arc_account_picker_resources_map.h"
#include "components/account_manager_core/pref_names.h"
+#include "chrome/grit/gaia_action_buttons_resources.h"
+#include "chrome/grit/gaia_action_buttons_resources_map.h"
#include "components/prefs/pref_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -114,6 +116,8 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
source->AddResourcePaths(base::make_span(kArcAccountPickerResources,
kArcAccountPickerResourcesSize));
+ source->AddResourcePaths(base::make_span(kGaiaActionButtonsResources,
+ kGaiaActionButtonsResourcesSize));
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Only add a filter when runing as test.
@@ -135,7 +139,6 @@ content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) {
IDR_INLINE_LOGIN_SIGNIN_BLOCKED_BY_POLICY_PAGE_JS},
{"signin_error_page.js", IDR_INLINE_LOGIN_SIGNIN_ERROR_PAGE_JS},
{"account_manager_shared_css.js", IDR_ACCOUNT_MANAGER_SHARED_CSS_JS},
- {"gaia_action_buttons.js", IDR_GAIA_ACTION_BUTTONS_JS},
{"error_screen.js", IDR_ACCOUNT_MANAGER_COMPONENTS_ERROR_SCREEN_JS},
// Resources for the server-based edu coexistence flow.
{"edu-coexistence", IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_HTML},
@@ -359,13 +362,14 @@ InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::InlineLoginHandlerChromeOS>(
base::BindRepeating(&WebDialogUIBase::CloseDialog,
- weak_factory_.GetWeakPtr(), nullptr /* args */)));
+ weak_factory_.GetWeakPtr(),
+ base::Value::List() /* args */)));
if (profile->IsChild()) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::EduCoexistenceLoginHandler>(
base::BindRepeating(&WebDialogUIBase::CloseDialog,
weak_factory_.GetWeakPtr(),
- nullptr /* args */)));
+ base::Value::List() /* args */)));
}
#else
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
index a0839d13b57..e5c4f646a26 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/signin_modal_dialog.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
@@ -377,6 +378,32 @@ class SigninViewControllerTestUtil {
#endif
}
+ static bool TryCompleteProfileCustomizationDialog(Browser* browser) {
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ NOTREACHED();
+ return false;
+#else
+ SigninViewController* signin_view_controller =
+ browser->signin_view_controller();
+ DCHECK(signin_view_controller);
+ if (!signin_view_controller->ShowsModalDialog())
+ return false;
+ content::WebContents* dialog_web_contents =
+ signin_view_controller->GetModalDialogWebContentsForTesting();
+ DCHECK(dialog_web_contents);
+ std::string button_selector =
+ GetButtonSelectorForApp("profile-customization-app", "doneButton");
+ if (!IsElementReady(dialog_web_contents, button_selector))
+ return false;
+
+ // content::ExecJs() might return false because this JavaScript execution
+ // terminates the renderer as a side effect.
+ std::ignore =
+ content::ExecJs(dialog_web_contents, button_selector + ".click();");
+ return true;
+#endif
+ }
+
static bool ShowsModalDialog(Browser* browser) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
@@ -485,6 +512,17 @@ bool SignInWithUI(Browser* browser,
#endif
}
+bool TryUntilSuccessWithTimeout(base::RepeatingCallback<bool()> try_callback,
+ base::TimeDelta timeout) {
+ const base::Time expire_time = base::Time::Now() + timeout;
+ while (base::Time::Now() <= expire_time) {
+ if (try_callback.Run())
+ return true;
+ RunLoopFor(base::Seconds(1));
+ }
+ return false;
+}
+
bool DismissSyncConfirmationDialog(Browser* browser,
base::TimeDelta timeout,
SyncConfirmationDialogAction action) {
@@ -517,28 +555,21 @@ bool CompleteSigninEmailConfirmationDialog(
Browser* browser,
base::TimeDelta timeout,
SigninEmailConfirmationDialog::Action action) {
- const base::Time expire_time = base::Time::Now() + timeout;
- while (base::Time::Now() <= expire_time) {
- if (SigninViewControllerTestUtil::TryCompleteSigninEmailConfirmationDialog(
- browser, action)) {
- return true;
- }
- RunLoopFor(base::Milliseconds(1000));
- }
- return false;
+ return TryUntilSuccessWithTimeout(
+ base::BindRepeating(SigninViewControllerTestUtil::
+ TryCompleteSigninEmailConfirmationDialog,
+ browser, action),
+ timeout);
}
bool CompleteReauthConfirmationDialog(Browser* browser,
base::TimeDelta timeout,
ReauthDialogAction action) {
- const base::Time expire_time = base::Time::Now() + timeout;
- while (base::Time::Now() <= expire_time) {
- if (SigninViewControllerTestUtil::TryCompleteReauthConfirmationDialog(
- browser, action))
- return true;
- RunLoopFor(base::Milliseconds(1000));
- }
- return false;
+ return TryUntilSuccessWithTimeout(
+ base::BindRepeating(
+ SigninViewControllerTestUtil::TryCompleteReauthConfirmationDialog,
+ browser, action),
+ timeout);
}
bool ConfirmReauthConfirmationDialog(Browser* browser,
@@ -552,4 +583,13 @@ bool CancelReauthConfirmationDialog(Browser* browser, base::TimeDelta timeout) {
ReauthDialogAction::kCancel);
}
+bool CompleteProfileCustomizationDialog(Browser* browser,
+ base::TimeDelta timeout) {
+ return TryUntilSuccessWithTimeout(
+ base::BindRepeating(
+ SigninViewControllerTestUtil::TryCompleteProfileCustomizationDialog,
+ browser),
+ timeout);
+}
+
} // namespace login_ui_test_utils
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
index a82ddc97c83..64fd97be265 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
@@ -76,6 +76,13 @@ bool ConfirmReauthConfirmationDialog(Browser* browser, base::TimeDelta timeout);
// dismissed before |timeout|.
bool CancelReauthConfirmationDialog(Browser* browser, base::TimeDelta timeout);
+// Waits for profile customization dialog to get displayed, then executes
+// javascript to click on done button. Returns false if dialog wasn't
+// dismissed before |timeout|.
+bool CompleteProfileCustomizationDialog(
+ Browser* browser,
+ base::TimeDelta timeout = kSyncConfirmationDialogTimeout);
+
} // namespace login_ui_test_utils
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_TEST_UTILS_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc
index 989cd927c58..bc0ec9cbad6 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc
@@ -33,8 +33,8 @@ const size_t kAvatarSize = 60;
}
ProfileCustomizationHandler::ProfileCustomizationHandler(
- base::OnceClosure done_closure)
- : done_closure_(std::move(done_closure)) {}
+ base::OnceCallback<void(CustomizationResult)> completion_callback)
+ : completion_callback_(std::move(completion_callback)) {}
ProfileCustomizationHandler::~ProfileCustomizationHandler() = default;
@@ -47,6 +47,9 @@ void ProfileCustomizationHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"done", base::BindRepeating(&ProfileCustomizationHandler::HandleDone,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "skip", base::BindRepeating(&ProfileCustomizationHandler::HandleSkip,
+ base::Unretained(this)));
}
void ProfileCustomizationHandler::OnJavascriptAllowed() {
@@ -101,8 +104,15 @@ void ProfileCustomizationHandler::HandleDone(const base::Value::List& args) {
GetProfileEntry()->SetLocalProfileName(profile_name,
/*is_default_name=*/false);
- if (done_closure_)
- std::move(done_closure_).Run();
+ if (completion_callback_)
+ std::move(completion_callback_).Run(CustomizationResult::kDone);
+}
+
+void ProfileCustomizationHandler::HandleSkip(const base::Value::List& args) {
+ CHECK_EQ(0u, args.size());
+
+ if (completion_callback_)
+ std::move(completion_callback_).Run(CustomizationResult::kSkip);
}
void ProfileCustomizationHandler::UpdateProfileInfo(
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h
index 2386414036e..82b30da452f 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h
@@ -18,7 +18,15 @@ class ProfileAttributesEntry;
class ProfileCustomizationHandler : public content::WebUIMessageHandler,
public ProfileAttributesStorage::Observer {
public:
- explicit ProfileCustomizationHandler(base::OnceClosure done_closure);
+ enum class CustomizationResult {
+ // User clicked on the "Done" button.
+ kDone = 0,
+ // User clicked on the "Skip" button.
+ kSkip = 1,
+ };
+
+ explicit ProfileCustomizationHandler(
+ base::OnceCallback<void(CustomizationResult)> completion_callback);
~ProfileCustomizationHandler() override;
ProfileCustomizationHandler(const ProfileCustomizationHandler&) = delete;
@@ -44,6 +52,7 @@ class ProfileCustomizationHandler : public content::WebUIMessageHandler,
// Handlers for messages from javascript.
void HandleInitialized(const base::Value::List& args);
void HandleDone(const base::Value::List& args);
+ void HandleSkip(const base::Value::List& args);
// Sends an updated profile info (avatar and colors) to the WebUI.
// `profile_path` is the path of the profile being updated, this function does
@@ -61,8 +70,9 @@ class ProfileCustomizationHandler : public content::WebUIMessageHandler,
ProfileAttributesStorage::Observer>
observed_profile_{this};
- // Called when the "Done" button has been pressed.
- base::OnceClosure done_closure_;
+ // Called when the "Done" or "Skip" button has been clicked. The callback
+ // normally closes native widget hosting Profile Customization webUI.
+ base::OnceCallback<void(CustomizationResult)> completion_callback_;
};
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_CUSTOMIZATION_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc b/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc
index 8fa13afbc0e..45172be6852 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/signin/profile_customization_ui.h"
+#include "base/callback_helpers.h"
#include "base/feature_list.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
#include "chrome/browser/ui/webui/signin/profile_customization_handler.h"
+#include "chrome/browser/ui/webui/signin/signin_url_utils.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h"
@@ -43,6 +45,10 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
IDR_SIGNIN_PROFILE_CUSTOMIZATION_PROFILE_CUSTOMIZATION_APP_HTML_JS},
{"profile_customization_browser_proxy.js",
IDR_SIGNIN_PROFILE_CUSTOMIZATION_PROFILE_CUSTOMIZATION_BROWSER_PROXY_JS},
+ {"images/profile_customization_illustration.svg",
+ IDR_SIGNIN_PROFILE_CUSTOMIZATION_IMAGES_PROFILE_CUSTOMIZATION_ILLUSTRATION_SVG},
+ {"images/profile_customization_illustration_dark.svg",
+ IDR_SIGNIN_PROFILE_CUSTOMIZATION_IMAGES_PROFILE_CUSTOMIZATION_ILLUSTRATION_DARK_SVG},
{"signin_shared.css.js", IDR_SIGNIN_SIGNIN_SHARED_CSS_JS},
{"signin_vars.css.js", IDR_SIGNIN_SIGNIN_VARS_CSS_JS},
};
@@ -57,10 +63,14 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
{"profileCustomizationInputLabel", IDS_PROFILE_CUSTOMIZATION_INPUT_LABEL},
{"profileCustomizationText", IDS_PROFILE_CUSTOMIZATION_TEXT},
{"profileCustomizationTitle", IDS_PROFILE_CUSTOMIZATION_TITLE_V2},
+ {"localProfileCreationTitle",
+ IDS_PROFILE_CUSTOMIZATION_LOCAL_PROFILE_CREATION_TITLE},
// Color picker strings:
{"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
{"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL},
+ {"themesContainerLabel",
+ IDS_PROFILE_CUSTOMIZATION_THEMES_CONTAINER_LABEL},
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
};
@@ -77,8 +87,12 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
source->AddBoolean(
"profileCustomizationInDialogDesign",
base::FeatureList::IsEnabled(kSyncPromoAfterSigninIntercept));
+ const GURL& url = web_ui->GetWebContents()->GetVisibleURL();
+ source->AddBoolean("isLocalProfileCreation",
+ GetProfileCustomizationStyle(url) ==
+ ProfileCustomizationStyle::kLocalProfileCreation);
- if (web_ui->GetWebContents()->GetVisibleURL().query() == "debug") {
+ if (url.query() == "debug") {
// Not intended to be hooked to anything. The bubble will not initialize it
// so we force it here.
Initialize(base::DoNothing());
@@ -89,9 +103,11 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
ProfileCustomizationUI::~ProfileCustomizationUI() = default;
-void ProfileCustomizationUI::Initialize(base::OnceClosure done_closure) {
- web_ui()->AddMessageHandler(
- std::make_unique<ProfileCustomizationHandler>(std::move(done_closure)));
+void ProfileCustomizationUI::Initialize(
+ base::OnceCallback<void(ProfileCustomizationHandler::CustomizationResult)>
+ completion_callback) {
+ web_ui()->AddMessageHandler(std::make_unique<ProfileCustomizationHandler>(
+ std::move(completion_callback)));
}
void ProfileCustomizationUI::BindInterface(
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.h b/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.h
index 2d069bd499c..026a71c340e 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_CUSTOMIZATION_UI_H_
#include "base/callback.h"
+#include "chrome/browser/ui/webui/signin/profile_customization_handler.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -33,7 +34,9 @@ class ProfileCustomizationUI
ProfileCustomizationUI& operator=(const ProfileCustomizationUI&) = delete;
// Initializes the ProfileCustomizationUI.
- void Initialize(base::OnceClosure done_closure);
+ void Initialize(
+ base::OnceCallback<void(ProfileCustomizationHandler::CustomizationResult)>
+ completion_callback);
// Instantiates the implementor of the
// customize_themes::mojom::CustomizeThemesHandlerFactory mojo interface
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
index cfce40537de..ac46eadeb17 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
@@ -372,80 +372,80 @@ void ProfilePickerHandler::EnableStartupMetrics() {
}
void ProfilePickerHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"mainViewInitialize",
base::BindRepeating(&ProfilePickerHandler::HandleMainViewInitialize,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"launchSelectedProfile",
base::BindRepeating(&ProfilePickerHandler::HandleLaunchSelectedProfile,
base::Unretained(this), /*open_settings=*/false));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"openManageProfileSettingsSubPage",
base::BindRepeating(&ProfilePickerHandler::HandleLaunchSelectedProfile,
base::Unretained(this), /*open_settings=*/true));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"launchGuestProfile",
base::BindRepeating(&ProfilePickerHandler::HandleLaunchGuestProfile,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"askOnStartupChanged",
base::BindRepeating(&ProfilePickerHandler::HandleAskOnStartupChanged,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getNewProfileSuggestedThemeInfo",
base::BindRepeating(
&ProfilePickerHandler::HandleGetNewProfileSuggestedThemeInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getProfileThemeInfo",
base::BindRepeating(&ProfilePickerHandler::HandleGetProfileThemeInfo,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"removeProfile",
base::BindRepeating(&ProfilePickerHandler::HandleRemoveProfile,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getProfileStatistics",
base::BindRepeating(&ProfilePickerHandler::HandleGetProfileStatistics,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"selectAccountLacros",
base::BindRepeating(&ProfilePickerHandler::HandleSelectAccountLacros,
base::Unretained(this)));
// TODO(crbug.com/1115056): Consider renaming this message to
// 'createLocalProfile' as this is only used for local profiles.
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getAvailableIcons",
base::BindRepeating(&ProfilePickerHandler::HandleGetAvailableIcons,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"createProfile",
base::BindRepeating(&ProfilePickerHandler::HandleCreateProfile,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getSwitchProfile",
base::BindRepeating(&ProfilePickerHandler::HandleGetSwitchProfile,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"confirmProfileSwitch",
base::BindRepeating(&ProfilePickerHandler::HandleConfirmProfileSwitch,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"cancelProfileSwitch",
base::BindRepeating(&ProfilePickerHandler::HandleCancelProfileSwitch,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"setProfileName",
base::BindRepeating(&ProfilePickerHandler::HandleSetProfileName,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"recordSignInPromoImpression",
base::BindRepeating(
&ProfilePickerHandler::HandleRecordSignInPromoImpression,
base::Unretained(this)));
#if BUILDFLAG(IS_CHROMEOS_LACROS)
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getAvailableAccounts",
base::BindRepeating(&ProfilePickerHandler::HandleGetAvailableAccounts,
base::Unretained(this)));
@@ -477,7 +477,7 @@ void ProfilePickerHandler::OnJavascriptDisallowed() {
}
void ProfilePickerHandler::HandleMainViewInitialize(
- const base::ListValue* args) {
+ const base::Value::List& args) {
if (!creation_time_on_startup_.is_null() && !main_view_initialized_) {
// This function can be called multiple times if the page is reloaded. The
// histogram is only recorded once.
@@ -492,12 +492,12 @@ void ProfilePickerHandler::HandleMainViewInitialize(
void ProfilePickerHandler::HandleLaunchSelectedProfile(
bool open_settings,
- const base::ListValue* args) {
+ const base::Value::List& args) {
TRACE_EVENT1("browser", "ProfilePickerHandler::HandleLaunchSelectedProfile",
- "args", args->DebugString());
- if (args->GetListDeprecated().empty())
+ "args", args.DebugString());
+ if (args.empty())
return;
- const base::Value& profile_path_value = args->GetListDeprecated()[0];
+ const base::Value& profile_path_value = args[0];
absl::optional<base::FilePath> profile_path =
base::ValueToFilePath(profile_path_value);
@@ -566,7 +566,7 @@ void ProfilePickerHandler::HandleLaunchSelectedProfile(
}
void ProfilePickerHandler::HandleLaunchGuestProfile(
- const base::ListValue* args) {
+ const base::Value::List& args) {
// TODO(crbug.com/1063856): Add check |IsGuestModeEnabled| once policy
// checking has been added to the UI.
profiles::SwitchToGuestProfile(
@@ -575,8 +575,7 @@ void ProfilePickerHandler::HandleLaunchGuestProfile(
}
void ProfilePickerHandler::HandleAskOnStartupChanged(
- const base::ListValue* args) {
- const auto& list = args->GetListDeprecated();
+ const base::Value::List& list) {
if (list.empty() || !list[0].is_bool())
return;
const bool show_on_startup = list[0].GetBool();
@@ -587,10 +586,10 @@ void ProfilePickerHandler::HandleAskOnStartupChanged(
}
void ProfilePickerHandler::HandleGetNewProfileSuggestedThemeInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ CHECK_EQ(1U, args.size());
+ const base::Value& callback_id = args[0];
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (IsSelectingSecondaryAccount(web_ui())) {
@@ -625,13 +624,13 @@ void ProfilePickerHandler::HandleGetNewProfileSuggestedThemeInfo(
}
void ProfilePickerHandler::HandleGetProfileThemeInfo(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(2U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
- const base::Value& user_theme_choice = args->GetListDeprecated()[1];
- int color_id = user_theme_choice.FindIntKey("colorId").value();
- absl::optional<SkColor> color = user_theme_choice.FindDoubleKey("color");
+ CHECK_EQ(2U, args.size());
+ const base::Value& callback_id = args[0];
+ const base::Value::Dict& user_theme_choice = args[1].GetDict();
+ int color_id = user_theme_choice.FindInt("colorId").value();
+ absl::optional<SkColor> color = user_theme_choice.FindDouble("color");
base::Value dict;
switch (color_id) {
case kDefaultThemeColorId:
@@ -655,25 +654,24 @@ void ProfilePickerHandler::HandleGetProfileThemeInfo(
}
void ProfilePickerHandler::HandleGetAvailableIcons(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ CHECK_EQ(1U, args.size());
+ const base::Value& callback_id = args[0];
ResolveJavascriptCallback(
callback_id,
base::Value(profiles::GetCustomProfileAvatarIconsAndLabels()));
}
-void ProfilePickerHandler::HandleCreateProfile(const base::ListValue* args) {
- CHECK_EQ(4U, args->GetListDeprecated().size());
- std::u16string profile_name =
- base::UTF8ToUTF16(args->GetListDeprecated()[0].GetString());
+void ProfilePickerHandler::HandleCreateProfile(const base::Value::List& args) {
+ CHECK_EQ(4U, args.size());
+ std::u16string profile_name = base::UTF8ToUTF16(args[0].GetString());
// profileColor is undefined for the default theme.
absl::optional<SkColor> profile_color;
- if (args->GetListDeprecated()[1].is_int())
- profile_color = args->GetListDeprecated()[1].GetInt();
- size_t avatar_index = args->GetListDeprecated()[2].GetInt();
- bool create_shortcut = args->GetListDeprecated()[3].GetBool();
+ if (args[1].is_int())
+ profile_color = args[1].GetInt();
+ size_t avatar_index = args[2].GetInt();
+ bool create_shortcut = args[3].GetBool();
base::TrimWhitespace(profile_name, base::TRIM_ALL, &profile_name);
CHECK(!profile_name.empty());
@@ -690,10 +688,11 @@ void ProfilePickerHandler::HandleCreateProfile(const base::ListValue* args) {
create_shortcut));
}
-void ProfilePickerHandler::HandleGetSwitchProfile(const base::ListValue* args) {
+void ProfilePickerHandler::HandleGetSwitchProfile(
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& callback_id = args->GetListDeprecated()[0];
+ CHECK_EQ(1U, args.size());
+ const base::Value& callback_id = args[0];
int avatar_icon_size =
kProfileCardAvatarSize * web_ui()->GetDeviceScaleFactor();
base::FilePath profile_path = ProfilePicker::GetSwitchProfilePath();
@@ -707,10 +706,10 @@ void ProfilePickerHandler::HandleGetSwitchProfile(const base::ListValue* args) {
}
void ProfilePickerHandler::HandleConfirmProfileSwitch(
- const base::ListValue* args) {
- if (args->GetListDeprecated().empty())
+ const base::Value::List& args) {
+ if (args.empty())
return;
- const base::Value& profile_path_value = args->GetListDeprecated()[0];
+ const base::Value& profile_path_value = args[0];
absl::optional<base::FilePath> profile_path =
base::ValueToFilePath(profile_path_value);
@@ -726,7 +725,7 @@ void ProfilePickerHandler::HandleConfirmProfileSwitch(
}
void ProfilePickerHandler::HandleCancelProfileSwitch(
- const base::ListValue* args) {
+ const base::Value::List& args) {
ProfilePicker::CancelSignedInFlow();
}
@@ -795,14 +794,14 @@ void ProfilePickerHandler::OnProfileCreationSuccess(
}
void ProfilePickerHandler::HandleRecordSignInPromoImpression(
- const base::ListValue* /*args*/) {
+ const base::Value::List& /*args*/) {
signin_metrics::RecordSigninImpressionUserActionForAccessPoint(
signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER);
}
-void ProfilePickerHandler::HandleSetProfileName(const base::ListValue* args) {
- CHECK_EQ(2U, args->GetListDeprecated().size());
- const base::Value& profile_path_value = args->GetListDeprecated()[0];
+void ProfilePickerHandler::HandleSetProfileName(const base::Value::List& args) {
+ CHECK_EQ(2U, args.size());
+ const base::Value& profile_path_value = args[0];
absl::optional<base::FilePath> profile_path =
base::ValueToFilePath(profile_path_value);
@@ -810,8 +809,7 @@ void ProfilePickerHandler::HandleSetProfileName(const base::ListValue* args) {
NOTREACHED();
return;
}
- std::u16string profile_name =
- base::UTF8ToUTF16(args->GetListDeprecated()[1].GetString());
+ std::u16string profile_name = base::UTF8ToUTF16(args[1].GetString());
base::TrimWhitespace(profile_name, base::TRIM_ALL, &profile_name);
CHECK(!profile_name.empty());
ProfileAttributesEntry* entry =
@@ -822,9 +820,9 @@ void ProfilePickerHandler::HandleSetProfileName(const base::ListValue* args) {
entry->SetLocalProfileName(profile_name, /*is_default_name=*/false);
}
-void ProfilePickerHandler::HandleRemoveProfile(const base::ListValue* args) {
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& profile_path_value = args->GetListDeprecated()[0];
+void ProfilePickerHandler::HandleRemoveProfile(const base::Value::List& args) {
+ CHECK_EQ(1U, args.size());
+ const base::Value& profile_path_value = args[0];
absl::optional<base::FilePath> profile_path =
base::ValueToFilePath(profile_path_value);
@@ -844,10 +842,10 @@ void ProfilePickerHandler::HandleRemoveProfile(const base::ListValue* args) {
}
void ProfilePickerHandler::HandleGetProfileStatistics(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetListDeprecated().size());
- const base::Value& profile_path_value = args->GetListDeprecated()[0];
+ CHECK_EQ(1U, args.size());
+ const base::Value& profile_path_value = args[0];
absl::optional<base::FilePath> profile_path =
base::ValueToFilePath(profile_path_value);
if (!profile_path)
@@ -892,12 +890,11 @@ void ProfilePickerHandler::OnProfileStatisticsReceived(
}
void ProfilePickerHandler::HandleSelectAccountLacros(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- CHECK_EQ(2U, args->GetListDeprecated().size());
- absl::optional<SkColor> profile_color =
- args->GetListDeprecated()[0].GetIfInt();
- const std::string& gaia_id = args->GetListDeprecated()[1].GetString();
+ CHECK_EQ(2U, args.size());
+ absl::optional<SkColor> profile_color = args[0].GetIfInt();
+ const std::string& gaia_id = args[1].GetString();
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (IsSelectingSecondaryAccount(web_ui())) {
@@ -1183,7 +1180,7 @@ void ProfilePickerHandler::HandleOpenAshAccountSettingsPage(
}
void ProfilePickerHandler::HandleGetAvailableAccounts(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
UpdateAvailableAccounts();
}
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
index caf22f68b0e..eeeae9e4966 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
@@ -73,29 +73,29 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
ProfilePickerEnterpriseCreationFlowBrowserTest,
CreateSignedInProfileSigninAlreadyExists_CancelSwitch);
- void HandleMainViewInitialize(const base::ListValue* args);
+ void HandleMainViewInitialize(const base::Value::List& args);
void HandleLaunchSelectedProfile(bool open_settings,
- const base::ListValue* args);
- void HandleLaunchGuestProfile(const base::ListValue* args);
- void HandleAskOnStartupChanged(const base::ListValue* args);
- void HandleRemoveProfile(const base::ListValue* args);
- void HandleGetProfileStatistics(const base::ListValue* args);
- void HandleSetProfileName(const base::ListValue* args);
+ const base::Value::List& args);
+ void HandleLaunchGuestProfile(const base::Value::List& args);
+ void HandleAskOnStartupChanged(const base::Value::List& args);
+ void HandleRemoveProfile(const base::Value::List& args);
+ void HandleGetProfileStatistics(const base::Value::List& args);
+ void HandleSetProfileName(const base::Value::List& args);
// TODO(crbug.com/1115056): Move to new handler for profile creation.
- void HandleSelectAccountLacros(const base::ListValue* args);
- void HandleGetNewProfileSuggestedThemeInfo(const base::ListValue* args);
- void HandleGetProfileThemeInfo(const base::ListValue* args);
- void HandleGetAvailableIcons(const base::ListValue* args);
- void HandleCreateProfile(const base::ListValue* args);
+ void HandleSelectAccountLacros(const base::Value::List& args);
+ void HandleGetNewProfileSuggestedThemeInfo(const base::Value::List& args);
+ void HandleGetProfileThemeInfo(const base::Value::List& args);
+ void HandleGetAvailableIcons(const base::Value::List& args);
+ void HandleCreateProfile(const base::Value::List& args);
// Profile switch screen:
- void HandleGetSwitchProfile(const base::ListValue* args);
- void HandleConfirmProfileSwitch(const base::ListValue* args);
- void HandleCancelProfileSwitch(const base::ListValue* args);
+ void HandleGetSwitchProfile(const base::Value::List& args);
+ void HandleConfirmProfileSwitch(const base::Value::List& args);
+ void HandleCancelProfileSwitch(const base::Value::List& args);
// |args| is unused.
- void HandleRecordSignInPromoImpression(const base::ListValue* args);
+ void HandleRecordSignInPromoImpression(const base::Value::List& args);
void OnLoadSigninFinished(bool success);
void GatherProfileStatistics(Profile* profile);
@@ -146,7 +146,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
// List of available accounts used by the profile choice and the account
// selection screens.
- void HandleGetAvailableAccounts(const base::ListValue* args);
+ void HandleGetAvailableAccounts(const base::Value::List& args);
// Queries accounts available for addition in the profile, and ends up sending
// them to the WebUI page.
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc
index 101211e4994..709ccb0709d 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc
@@ -125,8 +125,8 @@ class ProfilePickerHandlerTest : public testing::Test {
void InitializeMainViewAndVerifyProfileList(
const std::vector<ProfileAttributesEntry*>& ordered_profile_entries) {
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("mainViewInitialize", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("mainViewInitialize", empty_args);
VerifyProfileListWasPushed(ordered_profile_entries);
}
@@ -312,8 +312,8 @@ TEST_F(ProfilePickerHandlerTest, HandleGetAvailableAccounts_Empty) {
CompleteFacadeGetAccounts({});
// Send message to the handler.
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -345,8 +345,8 @@ TEST_F(ProfilePickerHandlerTest, HandleGetAvailableAccounts_Available) {
// ****** No accounts syncing in any profile: return all.
// Send message to the handler.
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -360,7 +360,7 @@ TEST_F(ProfilePickerHandlerTest, HandleGetAvailableAccounts_Available) {
secondary->SetAuthInfo(kGaiaId1, u"example1@gmail.com",
/*is_consented_primary_account=*/true);
// Send message to the handler.
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -404,8 +404,8 @@ TEST_F(ProfilePickerHandlerTest, ProfilePickerObservesAvailableAccounts) {
CompleteFacadeGetAccounts({account1, account2});
// Send message to the handler.
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -453,10 +453,10 @@ TEST_F(ProfilePickerHandlerTest, CreateProfileExistingAccount) {
// Request profile creation with the existing account.
ProfileWaiter profile_waiter;
- base::ListValue args;
+ base::Value::List args;
args.Append(/*color=*/base::Value());
args.Append(/*gaiaId=*/kGaiaId);
- web_ui()->HandleReceivedMessage("selectAccountLacros", &args);
+ web_ui()->HandleReceivedMessage("selectAccountLacros", args);
// Check profile creation.
Profile* new_profile = profile_waiter.WaitForProfileAdded();
@@ -518,10 +518,10 @@ TEST_F(ProfilePickerHandlerTest, CreateProfileNewAccount) {
// Request profile creation.
ProfileWaiter profile_waiter;
- base::ListValue args;
+ base::Value::List args;
args.Append(/*color=*/base::Value());
args.Append(/*gaiaId=*/base::Value(base::Value::Type::STRING));
- web_ui()->HandleReceivedMessage("selectAccountLacros", &args);
+ web_ui()->HandleReceivedMessage("selectAccountLacros", args);
// Check profile creation.
Profile* new_profile = profile_waiter.WaitForProfileAdded();
@@ -579,7 +579,7 @@ class ProfilePickerHandlerInUserProfileTest : public ProfilePickerHandlerTest {
return *data.arg3();
}
- Profile* secondary_profile_ = nullptr;
+ raw_ptr<Profile> secondary_profile_ = nullptr;
};
// Tests that accounts available as secondary are returned.
@@ -588,8 +588,8 @@ TEST_F(ProfilePickerHandlerInUserProfileTest,
CompleteFacadeGetAccounts({});
// Send message to the handler.
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -617,8 +617,8 @@ TEST_F(ProfilePickerHandlerInUserProfileTest,
// ****** No accounts assigned to "Secondary": return all.
// Send message to the handler.
- base::ListValue empty_args;
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ base::Value::List empty_args;
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -634,7 +634,7 @@ TEST_F(ProfilePickerHandlerInUserProfileTest,
->GetProfileAttributesWithPath(GetWebUIProfile()->GetPath());
profile_entry->SetGaiaIds({kGaiaId1});
// Send message to the handler.
- web_ui()->HandleReceivedMessage("getAvailableAccounts", &empty_args);
+ web_ui()->HandleReceivedMessage("getAvailableAccounts", empty_args);
// Check that the handler replied.
ASSERT_TRUE(!web_ui()->call_data().empty());
@@ -689,9 +689,9 @@ TEST_F(ProfilePickerHandlerInUserProfileTest,
TEST_F(ProfilePickerHandlerInUserProfileTest,
HandleGetNewProfileSuggestedThemeInfo_Default) {
// Send message to the handler.
- base::ListValue args;
+ base::Value::List args;
args.Append(kTestCallbackId);
- web_ui()->HandleReceivedMessage("getNewProfileSuggestedThemeInfo", &args);
+ web_ui()->HandleReceivedMessage("getNewProfileSuggestedThemeInfo", args);
// Check that the handler replied correctly.
const base::Value& theme_info = GetThemeInfoReply();
@@ -706,9 +706,9 @@ TEST_F(ProfilePickerHandlerInUserProfileTest,
theme_service->BuildAutogeneratedThemeFromColor(SK_ColorRED);
// Send message to the handler.
- base::ListValue args;
+ base::Value::List args;
args.Append(kTestCallbackId);
- web_ui()->HandleReceivedMessage("getNewProfileSuggestedThemeInfo", &args);
+ web_ui()->HandleReceivedMessage("getNewProfileSuggestedThemeInfo", args);
// Check that the handler replied correctly.
const base::Value& theme_info = GetThemeInfoReply();
@@ -753,10 +753,10 @@ TEST_F(ProfilePickerHandlerInUserProfileTest, NoAvailableAccount) {
});
// Request account addition.
- base::ListValue args;
+ base::Value::List args;
args.Append(/*color=*/base::Value());
args.Append(/*gaiaId=*/base::Value(base::Value::Type::STRING));
- web_ui()->HandleReceivedMessage("selectAccountLacros", &args);
+ web_ui()->HandleReceivedMessage("selectAccountLacros", args);
}
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.cc b/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.cc
index e8a43e7373a..6e653b3f5c2 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.cc
@@ -93,6 +93,6 @@ void ProfilePickerLacrosSignInProvider::OnLacrosProfileCreated(
}
void ProfilePickerLacrosSignInProvider::OnProfileSignedIn() {
- std::move(callback_).Run(profile_);
+ std::move(callback_).Run(profile_.get());
// The object gets deleted now.
}
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.h b/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.h
index fdcf03c5abc..293f73b6cc3 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_lacros_sign_in_provider.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_LACROS_SIGN_IN_PROVIDER_H_
#include "base/callback.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/lacros/account_manager/account_profile_mapper.h"
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
@@ -53,7 +54,7 @@ class ProfilePickerLacrosSignInProvider
// Sign-in callback, valid until it's called.
SignedInCallback callback_;
- Profile* profile_ = nullptr;
+ raw_ptr<Profile> profile_ = nullptr;
// Prevent |profile_| from being destroyed first.
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_;
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc b/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
index 02572cddbe4..afc6539247c 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
@@ -15,11 +15,9 @@
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
-#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/managed_ui.h"
#include "chrome/browser/ui/profile_picker.h"
-#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h"
#include "chrome/browser/ui/webui/signin/profile_picker_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
@@ -35,7 +33,6 @@
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_buildflags.h"
-#include "components/signin/public/base/signin_switches.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -54,6 +51,9 @@ namespace {
constexpr int kMinimumPickerSizePx = 620;
bool IsBrowserSigninAllowed() {
+#if BUILDFLAG(IS_CHROMEOS)
+ return true;
+#else
policy::PolicyService* policy_service = g_browser_process->policy_service();
DCHECK(policy_service);
const policy::PolicyMap& policies = policy_service->GetPolicies(
@@ -68,6 +68,7 @@ bool IsBrowserSigninAllowed() {
return static_cast<policy::BrowserSigninMode>(
browser_signin_value->GetInt()) !=
policy::BrowserSigninMode::kDisabled;
+#endif
}
std::string GetManagedDeviceDisclaimer() {
@@ -164,6 +165,8 @@ void AddStrings(content::WebUIDataSource* html_source) {
// Color picker.
{"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
{"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL},
+ {"themesContainerLabel",
+ IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_THEME_TEXT},
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
@@ -198,15 +201,9 @@ void AddStrings(content::WebUIDataSource* html_source) {
#endif
html_source->AddLocalizedString("mainViewTitle", main_view_title_id);
- int sign_in_button_label_id =
- IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_SIGNIN_BUTTON_LABEL;
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- if (!base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles)) {
- sign_in_button_label_id =
- IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_SIGNIN_BUTTON_LABEL_LACROS;
- }
-#endif
- html_source->AddLocalizedString("signInButtonLabel", sign_in_button_label_id);
+ html_source->AddLocalizedString(
+ "signInButtonLabel",
+ IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_SIGNIN_BUTTON_LABEL);
ProfilePicker::AvailabilityOnStartup availability_on_startup =
static_cast<ProfilePicker::AvailabilityOnStartup>(
@@ -223,13 +220,6 @@ void AddStrings(content::WebUIDataSource* html_source) {
#else
true);
#endif
- html_source->AddBoolean(
- "localProfileCreationFlowSupported",
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles));
-#else
- true);
-#endif
html_source->AddString("minimumPickerSize",
base::StringPrintf("%ipx", kMinimumPickerSizePx));
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc
index 9834dc5c17b..3cd2f9fd0e4 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc
@@ -11,6 +11,7 @@
#include "components/account_manager_core/account_addition_result.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/account_manager_core/chromeos/account_manager_mojo_service.h"
+#include "components/user_manager/user_manager.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
namespace chromeos {
@@ -68,8 +69,7 @@ SigninHelper::SigninHelper(
if (ash::AccountAppsAvailability::IsArcAccountRestrictionsEnabled())
DCHECK(arc_helper_);
-
- if (IsSecondaryGoogleAccountUsageEnabled()) {
+ if (!IsInitialPrimaryAccount() && IsSecondaryGoogleAccountUsageEnabled()) {
DCHECK(show_signin_blocked_error_);
restriction_fetcher_ =
std::make_unique<ash::UserCloudSigninRestrictionPolicyFetcherChromeOS>(
@@ -84,7 +84,7 @@ SigninHelper::~SigninHelper() = default;
void SigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
refresh_token_ = result.refresh_token;
- if (IsSecondaryGoogleAccountUsageEnabled()) {
+ if (!IsInitialPrimaryAccount() && IsSecondaryGoogleAccountUsageEnabled()) {
restriction_fetcher_->GetSecondaryGoogleAccountUsage(
/*access_token_fetcher=*/GaiaAccessTokenFetcher::
CreateExchangeRefreshTokenForAccessTokenInstance(
@@ -95,7 +95,6 @@ void SigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
weak_factory_.GetWeakPtr()));
return;
}
-
UpsertAccount(refresh_token_);
CloseDialogAndExit();
}
@@ -210,6 +209,13 @@ void SigninHelper::OnOAuth2RevokeTokenCompleted(
Exit();
}
+bool SigninHelper::IsInitialPrimaryAccount() {
+ return user_manager::UserManager::Get()
+ ->GetPrimaryUser()
+ ->GetAccountId()
+ .GetGaiaId() == account_key_.id();
+}
+
account_manager::AccountManager* SigninHelper::GetAccountManager() {
return account_manager_;
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h
index 598121f48a0..70e07514f5f 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h
@@ -110,6 +110,12 @@ class SigninHelper : public GaiaAuthConsumer {
scoped_refptr<network::SharedURLLoaderFactory> GetUrlLoaderFactory();
private:
+ // Returns the account that must be auto-signed-in to the Main Profile in
+ // Lacros. This is, when available, the account used to sign into the Chrome
+ // OS session. This may be a Gaia account or a Microsoft Active Directory
+ // account. This field will be null for Guest sessions, Managed Guest
+ // sessions, Demo mode, and Kiosks.
+ bool IsInitialPrimaryAccount();
// Fetcher to get SecondaryGoogleAccountUsage policy value.
std::unique_ptr<ash::UserCloudSigninRestrictionPolicyFetcherChromeOS>
restriction_fetcher_;
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos_browsertest.cc
index 7ab78ad01d1..448a54e55db 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos_browsertest.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/ui/webui/signin/signin_helper_chromeos.h"
-#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/constants/ash_features.h"
#include "base/run_loop.h"
+#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ash/account_manager/account_apps_availability.h"
@@ -16,12 +16,17 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/account.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/account_manager_core/chromeos/account_manager_mojo_service.h"
+#include "components/user_manager/user_manager.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
+#include "google_apis/gaia/gaia_urls.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
+#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
+#include "services/network/test/test_url_loader_factory.h"
namespace chromeos {
@@ -29,14 +34,35 @@ class SigninHelperChromeOSTest;
namespace {
+const char kFakePrimaryGaiaId[] = "primary_account_gaia";
+const char kFakePrimaryEmail[] = "primary@example.com";
const char kFakeGaiaId[] = "fake_gaia_id";
const char kFakeEmail[] = "fake_email@gmail.com";
const char kFakeAuthCode[] = "fake_auth_code";
const char kFakeDeviceId[] = "fake_device_id";
const char kFakeRefreshToken[] = "fake_refresh_token";
+const char kFakeEnterpriseGaiaId[] = "fake_enterprise_gaia_id";
const char kFakeEnterpriseEmail[] = "fake_enterprise@example.com";
const char kFakeEnterpriseDomain[] = "example.com";
+const char kSecureConnectApiGetSecondaryGoogleAccountUsageURL[] =
+ "https://secureconnect-pa.clients6.google.com/"
+ "v1:getManagedAccountsSigninRestriction?policy_name="
+ "SecondaryGoogleAccountUsage";
+;
+
+// Fake responses for the URL requests that are part of the sign-in flow.
+const char kOnClientOAuthSuccessBody[] =
+ R"({
+ "refresh_token": "refresh_token",
+ "access_token": "access_token",
+ "expires_in": 99999
+ })";
+const char kUserInfoURLBodyWithHostedDomain[] = R"({"hd": "%s"})";
+const char kUserInfoURLBodyWithoutHostedDomain[] = R"({})";
+const char kSecureConnectApiGetSecondaryGoogleAccountUsageURLBody[] =
+ R"({"policyValue": "%s"})";
+
// Convenience helper to allow a `closure` to be used in a context which is
// expecting a callback with arguments.
template <typename... T>
@@ -77,27 +103,6 @@ class TestSigninHelper : public SigninHelper {
~TestSigninHelper() override;
- void OnClientOAuthSuccess(const ClientOAuthResult& result) override {
- SigninHelper::OnClientOAuthSuccess(result);
- }
-
- void OnClientOAuthFailure(const GoogleServiceAuthError& error) override {
- SigninHelper::OnClientOAuthFailure(error);
- }
-
- void OnGetSecondaryGoogleAccountUsage(
- ash::UserCloudSigninRestrictionPolicyFetcherChromeOS::Status status,
- absl::optional<std::string> policy_result,
- const std::string& hosted_domain) override {
- SigninHelper::OnGetSecondaryGoogleAccountUsage(status, policy_result,
- hosted_domain);
- }
-
- void RevokeGaiaTokenOnServer() override {
- SigninHelper::OnOAuth2RevokeTokenCompleted(
- GaiaAuthConsumer::TokenRevocationStatus::kSuccess);
- }
-
private:
SigninHelperChromeOSTest* test_fixture_;
};
@@ -108,7 +113,10 @@ class SigninHelperChromeOSTest
: public InProcessBrowserTest,
public account_manager::AccountManager::Observer {
public:
- SigninHelperChromeOSTest() = default;
+ SigninHelperChromeOSTest()
+ : test_shared_loader_factory_(
+ base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
+ &test_url_loader_factory_)) {}
~SigninHelperChromeOSTest() override {
DCHECK_EQ(signin_helper_created_count_, signin_helper_deleted_count_);
@@ -126,8 +134,8 @@ class SigninHelperChromeOSTest
// Setup the main account:
account_manager::AccountKey kPrimaryAccountKey{
- "primary_account_gaia", account_manager::AccountType::kGaia};
- account_manager()->UpsertAccount(kPrimaryAccountKey, "primary@gmai.com",
+ kFakePrimaryGaiaId, account_manager::AccountType::kGaia};
+ account_manager()->UpsertAccount(kPrimaryAccountKey, kFakePrimaryEmail,
"access_token");
base::RunLoop().RunUntilIdle();
on_token_upserted_call_count_ = 0;
@@ -140,10 +148,9 @@ class SigninHelperChromeOSTest
on_token_upserted_account_ = absl::nullopt;
}
- TestSigninHelper* CreateSigninHelper(
- const base::RepeatingClosure& close_dialog_closure) {
+ void CreateSigninHelper(const base::RepeatingClosure& close_dialog_closure) {
OnSigninHelperCreated();
- return new TestSigninHelper(
+ new TestSigninHelper(
this, account_manager(), account_manager_mojo_service(),
close_dialog_closure,
/*show_signin_blocked_by_policy_page=*/base::DoNothing(),
@@ -167,10 +174,7 @@ class SigninHelperChromeOSTest
}
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory() {
- return browser()
- ->profile()
- ->GetDefaultStoragePartition()
- ->GetURLLoaderFactoryForBrowserProcess();
+ return test_shared_loader_factory_;
}
account_manager::AccountManager* account_manager() {
@@ -181,6 +185,56 @@ class SigninHelperChromeOSTest
return account_manager_mojo_service_;
}
+ protected:
+ void AddResponseClientOAuthSuccess() {
+ loader_factory().AddResponse(
+ GaiaUrls::GetInstance()->oauth2_token_url().spec(),
+ /*content=*/kOnClientOAuthSuccessBody, net::HTTP_OK);
+ }
+
+ void AddResponseClientOAuthFailure() {
+ loader_factory().AddResponse(
+ GaiaUrls::GetInstance()->oauth2_token_url().spec(),
+ /*content=*/R"({})", net::HTTP_BAD_REQUEST);
+ }
+
+ void AddResponseGetSecondaryGoogleAccountUsage(
+ const std::string& policy_value) {
+ loader_factory().AddResponse(
+ kSecureConnectApiGetSecondaryGoogleAccountUsageURL,
+ /*content=*/
+ base::StringPrintf(
+ kSecureConnectApiGetSecondaryGoogleAccountUsageURLBody,
+ policy_value.c_str()),
+ net::HTTP_OK);
+ }
+
+ void AddResponseGetUserInfoWithHostedDomain(
+ const std::string& hosted_domain) {
+ loader_factory().AddResponse(
+ GaiaUrls::GetInstance()->oauth_user_info_url().spec(),
+ /*content=*/
+ base::StringPrintf(kUserInfoURLBodyWithHostedDomain,
+ hosted_domain.c_str()),
+ net::HTTP_OK);
+ }
+
+ void AddResponseGetUserInfoWithoutHostedDomain() {
+ loader_factory().AddResponse(
+ GaiaUrls::GetInstance()->oauth_user_info_url().spec(),
+ /*content=*/kUserInfoURLBodyWithoutHostedDomain, net::HTTP_OK);
+ }
+
+ void AddResponseRevokeGaiaTokenOnServer() {
+ loader_factory().AddResponse(
+ GaiaUrls::GetInstance()->oauth2_revoke_url().spec(),
+ /*content=*/std::string(), net::HTTP_OK);
+ }
+
+ network::TestURLLoaderFactory& loader_factory() {
+ return test_url_loader_factory_;
+ }
+
private:
// account_manager::AccountManager::Observer overrides:
void OnTokenUpserted(const account_manager::Account& account) override {
@@ -196,6 +250,8 @@ class SigninHelperChromeOSTest
int signin_helper_deleted_count_ = 0;
int on_token_upserted_call_count_ = 0;
absl::optional<account_manager::Account> on_token_upserted_account_;
+ network::TestURLLoaderFactory test_url_loader_factory_;
+ scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_;
};
TestSigninHelper::~TestSigninHelper() {
@@ -205,13 +261,12 @@ TestSigninHelper::~TestSigninHelper() {
IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTest,
NoAccountAddedWhenAuthTokenFetchFails) {
base::RunLoop close_dialog_closure_run_loop;
- auto* helper = CreateSigninHelper(
+ // Set auth token fetch to fail.
+ AddResponseClientOAuthFailure();
+ CreateSigninHelper(
base::BindLambdaForTesting([&close_dialog_closure_run_loop]() {
close_dialog_closure_run_loop.Quit();
}));
- // Auth token fetch fails.
- helper->OnClientOAuthFailure(
- GoogleServiceAuthError(GoogleServiceAuthError::State::CONNECTION_FAILED));
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -223,10 +278,9 @@ IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTest,
IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTest,
AccountAddedWhenAuthTokenFetchSucceeds) {
base::RunLoop close_dialog_closure_run_loop;
- auto* helper =
- CreateSigninHelper(close_dialog_closure_run_loop.QuitClosure());
- // Auth token fetch succeeds.
- helper->OnClientOAuthSuccess(GetFakeOAuthResult());
+ CreateSigninHelper(close_dialog_closure_run_loop.QuitClosure());
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -243,10 +297,7 @@ class SigninHelperChromeOSTestWithArcAccountRestrictions
public ::ash::AccountAppsAvailability::Observer {
public:
SigninHelperChromeOSTestWithArcAccountRestrictions() {
- feature_list_.InitWithFeatures(
- /*enabled_features=*/{chromeos::features::kArcAccountRestrictions,
- chromeos::features::kLacrosSupport},
- /*disabled_features=*/{});
+ feature_list_.InitAndEnableFeature(chromeos::features::kLacrosSupport);
}
~SigninHelperChromeOSTestWithArcAccountRestrictions() override = default;
@@ -271,11 +322,10 @@ class SigninHelperChromeOSTestWithArcAccountRestrictions
SigninHelperChromeOSTest::TearDownOnMainThread();
}
- TestSigninHelper* CreateSigninHelper(
- std::unique_ptr<SigninHelper::ArcHelper> arc_helper,
- const base::RepeatingClosure& close_dialog_closure) {
+ void CreateSigninHelper(std::unique_ptr<SigninHelper::ArcHelper> arc_helper,
+ const base::RepeatingClosure& close_dialog_closure) {
OnSigninHelperCreated();
- return new TestSigninHelper(
+ new TestSigninHelper(
this, account_manager(), account_manager_mojo_service(),
close_dialog_closure,
/*show_signin_blocked_by_policy_page=*/base::DoNothing(),
@@ -353,10 +403,10 @@ IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestWithArcAccountRestrictions,
/*is_available_in_arc=*/true, /*is_account_addition=*/true,
account_apps_availability());
base::RunLoop close_dialog_closure_run_loop;
- auto* helper = CreateSigninHelper(
- std::move(arc_helper), close_dialog_closure_run_loop.QuitClosure());
- // Auth token fetch succeeds.
- helper->OnClientOAuthSuccess(GetFakeOAuthResult());
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ CreateSigninHelper(std::move(arc_helper),
+ close_dialog_closure_run_loop.QuitClosure());
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -388,13 +438,13 @@ IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestWithArcAccountRestrictions,
/*is_available_in_arc=*/false, /*is_account_addition=*/true,
account_apps_availability());
base::RunLoop close_dialog_closure_run_loop;
- auto* helper = CreateSigninHelper(
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ CreateSigninHelper(
std::move(arc_helper),
base::BindLambdaForTesting([&close_dialog_closure_run_loop]() {
close_dialog_closure_run_loop.Quit();
}));
- // Auth token fetch succeeds.
- helper->OnClientOAuthSuccess(GetFakeOAuthResult());
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -430,13 +480,13 @@ IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestWithArcAccountRestrictions,
/*is_available_in_arc=*/true, /*is_account_addition=*/false,
account_apps_availability());
base::RunLoop close_dialog_closure_run_loop;
- auto* helper = CreateSigninHelper(
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ CreateSigninHelper(
std::move(arc_helper),
base::BindLambdaForTesting([&close_dialog_closure_run_loop]() {
close_dialog_closure_run_loop.Quit();
}));
- // Auth token fetch succeeds.
- helper->OnClientOAuthSuccess(GetFakeOAuthResult());
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -461,25 +511,27 @@ class SigninHelperChromeOSTestSecondaryGoogleAccountUsage
feature_list_.InitWithFeatures(
/*enabled_features=*/{chromeos::features::kSecondaryGoogleAccountUsage,
chromeos::features::kLacrosSupport},
- /*disabled_features=*/{chromeos::features::kArcAccountRestrictions});
+ /*disabled_features=*/{chromeos::features::kLacrosSupport});
}
~SigninHelperChromeOSTestSecondaryGoogleAccountUsage() override = default;
- TestSigninHelper* CreateSigninHelper(
+ void CreateSigninHelper(
const base::RepeatingClosure& close_dialog_closure,
const base::RepeatingClosure& show_signin_blocked_by_policy_page,
+ const std::string& gaia_id,
const std::string& email) {
OnSigninHelperCreated();
// The `TestSigninHelper` deletes itself after its work is complete.
- return new TestSigninHelper(
- this, account_manager(), account_manager_mojo_service(),
- /*close_dialog_closure=*/close_dialog_closure,
- /*show_signin_blocked_by_policy_page=*/
- IgnoreArgs<const std::string&, const std::string&>(
- show_signin_blocked_by_policy_page),
- shared_url_loader_factory(), /*arc_helper=*/nullptr, kFakeGaiaId, email,
- kFakeAuthCode, kFakeDeviceId);
+
+ new TestSigninHelper(this, account_manager(),
+ account_manager_mojo_service(),
+ /*close_dialog_closure=*/close_dialog_closure,
+ /*show_signin_blocked_by_policy_page=*/
+ IgnoreArgs<const std::string&, const std::string&>(
+ show_signin_blocked_by_policy_page),
+ shared_url_loader_factory(), /*arc_helper=*/nullptr,
+ gaia_id, email, kFakeAuthCode, kFakeDeviceId);
}
private:
@@ -489,14 +541,17 @@ class SigninHelperChromeOSTestSecondaryGoogleAccountUsage
IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
AccountAddedForNonEnterpriseAccount) {
base::RunLoop close_dialog_closure_run_loop;
+
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ // Set no hosted domain for user info request.
+ AddResponseGetUserInfoWithoutHostedDomain();
// Non Enterprise account tries to sign in.
- auto* helper = CreateSigninHelper(
+ CreateSigninHelper(
/*close_dialog_closure=*/close_dialog_closure_run_loop.QuitClosure(),
/*show_signin_blocked_by_policy_page=*/
- base::RepeatingClosure(), kFakeEmail);
+ base::RepeatingClosure(), kFakeGaiaId, kFakeEmail);
- // Auth token fetch succeeds.
- helper->OnClientOAuthSuccess(GetFakeOAuthResult());
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -513,15 +568,18 @@ IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
AccountAddedForEnterpriseAccountWithNoPolicySet) {
base::RunLoop close_dialog_closure_run_loop;
+
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ // Set user info response with hosted domain (hd) value.
+ AddResponseGetUserInfoWithHostedDomain(kFakeEnterpriseDomain);
+ // Set SecondaryGoogleAccountUsage policy fetch to unset.
+ AddResponseGetSecondaryGoogleAccountUsage("unset");
// Enterprise account tries to sign in.
- auto* helper = CreateSigninHelper(
+ CreateSigninHelper(
/*close_dialog_closure=*/close_dialog_closure_run_loop.QuitClosure(),
/*show_signin_blocked_by_policy_page=*/
- base::RepeatingClosure(), kFakeEnterpriseEmail);
- // `GetSecondaryGoogleAccountUsage` succeeds.
- helper->OnGetSecondaryGoogleAccountUsage(
- ash::UserCloudSigninRestrictionPolicyFetcherChromeOS::Status::kSuccess,
- /*policy_value=*/absl::nullopt, kFakeEnterpriseEmail);
+ base::RepeatingClosure(), kFakeEnterpriseGaiaId, kFakeEnterpriseEmail);
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -539,15 +597,18 @@ IN_PROC_BROWSER_TEST_F(
SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
AccountAddedForEnterpriseAccountWithPolicyValueAllUsages) {
base::RunLoop close_dialog_closure_run_loop;
+
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ // Set user info response with hosted domain (hd) value.
+ AddResponseGetUserInfoWithHostedDomain(kFakeEnterpriseDomain);
+ // Set SecondaryGoogleAccountUsage policy fetch to all.
+ AddResponseGetSecondaryGoogleAccountUsage("all");
// Enterprise account tries to sign in.
- auto* helper = CreateSigninHelper(
+ CreateSigninHelper(
/*close_dialog_closure=*/close_dialog_closure_run_loop.QuitClosure(),
/*show_signin_blocked_by_policy_page=*/
- base::RepeatingClosure(), kFakeEnterpriseEmail);
- // `GetSecondaryGoogleAccountUsage` succeeds.
- helper->OnGetSecondaryGoogleAccountUsage(
- ash::UserCloudSigninRestrictionPolicyFetcherChromeOS::Status::kSuccess,
- /*policy_value=*/"all", kFakeEnterpriseDomain);
+ base::RepeatingClosure(), kFakeEnterpriseGaiaId, kFakeEnterpriseEmail);
// Make sure the close_dialog_closure was called.
close_dialog_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -565,16 +626,21 @@ IN_PROC_BROWSER_TEST_F(
SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
NoAccountAddedForEnterpriseAccountWithPolicyValuePrimaryAccountSignin) {
base::RunLoop show_signin_blocked_error_closure_run_loop;
+
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ // Set user info response with hosted domain (hd) value.
+ AddResponseGetUserInfoWithHostedDomain(kFakeEnterpriseDomain);
+ // Set SecondaryGoogleAccountUsage policy fetch to primary_account_signin.
+ AddResponseGetSecondaryGoogleAccountUsage("primary_account_signin");
+ // Set response for token revokation.
+ AddResponseRevokeGaiaTokenOnServer();
// Enterprise account tries to sign in.
- auto* helper = CreateSigninHelper(
+ CreateSigninHelper(
/*close_dialog_closure=*/base::RepeatingClosure(),
/*show_signin_blocked_by_policy_page=*/
show_signin_blocked_error_closure_run_loop.QuitClosure(),
- kFakeEnterpriseEmail);
- // `GetSecondaryGoogleAccountUsage` succeeds.
- helper->OnGetSecondaryGoogleAccountUsage(
- ash::UserCloudSigninRestrictionPolicyFetcherChromeOS::Status::kSuccess,
- /*policy_value=*/"primary_account_signin", kFakeEnterpriseEmail);
+ kFakeEnterpriseGaiaId, kFakeEnterpriseEmail);
// Make sure the show_signin_blocked_error_closure_run_loop was called.
show_signin_blocked_error_closure_run_loop.Run();
// Wait until SigninHelper finishes and deletes itself.
@@ -584,4 +650,28 @@ IN_PROC_BROWSER_TEST_F(
EXPECT_EQ(on_token_upserted_call_count(), 0);
}
+IN_PROC_BROWSER_TEST_F(SigninHelperChromeOSTestSecondaryGoogleAccountUsage,
+ ReauthForInitialPrimaryEnterpriseAccount) {
+ base::RunLoop close_dialog_closure_run_loop;
+ // Set auth token fetch to succeed.
+ AddResponseClientOAuthSuccess();
+ CreateSigninHelper(
+ /*close_dialog_closure=*/close_dialog_closure_run_loop.QuitClosure(),
+ /*show_signin_blocked_by_policy_page=*/
+ base::RepeatingClosure(),
+ user_manager::UserManager::Get()
+ ->GetPrimaryUser()
+ ->GetAccountId()
+ .GetGaiaId(),
+ kFakePrimaryEmail);
+
+ // Make sure the close_dialog_closure was called.
+ close_dialog_closure_run_loop.Run();
+ // Wait until SigninHelper finishes and deletes itself.
+ base::RunLoop().RunUntilIdle();
+
+ // 1 account should be upserted.
+ EXPECT_EQ(on_token_upserted_call_count(), 1);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_url_utils.cc b/chromium/chrome/browser/ui/webui/signin/signin_url_utils.cc
index c57bf508219..f804a1938f1 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_url_utils.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_url_utils.cc
@@ -14,80 +14,31 @@
namespace {
-// Query parameter names of the sync confirmtaion URL.
-const char kIsModalParamKey[] = "is_modal";
-const char kDesignParamKey[] = "design";
-const char kProfileColorParamKey[] = "profile_color";
+// Query parameter names of the sync confirmation and the profile customization
+// URL.
+const char kStyleParamKey[] = "style";
// Query parameter names of the reauth confirmation URL.
const char kAccessPointParamKey[] = "access_point";
-bool StringToDesignVersion(base::StringPiece input,
- SyncConfirmationUI::DesignVersion* output) {
- int int_value;
- if (!base::StringToInt(input, &int_value))
- return false;
-
- SyncConfirmationUI::DesignVersion value =
- static_cast<SyncConfirmationUI::DesignVersion>(int_value);
- // Make sure that `value` is a valid `DesignVersion`.
- switch (value) {
- case SyncConfirmationUI::DesignVersion::kColored:
- case SyncConfirmationUI::DesignVersion::kMonotone:
- *output = value;
- return true;
- // No default. Please update the switch statement when adding a new
- // enumerator.
- }
-
- return false;
-}
-
} // namespace
-SyncConfirmationURLParams GetParamsFromSyncConfirmationURL(const GURL& url) {
- // Use defaults provided by `SyncConfirmationURLParams` for parameters that
- // fail to parse.
- SyncConfirmationURLParams params;
-
- std::string is_modal_str;
- int is_modal;
- if (net::GetValueForKeyInQuery(url, kIsModalParamKey, &is_modal_str) &&
- base::StringToInt(is_modal_str, &is_modal)) {
- params.is_modal = is_modal;
- }
-
- std::string design_str;
- SyncConfirmationUI::DesignVersion design;
- if (net::GetValueForKeyInQuery(url, kDesignParamKey, &design_str) &&
- StringToDesignVersion(design_str, &design)) {
- params.design = design;
- }
-
- std::string profile_color_str;
- SkColor profile_color;
- if (net::GetValueForKeyInQuery(url, kProfileColorParamKey,
- &profile_color_str) &&
- base::StringToUint(profile_color_str, &profile_color)) {
- params.profile_color = profile_color;
+SyncConfirmationStyle GetSyncConfirmationStyle(const GURL& url) {
+ std::string style_str;
+ int style_int;
+ // Default to modal if the parameter is missing.
+ SyncConfirmationStyle style = SyncConfirmationStyle::kDefaultModal;
+ if (net::GetValueForKeyInQuery(url, kStyleParamKey, &style_str) &&
+ base::StringToInt(style_str, &style_int)) {
+ style = static_cast<SyncConfirmationStyle>(style_int);
}
-
- return params;
+ return style;
}
-GURL AppendSyncConfirmationQueryParams(
- const GURL& url,
- const SyncConfirmationURLParams& params) {
+GURL AppendSyncConfirmationQueryParams(const GURL& url,
+ SyncConfirmationStyle style) {
GURL url_with_params = net::AppendQueryParameter(
- url, kIsModalParamKey, base::NumberToString(params.is_modal));
- url_with_params = net::AppendQueryParameter(
- url_with_params, kDesignParamKey,
- base::NumberToString(static_cast<int>(params.design)));
- if (params.profile_color) {
- url_with_params =
- net::AppendQueryParameter(url_with_params, kProfileColorParamKey,
- base::NumberToString(*params.profile_color));
- }
+ url, kStyleParamKey, base::NumberToString(static_cast<int>(style)));
return url_with_params;
}
@@ -116,3 +67,24 @@ GURL GetReauthConfirmationURL(signin_metrics::ReauthAccessPoint access_point) {
base::NumberToString(static_cast<int>(access_point)));
return url;
}
+
+#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ProfileCustomizationStyle GetProfileCustomizationStyle(const GURL& url) {
+ std::string style_str;
+ int style_int;
+ // Default style if the parameter is missing.
+ ProfileCustomizationStyle style = ProfileCustomizationStyle::kDefault;
+ if (net::GetValueForKeyInQuery(url, kStyleParamKey, &style_str) &&
+ base::StringToInt(style_str, &style_int)) {
+ style = static_cast<ProfileCustomizationStyle>(style_int);
+ }
+ return style;
+}
+
+GURL AppendProfileCustomizationQueryParams(const GURL& url,
+ ProfileCustomizationStyle style) {
+ GURL url_with_params = net::AppendQueryParameter(
+ url, kStyleParamKey, base::NumberToString(static_cast<int>(style)));
+ return url_with_params;
+}
+#endif // BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_url_utils.h b/chromium/chrome/browser/ui/webui/signin/signin_url_utils.h
index de7b62c2914..7912ad9cc44 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_url_utils.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_url_utils.h
@@ -6,27 +6,24 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_URL_UTILS_H_
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
+#include "components/signin/public/base/signin_buildflags.h"
#include "components/signin/public/base/signin_metrics.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
-#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
-// Holds parameters for the chrome://sync-confirmation URL.
-// The default values correspond to the original usage of the sync confirmation
-// page -- in the modal flow.
-struct SyncConfirmationURLParams {
- bool is_modal = true;
- SyncConfirmationUI::DesignVersion design =
- SyncConfirmationUI::DesignVersion::kMonotone;
- absl::optional<SkColor> profile_color;
+// Keep enum values in sync with the JS tests defined in signin_browsertest.js.
+enum class SyncConfirmationStyle {
+ kDefaultModal = 0,
+ kSigninInterceptModal = 1,
+ kWindow = 2
};
-// Returns `SyncConfirmationURLParams` parsed from `url`.
-SyncConfirmationURLParams GetParamsFromSyncConfirmationURL(const GURL& url);
+// Returns which style the sync confirmation page is using, as a default modal
+// dialog, the signin intercept modal dialog version or as a window.
+SyncConfirmationStyle GetSyncConfirmationStyle(const GURL& url);
-// Adds URL query parameters specified by `params` to `url`.
+// Adds the `style` URL query parameters to `url` for the sync confirmation.
GURL AppendSyncConfirmationQueryParams(const GURL& url,
- const SyncConfirmationURLParams& params);
+ SyncConfirmationStyle style);
// Returns `ReauthAccessPoint` encoded in the query of the reauth confirmation
// URL.
@@ -37,4 +34,19 @@ signin_metrics::ReauthAccessPoint GetReauthAccessPointForReauthConfirmationURL(
// triggered by |access_point|.
GURL GetReauthConfirmationURL(signin_metrics::ReauthAccessPoint access_point);
+#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
+enum class ProfileCustomizationStyle {
+ kDefault = 0,
+ kLocalProfileCreation = 1
+};
+
+// Returns which style the profile customization page is using, as the default
+// profile customization page or the local profile creation page.
+ProfileCustomizationStyle GetProfileCustomizationStyle(const GURL& url);
+
+// Adds the `style` URL query parameters to `url` for the profile customization.
+GURL AppendProfileCustomizationQueryParams(const GURL& url,
+ ProfileCustomizationStyle style);
+#endif // BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
+
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_URL_UTILS_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_url_utils_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_url_utils_unittest.cc
index ec2c55bc5f3..04da60ef4c1 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_url_utils_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_url_utils_unittest.cc
@@ -6,76 +6,74 @@
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
#include "chrome/common/webui_url_constants.h"
+#include "components/signin/public/base/signin_buildflags.h"
#include "components/signin/public/base/signin_metrics.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
-#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
-MATCHER_P(ParamsEq, expected_params, "") {
- return arg.is_modal == expected_params.is_modal &&
- arg.design == expected_params.design &&
- arg.profile_color == expected_params.profile_color;
-}
-
-// Tests that the default values correspond to the usage of the sync
-// confirmation page in the modal flow.
-TEST(SigninURLUtilsTest, SyncConfirmationURLParamsDefault) {
- SyncConfirmationURLParams default_params;
- SyncConfirmationURLParams expected_params = {
- /*is_modal=*/true, SyncConfirmationUI::DesignVersion::kMonotone,
- absl::nullopt};
- EXPECT_THAT(default_params, ParamsEq(expected_params));
-}
-
TEST(SigninURLUtilsTest, ParseParameterlessSyncConfirmationURL) {
GURL url = GURL(chrome::kChromeUISyncConfirmationURL);
- SyncConfirmationURLParams parsed_params =
- GetParamsFromSyncConfirmationURL(url);
- // Default params are expected.
- SyncConfirmationURLParams expected_params;
- EXPECT_THAT(parsed_params, ParamsEq(expected_params));
+ EXPECT_EQ(SyncConfirmationStyle::kDefaultModal,
+ GetSyncConfirmationStyle(url));
}
-class SigninURLUtilsSyncConfirmationURLTest
- : public ::testing::TestWithParam<SyncConfirmationURLParams> {};
-
-TEST_P(SigninURLUtilsSyncConfirmationURLTest, GetAndParseURL) {
- SyncConfirmationURLParams params = GetParam();
+TEST(SigninURLUtilsSyncConfirmationURLTest, GetAndParseURL) {
+ // Modal version.
GURL url = AppendSyncConfirmationQueryParams(
- GURL(chrome::kChromeUISyncConfirmationURL), params);
+ GURL(chrome::kChromeUISyncConfirmationURL),
+ SyncConfirmationStyle::kDefaultModal);
+ EXPECT_TRUE(url.is_valid());
+ EXPECT_EQ(url.host(), chrome::kChromeUISyncConfirmationHost);
+ EXPECT_EQ(SyncConfirmationStyle::kDefaultModal,
+ GetSyncConfirmationStyle(url));
+
+ // Signin Intercept version.
+ url = AppendSyncConfirmationQueryParams(
+ GURL(chrome::kChromeUISyncConfirmationURL),
+ SyncConfirmationStyle::kSigninInterceptModal);
+ EXPECT_TRUE(url.is_valid());
+ EXPECT_EQ(url.host(), chrome::kChromeUISyncConfirmationHost);
+ EXPECT_EQ(SyncConfirmationStyle::kSigninInterceptModal,
+ GetSyncConfirmationStyle(url));
+
+ // Window version.
+ url = AppendSyncConfirmationQueryParams(
+ GURL(chrome::kChromeUISyncConfirmationURL),
+ SyncConfirmationStyle::kWindow);
EXPECT_TRUE(url.is_valid());
EXPECT_EQ(url.host(), chrome::kChromeUISyncConfirmationHost);
- SyncConfirmationURLParams parsed_params =
- GetParamsFromSyncConfirmationURL(url);
- EXPECT_THAT(parsed_params, ParamsEq(params));
+ EXPECT_EQ(SyncConfirmationStyle::kWindow, GetSyncConfirmationStyle(url));
}
-INSTANTIATE_TEST_SUITE_P(
- All,
- SigninURLUtilsSyncConfirmationURLTest,
- ::testing::Values(
- SyncConfirmationURLParams{},
- SyncConfirmationURLParams{
- true, SyncConfirmationUI::DesignVersion::kMonotone, absl::nullopt},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kMonotone, absl::nullopt},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kColored, absl::nullopt},
- SyncConfirmationURLParams{false,
- SyncConfirmationUI::DesignVersion::kColored,
- SK_ColorTRANSPARENT},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kColored, SK_ColorBLACK},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kColored, SK_ColorWHITE},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kColored, SK_ColorRED},
- SyncConfirmationURLParams{
- false, SyncConfirmationUI::DesignVersion::kColored, SK_ColorCYAN},
- SyncConfirmationURLParams{
- true, SyncConfirmationUI::DesignVersion::kColored, SK_ColorBLACK}));
+#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
+TEST(SigninURLUtilsTest, ParseParameterlessProfileCustomizationURL) {
+ GURL url = GURL(chrome::kChromeUIProfileCustomizationURL);
+ EXPECT_EQ(ProfileCustomizationStyle::kDefault,
+ GetProfileCustomizationStyle(url));
+}
+
+TEST(SigninURLUtilsProfileCustomizationURLTest, GetAndParseURL) {
+ // Default version.
+ GURL url = AppendProfileCustomizationQueryParams(
+ GURL(chrome::kChromeUIProfileCustomizationURL),
+ ProfileCustomizationStyle::kDefault);
+ EXPECT_TRUE(url.is_valid());
+ EXPECT_EQ(url.host(), chrome::kChromeUIProfileCustomizationHost);
+ EXPECT_EQ(ProfileCustomizationStyle::kDefault,
+ GetProfileCustomizationStyle(url));
+
+ // Profile Creation version.
+ url = AppendProfileCustomizationQueryParams(
+ GURL(chrome::kChromeUIProfileCustomizationURL),
+ ProfileCustomizationStyle::kLocalProfileCreation);
+ EXPECT_TRUE(url.is_valid());
+ EXPECT_EQ(url.host(), chrome::kChromeUIProfileCustomizationHost);
+ EXPECT_EQ(ProfileCustomizationStyle::kLocalProfileCreation,
+ GetProfileCustomizationStyle(url));
+}
+#endif // BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
class SigninURLUtilsReauthConfirmationURLTest
: public ::testing::TestWithParam<int> {};
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc
index f469be30389..0c8f880b2fc 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc
@@ -12,17 +12,13 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/chrome_signin_client.h"
#include "chrome/browser/signin/identity_manager_factory.h"
-#include "chrome/browser/signin/investigator_dependency_provider.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/guest_view/browser/guest_view_manager.h"
+#include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_utils.h"
#include "google_apis/gaia/gaia_auth_util.h"
-#include "ui/base/l10n/l10n_util.h"
SigninUIError CanOfferSignin(Profile* profile,
const std::string& gaia_id,
@@ -102,7 +98,7 @@ SigninUIError CanOfferSignin(Profile* profile,
// With force sign in enabled, cross account sign in is not allowed.
if (signin_util::IsForceSigninEnabled() &&
- IsCrossAccountError(profile, email, gaia_id)) {
+ IsCrossAccountError(profile, gaia_id)) {
std::string last_email =
profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
return SigninUIError::ProfileWasUsedByAnotherAccount(email, last_email);
@@ -112,12 +108,9 @@ SigninUIError CanOfferSignin(Profile* profile,
return SigninUIError::Ok();
}
-bool IsCrossAccountError(Profile* profile,
- const std::string& email,
- const std::string& gaia_id) {
- InvestigatorDependencyProvider provider(profile);
- InvestigatedScenario scenario =
- SigninInvestigator(email, gaia_id, &provider).Investigate();
-
- return scenario == InvestigatedScenario::kDifferentAccount;
+bool IsCrossAccountError(Profile* profile, const std::string& gaia_id) {
+ DCHECK(!gaia_id.empty());
+ std::string last_gaia_id =
+ profile->GetPrefs()->GetString(prefs::kGoogleServicesLastAccountId);
+ return !last_gaia_id.empty() && gaia_id != last_gaia_id;
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h
index c06e875b454..c40f07fcabc 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h
@@ -22,10 +22,8 @@ SigninUIError CanOfferSignin(Profile* profile,
const std::string& gaia_id,
const std::string& email);
-// Return true if the account given by |email| and |gaia_id| is signed in to
-// Chrome in a different profile.
-bool IsCrossAccountError(Profile* profile,
- const std::string& email,
- const std::string& gaia_id);
+// Return true if an account other than `gaia_id` was previously signed into
+// `profile`.
+bool IsCrossAccountError(Profile* profile, const std::string& gaia_id);
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_UTILS_DESKTOP_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
index b1c8d045ac0..26c21da1889 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
@@ -26,7 +26,6 @@
#include "components/consent_auditor/consent_auditor.h"
#include "components/signin/public/base/avatar_icon_util.h"
#include "components/signin/public/base/consent_level.h"
-#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -102,9 +101,6 @@ void SyncConfirmationHandler::HandleGoToSettings(
}
void SyncConfirmationHandler::HandleUndo(const base::Value::List& args) {
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- DCHECK(base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles));
-#endif
did_user_explicitly_interact_ = true;
CloseModalSigninWindow(LoginUIService::ABORT_SYNC);
}
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
index f8ceb71842d..7837bdbc563 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
@@ -14,7 +14,6 @@
#include "base/scoped_observation.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
-#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
@@ -33,7 +32,6 @@
#include "chrome/test/base/testing_profile.h"
#include "components/consent_auditor/fake_consent_auditor.h"
#include "components/signin/public/base/avatar_icon_util.h"
-#include "components/signin/public/base/signin_switches.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
@@ -213,11 +211,6 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
base::HistogramTester histogram_tester_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_adaptor_;
-
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- base::test::ScopedFeatureList feature_list_{
- switches::kLacrosNonSyncingProfiles};
-#endif
};
const char SyncConfirmationHandlerTest::kConsentText1[] = "consentText1";
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
index 08907edbb36..27035960d03 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
+#include <string>
+
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -11,9 +13,12 @@
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
+#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
@@ -25,7 +30,6 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/signin_resources.h"
#include "components/signin/public/base/avatar_icon_util.h"
-#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
@@ -39,27 +43,9 @@
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/webui_generated_resources.h"
-namespace {
-
-ProfileThemeColors GetProfileThemeColors(absl::optional<SkColor> theme_color) {
- return theme_color ? GetProfileThemeColorsForAutogeneratedColor(*theme_color)
- : GetDefaultProfileThemeColors();
-}
-
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
-bool SyncForced() {
- return !base::FeatureList::IsEnabled(switches::kLacrosNonSyncingProfiles);
-}
-#endif
-
-} // namespace
-
SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
: SigninWebDialogUI(web_ui), profile_(Profile::FromWebUI(web_ui)) {
- SyncConfirmationURLParams params = GetParamsFromSyncConfirmationURL(
- web_ui->GetWebContents()->GetVisibleURL());
- DCHECK(!(params.design == DesignVersion::kMonotone &&
- params.profile_color.has_value()));
+ const GURL& url = web_ui->GetWebContents()->GetVisibleURL();
const bool is_sync_allowed = SyncServiceFactory::IsSyncAllowed(profile_);
content::WebUIDataSource* source =
@@ -82,8 +68,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
IDS_SYNC_LOADING_CONFIRMATION_TITLE);
if (is_sync_allowed) {
- InitializeForSyncConfirmation(source, params.profile_color, params.design,
- params.is_modal);
+ InitializeForSyncConfirmation(source, GetSyncConfirmationStyle(url));
} else {
InitializeForSyncDisabled(source);
}
@@ -105,25 +90,13 @@ void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) {
void SyncConfirmationUI::InitializeForSyncConfirmation(
content::WebUIDataSource* source,
- absl::optional<SkColor> profile_creation_flow_color,
- DesignVersion design,
- bool is_modal_dialog) {
+ SyncConfirmationStyle style) {
int title_id = IDS_SYNC_CONFIRMATION_TITLE;
int info_title_id = IDS_SYNC_CONFIRMATION_SYNC_INFO_TITLE;
int confirm_label_id = IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL;
#if BUILDFLAG(IS_CHROMEOS_LACROS)
- if (SyncForced()) {
- title_id = IDS_SYNC_CONFIRMATION_TITLE_LACROS;
- info_title_id = IDS_SYNC_CONFIRMATION_SYNC_INFO_TITLE_LACROS;
- confirm_label_id = IDS_DONE;
- } else {
- title_id = IDS_SYNC_CONFIRMATION_TITLE_LACROS_NON_FORCED;
- }
+ title_id = IDS_SYNC_CONFIRMATION_TITLE_LACROS_NON_FORCED;
#endif
- AddStringResource(source, "syncConfirmationTitle", title_id);
- AddStringResource(source, "syncConfirmationSyncInfoTitle", info_title_id);
- AddStringResource(source, "syncConfirmationConfirmLabel", confirm_label_id);
-
AddStringResource(source, "syncConfirmationSyncInfoDesc",
IDS_SYNC_CONFIRMATION_SYNC_INFO_DESC);
AddStringResource(source, "syncConfirmationSettingsInfo",
@@ -138,21 +111,49 @@ void SyncConfirmationUI::InitializeForSyncConfirmation(
source->SetDefaultResource(
IDR_SIGNIN_SYNC_CONFIRMATION_SYNC_CONFIRMATION_HTML);
- source->AddBoolean("isNewDesign", design == DesignVersion::kColored);
-
- source->AddBoolean("isModalDialog", is_modal_dialog);
-
- bool sync_forced = false;
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
- if (SyncForced())
- sync_forced = true;
-#endif
- source->AddBoolean("syncForced", sync_forced);
+ source->AddBoolean("isModalDialog",
+ style == SyncConfirmationStyle::kDefaultModal ||
+ style == SyncConfirmationStyle::kSigninInterceptModal);
+ source->AddBoolean("isSigninInterceptFre",
+ style == SyncConfirmationStyle::kSigninInterceptModal);
+
+ source->AddString("accountPictureUrl",
+ profiles::GetPlaceholderAvatarIconUrl());
+ switch (style) {
+ case SyncConfirmationStyle::kSigninInterceptModal: {
+ DCHECK(base::FeatureList::IsEnabled(kSyncPromoAfterSigninIntercept));
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_->GetPath());
+ DCHECK(entry);
+ std::u16string gaia_name = entry->GetGAIANameToDisplay();
+ if (gaia_name.empty())
+ gaia_name = entry->GetLocalProfileName();
+ AddStringResourceWithPlaceholder(
+ source, "syncConfirmationTitle",
+ IDS_SYNC_CONFIRMATION_WELCOME_TITLE_SIGNIN_INTERCEPT, gaia_name);
+ AddStringResource(source, "syncConfirmationSyncInfoTitle",
+ IDS_SYNC_CONFIRMATION_SYNC_INFO_SIGNIN_INTERCEPT);
+ AddStringResource(source, "syncConfirmationConfirmLabel",
+ IDS_SYNC_CONFIRMATION_TURN_ON_SYNC_BUTTON_LABEL);
+ AddStringResource(source, "syncConfirmationUndoLabel", IDS_NO_THANKS);
+ AddStringResource(source, "syncConfirmationSettingsLabel",
+ IDS_SYNC_CONFIRMATION_MANAGE_SYNC_BUTTON_LABEL);
- switch (design) {
- case DesignVersion::kMonotone: {
- source->AddString("accountPictureUrl",
- profiles::GetPlaceholderAvatarIconUrl());
+ source->AddResourcePath(
+ "images/sync_confirmation_signin_intercept_illustration.svg",
+ IDR_SIGNIN_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_SIGNIN_INTERCEPT_ILLUSTRATION_SVG);
+ source->AddResourcePath(
+ "images/sync_confirmation_signin_intercept_illustration_dark.svg",
+ IDR_SIGNIN_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_SIGNIN_INTERCEPT_ILLUSTRATION_DARK_SVG);
+ break;
+ }
+ case SyncConfirmationStyle::kDefaultModal:
+ AddStringResource(source, "syncConfirmationTitle", title_id);
+ AddStringResource(source, "syncConfirmationSyncInfoTitle", info_title_id);
+ AddStringResource(source, "syncConfirmationConfirmLabel",
+ confirm_label_id);
AddStringResource(source, "syncConfirmationUndoLabel", IDS_CANCEL);
AddStringResource(source, "syncConfirmationSettingsLabel",
IDS_SYNC_CONFIRMATION_SETTINGS_BUTTON_LABEL);
@@ -164,24 +165,14 @@ void SyncConfirmationUI::InitializeForSyncConfirmation(
"images/sync_confirmation_illustration_dark.svg",
IDR_SIGNIN_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_ILLUSTRATION_DARK_SVG);
break;
- }
- case DesignVersion::kColored: {
- ProfileThemeColors colors =
- GetProfileThemeColors(profile_creation_flow_color);
- const int kAccountPictureSize = 128;
- gfx::Image avatar_picture = profiles::GetPlaceholderAvatarIconWithColors(
- colors.default_avatar_fill_color, colors.default_avatar_stroke_color,
- kAccountPictureSize);
- std::string avatar_picture_url =
- webui::GetBitmapDataUrl(avatar_picture.AsBitmap());
- source->AddString("accountPictureUrl", avatar_picture_url);
-
+ case SyncConfirmationStyle::kWindow:
+ AddStringResource(source, "syncConfirmationTitle", title_id);
+ AddStringResource(source, "syncConfirmationSyncInfoTitle", info_title_id);
+ AddStringResource(source, "syncConfirmationConfirmLabel",
+ confirm_label_id);
AddStringResource(source, "syncConfirmationUndoLabel", IDS_NO_THANKS);
AddStringResource(source, "syncConfirmationSettingsLabel",
IDS_SYNC_CONFIRMATION_REFRESHED_SETTINGS_BUTTON_LABEL);
- source->AddString("highlightColor", color_utils::SkColorToRgbaString(
- colors.profile_highlight_color));
-
source->AddResourcePath(
"images/sync_confirmation_refreshed_illustration.svg",
IDR_SIGNIN_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_SVG);
@@ -189,7 +180,6 @@ void SyncConfirmationUI::InitializeForSyncConfirmation(
"images/sync_confirmation_refreshed_illustration_dark.svg",
IDR_SIGNIN_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_DARK_SVG);
break;
- }
}
}
@@ -218,16 +208,29 @@ void SyncConfirmationUI::AddStringResource(content::WebUIDataSource* source,
const std::string& name,
int ids) {
source->AddLocalizedString(name, ids);
+ AddLocalizedStringToIdsMap(l10n_util::GetStringUTF8(ids), ids);
+}
+void SyncConfirmationUI::AddStringResourceWithPlaceholder(
+ content::WebUIDataSource* source,
+ const std::string& name,
+ int ids,
+ const std::u16string& parameter) {
+ std::string localized_string = l10n_util::GetStringFUTF8(ids, parameter);
+ source->AddString(name, localized_string);
+ AddLocalizedStringToIdsMap(localized_string, ids);
+}
+
+void SyncConfirmationUI::AddLocalizedStringToIdsMap(
+ const std::string& localized_string,
+ int ids) {
// When the strings are passed to the HTML, the Unicode NBSP symbol (\u00A0)
// will be automatically replaced with "&nbsp;". This change must be mirrored
// in the string-to-ids map. Note that "\u00A0" is actually two characters,
// so we must use base::ReplaceSubstrings* rather than base::ReplaceChars.
// TODO(msramek): Find a more elegant solution.
- std::string sanitized_string =
- base::UTF16ToUTF8(l10n_util::GetStringUTF16(ids));
+ std::string sanitized_string = localized_string;
base::ReplaceSubstringsAfterOffset(&sanitized_string, 0, "\u00A0" /* NBSP */,
"&nbsp;");
-
js_localized_string_to_ids_map_[sanitized_string] = ids;
}
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h
index 3e73365655c..eaa179c66bf 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h
@@ -12,7 +12,6 @@
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/webui/signin/signin_web_dialog_ui.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
-#include "third_party/skia/include/core/SkColor.h"
class Browser;
class Profile;
@@ -25,14 +24,14 @@ namespace ui {
class WebUI;
}
+enum class SyncConfirmationStyle;
+
// WebUI controller for the sync confirmation dialog.
//
// Note: This controller does not set the WebUI message handler. It is
// the responsability of the caller to pass the correct message handler.
class SyncConfirmationUI : public SigninWebDialogUI {
public:
- enum class DesignVersion { kMonotone, kColored };
-
explicit SyncConfirmationUI(content::WebUI* web_ui);
SyncConfirmationUI(const SyncConfirmationUI&) = delete;
@@ -45,11 +44,8 @@ class SyncConfirmationUI : public SigninWebDialogUI {
void InitializeMessageHandlerWithBrowser(Browser* browser) override;
private:
- void InitializeForSyncConfirmation(
- content::WebUIDataSource* source,
- absl::optional<SkColor> profile_creation_flow_color,
- DesignVersion design,
- bool is_modal_dialog);
+ void InitializeForSyncConfirmation(content::WebUIDataSource* source,
+ SyncConfirmationStyle style);
void InitializeForSyncDisabled(content::WebUIDataSource* source);
// Adds a string resource with the given GRD |ids| to the WebUI data |source|
@@ -60,6 +56,19 @@ class SyncConfirmationUI : public SigninWebDialogUI {
const std::string& name,
int ids);
+ // Adds a string resource with the given GRD |ids| and |parameter| as the
+ // placeholder to the WebUI data |source| named as |name|. Also stores a
+ // reverse mapping from the localized version of the string to the |ids| in
+ // order to later pass it to SyncConfirmationHandler.
+ void AddStringResourceWithPlaceholder(content::WebUIDataSource* source,
+ const std::string& name,
+ int ids,
+ const std::u16string& parameter);
+
+ // Adds a mapping from the localized version of a string |localized_string| to
+ // its given GRD |ids| in order to later pass it to SyncConfirmationHandler.
+ void AddLocalizedStringToIdsMap(const std::string& localized_string, int ids);
+
// For consent auditing.
std::unordered_map<std::string, int> js_localized_string_to_ids_map_;
diff --git a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.cc b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.cc
index 4409cdca023..3c0fd0dd4d1 100644
--- a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.cc
+++ b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/sync/sync_service_factory.h"
+#include "chrome/browser/sync/sync_startup_tracker.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
#include "chrome/browser/ui/tab_dialogs.h"
@@ -156,6 +157,11 @@ void SetCurrentTurnSyncOnHelper(Profile* profile, TurnSyncOnHelper* helper) {
} // namespace
+bool TurnSyncOnHelper::Delegate::
+ ShouldAbortBeforeShowSyncDisabledConfirmation() {
+ return false;
+}
+
// static
void TurnSyncOnHelper::Delegate::ShowLoginErrorForBrowser(
const SigninUIError& error,
@@ -206,6 +212,9 @@ TurnSyncOnHelper::TurnSyncOnHelper(
DCHECK(!account_info_.email.empty());
if (HasCanOfferSigninError()) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Not able to offer sign in.";
+#endif
// Do not self-destruct synchronously in the constructor.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&TurnSyncOnHelper::AbortAndDelete,
@@ -213,11 +222,15 @@ TurnSyncOnHelper::TurnSyncOnHelper(
return;
}
- if (!IsCrossAccountError(profile_, account_info_.email, account_info_.gaia)) {
+ if (!IsCrossAccountError(profile_, account_info_.gaia)) {
TurnSyncOnWithProfileMode(ProfileMode::CURRENT_PROFILE);
return;
}
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Cross-account error.";
+#endif
+
// Handles cross account sign in error. If |account_info_| does not match the
// last authenticated account of the current profile, then Chrome will show a
// confirmation dialog before starting sync.
@@ -248,6 +261,10 @@ TurnSyncOnHelper::TurnSyncOnHelper(
base::OnceClosure()) {}
TurnSyncOnHelper::~TurnSyncOnHelper() {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Destroying TurnSyncOnHelper.";
+#endif
+
DCHECK_EQ(this, GetCurrentTurnSyncOnHelper(profile_));
SetCurrentTurnSyncOnHelper(profile_, nullptr);
}
@@ -318,6 +335,10 @@ void TurnSyncOnHelper::OnEnterpriseAccountConfirmation(
}
void TurnSyncOnHelper::TurnSyncOnWithProfileMode(ProfileMode profile_mode) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Profile mode: "
+ << static_cast<int>(profile_mode);
+#endif
switch (profile_mode) {
case ProfileMode::CURRENT_PROFILE: {
// If this is a new signin (no account authenticated yet) try loading
@@ -342,6 +363,12 @@ void TurnSyncOnHelper::TurnSyncOnWithProfileMode(ProfileMode profile_mode) {
}
void TurnSyncOnHelper::OnRegisteredForPolicy(bool is_account_managed) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING)
+ << "crbug.com/1340791 | Policy registration passed, is_account_managed="
+ << is_account_managed;
+#endif
+
if (!is_account_managed) {
// Just finish signing in.
DVLOG(1) << "Policy registration failed";
@@ -363,6 +390,9 @@ void TurnSyncOnHelper::OnRegisteredForPolicy(bool is_account_managed) {
}
void TurnSyncOnHelper::LoadPolicyWithCachedCredentials() {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Requesting policies";
+#endif
DCHECK(policy_fetch_tracker_);
bool fetch_started = policy_fetch_tracker_->FetchPolicy(
base::BindOnce(&TurnSyncOnHelper::SigninAndShowSyncConfirmationUI,
@@ -420,6 +450,7 @@ void TurnSyncOnHelper::OnNewSignedInProfileCreated(Profile* new_profile) {
ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_SYNC_FLOW);
if (!new_profile) {
+ LOG(WARNING) << "Failed switching the Sync opt-in flow to a new profile.";
// TODO(atwilson): On error, unregister the client to release the DMToken
// and surface a better error for the user.
AbortAndDelete();
@@ -444,6 +475,11 @@ void TurnSyncOnHelper::OnNewSignedInProfileCreated(Profile* new_profile) {
}
void TurnSyncOnHelper::SigninAndShowSyncConfirmationUI() {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Passed initial set up, getting ready to "
+ "show the Sync opt-in screen";
+#endif
+
// Signin.
auto* primary_account_mutator = identity_manager_->GetPrimaryAccountMutator();
primary_account_mutator->SetPrimaryAccount(account_info_.account_id,
@@ -497,26 +533,50 @@ void TurnSyncOnHelper::SigninAndShowSyncConfirmationUI() {
policy::EnterpriseManagementAuthority::CLOUD_DOMAIN);
if (may_have_cloud_policies &&
- SyncStartupTracker::GetSyncServiceState(sync_service) ==
- SyncStartupTracker::SYNC_STARTUP_PENDING) {
- sync_startup_tracker_ =
- std::make_unique<SyncStartupTracker>(sync_service, this);
+ SyncStartupTracker::GetServiceStartupState(sync_service) ==
+ SyncStartupTracker::ServiceStartupState::kPending) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Waiting for Sync service to start.";
+#endif
+ sync_startup_tracker_ = std::make_unique<SyncStartupTracker>(
+ sync_service,
+ base::BindOnce(&TurnSyncOnHelper::OnSyncStartupStateChanged,
+ weak_pointer_factory_.GetWeakPtr()));
return;
}
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Sync service is ready.";
+ } else {
+ LOG(WARNING) << "crbug.com/1340791 | Sync service is not available.";
+#endif
}
ShowSyncConfirmationUI();
}
-void TurnSyncOnHelper::SyncStartupCompleted() {
- DCHECK(sync_startup_tracker_);
- sync_startup_tracker_.reset();
- ShowSyncConfirmationUI();
-}
-
-void TurnSyncOnHelper::SyncStartupFailed() {
- DCHECK(sync_startup_tracker_);
- sync_startup_tracker_.reset();
- ShowSyncConfirmationUI();
+void TurnSyncOnHelper::OnSyncStartupStateChanged(
+ SyncStartupTracker::ServiceStartupState state) {
+ switch (state) {
+ case SyncStartupTracker::ServiceStartupState::kPending:
+ NOTREACHED();
+ break;
+ case SyncStartupTracker::ServiceStartupState::kTimeout:
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | "
+#else
+ DVLOG(1)
+#endif
+ << "Waiting for Sync Service to start timed out.";
+ [[fallthrough]];
+ case SyncStartupTracker::ServiceStartupState::kError:
+ case SyncStartupTracker::ServiceStartupState::kComplete:
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Sync startup wait ended.";
+#endif
+ DCHECK(sync_startup_tracker_);
+ sync_startup_tracker_.reset();
+ ShowSyncConfirmationUI();
+ break;
+ }
}
// static
@@ -532,24 +592,40 @@ bool TurnSyncOnHelper::HasCurrentTurnSyncOnHelperForTesting(Profile* profile) {
void TurnSyncOnHelper::ShowSyncConfirmationUI() {
if (g_show_sync_enabled_ui_for_testing_ || GetSyncService()) {
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Showing Sync opt-in screen.";
+#endif
delegate_->ShowSyncConfirmation(
base::BindOnce(&TurnSyncOnHelper::FinishSyncSetupAndDelete,
weak_pointer_factory_.GetWeakPtr()));
- } else {
- // The sync disabled dialog has an explicit "sign-out" label for the
- // LoginUIService::ABORT_SYNC action, force the mode to remove the account.
- signin_aborted_mode_ = SigninAbortedMode::REMOVE_ACCOUNT;
- // Use the email-based heuristic if `account_info_` isn't fully initialized.
- const bool is_managed_account =
- account_info_.IsValid()
- ? account_info_.IsManaged()
- : !policy::BrowserPolicyConnector::IsNonEnterpriseUser(
- account_info_.email);
- delegate_->ShowSyncDisabledConfirmation(
- is_managed_account,
- base::BindOnce(&TurnSyncOnHelper::FinishSyncSetupAndDelete,
- weak_pointer_factory_.GetWeakPtr()));
+ return;
}
+
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | Proceeding with Sync disabled.";
+#endif
+
+ // Sync is disabled. Check if we need to display the disabled confirmation UI
+ // first.
+ if (delegate_->ShouldAbortBeforeShowSyncDisabledConfirmation()) {
+ FinishSyncSetupAndDelete(
+ LoginUIService::SyncConfirmationUIClosedResult::ABORT_SYNC);
+ return;
+ }
+
+ // The sync disabled dialog has an explicit "sign-out" label for the
+ // LoginUIService::ABORT_SYNC action, force the mode to remove the account.
+ signin_aborted_mode_ = SigninAbortedMode::REMOVE_ACCOUNT;
+ // Use the email-based heuristic if `account_info_` isn't fully initialized.
+ const bool is_managed_account =
+ account_info_.IsValid()
+ ? account_info_.IsManaged()
+ : !policy::BrowserPolicyConnector::IsNonEnterpriseUser(
+ account_info_.email);
+ delegate_->ShowSyncDisabledConfirmation(
+ is_managed_account,
+ base::BindOnce(&TurnSyncOnHelper::FinishSyncSetupAndDelete,
+ weak_pointer_factory_.GetWeakPtr()));
}
void TurnSyncOnHelper::FinishSyncSetupAndDelete(
@@ -557,6 +633,11 @@ void TurnSyncOnHelper::FinishSyncSetupAndDelete(
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile_);
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ LOG(WARNING) << "crbug.com/1340791 | FinishSyncSetupAndDelete with result="
+ << static_cast<int>(result);
+#endif
+
switch (result) {
case LoginUIService::CONFIGURE_SYNC_FIRST:
if (consent_service)
diff --git a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.h b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.h
index b7b7260a276..3ad96cae41b 100644
--- a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.h
+++ b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper.h
@@ -50,7 +50,7 @@ class SyncSetupInProgressHandle;
// Handles details of setting the primary account with IdentityManager and
// turning on sync for an account for which there is already a refresh token.
-class TurnSyncOnHelper : public SyncStartupTracker::Observer {
+class TurnSyncOnHelper {
public:
// Behavior when the signin is aborted (by an error or cancelled by the user).
// The mode has no effect on the sync-is-disabled flow where cancelling always
@@ -99,6 +99,14 @@ class TurnSyncOnHelper : public SyncStartupTracker::Observer {
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) = 0;
+ // Whether the delegate wants to silently abort the turn sync on process
+ // when the sync is disabled for the user before showing the sync disabled
+ // UI.
+ // This can be used in cases when the turn sync on is triggered not by the
+ // user action but a promo process.
+ // Defaults to false.
+ virtual bool ShouldAbortBeforeShowSyncDisabledConfirmation();
+
// Shows a screen informing that sync is disabled for the user.
// |is_managed_account| is true if the account (where sync is being set up)
// is managed (which may influence the UI or strings). |callback| must be
@@ -148,10 +156,6 @@ class TurnSyncOnHelper : public SyncStartupTracker::Observer {
TurnSyncOnHelper(const TurnSyncOnHelper&) = delete;
TurnSyncOnHelper& operator=(const TurnSyncOnHelper&) = delete;
- // SyncStartupTracker::Observer:
- void SyncStartupCompleted() override;
- void SyncStartupFailed() override;
-
// Fakes that sync enabled for testing, but does not create a sync service.
static void SetShowSyncEnabledUiForTesting(
bool show_sync_enabled_ui_for_testing);
@@ -159,6 +163,10 @@ class TurnSyncOnHelper : public SyncStartupTracker::Observer {
// Returns true if a `TurnSyncOnHelper` is currently active for `profile`.
static bool HasCurrentTurnSyncOnHelperForTesting(Profile* profile);
+ // Used as callback for `SyncStartupTracker`.
+ // Public for testing.
+ void OnSyncStartupStateChanged(SyncStartupTracker::ServiceStartupState state);
+
private:
friend class base::DeleteHelper<TurnSyncOnHelper>;
@@ -174,7 +182,7 @@ class TurnSyncOnHelper : public SyncStartupTracker::Observer {
};
// TurnSyncOnHelper deletes itself.
- ~TurnSyncOnHelper() override;
+ ~TurnSyncOnHelper();
// Handles can offer sign-in errors. It returns true if there is an error,
// and false otherwise.
diff --git a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_policy_fetch_tracker.cc b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_policy_fetch_tracker.cc
index 4204deb8d6d..7d6e79bc902 100644
--- a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_policy_fetch_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_policy_fetch_tracker.cc
@@ -14,10 +14,6 @@
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "content/public/browser/storage_partition.h"
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
-#include "components/policy/core/common/policy_loader_lacros.h"
-#endif
-
namespace {
class PolicyFetchTracker
: public TurnSyncOnHelperPolicyFetchTracker,
@@ -125,6 +121,8 @@ class PolicyFetchTracker
class LacrosPrimaryProfilePolicyFetchTracker
: public TurnSyncOnHelperPolicyFetchTracker {
public:
+ explicit LacrosPrimaryProfilePolicyFetchTracker(Profile* profile)
+ : profile_(profile) {}
~LacrosPrimaryProfilePolicyFetchTracker() override = default;
void SwitchToProfile(Profile* new_profile) override {
@@ -149,10 +147,10 @@ class LacrosPrimaryProfilePolicyFetchTracker
private:
bool IsManagedProfile() {
- const enterprise_management::PolicyData* policy =
- policy::PolicyLoaderLacros::main_user_policy_data();
- return policy && policy->has_managed_by();
+ return profile_->GetProfilePolicyConnector()->IsManaged();
}
+
+ Profile* profile_;
};
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
} // namespace
@@ -163,7 +161,7 @@ TurnSyncOnHelperPolicyFetchTracker::CreateInstance(
const AccountInfo& account_info) {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (profile->IsMainProfile()) {
- return std::make_unique<LacrosPrimaryProfilePolicyFetchTracker>();
+ return std::make_unique<LacrosPrimaryProfilePolicyFetchTracker>(profile);
}
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
return std::make_unique<PolicyFetchTracker>(profile, account_info);
diff --git a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_unittest.cc b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_unittest.cc
index c37b196fc76..ce44938edbc 100644
--- a/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/turn_sync_on_helper_unittest.cc
@@ -16,7 +16,6 @@
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
-#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
@@ -32,6 +31,7 @@
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
#include "chrome/browser/sync/sync_service_factory.h"
+#include "chrome/browser/sync/sync_startup_tracker.h"
#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/test/base/fake_profile_manager.h"
@@ -47,7 +47,6 @@
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/base/signin_pref_names.h"
-#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
@@ -78,6 +77,7 @@ namespace {
const char kEmail[] = "foo@gmail.com";
const char kPreviousEmail[] = "notme@bar.com";
+const char kPreviousAccountId[] = "gaia_id_for_not_me_at_bar_com";
const char kEnterpriseEmail[] = "enterprise@managed.com";
const char kEnterpriseHostedDomain[] = "managed.com";
@@ -147,6 +147,7 @@ class TestTurnSyncOnHelperDelegate : public TurnSyncOnHelper::Delegate {
void ShowSyncConfirmation(
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) override;
+ bool ShouldAbortBeforeShowSyncDisabledConfirmation() override;
void ShowSyncDisabledConfirmation(
bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
@@ -461,11 +462,13 @@ class TurnSyncOnHelperTest : public testing::Test {
.Times(0);
}
- void CheckSyncAborted(bool has_primary_account) {
+ void CheckSyncAborted(bool kept_account, int destroyed_delegate_count = 1) {
EXPECT_FALSE(
identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
- EXPECT_EQ(has_primary_account,
- identity_manager()->HasAccountWithRefreshToken(account_id()));
+ EXPECT_EQ(kept_account,
+ identity_manager()->HasPrimaryAccountWithRefreshToken(
+ signin::ConsentLevel::kSignin));
+ EXPECT_EQ(delegate_destroyed_, destroyed_delegate_count);
}
void CheckDelegateCalls() {
@@ -528,12 +531,21 @@ class TurnSyncOnHelperTest : public testing::Test {
std::move(callback).Run(sync_confirmation_result_);
}
+ bool OnShouldAbortBeforeShowSyncDisabledConfirmation() {
+ EXPECT_FALSE(sync_confirmation_shown_);
+ EXPECT_EQ(sync_disabled_confirmation_, kNotShown);
+ if (abort_before_show_sync_disabled_confirmation_)
+ sync_disabled_confirmation_ = kAbortedBeforeShown;
+ return abort_before_show_sync_disabled_confirmation_;
+ }
+
void OnShowSyncDisabledConfirmation(
bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) {
EXPECT_EQ(sync_disabled_confirmation_, kNotShown)
- << "Sync disabled confirmation should be shown only once.";
+ << "Sync disabled confirmation should be shown only once or aborted "
+ "without showing.";
sync_disabled_confirmation_ =
is_managed_account ? kShownManaged : kShownNonManaged;
if (run_delegate_callbacks_)
@@ -601,13 +613,19 @@ class TurnSyncOnHelperTest : public testing::Test {
protected:
// Type of sync disabled confirmation shown.
- enum SyncDisabledConfirmation { kNotShown, kShownManaged, kShownNonManaged };
+ enum SyncDisabledConfirmation {
+ kNotShown,
+ kAbortedBeforeShown,
+ kShownManaged,
+ kShownNonManaged
+ };
// Delegate behavior.
signin::SigninChoice merge_data_choice_ = signin::SIGNIN_CHOICE_CANCEL;
signin::SigninChoice enterprise_choice_ = signin::SIGNIN_CHOICE_CANCEL;
LoginUIService::SyncConfirmationUIClosedResult sync_confirmation_result_ =
LoginUIService::SyncConfirmationUIClosedResult::ABORT_SYNC;
+ bool abort_before_show_sync_disabled_confirmation_ = false;
bool run_delegate_callbacks_ = true;
// Expected delegate calls.
@@ -640,9 +658,6 @@ class TurnSyncOnHelperTest : public testing::Test {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
testing::NiceMock<account_manager::MockAccountManagerFacade>
mock_account_manager_facade_;
-
- base::test::ScopedFeatureList scoped_feature_list_{
- switches::kLacrosNonSyncingProfiles};
#endif
// State of the delegate calls.
@@ -691,6 +706,11 @@ void TestTurnSyncOnHelperDelegate::ShowSyncConfirmation(
test_fixture_->OnShowSyncConfirmation(std::move(callback));
}
+bool TestTurnSyncOnHelperDelegate::
+ ShouldAbortBeforeShowSyncDisabledConfirmation() {
+ return test_fixture_->OnShouldAbortBeforeShowSyncDisabledConfirmation();
+}
+
void TestTurnSyncOnHelperDelegate::ShowSyncDisabledConfirmation(
bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
@@ -763,7 +783,7 @@ TEST_F(TurnSyncOnHelperTest, SyncDisabledAbortRemoveAccount) {
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
base::RunLoop().RunUntilIdle();
// Check expectations.
- CheckSyncAborted(/*has_primary_account=*/false);
+ CheckSyncAborted(/*kept_account=*/false);
CheckDelegateCalls();
}
@@ -783,7 +803,7 @@ TEST_F(TurnSyncOnHelperTest, SyncDisabledAbortKeepAccount) {
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
base::RunLoop().RunUntilIdle();
// Check expectations.
- CheckSyncAborted(/*has_primary_account=*/false);
+ CheckSyncAborted(/*kept_account=*/false);
CheckDelegateCalls();
}
@@ -833,6 +853,44 @@ TEST_F(TurnSyncOnHelperTest, SyncDisabledManagedContinueKeepAccount) {
CheckDelegateCalls();
}
+// Tests that the sync aborted before displaying the sync disabled message and
+// `SigninAbortedMode::REMOVE_ACCOUNT` is honored.
+TEST_F(TurnSyncOnHelperTest, SyncDisabledAbortWithoutShowingUI_RemoveAccount) {
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kAbortedBeforeShown;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ abort_before_show_sync_disabled_confirmation_ = true;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ CheckSyncAborted(/*kept_account=*/false);
+ CheckDelegateCalls();
+}
+
+// Tests that the sync aborted before displaying the sync disabled message and
+// `SigninAbortedMode::KEEP_ACCOUNT` is honored.
+TEST_F(TurnSyncOnHelperTest, SyncDisabledAbortWithoutShowingUI_KeepAccount) {
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kAbortedBeforeShown;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ abort_before_show_sync_disabled_confirmation_ = true;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ CheckSyncAborted(/*kept_account=*/true);
+ CheckDelegateCalls();
+}
+
// Aborts the flow after the cross account dialog.
TEST_F(TurnSyncOnHelperTest, CrossAccountAbort) {
// Set expectations.
@@ -841,6 +899,8 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountAbort) {
// Configure the test.
profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername,
kPreviousEmail);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId,
+ kPreviousAccountId);
// Signin flow.
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
@@ -858,6 +918,8 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountAbortAlreadyManaged) {
// Configure the test.
profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername,
kPreviousEmail);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId,
+ kPreviousAccountId);
user_policy_signin_service()->set_dm_token("foo");
user_policy_signin_service()->set_client_id("bar");
chrome::enterprise_util::SetUserAcceptedAccountManagement(profile(), true);
@@ -881,10 +943,12 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountContinue) {
merge_data_choice_ = signin::SIGNIN_CHOICE_CONTINUE;
profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername,
kPreviousEmail);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId,
+ kPreviousAccountId);
// Signin flow.
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- CheckSyncAborted(/*has_primary_account=*/false);
+ CheckSyncAborted(/*kept_account=*/false);
CheckDelegateCalls();
}
@@ -899,6 +963,8 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountContinueAlreadyManaged) {
merge_data_choice_ = signin::SIGNIN_CHOICE_CONTINUE;
profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername,
kPreviousEmail);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId,
+ kPreviousAccountId);
user_policy_signin_service()->set_dm_token("foo");
user_policy_signin_service()->set_client_id("bar");
chrome::enterprise_util::SetUserAcceptedAccountManagement(profile(), true);
@@ -907,7 +973,7 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountContinueAlreadyManaged) {
// Check expectations.
// This was already a signed-in and managed enterprise account so we keep the
// user signed-in, overriding SigninAbortedMode::REMOVE_ACCOUNT.
- CheckSyncAborted(/*has_primary_account=*/true);
+ CheckSyncAborted(/*kept_account=*/true);
CheckDelegateCalls();
}
@@ -925,6 +991,8 @@ TEST_F(TurnSyncOnHelperTest, CrossAccountNewProfile) {
merge_data_choice_ = signin::SIGNIN_CHOICE_NEW_PROFILE;
profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername,
kPreviousEmail);
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId,
+ kPreviousAccountId);
// Signin flow.
ProfileWaiter profile_waiter;
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
@@ -1089,7 +1157,7 @@ TEST_F(TurnSyncOnHelperTest, SignedInAccountUndoSyncRemoveAccount) {
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// This was already a signed-in and managed enterprise account so we keep the
// user signed-in, overriding SigninAbortedMode::REMOVE_ACCOUNT.
- CheckSyncAborted(/*has_primary_account=*/true);
+ CheckSyncAborted(/*kept_account=*/true);
CheckDelegateCalls();
}
@@ -1105,7 +1173,7 @@ TEST_F(TurnSyncOnHelperTest, UndoSync) {
identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
CreateTurnOnSyncHelper(TurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- CheckSyncAborted(/*has_primary_account=*/false);
+ CheckSyncAborted(/*kept_account=*/false);
CheckDelegateCalls();
}
@@ -1222,7 +1290,8 @@ TEST_F(TurnSyncOnHelperTest,
SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW));
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
- sync_starter->SyncStartupCompleted();
+ sync_starter->OnSyncStartupStateChanged(
+ SyncStartupTracker::ServiceStartupState::kComplete);
CheckDelegateCalls();
}
@@ -1258,7 +1327,8 @@ TEST_F(TurnSyncOnHelperTest,
SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW));
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
- sync_starter->SyncStartupCompleted();
+ sync_starter->OnSyncStartupStateChanged(
+ SyncStartupTracker::ServiceStartupState::kComplete);
CheckDelegateCalls();
}
@@ -1294,7 +1364,8 @@ TEST_F(TurnSyncOnHelperTest,
SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW));
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
- sync_starter->SyncStartupFailed();
+ sync_starter->OnSyncStartupStateChanged(
+ SyncStartupTracker::ServiceStartupState::kError);
CheckDelegateCalls();
}
@@ -1332,7 +1403,8 @@ TEST_F(TurnSyncOnHelperTest,
SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW));
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
- sync_starter->SyncStartupFailed();
+ sync_starter->OnSyncStartupStateChanged(
+ SyncStartupTracker::ServiceStartupState::kError);
CheckDelegateCalls();
}
diff --git a/chromium/chrome/browser/ui/webui/signin_internals_ui.cc b/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
index a06dec4965e..59aa9306ce7 100644
--- a/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
@@ -122,10 +122,12 @@ void SignInInternalsHandler::HandleGetSignInInfo(
}
}
-void SignInInternalsHandler::OnSigninStateChanged(const base::Value* info) {
- FireWebUIListener("signin-info-changed", *info);
+void SignInInternalsHandler::OnSigninStateChanged(
+ const base::Value::Dict& info) {
+ FireWebUIListener("signin-info-changed", info);
}
-void SignInInternalsHandler::OnCookieAccountsFetched(const base::Value* info) {
- FireWebUIListener("update-cookie-accounts", *info);
+void SignInInternalsHandler::OnCookieAccountsFetched(
+ const base::Value::Dict& info) {
+ FireWebUIListener("update-cookie-accounts", info);
}
diff --git a/chromium/chrome/browser/ui/webui/signin_internals_ui.h b/chromium/chrome/browser/ui/webui/signin_internals_ui.h
index 3a2320d97d1..9f8020b555e 100644
--- a/chromium/chrome/browser/ui/webui/signin_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin_internals_ui.h
@@ -37,10 +37,10 @@ class SignInInternalsHandler : public content::WebUIMessageHandler,
void HandleGetSignInInfo(const base::Value::List& args);
// AboutSigninInternals::Observer::OnSigninStateChanged implementation.
- void OnSigninStateChanged(const base::Value* info) override;
+ void OnSigninStateChanged(const base::Value::Dict& info) override;
// Notification that the cookie accounts are ready to be displayed.
- void OnCookieAccountsFetched(const base::Value* info) override;
+ void OnCookieAccountsFetched(const base::Value::Dict& info) override;
};
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc
index 7ebc69487a7..744a8b9c8f8 100644
--- a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc
+++ b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui.cc
@@ -8,14 +8,10 @@
#include <string>
#include <vector>
-#include "base/base64url.h"
#include "base/bind.h"
#include "base/check.h"
-#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_refptr.h"
-#include "base/strings/string_piece_forward.h"
-#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
@@ -46,24 +42,8 @@
#include "ui/shell_dialogs/select_file_dialog.h"
#include "url/gurl.h"
-const char kSupportCaseIDQuery[] = "case_id";
-const char kModuleQuery[] = "module";
-
-// TODO(b/226318326): Move the utility functions to support_tool_ui_utils.h and
-// add unit tests for them.
namespace {
-// Returns the support case ID that's extracted from `url` with query
-// `kSupportCaseIDQuery`. Returns empty string if `url` doesn't contain support
-// case ID.
-std::string GetSupportCaseIDFromURL(const GURL& url) {
- std::string support_case_id;
- if (url.has_query()) {
- net::GetValueForKeyInQuery(url, kSupportCaseIDQuery, &support_case_id);
- }
- return support_case_id;
-}
-
content::WebUIDataSource* CreateSupportToolHTMLSource(const GURL& url) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISupportToolHost);
@@ -80,241 +60,6 @@ content::WebUIDataSource* CreateSupportToolHTMLSource(const GURL& url) {
return source;
}
-// Returns the human readable name corresponding to `data_collector_type`.
-std::string GetDataCollectorName(
- support_tool::DataCollectorType data_collector_type) {
- // This function will return translatable strings in future. For now, return
- // string constants until we have the translatable strings ready.
- switch (data_collector_type) {
- case support_tool::CHROME_INTERNAL:
- return "Internal";
- case support_tool::CRASH_IDS:
- return "Crash IDs";
- case support_tool::MEMORY_DETAILS:
- return "Memory Details";
- case support_tool::CHROMEOS_UI_HIERARCHY:
- return "UI Hierarchy";
- case support_tool::CHROMEOS_COMMAND_LINE:
- return "Command Line";
- case support_tool::CHROMEOS_DEVICE_EVENT:
- return "Device Event";
- case support_tool::CHROMEOS_IWL_WIFI_DUMP:
- return "IWL WiFi Dump";
- case support_tool::CHROMEOS_TOUCH_EVENTS:
- return "Touch Events";
- case support_tool::CHROMEOS_CROS_API:
- return "CROS API";
- case support_tool::CHROMEOS_LACROS:
- return "Lacros";
- case support_tool::CHROMEOS_REVEN:
- return "Chrome OS Reven";
- case support_tool::CHROMEOS_DBUS:
- return "DBus Details";
- case support_tool::CHROMEOS_NETWORK_ROUTES:
- return "Chrome OS Network Routes";
- default:
- return "Error: Undefined";
- }
-}
-
-// Decodes `module_query` string and initializes contents of `module`.
-void InitDataCollectionModuleFromURLQuery(
- support_tool::DataCollectionModule* module,
- const std::string& module_query) {
- std::string query_decoded;
- if (!module_query.empty() &&
- base::Base64UrlDecode(module_query,
- base::Base64UrlDecodePolicy::IGNORE_PADDING,
- &query_decoded)) {
- module->ParseFromString(query_decoded);
- }
-}
-
-// Returns data collector item for `type`. Sets isIncluded field true if
-// `module` contains `type`.
-base::Value::Dict GetDataCollectorItemForType(
- const support_tool::DataCollectionModule& module,
- const support_tool::DataCollectorType& type) {
- base::Value::Dict dict;
- dict.Set("name", GetDataCollectorName(type));
- dict.Set("protoEnum", type);
- dict.Set("isIncluded",
- base::Contains(module.included_data_collectors(), type));
- return dict;
-}
-
-// Returns data collector item for `type`. Sets isIncluded to false for all data
-// collector items.
-base::Value::Dict GetDataCollectorItemForType(
- const support_tool::DataCollectorType& type) {
- base::Value::Dict dict;
- dict.Set("name", GetDataCollectorName(type));
- dict.Set("protoEnum", type);
- dict.Set("isIncluded", false);
- return dict;
-}
-
-// Creates base::Value::List according to the format Support Tool UI
-// accepts and fills the contents with by decoding `module_query` to its
-// support_tool.pb components. Support Tool UI requests data collector items in
-// format:
-// type DataCollectorItem = {
-// name: string,
-// isIncluded: boolean,
-// protoEnum: number,
-// }
-// Returns only the data collectors that are available for user's device.
-base::Value::List GetDataCollectorItemsInQuery(std::string module_query) {
- base::Value::List data_collector_list;
- support_tool::DataCollectionModule module;
- InitDataCollectionModuleFromURLQuery(&module, module_query);
- for (const auto& type : kDataCollectors) {
- data_collector_list.Append(GetDataCollectorItemForType(module, type));
- }
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- for (const auto& type : kDataCollectorsChromeosAsh) {
- data_collector_list.Append(GetDataCollectorItemForType(module, type));
- }
-#if BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
- for (const auto& type : kDataCollectorsChromeosHwDetails) {
- data_collector_list.Append(GetDataCollectorItemForType(module, type));
- }
-#endif // BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
-#endif // BUILDFLAG(IS_CHROMEOS_ASH)
- return data_collector_list;
-}
-
-// Creates base::Value::List according to the format Support Tool UI
-// accepts and fills the contents with all data collectors with isIncluded:
-// false as a default choice. Support Tool UI requests data collector items in
-// format:
-// type DataCollectorItem = {
-// name: string,
-// isIncluded: boolean,
-// protoEnum: number,
-// }
-base::Value::List GetAllDataCollectors() {
- base::Value::List data_collector_list;
- for (const auto& type : kDataCollectors) {
- data_collector_list.Append(GetDataCollectorItemForType(type));
- }
- for (const auto& type : kDataCollectorsChromeosAsh) {
- data_collector_list.Append(GetDataCollectorItemForType(type));
- }
- for (const auto& type : kDataCollectorsChromeosHwDetails) {
- data_collector_list.Append(GetDataCollectorItemForType(type));
- }
- return data_collector_list;
-}
-
-std::set<support_tool::DataCollectorType> GetIncludedDataCollectorTypes(
- const base::Value::List* data_collector_items) {
- std::set<support_tool::DataCollectorType> included_data_collectors;
- for (const auto& item : *data_collector_items) {
- const base::Value::Dict* item_as_dict = item.GetIfDict();
- DCHECK(item_as_dict);
- absl::optional<bool> isIncluded = item_as_dict->FindBool("isIncluded");
- if (isIncluded && isIncluded.value()) {
- included_data_collectors.insert(
- static_cast<support_tool::DataCollectorType>(
- item_as_dict->FindInt("protoEnum").value()));
- }
- }
- return included_data_collectors;
-}
-
-// Returns start data collection result in a structure that Support Tool UI
-// accepts. The returned type is as follow: type StartDataCollectionResult = {
-// success: boolean,
-// errorMessage: string,
-// }
-base::Value GetStartDataCollectionResult(bool success,
- std::string error_message) {
- base::Value::Dict result;
- result.Set("success", success);
- result.Set("errorMessage", error_message);
- return base::Value(std::move(result));
-}
-
-// Returns the current time in YYYY_MM_DD_HH_mm format.
-std::string GetTimestampString(base::Time timestamp) {
- base::Time::Exploded tex;
- timestamp.LocalExplode(&tex);
- return base::StringPrintf("%04d_%02d_%02d_%02d_%02d", tex.year, tex.month,
- tex.day_of_month, tex.hour, tex.minute);
-}
-
-base::FilePath GetDefaultFileToExport(base::FilePath suggested_path,
- const std::string& case_id,
- base::Time timestamp) {
- std::string timestamp_string = GetTimestampString(timestamp);
- std::string filename =
- case_id.empty()
- ? base::StringPrintf("support_packet_%s", timestamp_string.c_str())
- : base::StringPrintf("support_packet_%s_%s", case_id.c_str(),
- timestamp_string.c_str());
- return suggested_path.AppendASCII(filename);
-}
-
-std::string GetDataCollectionModuleQuery(
- std::set<support_tool::DataCollectorType> included_data_collectors) {
- support_tool::DataCollectionModule module;
- for (const auto& data_collector : included_data_collectors) {
- module.add_included_data_collectors(data_collector);
- }
- std::string module_serialized;
- module.SerializeToString(&module_serialized);
- std::string data_collection_url_query;
- base::Base64UrlEncode(module_serialized,
- base::Base64UrlEncodePolicy::OMIT_PADDING,
- &data_collection_url_query);
- return data_collection_url_query;
-}
-
-// Returns a URL generation result in the type Support Tool UI expects.
-// type UrlGenerationResult = {
-// success: boolean,
-// url: string,
-// errorMessage: string,
-// }
-base::Value::Dict GetURLGenerationResult(bool success,
- std::string url,
- std::string error_message) {
- base::Value::Dict url_generation_response;
- url_generation_response.Set("success", success);
- url_generation_response.Set("url", url);
- url_generation_response.Set("errorMessage", error_message);
- return url_generation_response;
-}
-
-// Generates a customized chrome://support-tool URL from given `case_id` and
-// `data_collector_items` and returns the result in a format Support Tool UI
-// expects. Returns a result with error when there's no data collector selected
-// in `data_collector_items`.
-base::Value::Dict GenerateCustomizedURL(
- std::string case_id,
- const base::Value::List* data_collector_items) {
- base::Value::Dict url_generation_response;
- std::set<support_tool::DataCollectorType> included_data_collectors =
- GetIncludedDataCollectorTypes(data_collector_items);
- if (included_data_collectors.empty()) {
- // If there's no selected data collector to add, consider this as an error.
- return GetURLGenerationResult(
- /*success=*/false, /*url=*/std::string(), /*error_message=*/
- "No data collectors included. Please select a data collector.");
- }
- GURL customized_url("chrome://support-tool");
- if (!case_id.empty()) {
- customized_url =
- net::AppendQueryParameter(customized_url, kSupportCaseIDQuery, case_id);
- }
- customized_url = net::AppendQueryParameter(
- customized_url, kModuleQuery,
- GetDataCollectionModuleQuery(included_data_collectors));
- return GetURLGenerationResult(/*success=*/true, /*url=*/customized_url.spec(),
- /*error_message=*/std::string());
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -432,7 +177,7 @@ base::Value::List SupportToolMessageHandler::GetAccountsList() {
for (const auto& account : signin_ui_util::GetOrderedAccountsForDisplay(
profile, /*restrict_to_accounts_eligible_for_sync=*/false)) {
if (!account.IsEmpty())
- account_list.Append(base::Value(account.email));
+ account_list.Append(account.email);
}
return account_list;
}
@@ -443,7 +188,7 @@ void SupportToolMessageHandler::HandleGetEmailAddresses(
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, base::Value(GetAccountsList()));
+ ResolveJavascriptCallback(callback_id, GetAccountsList());
}
void SupportToolMessageHandler::HandleGetDataCollectors(
@@ -453,11 +198,11 @@ void SupportToolMessageHandler::HandleGetDataCollectors(
const base::Value& callback_id = args[0];
std::string module_query;
- net::GetValueForKeyInQuery(web_ui()->GetWebContents()->GetURL(), kModuleQuery,
- &module_query);
+ net::GetValueForKeyInQuery(web_ui()->GetWebContents()->GetURL(),
+ support_tool_ui::kModuleQuery, &module_query);
- ResolveJavascriptCallback(
- callback_id, base::Value(GetDataCollectorItemsInQuery(module_query)));
+ ResolveJavascriptCallback(callback_id,
+ GetDataCollectorItemsInQuery(module_query));
}
void SupportToolMessageHandler::HandleGetAllDataCollectors(
@@ -465,7 +210,7 @@ void SupportToolMessageHandler::HandleGetAllDataCollectors(
AllowJavascript();
CHECK_EQ(1U, args.size());
const base::Value& callback_id = args[0];
- ResolveJavascriptCallback(callback_id, base::Value(GetAllDataCollectors()));
+ ResolveJavascriptCallback(callback_id, GetAllDataCollectors());
}
// Starts data collection with the issue details and selected set of data
@@ -509,7 +254,7 @@ void SupportToolMessageHandler::OnDataCollectionDone(
std::set<SupportToolError> errors) {
AllowJavascript();
FireWebUIListener("data-collection-completed",
- base::Value(GetDetectedPIIDataItems(detected_pii)));
+ GetDetectedPIIDataItems(detected_pii));
}
void SupportToolMessageHandler::HandleCancelDataCollection(
@@ -600,8 +345,7 @@ void SupportToolMessageHandler::OnDataExportDone(
data_export_result.Set("path", std::string());
data_export_result.Set("error", export_error->error_message);
}
- FireWebUIListener("data-export-completed",
- base::Value(std::move(data_export_result)));
+ FireWebUIListener("data-export-completed", data_export_result);
}
void SupportToolMessageHandler::HandleShowExportedDataInFolder(
@@ -616,8 +360,8 @@ void SupportToolMessageHandler::HandleGenerateCustomizedURL(
std::string case_id = args[1].GetString();
const base::Value::List* data_collectors = args[2].GetIfList();
DCHECK(data_collectors);
- ResolveJavascriptCallback(callback_id, base::Value(GenerateCustomizedURL(
- case_id, data_collectors)));
+ ResolveJavascriptCallback(callback_id,
+ GenerateCustomizedURL(case_id, data_collectors));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.cc b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.cc
index 5cb97526cf4..af488f7731d 100644
--- a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.cc
+++ b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.cc
@@ -9,13 +9,23 @@
#include <string>
#include <vector>
+#include "base/base64url.h"
#include "base/check.h"
+#include "base/containers/contains.h"
+#include "base/files/file_path.h"
#include "base/strings/string_piece_forward.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/time/time.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/support_tool/data_collection_module.pb.h"
#include "chrome/browser/support_tool/data_collector.h"
+#include "chrome/browser/support_tool/support_tool_util.h"
#include "components/feedback/pii_types.h"
+#include "net/base/url_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "url/gurl.h"
namespace support_tool_ui {
@@ -33,6 +43,7 @@ const char kWindowTitle[] = "Window Titles";
const char kURL[] = "URLs";
const char kSerial[] = "Device & Component Serial Numbers";
const char kRemovableStorage[] = "Removable Storage Names";
+const char kEAP[] = "EAP Network Authentication Information";
const char kPiiItemDescriptionKey[] = "piiTypeDescription";
const char kPiiItemDetectedDataKey[] = "detectedData";
@@ -40,6 +51,17 @@ const char kPiiItemPIITypeKey[] = "piiType";
const char kPiiItemCountKey[] = "count";
const char kPiiItemKeepKey[] = "keep";
+const char kSupportCaseIDQuery[] = "case_id";
+const char kModuleQuery[] = "module";
+
+const char kDataCollectorName[] = "name";
+const char kDataCollectorProtoEnum[] = "protoEnum";
+const char kDataCollectorIncluded[] = "isIncluded";
+
+const char kUrlGenerationResultSuccess[] = "success";
+const char kUrlGenerationResultUrl[] = "url";
+const char kUrlGenerationResultErrorMessage[] = "errorMessage";
+
} // namespace support_tool_ui
namespace {
@@ -82,6 +104,123 @@ std::string GetPIITypeDescription(feedback::PIIType type_enum) {
}
}
+// Returns the human readable name corresponding to `data_collector_type`.
+std::string GetDataCollectorName(
+ support_tool::DataCollectorType data_collector_type) {
+ // This function will return translatable strings in future. For now, return
+ // string constants until we have the translatable strings ready.
+ switch (data_collector_type) {
+ case support_tool::CHROME_INTERNAL:
+ return "Chrome System Information";
+ case support_tool::CRASH_IDS:
+ return "Crash IDs";
+ case support_tool::MEMORY_DETAILS:
+ return "Memory Details";
+ case support_tool::CHROMEOS_UI_HIERARCHY:
+ return "UI Hierarchy";
+ case support_tool::CHROMEOS_COMMAND_LINE:
+ return "Additional Chrome OS Platform Logs";
+ case support_tool::CHROMEOS_DEVICE_EVENT:
+ return "Device Event";
+ case support_tool::CHROMEOS_IWL_WIFI_DUMP:
+ return "Intel WiFi NICs Debug Dump";
+ case support_tool::CHROMEOS_TOUCH_EVENTS:
+ return "Touch Events";
+ case support_tool::CHROMEOS_CROS_API:
+ return "LaCrOS System Information";
+ case support_tool::CHROMEOS_LACROS:
+ return "LaCrOS";
+ case support_tool::CHROMEOS_REVEN:
+ return "Chrome OS Flex Logs";
+ case support_tool::CHROMEOS_DBUS:
+ return "DBus Details";
+ case support_tool::CHROMEOS_NETWORK_ROUTES:
+ return "Chrome OS Network Routes";
+ case support_tool::CHROMEOS_SHILL:
+ return "Chrome OS Shill (Connection Manager) Logs";
+ default:
+ return "Error: Undefined";
+ }
+}
+
+// Decodes `module_query` string and initializes contents of `module`.
+void InitDataCollectionModuleFromURLQuery(
+ support_tool::DataCollectionModule* module,
+ const std::string& module_query) {
+ std::string query_decoded;
+ if (!module_query.empty() &&
+ base::Base64UrlDecode(module_query,
+ base::Base64UrlDecodePolicy::IGNORE_PADDING,
+ &query_decoded)) {
+ module->ParseFromString(query_decoded);
+ }
+}
+
+// Returns data collector item for `type`. Sets isIncluded field true if
+// `module` contains `type`.
+base::Value::Dict GetDataCollectorItemForType(
+ const support_tool::DataCollectionModule& module,
+ const support_tool::DataCollectorType& type) {
+ base::Value::Dict dict;
+ dict.Set(support_tool_ui::kDataCollectorName, GetDataCollectorName(type));
+ dict.Set(support_tool_ui::kDataCollectorProtoEnum, type);
+ dict.Set(support_tool_ui::kDataCollectorIncluded,
+ base::Contains(module.included_data_collectors(), type));
+ return dict;
+}
+
+// Returns data collector item for `type`. Sets isIncluded to false for all data
+// collector items.
+base::Value::Dict GetDataCollectorItemForType(
+ const support_tool::DataCollectorType& type) {
+ base::Value::Dict dict;
+ dict.Set(support_tool_ui::kDataCollectorName, GetDataCollectorName(type));
+ dict.Set(support_tool_ui::kDataCollectorProtoEnum, type);
+ dict.Set(support_tool_ui::kDataCollectorIncluded, false);
+ return dict;
+}
+
+// Returns the current time in YYYY_MM_DD_HH_mm format.
+std::string GetTimestampString(base::Time timestamp) {
+ base::Time::Exploded tex;
+ timestamp.LocalExplode(&tex);
+ return base::StringPrintf("%04d_%02d_%02d_%02d_%02d", tex.year, tex.month,
+ tex.day_of_month, tex.hour, tex.minute);
+}
+
+std::string GetDataCollectionModuleQuery(
+ std::set<support_tool::DataCollectorType> included_data_collectors) {
+ support_tool::DataCollectionModule module;
+ for (const auto& data_collector : included_data_collectors) {
+ module.add_included_data_collectors(data_collector);
+ }
+ std::string module_serialized;
+ module.SerializeToString(&module_serialized);
+ std::string data_collection_url_query;
+ base::Base64UrlEncode(module_serialized,
+ base::Base64UrlEncodePolicy::OMIT_PADDING,
+ &data_collection_url_query);
+ return data_collection_url_query;
+}
+
+// Returns a URL generation result in the type Support Tool UI expects.
+// type UrlGenerationResult = {
+// success: boolean,
+// url: string,
+// errorMessage: string,
+// }
+base::Value::Dict GetURLGenerationResult(bool success,
+ std::string url,
+ std::string error_message) {
+ base::Value::Dict url_generation_response;
+ url_generation_response.Set(support_tool_ui::kUrlGenerationResultSuccess,
+ success);
+ url_generation_response.Set(support_tool_ui::kUrlGenerationResultUrl, url);
+ url_generation_response.Set(support_tool_ui::kUrlGenerationResultErrorMessage,
+ error_message);
+ return url_generation_response;
+}
+
} // namespace
// type PIIDataItem = {
@@ -111,8 +250,8 @@ base::Value::List GetDetectedPIIDataItems(const PIIMap& detected_pii) {
static_cast<int>(pii_entry.second.size()));
// TODO(b/200511640): Set `keep` field to the value we'll get from URL's
// pii_masking_on query if it exists.
- pii_data_item.Set(support_tool_ui::kPiiItemKeepKey, false);
- detected_pii_data_items.Append(base::Value(std::move(pii_data_item)));
+ pii_data_item.Set(support_tool_ui::kPiiItemKeepKey, true);
+ detected_pii_data_items.Append(std::move(pii_data_item));
}
return detected_pii_data_items;
}
@@ -132,3 +271,124 @@ std::set<feedback::PIIType> GetPIITypesToKeep(
}
return pii_to_keep;
}
+
+std::string GetSupportCaseIDFromURL(const GURL& url) {
+ std::string support_case_id;
+ if (url.has_query()) {
+ net::GetValueForKeyInQuery(url, support_tool_ui::kSupportCaseIDQuery,
+ &support_case_id);
+ }
+ return support_case_id;
+}
+
+base::Value::List GetDataCollectorItemsInQuery(std::string module_query) {
+ base::Value::List data_collector_list;
+ support_tool::DataCollectionModule module;
+ InitDataCollectionModuleFromURLQuery(&module, module_query);
+ for (const auto& type : kDataCollectors) {
+ data_collector_list.Append(GetDataCollectorItemForType(module, type));
+ }
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ for (const auto& type : kDataCollectorsChromeosAsh) {
+ data_collector_list.Append(GetDataCollectorItemForType(module, type));
+ }
+#if BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
+ for (const auto& type : kDataCollectorsChromeosHwDetails) {
+ data_collector_list.Append(GetDataCollectorItemForType(module, type));
+ }
+#endif // BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ return data_collector_list;
+}
+
+base::Value::List GetAllDataCollectors() {
+ base::Value::List data_collector_list;
+ for (const auto& type : kDataCollectors) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+ for (const auto& type : kDataCollectorsChromeosAsh) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+ for (const auto& type : kDataCollectorsChromeosHwDetails) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+ return data_collector_list;
+}
+
+base::Value::List GetAllDataCollectorsForDevice() {
+ base::Value::List data_collector_list;
+ for (const auto& type : kDataCollectors) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ for (const auto& type : kDataCollectorsChromeosAsh) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+#if BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
+ for (const auto& type : kDataCollectorsChromeosHwDetails) {
+ data_collector_list.Append(GetDataCollectorItemForType(type));
+ }
+#endif // BUILDFLAG(IS_CHROMEOS_WITH_HW_DETAILS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ return data_collector_list;
+}
+
+std::set<support_tool::DataCollectorType> GetIncludedDataCollectorTypes(
+ const base::Value::List* data_collector_items) {
+ std::set<support_tool::DataCollectorType> included_data_collectors;
+ for (const auto& item : *data_collector_items) {
+ const base::Value::Dict* item_as_dict = item.GetIfDict();
+ DCHECK(item_as_dict);
+ absl::optional<bool> isIncluded = item_as_dict->FindBool("isIncluded");
+ if (isIncluded && isIncluded.value()) {
+ included_data_collectors.insert(
+ static_cast<support_tool::DataCollectorType>(
+ item_as_dict->FindInt("protoEnum").value()));
+ }
+ }
+ return included_data_collectors;
+}
+
+base::Value::Dict GetStartDataCollectionResult(bool success,
+ std::string error_message) {
+ base::Value::Dict result;
+ result.Set("success", success);
+ result.Set("errorMessage", error_message);
+ return result;
+}
+
+base::FilePath GetDefaultFileToExport(base::FilePath suggested_path,
+ const std::string& case_id,
+ base::Time timestamp) {
+ std::string timestamp_string = GetTimestampString(timestamp);
+ std::string filename =
+ case_id.empty()
+ ? base::StringPrintf("support_packet_%s", timestamp_string.c_str())
+ : base::StringPrintf("support_packet_%s_%s", case_id.c_str(),
+ timestamp_string.c_str());
+ return suggested_path.AppendASCII(filename);
+}
+
+base::Value::Dict GenerateCustomizedURL(
+ std::string case_id,
+ const base::Value::List* data_collector_items) {
+ base::Value::Dict url_generation_response;
+ std::set<support_tool::DataCollectorType> included_data_collectors =
+ GetIncludedDataCollectorTypes(data_collector_items);
+ if (included_data_collectors.empty()) {
+ // If there's no selected data collector to add, consider this as an error.
+ return GetURLGenerationResult(
+ /*success=*/false, /*url=*/std::string(), /*error_message=*/
+ "No data collectors included. Please select a data collector.");
+ }
+ GURL customized_url("chrome://support-tool");
+ if (!case_id.empty()) {
+ customized_url = net::AppendQueryParameter(
+ customized_url, support_tool_ui::kSupportCaseIDQuery, case_id);
+ }
+ customized_url = net::AppendQueryParameter(
+ customized_url, support_tool_ui::kModuleQuery,
+ GetDataCollectionModuleQuery(included_data_collectors));
+ return GetURLGenerationResult(/*success=*/true, /*url=*/customized_url.spec(),
+ /*error_message=*/std::string());
+}
diff --git a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h
index b9bc8359adf..d1fbbbac51a 100644
--- a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h
+++ b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils.h
@@ -7,9 +7,12 @@
#include <set>
+#include "base/time/time.h"
#include "base/values.h"
+#include "chrome/browser/support_tool/data_collection_module.pb.h"
#include "chrome/browser/support_tool/data_collector.h"
#include "components/feedback/pii_types.h"
+#include "url/gurl.h"
namespace support_tool_ui {
@@ -28,6 +31,7 @@ extern const char kWindowTitle[];
extern const char kURL[];
extern const char kSerial[];
extern const char kRemovableStorage[];
+extern const char kEAP[];
// String keys of the fields of PIIDataItem dictionary that Support Tool UI
// stores the detected PII to display it to user.
@@ -37,6 +41,19 @@ extern const char kPiiItemDetectedDataKey[];
extern const char kPiiItemCountKey[];
extern const char kPiiItemKeepKey[];
+// Support Tool URL query fields.
+extern const char kModuleQuery[];
+
+// String keys that Support Tool UI uses to store data collector items in
+// dictionary.
+extern const char kDataCollectorIncluded[];
+extern const char kDataCollectorProtoEnum[];
+
+// String keys of URL generation result that Support Tool UI accepts.
+extern const char kUrlGenerationResultSuccess[];
+extern const char kUrlGenerationResultUrl[];
+extern const char kUrlGenerationResultErrorMessage[];
+
} // namespace support_tool_ui
// Returns PIIDataItems in `detected_pii` where PIIDataItem is
@@ -53,4 +70,61 @@ base::Value::List GetDetectedPIIDataItems(const PIIMap& detected_pii);
std::set<feedback::PIIType> GetPIITypesToKeep(
const base::Value::List* pii_items);
+// Returns the support case ID that's extracted from `url` with query
+// `kSupportCaseIDQuery`. Returns empty string if `url` doesn't contain support
+// case ID.
+std::string GetSupportCaseIDFromURL(const GURL& url);
+
+// Creates base::Value::List according to the format Support Tool UI
+// accepts and fills the contents with by decoding `module_query` to its
+// support_tool.pb components. Support Tool UI requests data collector items in
+// format:
+// type DataCollectorItem = {
+// name: string,
+// isIncluded: boolean,
+// protoEnum: number,
+// }
+// Returns only the data collectors that are available for user's device.
+base::Value::List GetDataCollectorItemsInQuery(std::string module_query);
+
+// Creates base::Value::List according to the format Support Tool UI
+// accepts and fills the contents with all data collectors with isIncluded:
+// false as a default choice. Support Tool UI requests data collector items in
+// format:
+// type DataCollectorItem = {
+// name: string,
+// isIncluded: boolean,
+// protoEnum: number,
+// }
+base::Value::List GetAllDataCollectors();
+
+// Creates base::Value::List according to the format Support Tool UI
+// accepts and fills the contents with all data collectors with isIncluded:
+// false as a default choice. Only return data collectors available for caller's
+// platform.
+base::Value::List GetAllDataCollectorsForDevice();
+
+std::set<support_tool::DataCollectorType> GetIncludedDataCollectorTypes(
+ const base::Value::List* data_collector_items);
+
+// Returns start data collection result in a structure that Support Tool UI
+// accepts. The returned type is as follow: type StartDataCollectionResult = {
+// success: boolean,
+// errorMessage: string,
+// }
+base::Value::Dict GetStartDataCollectionResult(bool success,
+ std::string error_message);
+
+base::FilePath GetDefaultFileToExport(base::FilePath suggested_path,
+ const std::string& case_id,
+ base::Time timestamp);
+
+// Generates a customized chrome://support-tool URL from given `case_id` and
+// `data_collector_items` and returns the result in a format Support Tool UI
+// expects. Returns a result with error when there's no data collector selected
+// in `data_collector_items`.
+base::Value::Dict GenerateCustomizedURL(
+ std::string case_id,
+ const base::Value::List* data_collector_items);
+
#endif // CHROME_BROWSER_UI_WEBUI_SUPPORT_TOOL_SUPPORT_TOOL_UI_UTILS_H_
diff --git a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils_unittest.cc b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils_unittest.cc
index 682d862c413..ecdd6dde3e7 100644
--- a/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/support_tool/support_tool_ui_utils_unittest.cc
@@ -7,15 +7,22 @@
#include <set>
#include <string>
+#include "base/containers/contains.h"
#include "base/containers/fixed_flat_map.h"
#include "base/strings/string_piece_forward.h"
#include "base/values.h"
+#include "chrome/browser/support_tool/data_collection_module.pb.h"
#include "chrome/browser/support_tool/data_collector.h"
#include "components/feedback/pii_types.h"
+#include "net/base/url_util.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
+using ::testing::ContainerEq;
+using ::testing::IsEmpty;
+using ::testing::Not;
using ::testing::StrEq;
using ::testing::UnorderedElementsAreArray;
@@ -53,6 +60,24 @@ class SupportToolUiUtilsTest : public ::testing::Test {
SupportToolUiUtilsTest(const SupportToolUiUtilsTest&) = delete;
SupportToolUiUtilsTest& operator=(const SupportToolUiUtilsTest&) = delete;
+
+ // Change included field of `included_data_collectors` in `data_collectors` as
+ // true for testing.
+ void MarkDataCollectorsAsIncluded(
+ base::Value::List& data_collectors,
+ const std::set<support_tool::DataCollectorType>&
+ included_data_collectors) {
+ for (auto& data_collector : data_collectors) {
+ base::Value::Dict& data_collector_item = data_collector.GetDict();
+ absl::optional<int> data_collector_enum =
+ data_collector_item.FindInt(support_tool_ui::kDataCollectorProtoEnum);
+ ASSERT_TRUE(data_collector_enum);
+ if (base::Contains(included_data_collectors,
+ static_cast<support_tool::DataCollectorType>(
+ data_collector_enum.value())))
+ data_collector_item.Set(support_tool_ui::kDataCollectorIncluded, true);
+ }
+ }
};
TEST_F(SupportToolUiUtilsTest, PiiItems) {
@@ -91,3 +116,63 @@ TEST_F(SupportToolUiUtilsTest, PiiItems) {
// Check if the returned PII type set is as expected.
EXPECT_THAT(pii_to_keep_result, UnorderedElementsAreArray(kPIITypes));
}
+
+TEST_F(SupportToolUiUtilsTest, CustomizedUrl) {
+ const std::string test_case_id = "test_case_id_0";
+ // Get list of all data collectors.
+ base::Value::List expected_data_collectors = GetAllDataCollectorsForDevice();
+ std::set<support_tool::DataCollectorType> included_data_collectors = {
+ support_tool::DataCollectorType::CHROME_INTERNAL,
+ support_tool::DataCollectorType::CRASH_IDS};
+ MarkDataCollectorsAsIncluded(expected_data_collectors,
+ included_data_collectors);
+ base::Value::Dict url_generation_result =
+ GenerateCustomizedURL(test_case_id, &expected_data_collectors);
+ // The result must be successful.
+ EXPECT_TRUE(url_generation_result
+ .FindBool(support_tool_ui::kUrlGenerationResultSuccess)
+ .value());
+ // Error string must be empty.
+ EXPECT_EQ(*url_generation_result.FindString(
+ support_tool_ui::kUrlGenerationResultErrorMessage),
+ std::string());
+ const std::string* url_output = url_generation_result.FindString(
+ support_tool_ui::kUrlGenerationResultUrl);
+ ASSERT_TRUE(url_output);
+ // URL output shouldn't be empty.
+ EXPECT_THAT(*url_output, Not(IsEmpty()));
+ // Check that case ID in the URL is as expected.
+ EXPECT_EQ(GetSupportCaseIDFromURL(GURL(*url_output)), test_case_id);
+ // Get the data collector module from URL.
+ std::string data_collector_module;
+ net::GetValueForKeyInQuery(GURL(*url_output), support_tool_ui::kModuleQuery,
+ &data_collector_module);
+ EXPECT_THAT(data_collector_module, Not(IsEmpty()));
+ base::Value::List data_collector_items_result =
+ GetDataCollectorItemsInQuery(data_collector_module);
+ // Check that the output data collector list is equal to expected.
+ EXPECT_EQ(data_collector_items_result.size(),
+ expected_data_collectors.size());
+ for (size_t i = 0; i < data_collector_items_result.size(); i++) {
+ const base::Value::Dict& actual_data_collector_item =
+ data_collector_items_result[i].GetDict();
+ const base::Value::Dict& extected_data_collector_item =
+ expected_data_collectors[i].GetDict();
+ EXPECT_EQ(actual_data_collector_item
+ .FindInt(support_tool_ui::kDataCollectorProtoEnum)
+ .value(),
+ extected_data_collector_item
+ .FindInt(support_tool_ui::kDataCollectorProtoEnum)
+ .value());
+ EXPECT_EQ(actual_data_collector_item
+ .FindBool(support_tool_ui::kDataCollectorIncluded)
+ .value(),
+ extected_data_collector_item
+ .FindBool(support_tool_ui::kDataCollectorIncluded)
+ .value());
+ }
+ // Check if the output of GetIncludedDataCollectorTypes is equal to expected
+ // set of included data collectors.
+ EXPECT_THAT(GetIncludedDataCollectorTypes(&data_collector_items_result),
+ ContainerEq(included_data_collectors));
+}
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
index 44b93f0c6c1..31f10b952e7 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc
@@ -35,17 +35,17 @@ namespace {
// ExtensionStatusesHandler and FileMetadataHandler.
void ConvertExtensionStatusToDictionary(
const base::WeakPtr<extensions::ExtensionService>& extension_service,
- base::OnceCallback<void(const base::ListValue&)> callback,
+ base::OnceCallback<void(const base::Value::List)> callback,
const std::map<GURL, std::string>& status_map) {
if (!extension_service) {
- std::move(callback).Run(base::ListValue());
+ std::move(callback).Run(base::Value::List());
return;
}
extensions::ExtensionRegistry* extension_registry =
extensions::ExtensionRegistry::Get(extension_service->profile());
- base::ListValue list;
+ base::Value::List list;
for (auto itr = status_map.begin(); itr != status_map.end(); ++itr) {
std::string extension_id = itr->first.HostNoBrackets();
@@ -60,10 +60,10 @@ void ConvertExtensionStatusToDictionary(
dict.Set("extensionID", extension_id);
dict.Set("extensionName", extension->name());
dict.Set("status", itr->second);
- list.GetList().Append(std::move(dict));
+ list.Append(std::move(dict));
}
- std::move(callback).Run(list);
+ std::move(callback).Run(std::move(list));
}
} // namespace
@@ -74,7 +74,7 @@ ExtensionStatusesHandler::ExtensionStatusesHandler(Profile* profile)
ExtensionStatusesHandler::~ExtensionStatusesHandler() {}
void ExtensionStatusesHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getExtensionStatuses",
base::BindRepeating(&ExtensionStatusesHandler::HandleGetExtensionStatuses,
base::Unretained(this)));
@@ -83,20 +83,20 @@ void ExtensionStatusesHandler::RegisterMessages() {
// static
void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary(
Profile* profile,
- base::OnceCallback<void(const base::ListValue&)> callback) {
+ base::OnceCallback<void(const base::Value::List)> callback) {
DCHECK(profile);
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile);
if (!sync_service) {
- std::move(callback).Run(base::ListValue());
+ std::move(callback).Run(base::Value::List());
return;
}
extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
- std::move(callback).Run(base::ListValue());
+ std::move(callback).Run(base::Value::List());
return;
}
@@ -106,20 +106,17 @@ void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary(
}
void ExtensionStatusesHandler::HandleGetExtensionStatuses(
- const base::ListValue* args) {
+ const base::Value::List& args) {
AllowJavascript();
- DCHECK(args);
GetExtensionStatusesAsDictionary(
profile_,
- base::BindOnce(
- &ExtensionStatusesHandler::DidGetExtensionStatuses,
- weak_ptr_factory_.GetWeakPtr(),
- args->GetListDeprecated()[0].GetString() /* callback_id */));
+ base::BindOnce(&ExtensionStatusesHandler::DidGetExtensionStatuses,
+ weak_ptr_factory_.GetWeakPtr(),
+ args[0].GetString() /* callback_id */));
}
-void ExtensionStatusesHandler::DidGetExtensionStatuses(
- std::string callback_id,
- const base::ListValue& list) {
+void ExtensionStatusesHandler::DidGetExtensionStatuses(std::string callback_id,
+ base::Value::List list) {
ResolveJavascriptCallback(base::Value(callback_id), list);
}
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h
index 13e57b9f6f8..074654347f9 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h
@@ -30,15 +30,15 @@ class ExtensionStatusesHandler : public content::WebUIMessageHandler {
// extension drop down.
static void GetExtensionStatusesAsDictionary(
Profile* profile,
- base::OnceCallback<void(const base::ListValue&)> callback);
+ base::OnceCallback<void(const base::Value::List)> callback);
// WebUIMessageHandler implementation.
void RegisterMessages() override;
private:
- void HandleGetExtensionStatuses(const base::ListValue* args);
+ void HandleGetExtensionStatuses(const base::Value::List& args);
void DidGetExtensionStatuses(std::string callback_id,
- const base::ListValue& list);
+ const base::Value::List list);
raw_ptr<Profile> profile_;
base::WeakPtrFactory<ExtensionStatusesHandler> weak_ptr_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc
index 8b993ed96ab..60fe6bd323c 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc
@@ -33,20 +33,20 @@ FileMetadataHandler::FileMetadataHandler(Profile* profile)
FileMetadataHandler::~FileMetadataHandler() {}
void FileMetadataHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getExtensions",
base::BindRepeating(&FileMetadataHandler::HandleGetExtensions,
base::Unretained(this)));
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"getFileMetadata",
base::BindRepeating(&FileMetadataHandler::HandleGetFileMetadata,
base::Unretained(this)));
}
-void FileMetadataHandler::HandleGetFileMetadata(const base::ListValue* args) {
+void FileMetadataHandler::HandleGetFileMetadata(const base::Value::List& args) {
AllowJavascript();
- std::string callback_id = args->GetListDeprecated()[0].GetString();
- std::string extension_id = args->GetListDeprecated()[1].GetString();
+ std::string callback_id = args[0].GetString();
+ std::string extension_id = args[1].GetString();
if (extension_id.empty()) {
LOG(WARNING) << "GetFileMetadata() Extension ID wasn't given";
return;
@@ -76,18 +76,16 @@ void FileMetadataHandler::HandleGetFileMetadata(const base::ListValue* args) {
weak_factory_.GetWeakPtr(), callback_id));
}
-void FileMetadataHandler::HandleGetExtensions(const base::ListValue* args) {
+void FileMetadataHandler::HandleGetExtensions(const base::Value::List& args) {
AllowJavascript();
- DCHECK(args);
ExtensionStatusesHandler::GetExtensionStatusesAsDictionary(
- profile_,
- base::BindOnce(
- &FileMetadataHandler::DidGetExtensions, weak_factory_.GetWeakPtr(),
- args->GetListDeprecated()[0].GetString() /* callback_id */));
+ profile_, base::BindOnce(&FileMetadataHandler::DidGetExtensions,
+ weak_factory_.GetWeakPtr(),
+ args[0].GetString() /* callback_id */));
}
void FileMetadataHandler::DidGetExtensions(std::string callback_id,
- const base::ListValue& list) {
+ base::Value::List list) {
ResolveJavascriptCallback(base::Value(callback_id), list);
}
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h
index cd4632ee407..7ce55ade92c 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h
@@ -34,10 +34,10 @@ class FileMetadataHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void HandleGetExtensions(const base::ListValue* args);
- void DidGetExtensions(std::string callback_id, const base::ListValue& list);
+ void HandleGetExtensions(const base::Value::List& args);
+ void DidGetExtensions(std::string callback_id, base::Value::List list);
- void HandleGetFileMetadata(const base::ListValue* args);
+ void HandleGetFileMetadata(const base::Value::List& args);
void DidGetFileMetadata(std::string callback_id,
const base::ListValue& files);
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
index 905705cae81..34e39f6fc90 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc
@@ -105,17 +105,17 @@ void SyncFileSystemInternalsHandler::OnFileSynced(
void SyncFileSystemInternalsHandler::OnLogRecorded(
const sync_file_system::TaskLogger::TaskLog& task_log) {
- base::DictionaryValue dict;
+ base::Value::Dict dict;
int64_t duration = (task_log.end_time - task_log.start_time).InMilliseconds();
- dict.SetIntKey("duration", duration);
- dict.SetStringKey("task_description", task_log.task_description);
- dict.SetStringKey("result_description", task_log.result_description);
+ dict.Set("duration", static_cast<int>(duration));
+ dict.Set("task_description", task_log.task_description);
+ dict.Set("result_description", task_log.result_description);
- base::ListValue details;
+ base::Value::List details;
for (const std::string& detail : task_log.details) {
details.Append(detail);
}
- dict.SetKey("details", std::move(details));
+ dict.Set("details", std::move(details));
FireWebUIListener("task-log-recorded", dict);
}
@@ -159,20 +159,20 @@ void SyncFileSystemInternalsHandler::HandleGetLog(
last_log_id_sent = args[1].GetInt();
// Collate events which haven't been sent to WebUI yet.
- base::Value list(base::Value::Type::LIST);
- for (auto log_entry = log.begin(); log_entry != log.end(); ++log_entry) {
- if (log_entry->id <= last_log_id_sent)
+ base::Value::List list;
+ for (const auto& entry : log) {
+ if (entry.id <= last_log_id_sent)
continue;
- base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetIntKey("id", log_entry->id);
- dict.SetStringKey("time", google_apis::util::FormatTimeAsStringLocaltime(
- log_entry->when));
- dict.SetStringKey("logEvent", log_entry->what);
+ base::Value::Dict dict;
+ dict.Set("id", entry.id);
+ dict.Set("time",
+ google_apis::util::FormatTimeAsStringLocaltime(entry.when));
+ dict.Set("logEvent", entry.what);
list.Append(std::move(dict));
- last_log_id_sent = log_entry->id;
+ last_log_id_sent = entry.id;
}
- if (list.GetListDeprecated().empty())
+ if (list.empty())
return;
ResolveJavascriptCallback(callback_id, list);
diff --git a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js
index 77d0465da4f..ef6f5d08630 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js
@@ -48,7 +48,7 @@ SyncInternalsWebUITest.prototype = {
}
}
return false;
- }
+ },
};
/**
@@ -90,7 +90,7 @@ const HARD_CODED_ALL_NODES = [{
'UNIQUE_POSITION': 'INVALID[]',
'UNIQUE_SERVER_TAG': 'google_chrome_autofill',
'isDirty': false,
- 'modelType': 'Autofill'
+ 'modelType': 'Autofill',
},
{
'ATTACHMENT_METADATA': '',
@@ -120,8 +120,8 @@ const HARD_CODED_ALL_NODES = [{
'autofill': {
'name': 'Email',
'usage_timestamp': ['13038713887000000', '13038713890000000'],
- 'value': 'rlsynctet2'
- }
+ 'value': 'rlsynctet2',
+ },
},
'SERVER_UNIQUE_POSITION': 'INVALID[]',
'SERVER_VERSION': '1394241139528639',
@@ -129,8 +129,8 @@ const HARD_CODED_ALL_NODES = [{
'autofill': {
'name': 'Email',
'usage_timestamp': ['13038713887000000', '13038713890000000'],
- 'value': 'rlsynctet2'
- }
+ 'value': 'rlsynctet2',
+ },
},
'SYNCING': false,
'TRANSACTION_VERSION': '1',
@@ -139,10 +139,10 @@ const HARD_CODED_ALL_NODES = [{
'UNIQUE_POSITION': 'INVALID[]',
'UNIQUE_SERVER_TAG': '',
'isDirty': false,
- 'modelType': 'Autofill'
- }
+ 'modelType': 'Autofill',
+ },
],
- 'type': 'Autofill'
+ 'type': 'Autofill',
}];
/**
@@ -154,23 +154,23 @@ const HARD_CODED_ABOUT_INFO = {
{
'stat_status': 'uninitialized',
'stat_name': 'Error Type',
- 'stat_value': 'Uninitialized'
+ 'stat_value': 'Uninitialized',
},
{
'stat_status': 'uninitialized',
'stat_name': 'Action',
- 'stat_value': 'Uninitialized'
+ 'stat_value': 'Uninitialized',
},
{
'stat_status': 'uninitialized',
'stat_name': 'URL',
- 'stat_value': 'Uninitialized'
+ 'stat_value': 'Uninitialized',
},
{
'stat_status': 'uninitialized',
'stat_name': 'Error Description',
- 'stat_value': 'Uninitialized'
- }
+ 'stat_value': 'Uninitialized',
+ },
],
'actionable_error_detected': false,
'details': [
@@ -178,10 +178,10 @@ const HARD_CODED_ABOUT_INFO = {
'data': [{
'stat_status': '',
'stat_name': 'Summary',
- 'stat_value': 'Sync service initialized'
+ 'stat_value': 'Sync service initialized',
}],
'is_sensitive': false,
- 'title': 'Summary'
+ 'title': 'Summary',
},
],
'type_status': [
@@ -202,7 +202,7 @@ const HARD_CODED_ABOUT_INFO = {
'state': 'Running',
},
],
- 'unrecoverable_error_detected': false
+ 'unrecoverable_error_detected': false,
};
NETWORK_EVENT_DETAILS_1 = {
@@ -315,12 +315,16 @@ TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect',
toString: function() {
return 'node 1';
},
- }
+ },
]);
// Select the first list item and verify the search tab remains selected.
- document.querySelector('#sync-results-list').getListItemByIndex(0).selected =
- true;
+ const firstItem =
+ document.querySelector('#sync-results-list').querySelector('li');
+ assertFalse(firstItem.hasAttribute('selected'));
+ firstItem.click();
+ // Verify that this selected the item.
+ assertTrue(firstItem.hasAttribute('selected'));
assertTrue(searchTab.hasAttribute('selected'));
});
@@ -344,8 +348,8 @@ TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
// Check the type root and expand it.
const typeRoot = tree.items[0];
- assertFalse(typeRoot.expanded);
- typeRoot.expanded = true;
+ assertFalse(typeRoot.hasAttribute('expanded'));
+ typeRoot.toggleAttribute('expanded', true);
assertEquals(1, typeRoot.items.length);
// An actual sync node. The child of the type root.
@@ -353,7 +357,8 @@ TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
// Verify that selecting it affects the details view.
assertTrue(document.querySelector('#node-details').hasAttribute('hidden'));
- leaf.selected = true;
+ tree.selectedItem = leaf;
+ assertTrue(leaf.hasAttribute('selected'));
assertFalse(document.querySelector('#node-details').hasAttribute('hidden'));
});
diff --git a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
index 9a3d27a3365..928a174ed2c 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
@@ -180,13 +180,13 @@ void SyncInternalsMessageHandler::HandleRequestListOfTypes(
DCHECK(args.empty());
AllowJavascript();
- DictionaryValue event_details;
- base::Value type_list(base::Value::Type::LIST);
+ base::Value::Dict event_details;
+ base::Value::List type_list;
syncer::ModelTypeSet protocol_types = syncer::ProtocolTypes();
for (syncer::ModelType type : protocol_types) {
type_list.Append(ModelTypeToDebugString(type));
}
- event_details.SetKey(syncer::sync_ui_util::kTypes, std::move(type_list));
+ event_details.Set(syncer::sync_ui_util::kTypes, std::move(type_list));
FireWebUIListener(syncer::sync_ui_util::kOnReceivedListOfTypes,
event_details);
}
@@ -196,9 +196,9 @@ void SyncInternalsMessageHandler::HandleRequestIncludeSpecificsInitialState(
DCHECK(args.empty());
AllowJavascript();
- DictionaryValue value;
- value.SetBoolKey(syncer::sync_ui_util::kIncludeSpecifics,
- GetIncludeSpecificsInitialState());
+ base::Value::Dict value;
+ value.Set(syncer::sync_ui_util::kIncludeSpecifics,
+ GetIncludeSpecificsInitialState());
FireWebUIListener(
syncer::sync_ui_util::kOnReceivedIncludeSpecificsInitialState, value);
@@ -308,8 +308,8 @@ void SyncInternalsMessageHandler::HandleTriggerRefresh(
void SyncInternalsMessageHandler::OnReceivedAllNodes(
const std::string& callback_id,
- std::unique_ptr<base::ListValue> nodes) {
- ResolveJavascriptCallback(base::Value(callback_id), *nodes);
+ base::Value::List nodes) {
+ ResolveJavascriptCallback(base::Value(callback_id), nodes);
}
void SyncInternalsMessageHandler::OnStateChanged(SyncService* sync) {
@@ -318,8 +318,8 @@ void SyncInternalsMessageHandler::OnStateChanged(SyncService* sync) {
void SyncInternalsMessageHandler::OnProtocolEvent(
const syncer::ProtocolEvent& event) {
- std::unique_ptr<DictionaryValue> value(event.ToValue(include_specifics_));
- FireWebUIListener(syncer::sync_ui_util::kOnProtocolEvent, *value);
+ FireWebUIListener(syncer::sync_ui_util::kOnProtocolEvent,
+ event.ToValue(include_specifics_));
}
void SyncInternalsMessageHandler::OnInvalidationReceived(
@@ -329,7 +329,7 @@ void SyncInternalsMessageHandler::OnInvalidationReceived(
return;
}
- base::Value data_types_list(base::Value::Type::LIST);
+ base::Value::List data_types_list;
for (const auto& data_type_invalidation :
payload_message.data_type_invalidations()) {
const int field_number = data_type_invalidation.data_type_id();
@@ -345,10 +345,10 @@ void SyncInternalsMessageHandler::OnInvalidationReceived(
}
void SyncInternalsMessageHandler::SendAboutInfoAndEntityCounts() {
- std::unique_ptr<DictionaryValue> value = about_sync_data_delegate_.Run(
+ base::Value::Dict value = about_sync_data_delegate_.Run(
GetSyncService(),
chrome::GetChannelName(chrome::WithExtendedStable(true)));
- FireWebUIListener(syncer::sync_ui_util::kOnAboutInfoUpdated, *value);
+ FireWebUIListener(syncer::sync_ui_util::kOnAboutInfoUpdated, value);
if (SyncService* service = GetSyncService()) {
service->GetEntityCountsForDebugging(
@@ -361,23 +361,21 @@ void SyncInternalsMessageHandler::SendAboutInfoAndEntityCounts() {
void SyncInternalsMessageHandler::OnGotEntityCounts(
const std::vector<syncer::TypeEntitiesCount>& entity_counts) {
- base::Value count_list(base::Value::Type::LIST);
+ base::Value::List count_list;
for (const syncer::TypeEntitiesCount& count : entity_counts) {
- DictionaryValue count_dictionary;
- count_dictionary.SetStringPath(syncer::sync_ui_util::kModelType,
- ModelTypeToDebugString(count.type));
- count_dictionary.SetIntPath(syncer::sync_ui_util::kEntities,
- count.entities);
- count_dictionary.SetIntPath(syncer::sync_ui_util::kNonTombstoneEntities,
- count.non_tombstone_entities);
+ base::Value::Dict count_dictionary;
+ count_dictionary.Set(syncer::sync_ui_util::kModelType,
+ ModelTypeToDebugString(count.type));
+ count_dictionary.Set(syncer::sync_ui_util::kEntities, count.entities);
+ count_dictionary.Set(syncer::sync_ui_util::kNonTombstoneEntities,
+ count.non_tombstone_entities);
count_list.Append(std::move(count_dictionary));
}
- DictionaryValue event_details;
- event_details.SetKey(syncer::sync_ui_util::kEntityCounts,
- std::move(count_list));
+ base::Value::Dict event_details;
+ event_details.Set(syncer::sync_ui_util::kEntityCounts, std::move(count_list));
FireWebUIListener(syncer::sync_ui_util::kOnEntityCountsUpdated,
- std::move(event_details));
+ event_details);
}
SyncService* SyncInternalsMessageHandler::GetSyncService() {
diff --git a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h
index a80070918c3..d2c8e7879d5 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h
@@ -73,7 +73,7 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
// Callback used in GetAllNodes.
void OnReceivedAllNodes(const std::string& callback_id,
- std::unique_ptr<base::ListValue> nodes);
+ base::Value::List nodes);
// syncer::SyncServiceObserver implementation.
void OnStateChanged(syncer::SyncService* sync) override;
@@ -86,9 +86,8 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
protected:
using AboutSyncDataDelegate =
- base::RepeatingCallback<std::unique_ptr<base::DictionaryValue>(
- syncer::SyncService* service,
- const std::string& channel)>;
+ base::RepeatingCallback<base::Value::Dict(syncer::SyncService* service,
+ const std::string& channel)>;
// Constructor used for unit testing to override dependencies.
explicit SyncInternalsMessageHandler(
diff --git a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc
index 7f1a7a09f80..8f728a7a96d 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc
@@ -53,8 +53,7 @@ class TestSyncService : public syncer::FakeSyncService {
}
void GetAllNodesForDebugging(
- base::OnceCallback<void(std::unique_ptr<base::ListValue>)> callback)
- override {
+ base::OnceCallback<void(base::Value::List)> callback) override {
get_all_nodes_callback_ = std::move(callback);
}
@@ -67,16 +66,14 @@ class TestSyncService : public syncer::FakeSyncService {
int add_observer_count() const { return add_observer_count_; }
int remove_observer_count() const { return remove_observer_count_; }
- base::OnceCallback<void(std::unique_ptr<base::ListValue>)>
- get_all_nodes_callback() {
+ base::OnceCallback<void(base::Value::List)> get_all_nodes_callback() {
return std::move(get_all_nodes_callback_);
}
private:
int add_observer_count_ = 0;
int remove_observer_count_ = 0;
- base::OnceCallback<void(std::unique_ptr<base::ListValue>)>
- get_all_nodes_callback_;
+ base::OnceCallback<void(base::Value::List)> get_all_nodes_callback_;
};
static std::unique_ptr<KeyedService> BuildTestSyncService(
@@ -103,7 +100,7 @@ class SyncInternalsMessageHandlerTest : public ChromeRenderViewHostTestHarness {
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
- about_information_.SetStringKey("some_sync_state", "some_value");
+ about_information_.Set("some_sync_state", "some_value");
web_ui_.set_web_contents(web_contents());
test_sync_service_ = static_cast<TestSyncService*>(
@@ -127,13 +124,11 @@ class SyncInternalsMessageHandlerTest : public ChromeRenderViewHostTestHarness {
}
// Returns copies of the same constant dictionary, |about_information_|.
- std::unique_ptr<DictionaryValue> ConstructFakeAboutInformation(
- SyncService* service,
- const std::string& channel) {
+ base::Value::Dict ConstructFakeAboutInformation(SyncService* service,
+ const std::string& channel) {
++about_sync_data_delegate_call_count_;
last_delegate_sync_service_ = service;
- return base::DictionaryValue::From(
- base::Value::ToUniquePtrValue(about_information_.Clone()));
+ return about_information_.Clone();
}
void ValidateAboutInfoCall() {
@@ -200,7 +195,7 @@ class SyncInternalsMessageHandlerTest : public ChromeRenderViewHostTestHarness {
int about_sync_data_delegate_call_count_ = 0;
raw_ptr<SyncService> last_delegate_sync_service_ = nullptr;
// Fake return value for sync_ui_util::ConstructAboutInformation().
- base::DictionaryValue about_information_;
+ base::Value::Dict about_information_;
};
TEST_F(SyncInternalsMessageHandlerTest, AddRemoveObservers) {
@@ -244,28 +239,25 @@ TEST_F(SyncInternalsMessageHandlerTest, AddRemoveObserversSyncDisabled) {
}
TEST_F(SyncInternalsMessageHandlerTest, HandleGetAllNodes) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("getAllNodes_0");
- handler()->HandleGetAllNodes(args.GetList());
- test_sync_service()->get_all_nodes_callback().Run(
- std::make_unique<base::ListValue>());
+ handler()->HandleGetAllNodes(args);
+ test_sync_service()->get_all_nodes_callback().Run(base::Value::List());
EXPECT_EQ(1, CallCountWithName("cr.webUIResponse"));
- base::Value args2(base::Value::Type::LIST);
+ base::Value::List args2;
args2.Append("getAllNodes_1");
- handler()->HandleGetAllNodes(args2.GetList());
+ handler()->HandleGetAllNodes(args2);
// This breaks the weak ref the callback is hanging onto. Which results in
// the call count not incrementing.
handler()->DisallowJavascript();
- test_sync_service()->get_all_nodes_callback().Run(
- std::make_unique<base::ListValue>());
+ test_sync_service()->get_all_nodes_callback().Run(base::Value::List());
EXPECT_EQ(1, CallCountWithName("cr.webUIResponse"));
- base::Value args3(base::Value::Type::LIST);
+ base::Value::List args3;
args3.Append("getAllNodes_2");
- handler()->HandleGetAllNodes(args3.GetList());
- test_sync_service()->get_all_nodes_callback().Run(
- std::make_unique<base::ListValue>());
+ handler()->HandleGetAllNodes(args3);
+ test_sync_service()->get_all_nodes_callback().Run(base::Value::List());
EXPECT_EQ(2, CallCountWithName("cr.webUIResponse"));
}
@@ -290,10 +282,10 @@ TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoSyncDisabled) {
}
TEST_F(SyncInternalsMessageHandlerTest, WriteUserEvent) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("1000000000000000000");
args.Append("-1");
- handler()->HandleWriteUserEvent(args.GetList());
+ handler()->HandleWriteUserEvent(args);
ASSERT_EQ(1u, fake_user_event_service()->GetRecordedUserEvents().size());
const UserEventSpecifics& event =
@@ -304,10 +296,10 @@ TEST_F(SyncInternalsMessageHandlerTest, WriteUserEvent) {
}
TEST_F(SyncInternalsMessageHandlerTest, WriteUserEventBadParse) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("123abc");
args.Append("abcdefghijklmnopqrstuvwxyz");
- handler()->HandleWriteUserEvent(args.GetList());
+ handler()->HandleWriteUserEvent(args);
ASSERT_EQ(1u, fake_user_event_service()->GetRecordedUserEvents().size());
const UserEventSpecifics& event =
@@ -318,10 +310,10 @@ TEST_F(SyncInternalsMessageHandlerTest, WriteUserEventBadParse) {
}
TEST_F(SyncInternalsMessageHandlerTest, WriteUserEventBlank) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("");
args.Append("");
- handler()->HandleWriteUserEvent(args.GetList());
+ handler()->HandleWriteUserEvent(args);
ASSERT_EQ(1u, fake_user_event_service()->GetRecordedUserEvents().size());
const UserEventSpecifics& event =
@@ -335,10 +327,10 @@ TEST_F(SyncInternalsMessageHandlerTest, WriteUserEventBlank) {
}
TEST_F(SyncInternalsMessageHandlerTest, WriteUserEventZero) {
- base::Value args(base::Value::Type::LIST);
+ base::Value::List args;
args.Append("0");
args.Append("0");
- handler()->HandleWriteUserEvent(args.GetList());
+ handler()->HandleWriteUserEvent(args);
ASSERT_EQ(1u, fake_user_event_service()->GetRecordedUserEvents().size());
const UserEventSpecifics& event =
diff --git a/chromium/chrome/browser/ui/webui/system_info_ui.cc b/chromium/chrome/browser/ui/webui/system_info_ui.cc
index 8aacda54811..412c3321c97 100644
--- a/chromium/chrome/browser/ui/webui/system_info_ui.cc
+++ b/chromium/chrome/browser/ui/webui/system_info_ui.cc
@@ -87,7 +87,7 @@ class SystemInfoHandler : public WebUIMessageHandler {
// Callback for the "requestSystemInfo" message. This asynchronously requests
// system info and eventually returns it to the front end.
- void HandleRequestSystemInfo(const base::ListValue* args);
+ void HandleRequestSystemInfo(const base::Value::List& args);
void OnSystemInfo(std::unique_ptr<SystemLogsResponse> sys_info);
@@ -111,15 +111,15 @@ void SystemInfoHandler::OnJavascriptDisallowed() {
}
void SystemInfoHandler::RegisterMessages() {
- web_ui()->RegisterDeprecatedMessageCallback(
+ web_ui()->RegisterMessageCallback(
"requestSystemInfo",
base::BindRepeating(&SystemInfoHandler::HandleRequestSystemInfo,
base::Unretained(this)));
}
-void SystemInfoHandler::HandleRequestSystemInfo(const base::ListValue* args) {
+void SystemInfoHandler::HandleRequestSystemInfo(const base::Value::List& args) {
AllowJavascript();
- callback_id_ = args->GetListDeprecated()[0].GetString();
+ callback_id_ = args[0].GetString();
system_logs::SystemLogsFetcher* fetcher =
system_logs::BuildAboutSystemLogsFetcher();
@@ -140,8 +140,7 @@ void SystemInfoHandler::OnSystemInfo(
val.Set("statValue", it->second);
data.Append(std::move(val));
}
- ResolveJavascriptCallback(base::Value(callback_id_),
- base::Value(std::move(data)));
+ ResolveJavascriptCallback(base::Value(callback_id_), data);
callback_id_.clear();
}
diff --git a/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn b/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
index 4445be3269a..129721237b2 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
@@ -4,6 +4,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
+assert(is_linux || is_chromeos || is_win || is_mac || is_fuchsia)
+
mojom("mojo_bindings") {
sources = [ "tab_search.mojom" ]
public_deps = [
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc
index 239fc714a1d..99914ea08f2 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc
@@ -57,6 +57,21 @@ std::string GetLastActiveElapsedText(const base::Time& last_active_time) {
ui::TimeFormat::FORMAT_ELAPSED, ui::TimeFormat::LENGTH_SHORT, elapsed));
}
+// If Tab Group has no timestamp, we find the tab in the tab group with
+// the most recent navigation last active time.
+base::Time GetTabGroupTimeStamp(
+ const std::vector<std::unique_ptr<sessions::TabRestoreService::Tab>>&
+ tabs) {
+ base::Time last_active_time;
+ for (const auto& tab : tabs) {
+ const sessions::SerializedNavigationEntry& entry =
+ tab->navigations[tab->current_navigation_index];
+ if (entry.timestamp() > last_active_time)
+ last_active_time = entry.timestamp();
+ }
+ return last_active_time;
+}
+
// If a recently closed tab is associated to a group that is no longer
// open we create a TabGroup entry with the required fields to support
// rendering the tab's associated group information in the UI.
@@ -125,7 +140,7 @@ void TabSearchPageHandler::CloseTab(int32_t tab_id) {
auto* tab_strip_model = optional_details->tab_strip_model;
const int tab_index = optional_details->index;
tab_strip_model->CloseWebContentsAt(
- tab_index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
+ tab_index, TabCloseTypes::CLOSE_CREATE_HISTORICAL_TAB);
// Do not add code past this point.
}
@@ -369,12 +384,15 @@ void TabSearchPageHandler::AddRecentlyClosedEntries(
recently_closed_tab_group->title =
base::UTF16ToUTF8(tab_group_visual_data->title());
recently_closed_tab_group->tab_count = group->tabs.size();
- recently_closed_tab_group->last_active_time = entry->timestamp;
+ const base::Time last_active_time =
+ (entry->timestamp).is_null() ? GetTabGroupTimeStamp(group->tabs)
+ : entry->timestamp;
+ recently_closed_tab_group->last_active_time = last_active_time;
recently_closed_tab_group->last_active_elapsed_text =
- GetLastActiveElapsedText(entry->timestamp);
+ GetLastActiveElapsedText(last_active_time);
for (auto& tab : group->tabs) {
- if (AddRecentlyClosedTab(tab.get(), entry->timestamp,
+ if (AddRecentlyClosedTab(tab.get(), last_active_time,
recently_closed_tabs, tab_dedup_keys,
tab_group_ids, tab_groups)) {
recently_closed_tab_count += 1;
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc
index 423d2c9d710..9b876467a25 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_utils.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/metrics_reporter/metrics_reporter.h"
@@ -546,7 +547,7 @@ TEST_F(TabSearchPageHandlerTest, TabsChanged) {
// Close a tab in browser 1.
ASSERT_FALSE(IsTimerRunning());
browser1()->tab_strip_model()->CloseWebContentsAt(
- 0, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
+ 0, TabCloseTypes::CLOSE_CREATE_HISTORICAL_TAB);
ASSERT_FALSE(IsTimerRunning());
}
@@ -570,7 +571,7 @@ TEST_F(TabSearchPageHandlerTest, EventsDoNotPropagatedWhenWebUIIsHidden) {
// Closing a tab would usually result in a call to TabsRemoved().
browser1()->tab_strip_model()->CloseWebContentsAt(
- 0, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
+ 0, TabCloseTypes::CLOSE_CREATE_HISTORICAL_TAB);
}
// Ensure that tab model changes in a browser with a different profile
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc
index 293158595db..97f163773d7 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc
@@ -57,6 +57,8 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui)
{"mediaRecording", IDS_TAB_AX_LABEL_MEDIA_RECORDING_FORMAT},
{"audioMuting", IDS_TAB_AX_LABEL_AUDIO_MUTING_FORMAT},
{"audioPlaying", IDS_TAB_AX_LABEL_AUDIO_PLAYING_FORMAT},
+ {"expandRecentlyClosed", IDS_TAB_SEARCH_EXPAND_RECENTLY_CLOSED},
+ {"collapseRecentlyClosed", IDS_TAB_SEARCH_COLLAPSE_RECENTLY_CLOSED},
};
source->AddLocalizedStrings(kStrings);
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/BUILD.gn b/chromium/chrome/browser/ui/webui/tab_strip/BUILD.gn
index 23d36f377e6..bbb05fce7ac 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/tab_strip/BUILD.gn
@@ -9,6 +9,7 @@ mojom("mojo_bindings") {
public_deps = [
"//chrome/browser/ui/webui/tabs:mojo_bindings",
"//mojo/public/mojom/base",
+ "//ui/webui/resources/cr_components/color_change_listener:mojom",
"//url/mojom:url_mojom_gurl",
]
webui_module_path = "/"
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip.mojom b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip.mojom
index f5a096de3e8..b922dbdd4e4 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip.mojom
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip.mojom
@@ -113,9 +113,6 @@ interface PageHandler {
// Ungroup a tab.
UngroupTab(int32 tab_id);
- // Get colors of the current theme.
- GetThemeColors() => (map<string, string> colors);
-
// Get layout of the tab strip.
GetLayout() => (map<string, string> layout);
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc
index 8a1e80b8885..dfc0362dcee 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc
@@ -151,17 +151,6 @@ class WebUITabContextMenu : public ui::SimpleMenuModel::Delegate,
const int tab_index_;
};
-bool IsSortedAndContiguous(base::span<const int> sequence) {
- if (sequence.size() < 2)
- return true;
-
- if (!std::is_sorted(sequence.begin(), sequence.end()))
- return false;
-
- return sequence.back() ==
- sequence.front() + static_cast<int>(sequence.size()) - 1;
-}
-
} // namespace
TabStripPageHandler::~TabStripPageHandler() {
@@ -281,6 +270,14 @@ void TabStripPageHandler::OnTabStripModelChanged(
if (tab_strip_model->empty())
return;
+ // The context menu model is created when the menu is first shown. However, if
+ // the tab strip model changes, the context menu model may not longer reflect
+ // the current state of the tab strip. Actions then taken from the context
+ // menu may leave the tab strip in an inconsistent state, or result in DCHECK
+ // crashes. To ensure this does not occur close the context menu on a tab
+ // strip model change.
+ embedder_->CloseContextMenu();
+
switch (change.type()) {
case TabStripModelChange::kInserted: {
for (const auto& contents : change.GetInsert()->contents) {
@@ -297,32 +294,6 @@ void TabStripPageHandler::OnTabStripModelChanged(
}
case TabStripModelChange::kMoved: {
auto* move = change.GetMove();
-
- absl::optional<tab_groups::TabGroupId> tab_group_id =
- tab_strip_model->GetTabGroupForTab(move->to_index);
- if (tab_group_id.has_value()) {
- const gfx::Range tabs_in_group = tab_strip_model->group_model()
- ->GetTabGroup(tab_group_id.value())
- ->ListTabs();
-
- const ui::ListSelectionModel::SelectedIndices& sel =
- selection.new_model.selected_indices();
- const auto& selected_tabs = std::vector<int>(sel.begin(), sel.end());
- const bool all_tabs_in_group =
- IsSortedAndContiguous(base::make_span(selected_tabs)) &&
- selected_tabs.front() == static_cast<int>(tabs_in_group.start()) &&
- selected_tabs.size() == tabs_in_group.length();
-
- if (all_tabs_in_group) {
- // If the selection includes all the tabs within the changed tab's
- // group, it is an indication that the entire group is being moved.
- // To prevent sending multiple events for each tab in the group,
- // ignore these tabs moving as entire group moves will be handled by
- // TabGroupChange::kMoved.
- break;
- }
- }
-
page_->TabMoved(extensions::ExtensionTabUtil::GetTabId(move->contents),
move->to_index,
tab_strip_model->IsTabPinned(move->to_index));
@@ -342,8 +313,7 @@ void TabStripPageHandler::OnTabStripModelChanged(
if (selection.active_tab_changed()) {
content::WebContents* new_contents = selection.new_contents;
- int index = selection.new_model.active();
- if (new_contents && index != TabStripModel::kNoTab) {
+ if (new_contents && selection.new_model.active().has_value()) {
page_->TabActiveChanged(
extensions::ExtensionTabUtil::GetTabId(new_contents));
}
@@ -594,53 +564,6 @@ void TabStripPageHandler::GetGroupVisualData(
std::move(callback).Run(std::move(group_visual_datas));
}
-void TabStripPageHandler::GetThemeColors(GetThemeColorsCallback callback) {
- TRACE_EVENT0("browser", "TabStripPageHandler:HandleGetThemeColors");
- // This should return an object of CSS variables to rgba values so that
- // the WebUI can use the CSS variables to color the tab strip
- base::flat_map<std::string, std::string> colors;
- colors["--tabstrip-background-color"] = color_utils::SkColorToRgbaString(
- embedder_->GetColor(ThemeProperties::COLOR_FRAME_ACTIVE));
- colors["--tabstrip-tab-background-color"] = color_utils::SkColorToRgbaString(
- embedder_->GetColor(ThemeProperties::COLOR_TOOLBAR));
- colors["--tabstrip-tab-text-color"] = color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(kColorTabForegroundActiveFrameActive));
- colors["--tabstrip-tab-separator-color"] = color_utils::SkColorToRgbaString(
- SkColorSetA(embedder_->GetColorProviderColor(
- kColorTabForegroundActiveFrameActive),
- /* 16% opacity */ 0.16 * 255));
-
- std::string throbber_color = color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(kColorTabThrobber));
- colors["--tabstrip-tab-loading-spinning-color"] = throbber_color;
- colors["--tabstrip-tab-waiting-spinning-color"] =
- color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(kColorTabThrobberPreconnect));
- colors["--tabstrip-indicator-recording-color"] =
- color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(ui::kColorAlertHighSeverity));
- colors["--tabstrip-indicator-pip-color"] = throbber_color;
- colors["--tabstrip-indicator-capturing-color"] = throbber_color;
- colors["--tabstrip-tab-blocked-color"] = color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(ui::kColorButtonBackgroundProminent));
- colors["--tabstrip-focus-outline-color"] = color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(ui::kColorFocusableBorderFocused));
- colors["--tabstrip-tab-active-title-background-color"] =
- color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(kColorThumbnailTabBackground));
- colors["--tabstrip-tab-active-title-content-color"] =
- color_utils::SkColorToRgbaString(
- embedder_->GetColorProviderColor(kColorThumbnailTabForeground));
-
-#if !BUILDFLAG(IS_CHROMEOS_ASH)
- colors["--tabstrip-scrollbar-thumb-color-rgb"] =
- color_utils::SkColorToRgbString(color_utils::GetColorWithMaxContrast(
- embedder_->GetColor(ThemeProperties::COLOR_FRAME_ACTIVE)));
-#endif
-
- std::move(callback).Run(std::move(colors));
-}
-
void TabStripPageHandler::GroupTab(int32_t tab_id,
const std::string& group_id_string) {
int tab_index = -1;
@@ -702,12 +625,11 @@ void TabStripPageHandler::MoveGroup(const std::string& group_id_string,
// When a group is moved, all the tabs in it need to be selected at the same
// time. This mimics the way the native tab strip works and also allows
// this handler to ignore the events for each individual tab moving.
- int active_index =
- target_browser->tab_strip_model()->selection_model().active();
ui::ListSelectionModel group_selection;
group_selection.SetSelectedIndex(tabs_in_group.start());
group_selection.SetSelectionFromAnchorTo(tabs_in_group.end() - 1);
- group_selection.set_active(active_index);
+ group_selection.set_active(
+ target_browser->tab_strip_model()->selection_model().active());
target_browser->tab_strip_model()->SetSelectionFromModel(group_selection);
target_browser->tab_strip_model()->MoveGroupTo(group_id.value(), to_index);
@@ -835,9 +757,8 @@ void TabStripPageHandler::ShowTabContextMenu(int32_t tab_id,
browser, embedder_->GetAcceleratorProvider(), tab_index),
base::BindRepeating(&TabStripPageHandler::NotifyContextMenuClosed,
weak_ptr_factory_.GetWeakPtr()));
- base::UmaHistogramEnumeration(
- "TabStrip.Tab.WebUI.ActivationAction",
- TabStripModel::TabActivationTypes::kContextMenu);
+ base::UmaHistogramEnumeration("TabStrip.Tab.WebUI.ActivationAction",
+ TabActivationTypes::kContextMenu);
}
void TabStripPageHandler::GetLayout(GetLayoutCallback callback) {
@@ -866,7 +787,7 @@ void TabStripPageHandler::ReportTabActivationDuration(uint32_t duration_ms) {
UMA_HISTOGRAM_TIMES("WebUITabStrip.TabActivation",
base::Milliseconds(duration_ms));
base::UmaHistogramEnumeration("TabStrip.Tab.WebUI.ActivationAction",
- TabStripModel::TabActivationTypes::kTab);
+ TabActivationTypes::kTab);
}
void TabStripPageHandler::ReportTabDataReceivedDuration(uint32_t tab_count,
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h
index 65cf85240ec..01b36222e21 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h
@@ -79,6 +79,7 @@ class TabStripPageHandler : public tab_strip::mojom::PageHandler,
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveGroup);
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveGroupAcrossProfiles);
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveGroupAcrossWindows);
+ FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveGroupMultipleTabs);
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveTab);
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveTabAcrossProfiles);
FRIEND_TEST_ALL_PREFIXES(TabStripPageHandlerTest, MoveTabAcrossWindows);
@@ -109,7 +110,6 @@ class TabStripPageHandler : public tab_strip::mojom::PageHandler,
// tab_strip::mojom::PageHandler:
void GetTabs(GetTabsCallback callback) override;
void GetGroupVisualData(GetGroupVisualDataCallback callback) override;
- void GetThemeColors(GetThemeColorsCallback callback) override;
void CloseContainer() override;
void CloseTab(int32_t tab_id, bool tab_was_swiped) override;
void ShowEditDialogForGroup(const std::string& group_id,
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler_unittest.cc
index 8ef400e1e62..31c9d9bed9a 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler_unittest.cc
@@ -32,6 +32,7 @@
using testing::_;
using testing::AtLeast;
+using testing::InSequence;
using testing::Truly;
namespace {
@@ -68,7 +69,6 @@ class StubTabStripUIEmbedder : public TabStripUIEmbedder {
}
void HideEditDialogForGroup() override {}
TabStripUILayout GetLayout() override { return TabStripUILayout(); }
- SkColor GetColor(int id) const override { return SK_ColorWHITE; }
SkColor GetColorProviderColor(ui::ColorId id) const override {
return SK_ColorWHITE;
}
@@ -269,23 +269,82 @@ TEST_F(TabStripPageHandlerTest, GroupTab) {
TEST_F(TabStripPageHandlerTest, MoveGroup) {
AddTab(browser(), GURL("http://foo/1"));
AddTab(browser(), GURL("http://foo/2"));
- tab_groups::TabGroupId group_id =
- browser()->tab_strip_model()->AddToNewGroup({0});
+
+ auto* tab_strip_model = browser()->tab_strip_model();
+ const int moved_tab_id = extensions::ExtensionTabUtil::GetTabId(
+ tab_strip_model->GetWebContentsAt(0));
+ tab_groups::TabGroupId group_id = tab_strip_model->AddToNewGroup({0});
web_ui()->ClearTrackedCalls();
// Move the group to index 1.
- int new_index = 1;
- handler()->MoveGroup(group_id.ToString(), new_index);
+ constexpr int kMoveIndex = 1;
+ handler()->MoveGroup(group_id.ToString(), kMoveIndex);
+
+ gfx::Range tabs_in_group =
+ tab_strip_model->group_model()->GetTabGroup(group_id)->ListTabs();
+ ASSERT_EQ(kMoveIndex, static_cast<int>(tabs_in_group.start()));
+ ASSERT_EQ(kMoveIndex, static_cast<int>(tabs_in_group.end()) - 1);
+
+ EXPECT_CALL(page_, TabMoved(moved_tab_id, kMoveIndex, false));
+ EXPECT_CALL(page_, TabGroupMoved(group_id.ToString(), kMoveIndex));
+}
+
+class MockTabStripModelObserver : public TabStripModelObserver {
+ public:
+ MOCK_METHOD(void,
+ OnTabStripModelChanged,
+ (TabStripModel*,
+ const TabStripModelChange&,
+ const TabStripSelectionChange&),
+ (override));
+ MOCK_METHOD(void, OnTabGroupChanged, (const TabGroupChange&), (override));
+};
- gfx::Range tabs_in_group = browser()
- ->tab_strip_model()
- ->group_model()
- ->GetTabGroup(group_id)
- ->ListTabs();
- ASSERT_EQ(new_index, static_cast<int>(tabs_in_group.start()));
- ASSERT_EQ(new_index, static_cast<int>(tabs_in_group.end()) - 1);
+// Tests the event order from a multi-tab group move. The WebUI event handling
+// implementation relies on this order of events. If it ever changes the WebUI
+// implementation should also change.
+TEST_F(TabStripPageHandlerTest, ValidateTabGroupEventStream) {
+ MockTabStripModelObserver mock_observer_;
+ auto* tab_strip_model = browser()->tab_strip_model();
+ tab_strip_model->AddObserver(&mock_observer_);
+
+ AddTab(browser(), GURL("http://foo/1"));
+ AddTab(browser(), GURL("http://foo/2"));
+ AddTab(browser(), GURL("http://foo/3"));
+ AddTab(browser(), GURL("http://foo/4"));
+ AddTab(browser(), GURL("http://foo/5"));
- EXPECT_CALL(page_, TabGroupMoved(group_id.ToString(), new_index));
+ // Group tabs {0, 1, 2} together.
+ std::vector<int> tab_group_indicies = {0, 1, 2};
+ tab_groups::TabGroupId group_id =
+ tab_strip_model->AddToNewGroup(tab_group_indicies);
+
+ // Moving tabs {0, 1, 2} to index 4 will result in the first tab in the group
+ // being at index 2 after the move.
+ constexpr int kMoveIndex = 4;
+ constexpr int kNewGroupStartIndex = 2;
+ {
+ InSequence s;
+ EXPECT_CALL(mock_observer_,
+ OnTabStripModelChanged(
+ _, Truly([&](const TabStripModelChange& change) {
+ auto* move = change.GetMove();
+ return change.type() == TabStripModelChange::kMoved &&
+ move->to_index == kMoveIndex;
+ }),
+ _))
+ .Times(3);
+ EXPECT_CALL(
+ mock_observer_,
+ OnTabGroupChanged(Truly([&](const TabGroupChange& change) {
+ TabGroupModel* group_model = tab_strip_model->group_model();
+ const int start_tab =
+ group_model->GetTabGroup(change.group)->ListTabs().start();
+ return change.type == TabGroupChange::kMoved &&
+ change.group == group_id && start_tab == kNewGroupStartIndex;
+ })));
+ }
+ tab_strip_model->MoveGroupTo(group_id, kMoveIndex);
}
TEST_F(TabStripPageHandlerTest, MoveGroupAcrossWindows) {
@@ -634,4 +693,4 @@ TEST_F(TabStripPageHandlerTest, OnThemeChanged) {
webui::GetNativeTheme(web_ui()->GetWebContents())
->NotifyOnNativeThemeUpdated();
EXPECT_CALL(page_, ThemeChanged());
-} \ No newline at end of file
+}
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc
index ac92cb442e3..6679eae1f08 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/webui/color_change_listener/color_change_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.h"
#include "chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h"
@@ -59,16 +60,6 @@ TabStripUI::TabStripUI(content::WebUI* web_ui)
html_source->AddString("tabIdDataType", kWebUITabIdDataType);
html_source->AddString("tabGroupIdDataType", kWebUITabGroupIdDataType);
- // Add a load time string for the frame color to allow the tab strip to paint
- // a background color that matches the frame before any content loads.
- // TODO(https://crbug.com/1060398): Update the tab strip color to respond
- // appopriately to activation changes.
- const auto& color_provider = web_ui->GetWebContents()->GetColorProvider();
- const SkColor frame_color =
- color_provider.GetColor(kColorThumbnailTabStripBackgroundActive);
- html_source->AddString("frameColor",
- color_utils::SkColorToRgbaString(frame_color));
-
static constexpr webui::LocalizedString kStrings[] = {
{"tabListTitle", IDS_ACCNAME_TAB_LIST},
{"closeTab", IDS_ACCNAME_CLOSE},
@@ -109,6 +100,12 @@ void TabStripUI::BindInterface(
page_factory_receiver_.Bind(std::move(receiver));
}
+void TabStripUI::BindInterface(
+ mojo::PendingReceiver<color_change_listener::mojom::PageHandler> receiver) {
+ color_provider_handler_ = std::make_unique<ColorChangeHandler>(
+ web_ui()->GetWebContents(), std::move(receiver));
+}
+
void TabStripUI::CreatePageHandler(
mojo::PendingRemote<tab_strip::mojom::Page> page,
mojo::PendingReceiver<tab_strip::mojom::PageHandler> receiver) {
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.h b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.h
index d28ce8e76d7..d053986cc0f 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.h
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.h
@@ -14,8 +14,10 @@
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"
+#include "ui/webui/resources/cr_components/color_change_listener/color_change_listener.mojom.h"
class Browser;
+class ColorChangeHandler;
class TabStripPageHandler;
class TabStripUIEmbedder;
@@ -39,6 +41,12 @@ class TabStripUI : public ui::MojoWebUIController,
void BindInterface(
mojo::PendingReceiver<tab_strip::mojom::PageHandlerFactory> receiver);
+ // Instantiates the implementor of the mojom::PageHandler mojo interface
+ // passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<color_change_listener::mojom::PageHandler>
+ receiver);
+
// Initialize TabStripUI with its embedder and the Browser it's running in.
// Must be called exactly once. The WebUI won't work until this is called.
// |Deinitialize| is called during |embedder|'s destructor. It release the
@@ -66,6 +74,8 @@ class TabStripUI : public ui::MojoWebUIController,
std::unique_ptr<TabStripPageHandler> page_handler_;
+ std::unique_ptr<ColorChangeHandler> color_provider_handler_;
+
mojo::Receiver<tab_strip::mojom::PageHandlerFactory> page_factory_receiver_{
this};
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc
index 53f3ab537d2..88a16082598 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc
@@ -51,7 +51,6 @@ class MockTabStripUIEmbedder : public TabStripUIEmbedder {
void(gfx::Point, gfx::Rect, tab_groups::TabGroupId));
MOCK_METHOD0(HideEditDialogForGroup, void());
MOCK_METHOD0(GetLayout, TabStripUILayout());
- MOCK_CONST_METHOD1(GetColor, SkColor(int));
MOCK_CONST_METHOD1(GetColorProviderColor, SkColor(ui::ColorId));
};
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h
index 3071e5bd587..42b8dae795b 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_embedder.h
@@ -38,7 +38,6 @@ class TabStripUIEmbedder {
virtual TabStripUILayout GetLayout() = 0;
- virtual SkColor GetColor(int id) const = 0;
virtual SkColor GetColorProviderColor(ui::ColorId id) const = 0;
};
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc
index 884cb3e34bf..a70bb4a0f45 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc
@@ -69,12 +69,12 @@ void MoveTabAcrossWindows(Browser* source_browser,
source_browser->tab_strip_model()->DetachWebContentsAtForInsertion(
from_index);
- int add_types = TabStripModel::ADD_NONE;
+ int add_types = AddTabTypes::ADD_NONE;
if (was_active) {
- add_types |= TabStripModel::ADD_ACTIVE;
+ add_types |= AddTabTypes::ADD_ACTIVE;
}
if (was_pinned) {
- add_types |= TabStripModel::ADD_PINNED;
+ add_types |= AddTabTypes::ADD_PINNED;
}
target_browser->tab_strip_model()->InsertWebContentsAt(
diff --git a/chromium/chrome/browser/ui/webui/test_data_source.cc b/chromium/chrome/browser/ui/webui/test_data_source.cc
index 4b636f51159..f301c859b55 100644
--- a/chromium/chrome/browser/ui/webui/test_data_source.cc
+++ b/chromium/chrome/browser/ui/webui/test_data_source.cc
@@ -64,19 +64,19 @@ void TestDataSource::StartDataRequest(
std::move(callback)));
}
-std::string TestDataSource::GetMimeType(const std::string& path) {
- std::string clean_path = GetURLForPath(path).path();
- if (base::EndsWith(clean_path, ".html",
+std::string TestDataSource::GetMimeType(const GURL& url) {
+ if (base::EndsWith(url.path_piece(), ".html",
base::CompareCase::INSENSITIVE_ASCII) ||
- base::StartsWith(GetURLForPath(path).query(), kModuleQuery,
+ base::StartsWith(url.query_piece(), kModuleQuery,
base::CompareCase::INSENSITIVE_ASCII)) {
// Direct request for HTML, or autogenerated HTML response for module query.
return "text/html";
}
// The test data source currently only serves HTML and JS.
- CHECK(base::EndsWith(clean_path, ".js", base::CompareCase::INSENSITIVE_ASCII))
+ CHECK(base::EndsWith(url.path_piece(), ".js",
+ base::CompareCase::INSENSITIVE_ASCII))
<< "Tried to read file with unexpected type from test data source: "
- << path;
+ << url.path_piece();
return "application/javascript";
}
diff --git a/chromium/chrome/browser/ui/webui/test_data_source.h b/chromium/chrome/browser/ui/webui/test_data_source.h
index cbc2af8cdd2..b0091f1341f 100644
--- a/chromium/chrome/browser/ui/webui/test_data_source.h
+++ b/chromium/chrome/browser/ui/webui/test_data_source.h
@@ -28,7 +28,7 @@ class TestDataSource : public content::URLDataSource {
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool ShouldServeMimeTypeAsContentTypeHeader() override;
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.cc b/chromium/chrome/browser/ui/webui/theme_handler.cc
index a98b4db5e77..760c66bf73b 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.cc
+++ b/chromium/chrome/browser/ui/webui/theme_handler.cc
@@ -79,8 +79,8 @@ void ThemeHandler::SendThemeChanged() {
bool has_custom_bg = ThemeService::GetThemeProviderForProfile(GetProfile())
.HasCustomImage(IDR_THEME_NTP_BACKGROUND);
// TODO(dbeam): why does this need to be a dictionary?
- base::DictionaryValue dictionary;
- dictionary.SetBoolKey("hasCustomBackground", has_custom_bg);
+ base::Value::Dict dictionary;
+ dictionary.Set("hasCustomBackground", has_custom_bg);
FireWebUIListener("theme-changed", dictionary);
}
diff --git a/chromium/chrome/browser/ui/webui/theme_source.cc b/chromium/chrome/browser/ui/webui/theme_source.cc
index f93be69f313..f402c2fd101 100644
--- a/chromium/chrome/browser/ui/webui/theme_source.cc
+++ b/chromium/chrome/browser/ui/webui/theme_source.cc
@@ -4,13 +4,17 @@
#include "chrome/browser/ui/webui/theme_source.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/branding_buildflags.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resources_util.h"
#include "chrome/browser/search/instant_service.h"
@@ -31,6 +35,7 @@
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "net/base/url_util.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
@@ -42,6 +47,10 @@
#include "ui/gfx/image/image_skia_rep.h"
#include "url/gurl.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+
namespace {
GURL GetThemeUrl(const std::string& path) {
@@ -108,33 +117,7 @@ void ThemeSource::StartDataRequest(
// colors_css_updater.js.
constexpr char kColorsCssPath[] = "colors.css";
if (parsed_path == kColorsCssPath) {
- const ui::ColorProvider& color_provider =
- wc_getter.Run()->GetColorProvider();
-
- auto generate_color_mapping = [](ui::ColorId start, ui::ColorId end,
- std::string (*color_id_name)(ui::ColorId),
- const ui::ColorProvider& color_provider) {
- std::string css_string;
- for (ui::ColorId id = start; id < end; ++id) {
- const SkColor color = color_provider.GetColor(id);
- std::string css_id_to_color_mapping = base::StringPrintf(
- "%s:%s;",
- ui::ConvertColorProviderColorIdToCSSColorId(color_id_name(id))
- .c_str(),
- ui::ConvertSkColorToCSSColor(color).c_str());
- base::StrAppend(&css_string, {css_id_to_color_mapping});
- }
- return css_string;
- };
-
- std::string css_string = base::StrCat(
- {"html {",
- generate_color_mapping(ui::kUiColorsStart, ui::kUiColorsEnd,
- &ui::ColorIdName, color_provider),
- generate_color_mapping(kChromeColorsStart, kChromeColorsEnd,
- &ChromeColorIdName, color_provider),
- "}"});
- std::move(callback).Run(base::RefCountedString::TakeString(&css_string));
+ SendColorsCss(url, wc_getter, std::move(callback));
return;
}
@@ -186,7 +169,7 @@ void ThemeSource::StartDataRequest(
// user can also enter these into the omnibox, so we need to fail
// gracefully.
std::move(callback).Run(nullptr);
- } else if ((GetMimeType(path) == "image/png") &&
+ } else if ((GetMimeType(url) == "image/png") &&
((scale > max_scale) || (frame != -1))) {
// This will extract and scale frame 0 of animated images.
// TODO(reveman): Support scaling of animated images and avoid scaling and
@@ -198,9 +181,9 @@ void ThemeSource::StartDataRequest(
}
}
-std::string ThemeSource::GetMimeType(const std::string& path) {
+std::string ThemeSource::GetMimeType(const GURL& url) {
std::string parsed_path;
- webui::ParsePathAndScale(GetThemeUrl(path), &parsed_path, nullptr);
+ webui::ParsePathAndScale(url, &parsed_path, nullptr);
return IsNewTabCssPath(parsed_path) ? "text/css" : "image/png";
}
@@ -257,6 +240,94 @@ void ThemeSource::SendThemeImage(
std::move(callback).Run(data.get());
}
+void ThemeSource::SendColorsCss(
+ const GURL& url,
+ const content::WebContents::Getter& wc_getter,
+ content::URLDataSource::GotDataCallback callback) {
+ const ui::ColorProvider& color_provider = wc_getter.Run()->GetColorProvider();
+
+ std::string sets_param;
+ std::vector<base::StringPiece> color_id_sets;
+ if (!net::GetValueForKeyInQuery(url, "sets", &sets_param)) {
+ LOG(ERROR)
+ << "colors.css requires a 'sets' query parameter to specify the color "
+ "id sets returned e.g chrome://theme/colors.css?sets=ui,chrome";
+ std::move(callback).Run(nullptr);
+ return;
+ }
+ color_id_sets = base::SplitStringPiece(sets_param, ",", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_ALL);
+
+ using ColorIdCSSCallback = base::RepeatingCallback<std::string(ui::ColorId)>;
+ auto generate_color_mapping = [&color_id_sets, &color_provider](
+ std::string set_name, ui::ColorId start,
+ ui::ColorId end,
+ ColorIdCSSCallback color_css_name) {
+ // Only return these mappings if specified in the query parameter.
+ auto it = std::find(color_id_sets.begin(), color_id_sets.end(), set_name);
+ if (it == color_id_sets.end()) {
+ return std::string();
+ }
+ color_id_sets.erase(it);
+ std::string css_string;
+ for (ui::ColorId id = start; id < end; ++id) {
+ const SkColor color = color_provider.GetColor(id);
+ std::string css_id_to_color_mapping =
+ base::StringPrintf("%s:%s;", color_css_name.Run(id).c_str(),
+ ui::ConvertSkColorToCSSColor(color).c_str());
+ base::StrAppend(&css_string, {css_id_to_color_mapping});
+ }
+ return css_string;
+ };
+
+ // Convenience lambda for wrapping
+ // |ConvertColorProviderColorIdToCSSColorId|.
+ auto generate_color_provider_mapping = [&generate_color_mapping](
+ std::string set_name,
+ ui::ColorId start, ui::ColorId end,
+ std::string (*color_id_name)(
+ ui::ColorId)) {
+ auto color_id_to_css_name = base::BindRepeating(
+ [](std::string (*color_id_name)(ui::ColorId), ui::ColorId id) {
+ return ui::ConvertColorProviderColorIdToCSSColorId(color_id_name(id));
+ },
+ color_id_name);
+ return generate_color_mapping(set_name, start, end, color_id_to_css_name);
+ };
+
+ std::string css_string = base::StrCat({
+ // This selector requires more specificity than other existing CSS
+ // selectors that define variables. We increase the specifity by adding
+ // a pseudoselector.
+ "html:not(#z) {",
+ generate_color_provider_mapping("ui", ui::kUiColorsStart,
+ ui::kUiColorsEnd, ui::ColorIdName),
+ generate_color_provider_mapping("chrome", kChromeColorsStart,
+ kChromeColorsEnd, &ChromeColorIdName),
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ generate_color_mapping("ref", cros_tokens::kCrosRefColorsStart,
+ cros_tokens::kCrosRefColorsEnd,
+ base::BindRepeating(cros_tokens::ColorIdName)),
+ generate_color_mapping("sys", cros_tokens::kCrosSysColorsStart,
+ cros_tokens::kCrosSysColorsEnd,
+ base::BindRepeating(cros_tokens::ColorIdName)),
+ generate_color_mapping("legacy",
+ cros_tokens::kLegacySemanticColorsStart,
+ cros_tokens::kLegacySemanticColorsEnd,
+ base::BindRepeating(cros_tokens::ColorIdName)),
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ "}"
+ });
+ if (!color_id_sets.empty()) {
+ LOG(ERROR)
+ << "Unrecognized color set(s) specified for chrome://theme/colors.css: "
+ << base::JoinString(color_id_sets, ",");
+ std::move(callback).Run(nullptr);
+ return;
+ }
+ std::move(callback).Run(base::RefCountedString::TakeString(&css_string));
+}
+
std::string ThemeSource::GetAccessControlAllowOriginForOrigin(
const std::string& origin) {
std::string allowed_origin_prefix = content::kChromeUIScheme;
diff --git a/chromium/chrome/browser/ui/webui/theme_source.h b/chromium/chrome/browser/ui/webui/theme_source.h
index b58abc6d35f..585077ffdf8 100644
--- a/chromium/chrome/browser/ui/webui/theme_source.h
+++ b/chromium/chrome/browser/ui/webui/theme_source.h
@@ -30,7 +30,7 @@ class ThemeSource : public content::URLDataSource {
const GURL& url,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
bool AllowCaching() override;
bool ShouldServiceRequest(const GURL& url,
content::BrowserContext* browser_context,
@@ -53,6 +53,13 @@ class ThemeSource : public content::URLDataSource {
int resource_id,
float scale);
+ // Generates and sends a CSS stylesheet with colors from the |ColorProvider|.
+ // A 'sets' query parameter must be specified to indicate which colors should
+ // be in the stylesheet. e.g chrome://theme/colors.css?sets=ui,chrome
+ void SendColorsCss(const GURL& url,
+ const content::WebContents::Getter& wc_getter,
+ content::URLDataSource::GotDataCallback callback);
+
// The profile this object was initialized with.
raw_ptr<Profile> profile_;
diff --git a/chromium/chrome/browser/ui/webui/theme_source_unittest.cc b/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
index 927951015d2..254b5caecec 100644
--- a/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
@@ -74,10 +74,14 @@ class WebUISourcesTest : public testing::Test {
};
TEST_F(WebUISourcesTest, ThemeSourceMimeTypes) {
- EXPECT_EQ(theme_source()->GetMimeType("css/new_tab_theme.css"), "text/css");
- EXPECT_EQ(theme_source()->GetMimeType("css/new_tab_theme.css?foo"),
- "text/css");
- EXPECT_EQ(theme_source()->GetMimeType("WRONGURL"), "image/png");
+ EXPECT_EQ(
+ theme_source()->GetMimeType(GURL("chrome://theme/css/new_tab_theme.css")),
+ "text/css");
+ EXPECT_EQ(theme_source()->GetMimeType(
+ GURL("chrome://theme/css/new_tab_theme.css?foo")),
+ "text/css");
+ EXPECT_EQ(theme_source()->GetMimeType(GURL("chrome://theme/WRONGURL")),
+ "image/png");
}
TEST_F(WebUISourcesTest, ThemeSourceImages) {
@@ -119,7 +123,7 @@ TEST_F(WebUISourcesTest, ThemeSourceColorsCSS) {
// functions.
size_t empty_size = 0;
- StartDataRequest("colors.css");
+ StartDataRequest("colors.css?sets=ui");
base::RunLoop().RunUntilIdle();
EXPECT_NE(result_data_size_, empty_size);
}
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc
index fc7b84f2da6..1a316a71053 100644
--- a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc
@@ -50,14 +50,14 @@ ChromeTranslateInternalsHandler::GetVariationsService() {
}
void ChromeTranslateInternalsHandler::RegisterMessageCallback(
- const std::string& message,
+ base::StringPiece message,
MessageCallback callback) {
web_ui()->RegisterMessageCallback(message, std::move(callback));
}
void ChromeTranslateInternalsHandler::CallJavascriptFunction(
- const std::string& function_name,
- const std::vector<const base::Value*>& args) {
+ base::StringPiece function_name,
+ base::span<const base::ValueView> args) {
web_ui()->CallJavascriptFunctionUnsafe(function_name, args);
}
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h
index 88fc56f40ff..0b80e2ab5a0 100644
--- a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h
+++ b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h
@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_
-#include <string>
-
#include "base/callback_list.h"
#include "components/translate/translate_internals/translate_internals_handler.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -28,11 +26,10 @@ class ChromeTranslateInternalsHandler
// translate::TranslateInternalsHandler.
translate::TranslateClient* GetTranslateClient() override;
variations::VariationsService* GetVariationsService() override;
- void RegisterMessageCallback(const std::string& message,
+ void RegisterMessageCallback(base::StringPiece message,
MessageCallback callback) override;
- void CallJavascriptFunction(
- const std::string& function_name,
- const std::vector<const base::Value*>& args) override;
+ void CallJavascriptFunction(base::StringPiece function_name,
+ base::span<const base::ValueView> args) override;
// content::WebUIMessageHandler methods:
void RegisterMessages() override;
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
index 1811d1154fd..bfec185e6cf 100644
--- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
@@ -38,8 +38,9 @@ content::WebUIDataSource* CreateTranslateInternalsHTMLSource() {
network::mojom::CSPDirectiveName::TrustedTypes,
"trusted-types static-types;");
- base::Value langs = translate::TranslateInternalsHandler::GetLanguages();
- for (const auto key_value_pair : langs.DictItems()) {
+ base::Value::Dict langs =
+ translate::TranslateInternalsHandler::GetLanguages();
+ for (const auto key_value_pair : langs) {
DCHECK(key_value_pair.second.is_string());
std::string key = "language-" + key_value_pair.first;
const std::string& value = key_value_pair.second.GetString();
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
index 70a5a8de7ff..2e5c1019980 100644
--- a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
@@ -22,14 +22,10 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUIUsbInternalsHost);
static constexpr webui::ResourcePath kPaths[] = {
- {"usb_device.mojom-webui.js", IDR_USB_DEVICE_MOJOM_WEBUI_JS},
{"usb_enumeration_options.mojom-webui.js",
IDR_USB_ENUMERATION_OPTIONS_MOJOM_WEBUI_JS},
- {"usb_manager.mojom-webui.js", IDR_USB_DEVICE_MANAGER_MOJOM_WEBUI_JS},
{"usb_manager_client.mojom-webui.js",
IDR_USB_DEVICE_MANAGER_CLIENT_MOJOM_WEBUI_JS},
- {"usb_manager_test.mojom-webui.js",
- IDR_USB_DEVICE_MANAGER_TEST_MOJOM_WEBUI_JS},
};
source->AddResourcePaths(kPaths);
diff --git a/chromium/chrome/browser/ui/webui/version/version_handler.cc b/chromium/chrome/browser/ui/webui/version/version_handler.cc
index 1fc7153d57b..79b67957827 100644
--- a/chromium/chrome/browser/ui/webui/version/version_handler.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler.cc
@@ -92,12 +92,11 @@ void VersionHandler::HandleRequestVariationInfo(const base::Value::List& args) {
const std::string& callback_id = args[0].GetString();
const bool include_variations_cmd = args[1].GetBool();
- base::Value response(base::Value::Type::DICTIONARY);
- response.SetKey(version_ui::kKeyVariationsList,
- version_ui::GetVariationsList());
+ base::Value::Dict response;
+ response.Set(version_ui::kKeyVariationsList, version_ui::GetVariationsList());
if (include_variations_cmd) {
- response.SetKey(version_ui::kKeyVariationsCmd,
- version_ui::GetVariationsCommandLineAsValue());
+ response.Set(version_ui::kKeyVariationsCmd,
+ version_ui::GetVariationsCommandLineAsValue());
}
ResolveJavascriptCallback(base::Value(callback_id), response);
}
@@ -127,8 +126,8 @@ void VersionHandler::OnGotFilePaths(std::string callback_id,
std::u16string* executable_path_data,
std::u16string* profile_path_data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::Value response(base::Value::Type::DICTIONARY);
- response.SetKey(version_ui::kKeyExecPath, base::Value(*executable_path_data));
- response.SetKey(version_ui::kKeyProfilePath, base::Value(*profile_path_data));
+ base::Value::Dict response;
+ response.Set(version_ui::kKeyExecPath, *executable_path_data);
+ response.Set(version_ui::kKeyProfilePath, *profile_path_data);
ResolveJavascriptCallback(base::Value(callback_id), response);
}
diff --git a/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc
index b2b68800fb1..e75ae56548e 100644
--- a/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc
@@ -14,8 +14,11 @@
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ash/crosapi/browser_manager.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
+#include "chromeos/strings/grit/chromeos_strings.h"
+#include "ui/base/l10n/l10n_util.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/lacros_url_handling.h"
#endif
@@ -54,8 +57,8 @@ void VersionHandlerChromeOS::HandleRequestVersionInfo(
weak_factory_.GetWeakPtr()));
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
- base::BindOnce(&chromeos::version_loader::GetARCAndroidSDKVersion),
- base::BindOnce(&VersionHandlerChromeOS::OnARCVersion,
+ base::BindOnce(&VersionHandlerChromeOS::GetArcAndArcAndroidSdkVersions),
+ base::BindOnce(&VersionHandlerChromeOS::OnArcAndArcAndroidSdkVersions,
weak_factory_.GetWeakPtr()));
const bool showSystemFlagsLink = crosapi::browser_util::IsLacrosEnabled();
@@ -97,7 +100,27 @@ void VersionHandlerChromeOS::OnOSFirmware(const std::string& version) {
FireWebUIListener("return-os-firmware-version", base::Value(version));
}
-void VersionHandlerChromeOS::OnARCVersion(const std::string& version) {
- FireWebUIListener("return-arc-version", base::Value(version));
+void VersionHandlerChromeOS::OnArcAndArcAndroidSdkVersions(
+ const std::string& version) {
+ FireWebUIListener("return-arc-and-arc-android-sdk-versions",
+ base::Value(version));
}
+
+// static
+std::string VersionHandlerChromeOS::GetArcAndArcAndroidSdkVersions() {
+ std::string arc_version = chromeos::version_loader::GetArcVersion();
+ absl::optional<std::string> arc_android_sdk_version =
+ chromeos::version_loader::GetArcAndroidSdkVersion();
+ if (!arc_android_sdk_version.has_value()) {
+ arc_android_sdk_version = base::UTF16ToUTF8(
+ l10n_util::GetStringUTF16(IDS_ARC_SDK_VERSION_UNKNOWN));
+ }
+ std::string sdk_label =
+ base::UTF16ToUTF8(l10n_util::GetStringUTF16(IDS_ARC_SDK_VERSION_LABEL));
+ std::string labeled_version =
+ base::StringPrintf("%s %s %s", arc_version.c_str(), sdk_label.c_str(),
+ arc_android_sdk_version->c_str());
+ return labeled_version;
+}
+
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h
index 80e6e7b64d3..53467079c33 100644
--- a/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h
@@ -9,7 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/webui/version/version_handler.h"
-#include "chromeos/dbus/util/version_loader.h"
+#include "chromeos/version/version_loader.h"
// VersionHandlerChromeOS is responsible for loading the Chrome OS
// version.
@@ -30,13 +30,14 @@ class VersionHandlerChromeOS : public VersionHandler {
// Callbacks from chromeos::VersionLoader.
void OnVersion(const std::string& version);
void OnOSFirmware(const std::string& version);
- void OnARCVersion(const std::string& version);
+ void OnArcAndArcAndroidSdkVersions(const std::string& version);
// Callback for the "crosUrlVersionRedirect" message.
void HandleCrosUrlVersionRedirect(const base::Value::List& args);
private:
base::WeakPtrFactory<VersionHandlerChromeOS> weak_factory_{this};
+ static std::string GetArcAndArcAndroidSdkVersions();
};
#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/version/version_ui.cc b/chromium/chrome/browser/ui/webui/version/version_ui.cc
index 55f50b83594..b6b62055ea7 100644
--- a/chromium/chrome/browser/ui/webui/version/version_ui.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_ui.cc
@@ -5,10 +5,15 @@
#include "chrome/browser/ui/webui/version/version_ui.h"
#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
#include "base/command_line.h"
+#include "base/debug/debugging_buildflags.h"
#include "base/i18n/message_formatter.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
@@ -53,6 +58,10 @@
#include "chrome/browser/ui/webui/version/version_util_win.h"
#endif
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chromeos/startup/browser_params_proxy.h"
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
using content::WebUIDataSource;
namespace {
@@ -66,6 +75,7 @@ WebUIDataSource* CreateVersionUIDataSource() {
{version_ui::kLogoAltText, IDS_SHORT_PRODUCT_LOGO_ALT_TEXT},
{version_ui::kApplicationLabel, IDS_PRODUCT_NAME},
{version_ui::kCompany, IDS_ABOUT_VERSION_COMPANY_NAME},
+ {version_ui::kCopyLabel, IDS_VERSION_UI_COPY_LABEL},
{version_ui::kRevision, IDS_VERSION_UI_REVISION},
{version_ui::kUserAgentName, IDS_VERSION_UI_USER_AGENT},
{version_ui::kCommandLineName, IDS_VERSION_UI_COMMAND_LINE},
@@ -110,6 +120,22 @@ WebUIDataSource* CreateVersionUIDataSource() {
return html_source;
}
+std::string GetProductModifier() {
+ std::vector<std::string> modifier_parts;
+ if (std::string channel_name =
+ chrome::GetChannelName(chrome::WithExtendedStable(true));
+ !channel_name.empty()) {
+ modifier_parts.push_back(std::move(channel_name));
+ }
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ modifier_parts.emplace_back("lacros");
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+#if BUILDFLAG(DCHECK_IS_CONFIGURABLE)
+ modifier_parts.emplace_back("dcheck");
+#endif // BUILDFLAG(DCHECK_IS_CONFIGURABLE)
+ return base::JoinString(modifier_parts, "-");
+}
+
} // namespace
VersionUI::VersionUI(content::WebUI* web_ui)
@@ -176,16 +202,14 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
// Data strings.
html_source->AddString(version_ui::kVersion,
version_info::GetVersionNumber());
+
+ html_source->AddString(version_ui::kVersionModifier, GetProductModifier());
+
#if BUILDFLAG(IS_CHROMEOS_LACROS)
- // On Lacros, add channel string with "Lacros".
- html_source->AddString(
- version_ui::kVersionModifier,
- "Lacros/" + chrome::GetChannelName(chrome::WithExtendedStable(true)));
-#else
- html_source->AddString(
- version_ui::kVersionModifier,
- chrome::GetChannelName(chrome::WithExtendedStable(true)));
-#endif
+ auto* init_params = chromeos::BrowserParamsProxy::Get();
+ html_source->AddString(version_ui::kAshChromeVersion,
+ init_params->AshChromeVersion().value_or("0.0.0.0"));
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
html_source->AddString(version_ui::kJSEngine, "V8");
html_source->AddString(version_ui::kJSVersion, V8_VERSION_STRING);
html_source->AddString(
@@ -243,3 +267,17 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
html_source->AddString(version_ui::kSanitizer,
version_info::GetSanitizerList());
}
+
+#if !BUILDFLAG(IS_ANDROID)
+// static
+std::u16string VersionUI::GetAnnotatedVersionStringForUi() {
+ return l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_ABOUT_PAGE_BROWSER_VERSION,
+ base::UTF8ToUTF16(version_info::GetVersionNumber()),
+ l10n_util::GetStringUTF16(version_info::IsOfficialBuild()
+ ? IDS_VERSION_UI_OFFICIAL
+ : IDS_VERSION_UI_UNOFFICIAL),
+ base::UTF8ToUTF16(GetProductModifier()),
+ l10n_util::GetStringUTF16(VersionUI::VersionProcessorVariation()));
+}
+#endif // !BUILDFLAG(IS_ANDROID)
diff --git a/chromium/chrome/browser/ui/webui/version/version_ui.h b/chromium/chrome/browser/ui/webui/version/version_ui.h
index 349b148c417..5e0f3c9ca4e 100644
--- a/chromium/chrome/browser/ui/webui/version/version_ui.h
+++ b/chromium/chrome/browser/ui/webui/version/version_ui.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
+#include "build/build_config.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -24,6 +25,11 @@ class VersionUI : public content::WebUIController {
// Loads a data source with many named details comprising version info.
// The keys are from version_ui_constants.
static void AddVersionDetailStrings(content::WebUIDataSource* html_source);
+
+#if !BUILDFLAG(IS_ANDROID)
+ // Returns a localized version string suitable for displaying in UI.
+ static std::u16string GetAnnotatedVersionStringForUi();
+#endif // !BUILDFLAG(IS_ANDROID)
};
#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.cc b/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.cc
index 2d94714194a..e6f9e32f01e 100644
--- a/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.cc
+++ b/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.cc
@@ -187,9 +187,10 @@ base::Value BuildPreinstalledWebAppConfigsJson(
base::Value BuildExternallyManagedWebAppPrefsJson(Profile* profile) {
base::Value root(base::Value::Type::DICTIONARY);
- root.SetKey(
- kExternallyManagedWebAppPrefs,
- profile->GetPrefs()->GetDictionary(prefs::kWebAppsExtensionIDs)->Clone());
+ root.SetKey(kExternallyManagedWebAppPrefs,
+ base::Value(profile->GetPrefs()
+ ->GetValueDict(prefs::kWebAppsExtensionIDs)
+ .Clone()));
return root;
}
@@ -197,8 +198,8 @@ base::Value BuildPreinstalledAppsUninstalledByUserJson(Profile* profile) {
base::Value::Dict root;
root.Set(kPreinstalledAppsUninstalledByUserConfigs,
profile->GetPrefs()
- ->GetDictionary(prefs::kUserUninstalledPreinstalledWebAppPref)
- ->Clone());
+ ->GetValueDict(prefs::kUserUninstalledPreinstalledWebAppPref)
+ .Clone());
return base::Value(std::move(root));
}
@@ -268,7 +269,7 @@ void BuildDirectoryState(base::FilePath file_or_folder,
// reference.
if (!info.is_directory) {
folder->Set(file_or_folder.AsUTF8Unsafe(),
- base::StrCat({base::NumberToString(info.size / 1024), "kb"}));
+ base::StrCat({base::NumberToString(info.size), " bytes"}));
return;
}
@@ -294,7 +295,30 @@ base::Value BuildWebAppDiskStateJson(base::FilePath root_directory,
return root;
}
-void BuildWebAppInternalsJson(
+void BuildResponse(Profile* profile,
+ base::OnceCallback<void(base::Value root)> callback) {
+ auto* provider = web_app::WebAppProvider::GetForLocalAppsUnchecked(profile);
+ if (!provider) {
+ return std::move(callback).Run(
+ base::Value("Web app system not enabled for profile."));
+ }
+
+ provider->on_registry_ready().Post(
+ FROM_HERE,
+ base::BindOnce(&WebAppInternalsSource::BuildWebAppInternalsJson, profile,
+ std::move(callback)));
+}
+
+void ConvertValueToJsonData(content::URLDataSource::GotDataCallback callback,
+ base::Value value) {
+ std::string data = value.DebugString();
+ std::move(callback).Run(base::RefCountedString::TakeString(&data));
+}
+
+} // namespace
+
+// static
+void WebAppInternalsSource::BuildWebAppInternalsJson(
Profile* profile,
base::OnceCallback<void(base::Value root)> callback) {
auto* provider = web_app::WebAppProvider::GetForLocalAppsUnchecked(profile);
@@ -320,27 +344,6 @@ void BuildWebAppInternalsJson(
std::move(callback));
}
-void BuildResponse(Profile* profile,
- base::OnceCallback<void(base::Value root)> callback) {
- auto* provider = web_app::WebAppProvider::GetForLocalAppsUnchecked(profile);
- if (!provider) {
- return std::move(callback).Run(
- base::Value("Web app system not enabled for profile."));
- }
-
- provider->on_registry_ready().Post(
- FROM_HERE,
- base::BindOnce(&BuildWebAppInternalsJson, profile, std::move(callback)));
-}
-
-void ConvertValueToJsonData(content::URLDataSource::GotDataCallback callback,
- base::Value value) {
- std::string data = value.DebugString();
- std::move(callback).Run(base::RefCountedString::TakeString(&data));
-}
-
-} // namespace
-
WebAppInternalsSource::WebAppInternalsSource(Profile* profile)
: profile_(profile) {}
@@ -350,7 +353,7 @@ std::string WebAppInternalsSource::GetSource() {
return chrome::kChromeUIWebAppInternalsHost;
}
-std::string WebAppInternalsSource::GetMimeType(const std::string& path) {
+std::string WebAppInternalsSource::GetMimeType(const GURL& url) {
return "application/json";
}
diff --git a/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.h b/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.h
index 7d552230392..97aafa8e358 100644
--- a/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.h
+++ b/chromium/chrome/browser/ui/webui/web_app_internals/web_app_internals_source.h
@@ -17,6 +17,10 @@ class Profile;
// associated profile.
class WebAppInternalsSource : public content::URLDataSource {
public:
+ static void BuildWebAppInternalsJson(
+ Profile* profile,
+ base::OnceCallback<void(base::Value root)> callback);
+
explicit WebAppInternalsSource(Profile* profile);
WebAppInternalsSource(const WebAppInternalsSource&) = delete;
WebAppInternalsSource& operator=(const WebAppInternalsSource&) = delete;
@@ -24,7 +28,7 @@ class WebAppInternalsSource : public content::URLDataSource {
// content::URLDataSource:
std::string GetSource() override;
- std::string GetMimeType(const std::string& path) override;
+ std::string GetMimeType(const GURL& url) override;
void StartDataRequest(
const GURL& url,
const content::WebContents::Getter& wc_getter,
diff --git a/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc b/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
index eccf912468d..2001607ccfc 100644
--- a/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
@@ -66,8 +66,7 @@ TEST_F(WebDialogWebContentsDelegateTest, DoNothingMethodsTest) {
// None of the following calls should do anything.
history::HistoryAddPageArgs should_add_args(
GURL(), base::Time::Now(), 0, 0, GURL(), history::RedirectList(),
- ui::PAGE_TRANSITION_TYPED, false, history::SOURCE_SYNCED, false, true,
- false);
+ ui::PAGE_TRANSITION_TYPED, false, history::SOURCE_SYNCED, false, true);
test_web_contents_delegate_->NavigationStateChanged(
nullptr, content::InvalidateTypes(0));
test_web_contents_delegate_->ActivateContents(nullptr);
diff --git a/chromium/chrome/browser/ui/webui/webapks/OWNERS b/chromium/chrome/browser/ui/webui/webapks/OWNERS
new file mode 100644
index 00000000000..3fa3f228e00
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/webapks/OWNERS
@@ -0,0 +1 @@
+file://components/webapk/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc
index 336d6e3a176..fedbf8860a9 100644
--- a/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc
+++ b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc
@@ -47,37 +47,34 @@ void WebApksHandler::HandleRequestWebApkUpdate(const base::Value::List& args) {
void WebApksHandler::OnWebApkInfoRetrieved(const WebApkInfo& webapk_info) {
if (!IsJavascriptAllowed())
return;
- base::DictionaryValue result;
- result.SetStringKey("name", webapk_info.name);
- result.SetStringKey("shortName", webapk_info.short_name);
- result.SetStringKey("packageName", webapk_info.package_name);
- result.SetStringKey("id", webapk_info.id);
- result.SetIntKey("shellApkVersion", webapk_info.shell_apk_version);
- result.SetIntKey("versionCode", webapk_info.version_code);
- result.SetStringKey("uri", webapk_info.uri);
- result.SetStringKey("scope", webapk_info.scope);
- result.SetStringKey("manifestUrl", webapk_info.manifest_url);
- result.SetStringKey("manifestStartUrl", webapk_info.manifest_start_url);
- result.SetStringKey("displayMode",
- blink::DisplayModeToString(webapk_info.display));
- result.SetStringKey(
- "orientation",
- blink::WebScreenOrientationLockTypeToString(webapk_info.orientation));
- result.SetStringKey("themeColor",
- ui::OptionalSkColorToString(webapk_info.theme_color));
- result.SetStringKey("backgroundColor", ui::OptionalSkColorToString(
- webapk_info.background_color));
- result.SetDoubleKey("lastUpdateCheckTimeMs",
- webapk_info.last_update_check_time.ToJsTime());
- result.SetDoubleKey("lastUpdateCompletionTimeMs",
- webapk_info.last_update_completion_time.ToJsTime());
- result.SetBoolKey("relaxUpdates", webapk_info.relax_updates);
- result.SetStringKey("backingBrowser",
- webapk_info.backing_browser_package_name);
- result.SetBoolKey("isBackingBrowser", webapk_info.is_backing_browser);
- result.SetStringKey("updateStatus",
- webapk_info.is_backing_browser
- ? webapk_info.update_status
- : "Current browser doesn't own this WebAPK.");
+ base::Value::Dict result;
+ result.Set("name", webapk_info.name);
+ result.Set("shortName", webapk_info.short_name);
+ result.Set("packageName", webapk_info.package_name);
+ result.Set("id", webapk_info.id);
+ result.Set("shellApkVersion", webapk_info.shell_apk_version);
+ result.Set("versionCode", webapk_info.version_code);
+ result.Set("uri", webapk_info.uri);
+ result.Set("scope", webapk_info.scope);
+ result.Set("manifestUrl", webapk_info.manifest_url);
+ result.Set("manifestStartUrl", webapk_info.manifest_start_url);
+ result.Set("manifestId", webapk_info.manifest_id);
+ result.Set("displayMode", blink::DisplayModeToString(webapk_info.display));
+ result.Set("orientation", blink::WebScreenOrientationLockTypeToString(
+ webapk_info.orientation));
+ result.Set("themeColor",
+ ui::OptionalSkColorToString(webapk_info.theme_color));
+ result.Set("backgroundColor",
+ ui::OptionalSkColorToString(webapk_info.background_color));
+ result.Set("lastUpdateCheckTimeMs",
+ webapk_info.last_update_check_time.ToJsTime());
+ result.Set("lastUpdateCompletionTimeMs",
+ webapk_info.last_update_completion_time.ToJsTime());
+ result.Set("relaxUpdates", webapk_info.relax_updates);
+ result.Set("backingBrowser", webapk_info.backing_browser_package_name);
+ result.Set("isBackingBrowser", webapk_info.is_backing_browser);
+ result.Set("updateStatus", webapk_info.is_backing_browser
+ ? webapk_info.update_status
+ : "Current browser doesn't own this WebAPK.");
FireWebUIListener("web-apk-info", result);
}
diff --git a/chromium/chrome/browser/ui/webui/webui_allowlist_provider_unittest.cc b/chromium/chrome/browser/ui/webui/webui_allowlist_provider_unittest.cc
index 7ce26dc8db1..23aebb46ada 100644
--- a/chromium/chrome/browser/ui/webui/webui_allowlist_provider_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_allowlist_provider_unittest.cc
@@ -20,6 +20,8 @@
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/pref_names.h"
+using QueryReason = content_settings::CookieSettings::QueryReason;
+
class WebUIAllowlistProviderTest : public ChromeRenderViewHostTestHarness {
public:
HostContentSettingsMap* GetHostContentSettingsMap(Profile* profile) {
@@ -267,29 +269,30 @@ TEST_F(WebUIAllowlistProviderTest,
// cookies.
EXPECT_TRUE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(top_level_url),
- url::Origin::Create(top_level_url)));
+ url::Origin::Create(top_level_url), QueryReason::kCookies));
// Allowlisted origin on its own can't use cookies.
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(third_party_url),
- url::Origin::Create(third_party_url)));
+ url::Origin::Create(third_party_url), QueryReason::kCookies));
// Allowlisted origin embedded in Web top-level origin can't use cookies.
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
GURL("https://example2.com"),
net::SiteForCookies::FromUrl(third_party_url),
- url::Origin::Create(third_party_url)));
+ url::Origin::Create(third_party_url), QueryReason::kCookies));
// Allowlisted origin making subresource request (e.g. image) can't use
// cookies.
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
- third_party_url, net::SiteForCookies(), absl::nullopt));
+ third_party_url, net::SiteForCookies(), absl::nullopt,
+ QueryReason::kCookies));
// Allowlisted origin embedded in the wrong WebUI origin can't use cookies.
const GURL url_no_permission_webui = GURL("chrome-untrusted://no-perm");
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(url_no_permission_webui),
- url::Origin::Create(url_no_permission_webui)));
+ url::Origin::Create(url_no_permission_webui), QueryReason::kCookies));
// Other permissions aren't affected.
EXPECT_EQ(CONTENT_SETTING_BLOCK,
@@ -317,29 +320,30 @@ TEST_F(WebUIAllowlistProviderTest,
EXPECT_TRUE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(top_level_url),
- url::Origin::Create(top_level_url)));
+ url::Origin::Create(top_level_url), QueryReason::kCookies));
// Allowlisted origin on its own can use cookies, because only third-party
// cookies are blocked.
EXPECT_TRUE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(third_party_url),
- url::Origin::Create(third_party_url)));
+ url::Origin::Create(third_party_url), QueryReason::kCookies));
// Allowlisted origin embedded in Web top-level origin can't use cookies.
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
GURL("https://example2.com"),
net::SiteForCookies::FromUrl(third_party_url),
- url::Origin::Create(third_party_url)));
+ url::Origin::Create(third_party_url), QueryReason::kCookies));
// Allowlisted origin embedded in the wrong WebUI origin can't use cookies.
const GURL url_no_permission_webui = GURL("chrome-untrusted://no-perm");
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
third_party_url, net::SiteForCookies::FromUrl(url_no_permission_webui),
- url::Origin::Create(url_no_permission_webui)));
+ url::Origin::Create(url_no_permission_webui), QueryReason::kCookies));
// Allowlisted origin making subresource request (e.g. image) can't use
// cookies.
EXPECT_FALSE(cookies_settings->IsFullCookieAccessAllowed(
- third_party_url, net::SiteForCookies(), absl::nullopt));
+ third_party_url, net::SiteForCookies(), absl::nullopt,
+ QueryReason::kCookies));
// Other permissions aren't affected.
EXPECT_EQ(CONTENT_SETTING_BLOCK,
diff --git a/chromium/chrome/browser/ui/webui/webui_util.cc b/chromium/chrome/browser/ui/webui/webui_util.cc
index 527715ad126..3b2c9227648 100644
--- a/chromium/chrome/browser/ui/webui/webui_util.cc
+++ b/chromium/chrome/browser/ui/webui/webui_util.cc
@@ -19,6 +19,8 @@
#include "chrome/browser/browser_process_platform_part.h"
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#include "base/enterprise_util.h"
+#elif BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chromeos/startup/browser_params_proxy.h"
#endif
#if defined(TOOLKIT_VIEWS)
@@ -71,6 +73,8 @@ bool IsEnterpriseManaged() {
return connector->IsDeviceEnterpriseManaged();
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
return base::IsManagedDevice();
+#elif BUILDFLAG(IS_CHROMEOS_LACROS)
+ return chromeos::BrowserParamsProxy::Get()->IsDeviceEnterprisedManaged();
#else
return false;
#endif
diff --git a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
index ce744668635..17f9ca44ea3 100644
--- a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
@@ -26,6 +27,13 @@
#include "extensions/test/extension_test_message_listener.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_switches.h"
+#include "chrome/browser/ash/login/test/oobe_screen_waiter.h"
+#include "chrome/browser/ash/login/ui/login_display_host.h"
+#include "chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h"
+#endif
+
// Turn these tests off on Mac while we collect data on windows server crashes
// on mac chromium builders.
// http://crbug.com/653353
@@ -40,7 +48,7 @@ class WebUIMessageListener : public base::SupportsWeakPtr<WebUIMessageListener>{
public:
WebUIMessageListener(content::WebUI* web_ui, const std::string& message)
: message_loop_(new content::MessageLoopRunner) {
- web_ui->RegisterDeprecatedMessageCallback(
+ web_ui->RegisterMessageCallback(
message,
base::BindRepeating(&WebUIMessageListener::HandleMessage, AsWeakPtr()));
}
@@ -54,7 +62,7 @@ class WebUIMessageListener : public base::SupportsWeakPtr<WebUIMessageListener>{
}
private:
- void HandleMessage(const base::ListValue* test_result) {
+ void HandleMessage(const base::Value::List& test_result) {
message_loop_->Quit();
}
@@ -123,30 +131,44 @@ class WebUIWebViewBrowserTest : public WebUIBrowserTest {
base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
ASSERT_TRUE(embedded_test_server()->Start());
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // Wait for the OOBE WebUI to be shown.
+ ash::OobeScreenWaiter(chromeos::WelcomeView::kScreenId).Wait();
+ SetWebUIInstance(
+ ash::LoginDisplayHost::default_host()->GetOobeUI()->web_ui());
+#else
+ ASSERT_TRUE(
+ ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
+#endif
}
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ WebUIBrowserTest::SetUpCommandLine(command_line);
+ // Force showing OOBE WebUI on the ChromeOS ASH configuration.
+ command_line->AppendSwitch(ash::switches::kLoginManager);
+ command_line->AppendSwitch(ash::switches::kForceLoginManagerInTests);
+ }
+#endif
+
GURL GetTestUrl(const std::string& path) const {
return embedded_test_server()->base_url().Resolve(path);
}
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
GURL GetWebViewEnabledWebUIURL() const {
-#if BUILDFLAG(IS_CHROMEOS_ASH)
- return GURL(chrome::kChromeUIOobeURL).Resolve("/login");
-#else
return GURL(signin::GetEmbeddedPromoURL(
signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
signin_metrics::Reason::kForcedSigninPrimaryAccount, false));
-#endif
}
+#endif
};
// Checks that hiding and showing the WebUI host page doesn't break guests in
// it.
// Regression test for http://crbug.com/515268
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, DisplayNone) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testDisplayNone", base::Value(GetTestUrl("empty.html").spec())));
}
@@ -158,65 +180,30 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, DisplayNone) {
#define MAYBE_ExecuteScriptCode ExecuteScriptCode
#endif
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, MAYBE_ExecuteScriptCode) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testExecuteScriptCode", base::Value(GetTestUrl("empty.html").spec())));
}
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, ExecuteScriptCodeFromFile) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testExecuteScriptCodeFromFile",
base::Value(GetTestUrl("empty.html").spec())));
}
-// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-#define MAYBE_AddContentScript DISABLED_AddContentScript
-#else
-#define MAYBE_AddContentScript AddContentScript
-#endif
-IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, MAYBE_AddContentScript) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
+IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddContentScript) {
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddContentScript", base::Value(GetTestUrl("empty.html").spec())));
}
-// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-#define MAYBE_AddMultiContentScripts DISABLED_AddMultiContentScripts
-#else
-#define MAYBE_AddMultiContentScripts AddMultiContentScripts
-#endif
-IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, MAYBE_AddMultiContentScripts) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
+IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddMultiContentScripts) {
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddMultiContentScripts",
base::Value(GetTestUrl("empty.html").spec())));
}
-// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-#define MAYBE_AddContentScriptWithSameNameShouldOverwriteTheExistingOne \
- DISABLED_AddContentScriptWithSameNameShouldOverwriteTheExistingOne
-#else
-#define MAYBE_AddContentScriptWithSameNameShouldOverwriteTheExistingOne \
- AddContentScriptWithSameNameShouldOverwriteTheExistingOne
-#endif
IN_PROC_BROWSER_TEST_F(
WebUIWebViewBrowserTest,
- MAYBE_AddContentScriptWithSameNameShouldOverwriteTheExistingOne) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
+ AddContentScriptWithSameNameShouldOverwriteTheExistingOne) {
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddContentScriptWithSameNameShouldOverwriteTheExistingOne",
base::Value(GetTestUrl("empty.html").spec())));
@@ -233,25 +220,12 @@ IN_PROC_BROWSER_TEST_F(
IN_PROC_BROWSER_TEST_F(
WebUIWebViewBrowserTest,
MAYBE_AddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView",
base::Value(GetTestUrl("empty.html").spec())));
}
-// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-#define MAYBE_AddAndRemoveContentScripts DISABLED_AddAndRemoveContentScripts
-#else
-#define MAYBE_AddAndRemoveContentScripts AddAndRemoveContentScripts
-#endif
-IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
- MAYBE_AddAndRemoveContentScripts) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
+IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddAndRemoveContentScripts) {
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddAndRemoveContentScripts",
base::Value(GetTestUrl("empty.html").spec())));
@@ -269,9 +243,6 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
#endif
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
MAYBE_AddContentScriptsWithNewWindowAPI) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddContentScriptsWithNewWindowAPI",
base::Value(GetTestUrl("guest_from_opener.html").spec())));
@@ -281,9 +252,6 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
IN_PROC_BROWSER_TEST_F(
WebUIWebViewBrowserTest,
DISABLED_ContentScriptIsInjectedAfterTerminateAndReloadWebView) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testContentScriptIsInjectedAfterTerminateAndReloadWebView",
base::Value(GetTestUrl("empty.html").spec())));
@@ -299,25 +267,22 @@ IN_PROC_BROWSER_TEST_F(
#endif
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
MAYBE_ContentScriptExistsAsLongAsWebViewTagExists) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testContentScriptExistsAsLongAsWebViewTagExists",
base::Value(GetTestUrl("empty.html").spec())));
}
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddContentScriptWithCode) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
-
ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
"testAddContentScriptWithCode",
base::Value(GetTestUrl("empty.html").spec())));
}
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-// TODO(crbug.com/662673) Flaky on CrOS trybots.
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+// Incognito on CrOS is tested by the usual AddContentScript - OOBE context is
+// running inside incognito (signin) profile.
+
+// TODO(crbug.com/662673) Flaky
#define MAYBE_AddContentScriptIncognito DISABLED_AddContentScriptIncognito
// Right now we only have incognito WebUI on CrOS, but this should
// theoretically work for all platforms.
@@ -335,14 +300,16 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
#endif
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, ContextMenuInspectElement) {
- ASSERT_TRUE(
- ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL()));
content::ContextMenuParams params;
- TestRenderViewContextMenu menu(*browser()
- ->tab_strip_model()
- ->GetActiveWebContents()
- ->GetPrimaryMainFrame(),
- params);
+ content::WebContents* web_contents =
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ // OOBE WebUI.
+ ash::LoginDisplayHost::default_host()->GetOobeWebContents();
+#else
+ browser()->tab_strip_model()->GetActiveWebContents();
+#endif
+
+ TestRenderViewContextMenu menu(*web_contents->GetPrimaryMainFrame(), params);
EXPECT_FALSE(menu.IsItemPresent(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
}
diff --git a/chromium/chrome/browser/ui/webui/welcome/helpers.h b/chromium/chrome/browser/ui/webui/welcome/helpers.h
index 08fea988649..70fb23b50f9 100644
--- a/chromium/chrome/browser/ui/webui/welcome/helpers.h
+++ b/chromium/chrome/browser/ui/webui/welcome/helpers.h
@@ -5,12 +5,12 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_HELPERS_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_HELPERS_H_
+#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "build/build_config.h"
namespace base {
class DictionaryValue;
-struct Feature;
} // namespace base
namespace policy {
diff --git a/chromium/chrome/browser/ui/webui/welcome/ntp_background_handler.cc b/chromium/chrome/browser/ui/webui/welcome/ntp_background_handler.cc
index cb603f9508d..ef6512dba0a 100644
--- a/chromium/chrome/browser/ui/webui/welcome/ntp_background_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/ntp_background_handler.cc
@@ -119,7 +119,7 @@ void NtpBackgroundHandler::HandleGetBackgrounds(const base::Value::List& args) {
list_value.Append(std::move(element));
}
- ResolveJavascriptCallback(callback_id, base::Value(std::move(list_value)));
+ ResolveJavascriptCallback(callback_id, list_value);
}
void NtpBackgroundHandler::HandleSetBackground(const base::Value::List& args) {
diff --git a/chromium/chrome/browser/ui/webui/whats_new/whats_new_ui.cc b/chromium/chrome/browser/ui/webui/whats_new/whats_new_ui.cc
index 3d2b4d0ca4c..44f99aec443 100644
--- a/chromium/chrome/browser/ui/webui/whats_new/whats_new_ui.cc
+++ b/chromium/chrome/browser/ui/webui/whats_new/whats_new_ui.cc
@@ -91,13 +91,12 @@ void WhatsNewUI::BindInterface(
void WhatsNewUI::CreateBrowserCommandHandler(
mojo::PendingReceiver<browser_command::mojom::CommandHandler>
pending_handler) {
- // No supported commands for M104 only. New command to be added for M106.
- std::vector<browser_command::mojom::Command> supported_commands = {};
+ std::vector<browser_command::mojom::Command> supported_commands = {
+ browser_command::mojom::Command::kStartTabGroupTutorial,
+ browser_command::mojom::Command::kOpenPasswordManager,
+ };
command_handler_ = std::make_unique<BrowserCommandHandler>(
std::move(pending_handler), profile_, supported_commands);
- command_handler_->ConfigureFeedbackCommand(
- {GURL(chrome::kChromeUIWhatsNewURL), chrome::kFeedbackSourceWhatsNew,
- "whats-new-page"});
}
void WhatsNewUI::TryShowHatsSurveyWithTimeout() {